Prestashop 1.6.1 and above, and Prestashop 1.7 and above, present a tax application problem when rounding system is set Round on each item and a rounding problem when set to Round on each line or Round on the total.
Prestashop cart calculates at first the total price tax excluded and tax included, and then applies a subtraction to get the total tax amount. This procedure, in our opinion, leads to a rounding problem. Let’s see why.
Round on each item calculation
This is a real example:
Prestashop gets these values by applying taxes to a net price of 1,644262, in doing so getting a gross price of 2,005999, rounded to 2,01
Round on each line or Round on the total calculation
If the rounding is set instead to Round on each line or Round on the total, there is a problem whit tax application that is performed before quantity sum up.
By using the same product of the above example, and placing into the cart 1 item, we get:
- unit net price 1,64
- total net price 1,64
- taxes 0,37
- total gross price 2,01
By reviewing Prestashop cart’s process, the total gross price (tax included) gets calculated by applying taxes on a net price of 1,644262 that equals to 2,005999, rounded to 2,01
By performing the same check done before, if we apply taxes to the total net rounded price (the taxable income for each order line), we get 2,0008 rounded to 2,00.
To fix these issues, we have modified the Cart.php class, applying calculation on net prices at first and applying taxes only at the end of rounding.