Forums / Currencies & Sales Taxes, VAT, GST, etc. / order of operations for calculating tax?

order of operations for calculating tax?

Locked

Views: 2,750

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
16 Apr 2008, 8:51 PM
#1
amandabto avatar

amandabto

New Zenner

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

order of operations for calculating tax?

The zen cart total is almost always $0.01 off from my client's accounting software. They're both calculating to 3 decimal points

In trying to figure out why, it looks like zen cart is just taking the product sub total (for each tax rate) and doing the calculation where I think the accounting software is adding up the taxes for each item

An example:
2 items @ $16.95, tax = 5%
2 * ( $16.95 * 0.05 ) = $1.694 ==> $1.69
(2 * $16.95 ) * 0.05 = $1.695 ==> $1.70

...maybe?
Could someone just tell me which file does the tax calculation? I'm good with php so I can read the code and figure out what's going on... as soon as I find it, that is

Thanks
Amanda

18 Apr 2008, 9:01 PM
#2
amandabto avatar

amandabto

New Zenner

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

Re: order of operations for calculating tax?

extra special "makes me want to cry" update

Using my trusty calculator that hasn't gotten this much use since university, it would appear that zen cart is rounding all my taxes to 2 decimal places and then adding them. Since I set Config > My Store > Tax Decimal Places = 3, I thought this was weird

After a lot of digging and echo-ing random msgs on the screen to see where I am I found the code that loops through all the products to calculate the total tax based on the tax for each product

Line 512 of includes/classes/order.php this code:
$tax_add = zen_round(($products_tax / 100) * $shown_price, $currencies->currencies[$this->info['currency']]['decimal_places']);

$currencies->currencies[$this->info['currency']]['decimal_places'] = 2

Can anyone suggest why it's rounding my individual product tax to 2 decimal places instead of using My Store > Tax Decimal Places? Is My Store > Tax Decimal Places not used for what I'm thinking it's used for?

Anyone? Bueller?

25 Apr 2008, 9:29 PM
#3
amandabto avatar

amandabto

New Zenner

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

Re: order of operations for calculating tax?

It ended up looking like the client's accounting software would add together all the gst, round to 2 decimals, add together all the pst, round that to 2 decimals and then add those 2 sub totals together

I found code in includes/classes/orders.php that calculated the tax for each product by multiplying the product price by the TOTAL TAXES for that product (13% instead of 5% and 8%) and ROUNDING TO 2 DECIMALS immediately - completely ignoring the TAX_DECIMAL_PLACES

Within the existing loop through each product, I used zen_get_multiple_tax_rates to get an array of all the tax rates and loops through them using TAX_DECIMAL_PLACES to round to whatever was in the admin congif. Then, outside of the loop through all products, I rounded $this->info['tax'] to 2 decimal places

I'm pretty sure the same thing would have to be done to the shipping but the client has decided they don't care :huh:

Hope this helps
amanda