10 min read

In this article by William Rice, we will see how to create Tax Rules in Magento. In the real world, the tax rate that you pay is based on three things: location, product type, and purchaser type. In Magento, we can create Tax Rules that determine the amount of tax that a customer pays, based upon the shipping address, product class, and customer class.

When you buy a product, you sometimes pay sales tax on that product. The sales tax that you pay is based on:

  • Where you purchased the product from. Tax rules vary in different cities, states, and countries.
  • The type of product that you purchased. For example, many places don’t tax clothing purchases. And, some places tax only some kinds of clothing. This means that you must be able to apply different tax rates to different kinds of products.
  • The type of purchaser you are. For example, if you buy a laser printer for your home, it is likely that you will pay sales tax. This is because you are a retail customer. If you buy the same printer for your business, in most places you will not pay sales tax. This is because you are a business customer.
  • The amount of the purchase. For example, some places tax clothing purchases only above a specific amount.

Anatomy of a Tax Rule

A Tax Rule is a combination of the tax rate, shipping address, product class, customer class, and amount of purchase.

A Tax Rule states that you pay this amount of tax if you are this class of purchaser, and you bought this class of product for this amount, and are shipping it to this place.

The components of a Tax Rule are shown in the following screenshot. This screen is found under Sales | Tax | Manage Tax Rules | Add New Tax Rule.

Creating Tax Rules in Magento

You will see the Name of the Tax Rule while working in the backend.

Customer Tax Class

Customer Tax Class is a type of customer that is making a purchase. Before creating a Tax Rule, you will need to have at least one Customer Tax Class. Magento provides you with a Tax Rule called Retail Customer. If you serve different types of customers—retail, business, and nonprofit—you will need to create different Customer Tax Classes.

Product Tax Class

Product Tax Class is a type of Product that is being purchased. When you create a Product, you will assign a Product Tax Class to that Product. Magento comes with two Product Tax Classes:Taxable Goods and Shipping. The class Shipping is applied to shipping charges because some places charge sales tax on shipping. If your customer’s sales tax is different for different types of Products, then you will need to create a Product Tax Class for each type of Product.

Tax Rate

Tax Rate is a combination of place, or tax zone, and percentage. A zone can be a country, state, or zip code.

Each zone that you specify can have up to five sales tax percentages. For example, in the default installation of Magento, there is one tax rate for the zone New York. This is 8.3750 percent, and applies to retail customers. The following window can be found at Sales | Tax | Manage Tax Zones & Rates and then clicking on US-NY-*-Rate 1:

Creating Tax Rules in Magento

So in the screenshot of our Tax Rule, the Tax Rate US-NY-*-Rate 1 doesn’t mean “a sales tax of 1 percent.” It means “Tax rate number 1 for New York, which is 8.3750 percent.”

In this scenario, New York charges 8.3750 percent sales tax on retail sales. If New York does not charge sales tax for wholesale customers, and you sell to wholesale customers, then you will need to create another Tax Rate for New York:

Creating Tax Rules in Magento

Whenever a zone has different sales taxes for different types of products or customers, you will need to create different Tax Rates for that zone.

Priority

If several Tax Rules try to apply several Tax Rates at the same time, how should Magento handle them? Should it add them all together? Or, should it apply one rate, calculate the total, and then apply the second rate to that total? That is, should Magento add them or compound them?

For example, suppose you sell a product in Philadelphia, Pennsylvania. Further suppose that according to the Tax Rule for Pennsylvania, the sales tax for that item is 6 percent, and that the Tax Rule for Philadelphia adds another 1 percent. In this case, you want Magento to add the two sales taxes. So, you would give the two Tax Rates the same Priority.

By contrast, Tax Rates that belong to Tax Rules with different Priorities are compounded. The Tax Rate with the higher Priority (the lower number) is applied, and the next higher Priority is applied to that total, and so on.

Sort Order

Sort Order determines the Tax Rules’ position in the list of Tax Rules.

Why create Tax Rules now?

Why create a Tax Rule now, before adding our first Product? When you add a Product to your store, you put that Product into a Category, assign an Attribute Set, and select a Tax Class for that Product. By default, Magento comes with two Product Tax Classes and one Tax Rule already created. The Product Tax Classes are Taxable Goods and Shipping. The Tax Rule is Retail Customer-Taxable Goods-Rate 1. If you sell anything other than taxable goods, or sell to anyone other than retail customers, you will need to create a new Tax Rule to cover that situation.

Creating a Tax Rule

The process for creating a Tax Rule is:

  1. Create the Customer Tax Classes that you need, or confirm that you have them.
  2. Create the Product Tax Classes that you need, or confirm that you have them.
  3. Create the Tax Rates that you need, or confirm that you have them and that they apply to the zones that you need.
  4. Create and name the Tax Rule:

    • Assign Customer Tax Class, Product Tax Class, and Tax Rates to the Rule.
    • Use the Priority to determine whether the Rule is added, or compounded, with other Rules.
    • Determine the Sort Order of the Rule and save it.

Each of these steps is covered in the subsections that follow.

Time for action: Creating a Customer Tax Class

    1. From the Admin Panel, select Sales | Tax | Customer Tax Classes. The Customer Tax Classes page is displayed. If this is a new installation, only one Class is listed, Retail Customer as shown in the following screenshot:

Creating Tax Rules in Magento

    1. Click on Add New. A Customer Tax Class Information page is displayed.

