Zen Cart Logo
Forums / Currencies & Sales Taxes, VAT, GST, etc. / Different Total Displayed

Different Total Displayed

Views: 15,865

Results 21 to 40 of 58
24 Jan 2024, 05:36
#21
todoonada avatar

todoonada

Zen Follower

Join Date:
Nov 2006
Posts:
127
Plugin Contributions:
0

Different Total Displayed

lat9:

@todonada, have you tested to see if the code in the current GitHub master branch (https://github.com/zencart/zencart) corrects this issue? I'm pretty sure that this was one of the test cases I used when making those pricing-calculation updates.

Sorry for the late reply!

I applied the changes described here
https://github.com/lat9/zencart/commit/0d775ce6eec3788c37e291f19d44631fc0b06cba
and here
https://github.com/zencart/zencart/pull/6141/files

So far everything seems to work fine and the problem from the initial post is solved thanks to your code changes.

24 Jan 2024, 13:55
#22
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Different Total Displayed

todoonada:

Sorry for the late reply!

I applied the changes described here
https://github.com/lat9/zencart/commit/0d775ce6eec3788c37e291f19d44631fc0b06cba
and here
https://github.com/zencart/zencart/pull/6141/files

So far everything seems to work fine and the problem from the initial post is solved thanks to your code changes.
Thanks to you, @todoonada! I appreciate the 3rd-party verification as well as your original posting of the issue.

12 Feb 2024, 03:33
#23
todoonada avatar

todoonada

Zen Follower

Join Date:
Nov 2006
Posts:
127
Plugin Contributions:
0

Re: Different Total Displayed

Hello lat9,
I have one more question.
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.

Where do I have to change your code?

12 Feb 2024, 04:51
#24
todoonada avatar

todoonada

Zen Follower

Join Date:
Nov 2006
Posts:
127
Plugin Contributions:
0

Re: Different Total Displayed

I went to includes/modules/order_total/ot_tax.php
and changed line 98 from

'text' => $currencies->format($taxValue, true, $order->info['currency'], $order->info['currency_value']),

to

'text' => $taxValue,

Now on the front end the 10% tax is displayed as 173.3. Round this and it is 173 of course.
The value of 173.3 is not correctly. It should be 173.6.
So it seems it is not the wrong rounding method, but the calculation of $taxValue is off.

12 Feb 2024, 05:43
#25
todoonada avatar

todoonada

Zen Follower

Join Date:
Nov 2006
Posts:
127
Plugin Contributions:
0

Re: Different Total Displayed

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.

12 Mar 2024, 07:15
#26
oldngrey avatar

oldngrey

Zen Follower

Join Date:
Apr 2008
Location:
Qld, Australia
Posts:
417
Plugin Contributions:
0

Re: Different Total Displayed

Versions affected: zc158a with patches and zc200
file /includes/classes/order.php

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 ]
12 Mar 2024, 12:54
#27
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Different Total Displayed

Thanks for the details, OldNGrey. Once I've coffeed-up, I'll take a look on zc200-rc1 and report back.

12 Mar 2024, 13:07
#28
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Different Total Displayed

OldNGrey, what's the full (with 4 decimal digits) price recorded in the database for that 118.77 product?

12 Mar 2024, 13:08
#29
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Different Total Displayed

todoonada:

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.
@todoonada, I'll be looking at this as well using the zc200-rc1 code.

12 Mar 2024, 13:17
#30
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Different Total Displayed

Zen Cart issue created to track the correction(s) for the above two pricing issues: https://github.com/zencart/zencart/issues/6318

12 Mar 2024, 13:48
#31
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Different Total Displayed

@todoonada and @OldNGrey, what's the value in use for Configuration :: My Store :: Currency Conversion Ratio?

12 Mar 2024, 21:22
#32
oldngrey avatar

oldngrey

Zen Follower

Join Date:
Apr 2008
Location:
Qld, Australia
Posts:
417
Plugin Contributions:
0

Re: Different Total Displayed

Item #608 products_price = 118.7727
Configuration :: My Store :: Currency Conversion Ratio = 1.025

12 Mar 2024, 23:53
#33
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Different Total Displayed

@OldNGrey and @todoonada, please see this PR: https://github.com/zencart/zencart/pull/6319

I've verified that the changes correct *each *of the issues identified in this thread and would appreciate some 3rd-party validation!

13 Mar 2024, 18:49
#34
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Location:
Japan
Posts:
364
Plugin Contributions:
6

Re: Different Total Displayed

Using this PR, I did some testing changing all I can, price, tax display and value... As long as I use main currency, calculation was all good. But when using another currency, things get weird...
Second currency rate is 155 and tax is 10%, no decimal. I have two products in cart, one is priced at 48.34 (53.174 with tax) and the other is at 35 (38.5 w.tax).

When not displaying tax:
I got in cart product price 1 at 7440 (instead of 7493) and product 2 at 5425 as it should be.
In last checkout screen, product price 1 is still wrong, but all calculations are correct for these prices (7440 and 5425).

