Samiksha Hiwase | 7 min read | August 14, 2020

Magento Price Cases with Tax: Rounding Issues and Solution

1. Quickread

In various e-commerce applications, it is important to know how the prices are computed and what rules are required to apply to display the correct price. Many times Magento store owners face rounding off issues with the grand total. The roundoff issues occur mostly on product prices when tax is included. While working on Magento, you must know about the importance of price calculations.
There are Unit price, Row total, and Total methods used to calculate the prices. It is necessary to check the methods very carefully that are used to calculate the prices to avoid tax issues and warnings. So in this blog, you will find all the details of price calculations with examples and all information related to how to configure the general tax setting.

2. What are Tax Calculation Methods

Tax Calculation Method Based on the Unit price, Row Total, and Total.
  • Unit Price Method:-
The unit price means that Magento will calculate tax on each quantity of each product in the cart, then round those-up and add them together. In Magento 2, the customer has a separate billing and shipping address.
  • Row Total Method:-
As Row total is applied to the individual product item price that is obtained from based product price multiplies with quantity.
  • Total Method:-
As the name of the method, this tax is applied only on the calculated final Total.

3. How to Configure the General Tax Setting

The following instructions take you through the basic tax configuration for your Magento installation. Before setting up your taxes, make sure that you are familiar with the tax requirements. Then, complete the tax configuration according to your requirements.
On the Admin sidebar, go to Stores > Settings > Configuration
For a multisite configuration, set Store View to the website and store that is the target of the configuration.
In the left panel, expand Sales and choose Tax.

Calculation Setting

Expand the calculation setting section
There are three values for the option “Tax calculation method based on” under Magento tax settings. The Magento store owners can configure this option as per the business requirement.
Here, is the image of the Dropdown list:-
You can Set the Tax Calculation Method Based on one of the following:
Unit Price The price of each product
Row Total The total of the line item in the order, less discounts
Total The order total
The rounding algorithm has an impact on tax prices, you need to take a look at how it is utilized. You have to understand the important operations of the tax class. There are 3 methods in the Tax class for calculating the tax on the shopping cart :
  • Total – it applies tax only on calculated totals.
  • Row – applied to individual product item price that is obtained from base product price multiplied with quantity.
  • Unit – it is applied to individual product items and adds everything together to get the tax rate.
  • Remember, the difference between Unit and Row base tax calculation is Quantity is not directly get multiplies with the item price in the cart.

4. Unit Price

Unit Price calculates Tax on the price of each product. Magento calculates the tax for each item and displays prices tax-inclusive. To calculate the tax total, Magento rounds the tax for each item and then adds them together.

Unit Price Calculation:

Let’s see the following image where the calculation of all prices is shown and after adding the total price is round off.
  • To understand more clearly let’s consider an example where the tax rate is 18%.
Product Name Quantity Base Price Excluded Tax Included Tax Total
A 1 91.4 91.4 18 % 91.4*1.18=107.852 107.86
B 1 21.4 21.4 18 % 21.4*1.18=25.252 25.26
C 1 31.4 31.4 18 % 31.4*1.18=37.052 37.06
D 1 41.4 41.4 18 % 41.4*1.18=48.852 48.86
E 1 51.4 51.4 18 % 51.4*1.18=60.652 60.66
Total     237 18 279.66 279.70
Here the tax calculation is based on units. So for a product, A – 91.4*1.18=107.852 and then rounded to the nearest round off 107.86 for each unit total. And the same happens for product B, C, D, and E. This then gives a total of 279.70 for all units.

5. Row Total

Row Total calculates tax on the total of the line item in the order, fewer discounts. Magento calculates the tax for each line. To calculate the tax total, Magento rounds the tax for each line item and then adds them together.
In row total, each row item minus discounts is taxed and then added to other rows to form the grand total price with tax.

Row Total calculation

Product Name Quantity Base Price Excluded Tax Included Tax Total
A 1 91.4 91.4 18 % 91.4*1.18=107.852 107.85
B 1 21.4 21.4 18 % 21.4*1.18=25.252 25.25
C 1 31.4 31.4 18 % 31.4*1.18=37.052 37.05
D 1 41.4 41.4 18 % 41.4*1.18=48.852 48.85
E 1 51.4 51.4 18 % 51.4*1.18=60.652 60.65
Total     237 18 279.66 279.65
In this configuration, the calculations of tax happen at the row total.
So for product A = 91.4*1.18=107.852. When rounded to the nearest it comes 107.85. And the same happens for product B, C, D, and E. This then gives a total of 279.65 for all units.

6. Total

Row Total calculates tax on the total of the line item in the order, fewer discounts. Magento calculates the tax for each line. To calculate the tax total, Magento rounds the tax for each line item and then adds them together.
In the unit price where rounding occurs on each item separately, Magento applies tax to all items separately, adds them together, and then applies rounding.
Product Name Quantity Base Price Excluded Tax Included Tax Total
A 1 91.4 91.4 18 % 91.4*1.18=107.852 107.86
B 1 21.4 21.4 18 % 21.4*1.18=25.252 25.26
C 1 31.4 31.4 18 % 31.4*1.18=37.052 37.06
D 1 41.4 41.4 18 % 41.4*1.18=48.852 48.86
E 1 51.4 51.4 18 % 51.4*1.18=60.652 60.66
Total     237 18 279.70
In total calculation, there is no rounding until all the totals are calculated. So for all products total is 279.70 which then rounds to the nearest 279.7
When tax configuration has a problem and misconfigured it triggers a warning with the mismatch in the total and causes rounding issues. Also, the Magento round off the tax calculation and customer see the amount on the cart is different than the amount expected to pay.
You can see Unit Price Calculation: Total is 279.70 and Row Calculation: Total is 279.65

Note:-

You need to be very careful while calculating price with including tax because the numbers will be in decimals. ( that is also called, float type). So never trust on the floating numbers when you get the last digit in decimal format and do not compare floating point numbers directly for equality.
The taxes round off issue basically due to a misconfiguration of Tax calculation setting under the Tax tab in the backend configuration.

7. Detail About Warnings in the Excluding and Including Tax:

The most common warnings are
  • Tax discount configuration might result in different discounts than a customer might expect for the store(s)
  • Tax configuration can result in rounding errors for the store(s)

Excluding Tax

As per the Magento standard tax configuration, it shall be as below:
Product Display Unit Price Row Total Total
Tax Class for Shipping Shipping (is taxed)
Excluding Tax OK OK OK
Including Tax OK OK OK
Including and Excluding Tax OK OK Warning

Including Tax

Catalog Prices: Including Tax
Product Display Unit Price Row Total Total
Excluding Tax OK OK OK
Including Tax OK OK OK
Including and Excluding Tax OK Warning Warning
The Magento standards strongly recommend that you use the following settings to avoid issues when configuring taxes in relation to discounts:
Field Recommended Setting
Apply Customer Tax After Discount
Apply Discount on Prices US and Canada—Excluding Tax
EU—Including Tax
Following is the image of the recommended settings:-

8. Conclusion

All methods of price calculation are mention in this blog. Also, explain how the issues of round off occur in Magento and how it gets resolve with using settings. This page covers the example regarding Unit Price and Row Total. And you will get the details of Tax calculation method with Excluding and Including Tax.
Hope you will get the answer to which setting is recommended to avoid the warning in tax calculation methods. If you will face any problem while implementing the above methods of price calculation with tax then feel free to contact us.

For Further Details or Additional Information

OR

If you want to know more about our Services