Creating Tax Rules in Magento

  1. Enter a name for the Customer Tax Class.
  2. In our demo store, we are going to create Customer Tax Classes for Business and Nonprofit customers.
  3. Click on Save Class. Repeat these steps until all of the Customer Tax Classes that you need have been created.

What just happened?

A Tax Rule is composed of a Customer Class, Product Class, Tax Rate, and the location of the purchaser. You have just created the first part of that formula: the Customer Class.

Time for action: Creating a Product Tax Class

    1. From the Admin Panel, select Sales | Tax | Product Tax Classes. The Product Tax Classes page is displayed. If this is a new installation, only two Classes are listed: Shipping and Taxable Goods.
    2. Click on Add New. The Product Tax Class Information page gets displayed:

Creating Tax Rules in Magento

  1. Enter a name for the Product Tax Class. In our demo store, we are going to create Product Tax Classes for Food and Nonfood products. We will apply the Food class to the coffee that we sell. We will apply the Nonfood class to the mugs, coffee presses, and other coffee accessories that we sell.
  2. Click on Save Class. Repeat these steps until all of the Product Tax Classes that you need have been created.

What just happened?

A Tax Rule is composed of a Customer Class, Product Class, Tax Rate, and the location of the purchaser. You have just created the second part of that formula: the Product Class.

Creating Tax Rates

In Magento, you can create Tax Rates one at a time. You can also import Tax Rates in bulk. Each method is covered in the next section.

Time for action: Creating a Tax Rate in Magento

    1. From the Admin Panel, select Sales | Tax | Manage Tax Zones & Rates.

      The Manage Tax Rates page is displayed. If this is a new installation, only two Tax Rates are listed: US-CA-*-Rate 1 and US-NY-*-Rate 1.

    2. Click on Add New Tax Rate. The Add New Tax Rate page gets displayed:

Creating Tax Rules in Magento

    1. Tax Identifier is the name that you give this Tax Rate. You will see this name when you select this Tax Rate. The example that we saw is named US-CA-*-Rate 1. Notice how this name tells you the Country, State, and Zip/Post code for the Tax Rate. (The asterisk indicates that it applies to all zip codes in California.) It also tells which rate applies. Notice that the name doesn’t give the actual percentage, which is 8.25%. Instead, it says Rate 1. This is because the percentage can change when California changes its tax rate. If you include the actual rate in the name, you would need to rename this Tax Rate when California changes the rate. Another way this rate could have been named is US-CA-All- Retail. Before creating new Tax Rates, you should develop a naming scheme that works for you and your business.
    2. Country, State, and Zip/Post Code determine the zone to which this Tax Rate applies. Magento calculates sales tax based upon the billing address, and not the shipping address. Country and State are drop-down lists. You must select from the options given to you. Zip/Post Code accepts both numbers and letters. You can enter an asterisk in this field and it will be a wild card. That is, the rate will apply to all zip/post codes in the selected country and state. You can enter a zip/post code without entering a country or state. If you do this, you should be sure that zip/post code is unique in the entire world. Suppose you have one tax rate for all zip codes in a country/state, such as 6% for United States/Pennsylvania. Also, suppose that you want to have a different tax rate for a few zip codes in that state. In this case, you would create separate tax rates for those few zip codes. The rates for the specific zip codes would override the rates for the wild card. So in a Tax Rate, a wild card means, “All zones unless this is overridden by a specific zone.” In our demo store, we are going to create a Tax Rate for retail customers who live in the state of Pennsylvania, but not in the city of Philadelphia as shown:

Creating Tax Rules in Magento

  1. Click on Save Rate. You are taken back to the Manage Tax Rates page. The Tax Rate that you just added should be listed on the page. This procedure is useful for adding Tax Rates one at a time. However, if you need to add many Tax Rates at once, you will probably want to use the Import Tax Rates feature. This enables you to import a .csv, or a text-only file. You usually create the file in a spreadsheet such as OpenOffice Calc or Excel. The next section covers importing Tax Rates.

What just happened?

A Tax Rule is composed of a Customer Class, Product Class, Tax Rate, and the location of the purchaser. You have just created the third part of that formula: the Tax Rate. The Tax Rate included the location and the percentage of tax. You created the Tax Rate by manually entering the information into the system, which is suitable if you don’t have too many Tax Rates to type.

Time for action: Exporting and importing Tax Rates

In my demo store, I have created a Tax Rate for the state of Pennsylvania. The Tax Rate for the city of Philadelphia is different. However, Magento doesn’t enable me to choose a separate Tax Rate based on the city. So I must create a Tax Rate for each zip code in the city of Philadelphia. At this time there are 84 zip codes, and are shown here:

 

 

19019

19092

19093

19099

19101

19102

19103

19104

19105

19106

19107

19108

19109

19110

19111

19112

19113

19114

19115

19116

19118

19119

19120

19121

19122

19123

19124

19125

19126

19127

19128

19129

19130

19131

19132

19133

19134

19135

19136

19137

19138

19139

19140

19141

19142

19143

19144

19145

19146

19147

19148

19149

19150

19151

19152

19153

19154

19155

19160

19161

19162

19170

19171

19172

19173

19175

19177

19178

19179

19181

19182

19183

19184

19185

19187

19188

19191

19192

19193

19194

19196

19197

19244

19255

 

 

 

 


Subscribe to the weekly Packt Hub newsletter. We'll send you this year's Skill Up Developer Skills Report.

* indicates required

LEAVE A REPLY

Please enter your comment!
Please enter your name here