When displaying prices with tax:
I got in cart product price 1 at 8215 (instead of 8242) and product 2 at 6045 (instead of 5968).
In last checkout screen, product price 1 is 8242 and product 2 is 5968 as they should be but subtotal (14260 instead of 14210) and tax (1296 instead of 1292) are wrong. Total is 15035, which I have no idea how it ends to this value...

I am not sure if it is related to tax calculation, it might be more of a rounding problem when converting currencies.

13 Mar 2024, 19:00
#35
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Location:
Japan
Posts:
364
Plugin Contributions:
6

Re: Different Total Displayed

pilou2:

...Total is 15035, which I have no idea how it ends to this value...

I figure this out, 15035 = 14260 + 775 (shipping fee). It is time for me to sleep...

14 Mar 2024, 01:49
#36
oldngrey avatar

oldngrey

Zen Follower

Join Date:
Apr 2008
Location:
Qld, Australia
Posts:
417
Plugin Contributions:
0

Re: Different Total Displayed

From my testing with the conversion from AUD to EUR, or any other currency I have set, the display for payment information is now correct.
Thank you Lat9

14 Mar 2024, 03:47
#37
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Location:
Japan
Posts:
364
Plugin Contributions:
6

Re: Different Total Displayed

I think I figured out part of the problem. In my currency with rate 155 (JPY) I use 0 decimal. It seems that currency conversion in cart rounds to 0 decimals before conversion:
Product price 48.34 becomes 48 which multiply by 155 gives 7440 which is exactly the wrong price I got in cart without tax.
Second product price 35.00 has 0 as decimal. This is why price after conversion is still right. I don't know where it is in the code yet.

When displaying prices with tax:
Product 1: 48.34 x 1.1 = 53.174 ----> 53 x 155 = 8215 Which is what I got.
Product 2: 35.00 x 1.1 = 38.5 ----> 39 x 155 = 6045 Which is what I got too!

Rounding to new decimal setting should be done after conversion.

Calculation in last checkout screen is different and there might be something else to figure out...

14 Mar 2024, 05:29
#38
todoonada avatar

todoonada

Zen Follower

Join Date:
Nov 2006
Posts:
127
Plugin Contributions:
0

Re: Different Total Displayed

lat9:

@todoonada and @OldNGrey, what's the value in use for Configuration :: My Store :: Currency Conversion Ratio?

It is 1.05.
I only use one currency.

14 Mar 2024, 12:48
#39
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Different Total Displayed

pilou2:

I think I figured out part of the problem. In my currency with rate 155 (JPY) I use 0 decimal. It seems that currency conversion in cart rounds to 0 decimals before conversion:
Product price 48.34 becomes 48 which multiply by 155 gives 7440 which is exactly the wrong price I got in cart without tax.
Second product price 35.00 has 0 as decimal. This is why price after conversion is still right. I don't know where it is in the code yet.

When displaying prices with tax:
Product 1: 48.34 x 1.1 = 53.174 ----> 53 x 155 = 8215 Which is what I got.
Product 2: 35.00 x 1.1 = 38.5 ----> 39 x 155 = 6045 Which is what I got too!

Rounding to new decimal setting should be done after conversion.

Calculation in last checkout screen is different and there might be something else to figure out...
Thank you for taking the time to check this out. It would help me to reproduce and then correct the issue if I could verify:

Store currency, number of decimal digits (sounds like 2)
What is the 1.1 that multiplies the product pricing, for example 48.34 x 1.1 = 53.174
Store currency, converted to JPY with a 155 conversion rate.

14 Mar 2024, 13:43
#40
pilou2 avatar

pilou2

Zen Follower

Join Date:
Jun 2008
Location:
Japan
Posts:
364
Plugin Contributions:
6

Re: Different Total Displayed

lat9:

Thank you for taking the time to check this out. It would help me to reproduce and then correct the issue if I could verify:

Store currency, number of decimal digits (sounds like 2)
What is the 1.1 that multiplies the product pricing, for example 48.34 x 1.1 = 53.174
Store currency, converted to JPY with a 155 conversion rate.

The main currency is default US$. I use a default cart with demo data to which I added Japanese yen as currency with rate (including factor 1.05) of 155 (155.00000000) and has 0 decimal. Then I modified Tax to apply worldwide and at a 10% rate which makes it easier for debugging. Then, I modified some products prices and one is 48.3400 without tax and the other is 35.0000 without tax too.
Now, I suppose you understand 48.34 (price w.o.t.) x 1.1 (10% tax).
1.1 is 1 + 10/100...

I looked at the code and find some rounding (line 118 in shopping cart header and some in shopping cart class) I can suppress to get correct prices, but then the 'one digit off' bug comes back. I think these rounding were added to correct this bug, but in fact hide it.
Probably, the right thing to do would be to do a rounding after currency conversion (if necessary) but before any other calculation like adding tax, then a last rounding before displaying.

I could not find where currency conversion is done for subtotals. It seems subtotal is calculated differently depending on page you are: cart, checkout payment and checkout confirmation... If you know where this currency conversion is done, please let me know.