Many times Magento store owners face rounding off issues with the grand total. This round off issue could be with product price or tax. In some cases, cart rules cause a rounding issue.

One of the common issues is with Tax. The tax round off issue basically due to a misconfiguration of Tax calculation setting under Tax tab in the backend configuration. The tax calculation has options to decide how a store owner wants to calculate the tax on order as per the store’s terms and country wise Tax rules and practices.

There are three values for the option “Tax calculation based on” under Magento 2 tax settings under Stores > Configuration > Tax > Calculation Settings

1. Unit Price: It 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.

2. Row Total: It 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.

3. Total: It calculates tax on the order total. Magento calculates the tax for each item and adds those tax values to calculate the total unrounded tax amount for the order. Magento then applies the specified rounding mode to the total tax to determine the total tax for the order.

The Magento store owners can configure this option as per the business requirement.

Let’s discuss this more in detail over an example.

Assume tax rate is 1.2

1. Unit Price Calculation : Here we have considered 20% tax rate.

Product Name Qty Base Price Ex Tax Inc Tax Row Total
ABC 4 14.39 14.39 17.268 (17.27) 69.08
XYZ 2 19.38 38.76 23.256(23.26) 46.52
Total 40.524(40.52) 115.60

Here the tax calculation is based on units. So for product ABC 14.39 x 1.2 = 17.268 and then rounded to the nearest round off 17.27 for each unit total. And it happens the same for product XYZ. This then gives a total of 115.6 for all units.

1. Row Calculation

Product Name Qty Base Price Ex Tax Inc Tax
ABC 4 14.39 57.56 69.072 (69.07)
XYZ 2 19.38 38.76 46.512 (46.51)
Total 115.584 (115.58)

In this configuration, the calculations of tax happen at the row total. So for product ABC (14.39 x 4) x 1.2 = 69.072 and product XYZ (19.38 x4) x 1.2 = 46.512. When rounded to the nearest it comes 69.07 and 46.51 for each row respectively. This gives a total of 115.58.

You can see that in case of :

1. Unit Price Calculation : Total is 115.60
2. Row Calculation : Total is 115.58

3. Total

Product Name Qty Base Price Ex Tax Inc Tax Row Total
ABC 4 14.39 14.39 17.268 69.072
XYZ 2 19.38 38.76 23.256 46.512
Total 115.584 (115.58)

In total calculation, there is no rounding until all the totals are calculated. So for all products total is 115.584 which then rounds to nearest 115.58.

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.

It has been seen that these conditions occur when

1. The tax calculation method is set to “Row” or “Total,”

2. The customer is presented with prices that both exclude and include tax, or a tax on an item basis in the cart

The most common warnings are

• Tax discount configuration might result in different discounts than a customer might expect for store(s)

• Tax configuration can result in rounding errors for store(s)

As per the Magento standard tax configuration, it shall be as below:

Tax Calculation Method Based On: Excluding Tax

Tax Excluded

Price 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

Catalog Prices: Including Tax

Tax Included

Price 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