ZenCart version: 1.5.9
In certain minority of cases involving customer orders containing multiple products, there is a rounding error in the computed sales tax and the sales tax paid by the customer is off by one penny. This does not happen often, but more likely to occur when tax percentage is to two decimal places (as in California base tax rate of 8.25%).
Repro steps:
1. Create a product "Red Gumball" with price $3.95.
2. Create product "Blue T-Shirt" with price $8.95.
3. Set California sales tax to 8.25%.
4. Have California customer purchase a red gumball and a blue t-shirt with product total of $12.90.
5. See that ZenCart is charging incorrect tax of $1.07
6. Expected result: The correct tax to be charged the customer is $1.06 obtained by (12.90 * 0.0825).
Reason: ZenCart is computing sales tax for each product, rounding, and then totalling. This is wrong. You should not round intermediary calculations.
The correct order is to total, compute sales tax, and then round.
Proposed code fix:
1. Remove the call to zen_round() from zen_add_tax() and zen_calculate_tax() functions in the file includes/functions/functions_taxes.php.
2. Remove the call to zen_round() from the file includes/classes/order.php
Bookmarks