Forums / Bug Reports / Rounding error in Sales Tax

Rounding error in Sales Tax

Locked

Started by artcoder on 17 Apr 2009, 4:32 PM · Views: 7,989

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
17 Apr 2009, 4:32 PM
#1
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Rounding error in Sales Tax

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

18 Apr 2009, 5:56 AM
#2
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Re: Rounding error in Sales Tax

Sorry, the zencart version that I meant to say was ZenCart version 1.3.8.

22 May 2009, 1:50 AM
#3
oriontool avatar

oriontool

New Zenner

Join Date:
Apr 2009
Posts:
52
Plugin Contributions:
0

Re: Rounding error in Sales Tax

Sorry, I am new at this. Is this a FIX or a recommended fix?

I am not very comfortable with making changes and want to make sure that I do this correctly.

Thanks!

Professional accessories for your two-way radio.
The Earphone Guy

9 Jun 2009, 6:21 AM
#4
marco_k avatar

marco_k

New Zenner

Join Date:
Jan 2008
Posts:
22
Plugin Contributions:
0

Re: Rounding error in Sales Tax

Is there really no solution for this problem?
I find it very frustrating, and many others.
This seems to me a bug that should be solved asap.

16 Jun 2009, 3:47 AM
#5
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Re: Rounding error in Sales Tax

To fix the sales tax error on my clients' ZenCart sites, I made code changes as described in learnwebdesignonline.com/tutorials/zencart/sales-tax-error.

23 Jun 2009, 8:54 AM
#6
marco_k avatar

marco_k

New Zenner

Join Date:
Jan 2008
Posts:
22
Plugin Contributions:
0

Re: Rounding error in Sales Tax

artcoder:

To fix the sales tax error on my clients' ZenCart sites, I made code changes as described in this tutorial linked here.

I've tried and it didn't work.

Can you show me how your follow files look like?
includes/functions/functions_taxes.php
includes/classes/order.php
includes/functions/functions_general.php
includes/functions/functions_taxes.php

it's a long shot but maybe i can copy these files to my server and give it a try.

8 Sep 2009, 10:45 PM
#7
lumpylumpy avatar

lumpylumpy

New Zenner

Join Date:
Feb 2008
Posts:
27
Plugin Contributions:
0

Re: Rounding error in Sales Tax

Hi, i have tried i think everything on this forum regarding the tax rounding problem in Zen Cart.
I made the changes as in the tutorial and my rounding problems whent away.:clap:
PM me and i can give you those files to compare.
Best regards Zoli.

23 Oct 2009, 9:41 AM
#8
wayonhigh avatar

wayonhigh

New Zenner

Join Date:
Oct 2009
Posts:
8
Plugin Contributions:
0

Re: Rounding error in Sales Tax

Hi,

Thanks for the tutorial. My prices are now calculating correctly. The only place I have noticed which is still using the old calculation is on the Admin invoice. (Customers > Orders)

Could anyone help me out with correcting that?

Thanks,
Joe

25 Oct 2009, 4:14 AM
#9
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Re: Rounding error in Sales Tax

When I applied the changes in learnwebdesignonline.com/tutorials/zencart/sales-tax-error it fixed the rounding problem as displayed in customer checkout pages as well as in the Admin Orders invoice.

Note that there are two files that needed to be changed.

7 May 2010, 5:28 PM
#10
artcoder avatar

artcoder

Zen Follower

Join Date:
Jan 2007
Posts:
166
Plugin Contributions:
0

Re: Rounding error in Sales Tax

This rounding issue and fix only applies to version 1.5.8 -- not 1.5.9.

10 May 2010, 8:40 PM
#11
djw925 avatar

djw925

New Zenner

Join Date:
Nov 2009
Location:
worcester
Posts:
3
Plugin Contributions:
0

Re: Rounding error in Sales Tax

Hello - any suggestions for this one please??

I am currently using version 1.3.8 and also having pricing issues.

I have had the dynamic price updater installed to allow pricing of products that have attributes that affect the final cost.

It was working great and the price was displaying correctly on the product page (some have two attributes, some have three - all selections affect the price) and correctly also in the cart .......until

I changed the individual product option to 'taxable goods'.

Now the price on the product page is always higher (approx 1%) than it should be. If you refresh the page, you can see the CORRECT price very briefly and then it settles INCORRECTLY.

However, when you add the product to cart, the price reverts back to the CORRECT price that has been set for that particular product!!

Please see:

http://www.prestigeringcompany.com/index.php?main_page=product_info&cPath=39_40&products_id=377

I have seen the solutions talked about on this thread, but not entirely sure that this is the same problem as mine, as on the particular product (above) I have NOT split the prices anywhere (for testing purposes) and just put one price into the metal attribute, therefore eliminating any 'rounding up' issues that may occur if having multiple prices split on one product.

Any suggestions would be very appreciated.

Thanks

Darrel:wacko:

1 Nov 2010, 2:04 PM
#12
cocolala avatar

cocolala

New Zenner

Join Date:
Jan 2010
Posts:
31
Plugin Contributions:
0

Re: Rounding error in Sales Tax

WayOnHigh:

Hi,

Thanks for the tutorial. My prices are now calculating correctly. The only place I have noticed which is still using the old calculation is on the Admin invoice. (Customers > Orders)

Could anyone help me out with correcting that?

Thanks,
Joe

anyone have a solution to this? I have the same prob. The admin invoice is showing figures that are not rounded off.