chrometweaks.org

iPage web hosts, HTML, RSS, PHP, affiliations...?

Click Here To View All Answers...


First question I got is iPage web hosts, HTML, RSS, PHP, affiliations...? Thanks for any response. My other question... Yes, I've searched the forums for this. I came up with this thread:.

Http://forums.oscommerce.com/index.php?sho...=0&#entry130452.

This discusses MS1, and the fix mentioned there has apparently been implemented in MS2. However, I'm still having a problem..

A client of mine is having issues with the sales tax rounding incorrectly. Some (but not all) of his orders are off by 1c. While 1c is not a big issue monetarily, it's a headache for accounting. What I've gathered is that the sales tax is being rounded up regardless of whether it should be or not. Example:.

An order on 3/7 - subtotal plus shipping was $72.38.

With a tax rate of 8.75% totaling $78.71325. This should be rounded to.

$78.71 but it was charged at $78.72..

Another order on 3/5 with subtotal plus shipping of $36.03 with a.

Tax rate of 8.625% totaling $39.13758 which was rounded correctly to $39.14..

Has anyone else seen this? Is there a fix posted somewhere that I was unable to find?..

Comments (28)

I would like to know the answer too. Anyone here know what is the answer. I'll do some poking around and get back to you if I got an anything. You should email the people at iPage as they probably know..

Comment #1

Maybe look at(in admin/catagories):.

Function updateGross() {.

Var taxRate = getTaxRate();.

Var grossValue = document.forms["new_product"].products_price.value;.

If (taxRate > 0) {.

GrossValue = grossValue * ((taxRate / 100) + 1);.

}.

Document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);.

}.

Function updateNet() {.

Var taxRate = getTaxRate();.

Var netValue = document.forms["new_product"].products_price_gross.value;.

If (taxRate > 0) {.

NetValue = netValue / ((taxRate / 100) + 1);.

}.

Document.forms["new_product"].products_price.value = doRound(netValue, 4);.

}..

Comment #2

Yesudo - I think that function only has to do with calculating the price after tax when you are inputting your products..

Maybe this information could help..

There are 17 orders in record that needed sales tax calculated. Of these seventeen, only four were rounded incorrectly. Of those four, two were in the same tax zone - the other two were in two different tax zones. The percentages for the three zones are all different. Three of the orders were rounded down when they should have been rounded up, one was rounded up instead of down. One order used a coupon (which was calculated after taxes) and one had a "low order fee" - a taxable item.

I can't find a pattern here anywhere..

Here are my calculations of what the taxes should have been with the calculations made by osCommerce:.

2.1153 - osC rounded to 2.11.

12.397575 - osC rounded to 12.39.

4.815125 - osC rounded to 4.81.

6.33325 - osC rounded to 6.34.

Can anyone offer a suggestion of where to turn next for debugging this?.

This post has been edited by.

BlueNoteMKVI.

: 12 March 2004, 00:37..

Comment #3

What do you have the tax padding set at in admin/configuration/my store tax decimal places..

Comment #4

Round function as PHP defines it.

Example 1. round() examples.

<?php.

Echo round(3.4); // 3.

Echo round(3.5); // 4.

Echo round(3.6); // 4.

Echo round(3.6, 0); // 4.

Echo round(1.95583, 2); // 1.96.

Echo round(1241757, -3); // 1242000.

Echo round(5.045, 2); // 5.04.

Echo round(5.055, 2); // 5.06.

?>.

Caution.

When rounding on exact halves round() rounds down on evens and up on odds. If you want to always force it in one direction on a .5 (or .05 in your case) add or substract a tiny fuzz factor. The reason behind rounding half the values down and the other half up is to avoid the classical banking problem where if you always rounded down you would be stealing money from your customers, or if you always rounded up you would end up over time losing money. By averaging it out through evens and odds you statistically break even..

As you can see you can set the precision in the round function. I would assume if this doesn't exist it uses the system precision instead....

Comment #5

Tax padding is set to 0. I assume this means 0 decimal places beyond the standard for that currency? ie, for US dollars now it should round to xx.xx, but if I set that padding to 1 it would round to xx.xxx?.

The information on the round() function is interesting! I didn't know about the up on evens/down on odds thing. However, osCommerce uses tep_round() instead of round(). tep_round() always rounds up on .05...

Comment #6

I think the problem is this:.

Right now the order total module "subtotal" is sorted to be directly below the products ordered - but before shipping and extra fees which are all taxable. I believe tax is calculated on the subtotal, then rounded. Tax is then calculated on each of the other modules, and each of those numbers rounded. All of those rounded numbers are then added together to get the total sales tax..

I believe I can fix the problem by changing the subtotal to come after all of the taxable items (including shipping, low order fees etc.) which should then cause the tax to be calculated only once, on that subtotal..

Does this sound logical?..

Comment #7

Bumping this topic: BlueNoteMKVI, did you solve this problem? Was it indeed the order of your sort?.

And about the tax padding, should it indeed be set to zero if your currency decimal place is set to 2?..

Comment #8

I haven't solved the problem, no. I've just stopped worrying about it...

Comment #9

Yes, I've searched the forums for this. I came up with this thread:.

Http://forums.oscommerce.com/index.php?sho...=0&#entry130452.

This discusses MS1, and the fix mentioned there has apparently been implemented in MS2. However, I'm still having a problem..

A client of mine is having issues with the sales tax rounding incorrectly. Some (but not all) of his orders are off by 1c. While 1c is not a big issue monetarily, it's a headache for accounting. What I've gathered is that the sales tax is being rounded up regardless of whether it should be or not. Example:.

An order on 3/7 - subtotal plus shipping was $72.38.

With a tax rate of 8.75% totaling $78.71325. This should be rounded to.

$78.71 but it was charged at $78.72..

Another order on 3/5 with subtotal plus shipping of $36.03 with a.

Tax rate of 8.625% totaling $39.13758 which was rounded correctly to $39.14..

Has anyone else seen this? Is there a fix posted somewhere that I was unable to find?..

Comment #10

Orders.php in the admin screen..

I don't know what shows up in checkout_confirmation.php - I haven't done much testing on that. The amount being passed to the payment module, however, is the same (occasionally incorrect) amount that's being shown on the admin screen...

Comment #11


This question was taken from a support group/message board and re-posted here so others can learn from it.