zencart / zencart

Zen Cart® is a full-function e-commerce application for your website.
https://github.com/zencart/zencart/releases
Other
375 stars 233 forks source link

More pricing woes #6318

Closed lat9 closed 7 months ago

lat9 commented 7 months ago

From this Zen Cart forum thread, still a couple of wonky calculations:

From @todoonada:

Currently a tax of 173.6363 is rounded to 173. (I have no decimals in the currency). I would like to have it rounded to 174 (half round up method). In the sense of "Total is 1910, a 10% tax of 174 is included". Now it displays 173 instead of 174.

Sorry, some further information:

a) If I have a product price of 8280 and no shipping costs, the tax is displayed correctly as 753. b) If I have a product price of 8280 and shipping costs of 910 (total of 9190), the tax is displayed as 836, it should be 835. c) If I change the product price to 9190 (same like total in above) and free shipping, the tax is displayed correctly 835.

So it seems there is something wrong with the tax calculation of the shipping costs.

From @OldNGreyBMR

Issue: currency conversion applied on item price in shopping_cart and reapplied on the sub-total for checkout_payment.

I updated /includes/classes/order.php to include changes from #6094 and #6141 to correct tax calculations. Prices are displayed including tax. Most orders are for domestic orders so they include tax. When the delivery address is overseas the items become tax exempt. This is determined by zones.

Now with the new code:

  • user selects a currency eg Euro and creates an account with a delivery address outside Australia.
  • The currency conversion is applied on the item:
  • item cost in AUD ex tax = $118.77 converted to EUR = €73.58 [ conversion rate of 0.61948508] = result is OK
    • in checkout shipping, postage is calculated and returned in Euro = result is OK
  • in checkout payment, the sub-total before postage is now €45.93 = INCORRECT [ this is the items price in EURO reconverted to EURO by the same conversion factor ]
lat9 commented 7 months ago

OK, I've modeled @todoonada's example in a site set with Display Prices with tax (both storefront and admin), with a 10% tax rate. That test site's default currency was set to have 0 decimal-digits.

Product tax is 752.72727, rounded to 0 decimal digits is 753; shipping tax is 82.72727, rounded to 0 decimal digits is 83. Resultant sum is 836.

IMO, these calculations are correct since the product(s) tax and the shipping tax are separately-calculated items.

However, if when I created another product with a gross price of 910 (net price 827.2727) and added that to the cart along with the gross 8280 product, the tax should be a total of 835 (since all products are in the same tax-class), but the calculated product tax was also 836.

This is due to the order-class' addition of product taxes to the order on a product-by-product basis, instead of summing the products' cost for each tax-class and then applying the tax % on the sum.

lat9 commented 7 months ago

Also modeled (and confirmed) @OldNGreyBMR's portion of the issue.