Mail Bag

Answering Your Questions Since... 9:30am
Joined: 28 Aug 2005
Posts: 113
|
Posted: Aug 21, 2007 08:12am Post subject: How does Modular Merchant round taxes? |
|
|
| Quote: | | My state's tax rate is 8.9%. The tax calculation for a recent order came out to $1.60111, and the shopping cart rounded this up to $1.61. Is this correct? I thought the rounding rule was that .4 and lower gets rounded down to zero. What logic does Modular Merchant use to round partial cents? |
Modular Merchant always rounds partial cents in tax calculations up to the nearest whole cent. Here's why...
Before I started working on shopping carts, I also thought that any decimal of .4 or lower was rounded down. Unfortunately, it's not quite as simple as that.
There are actually quite a number of rules governing how a decimal number can be rounded, including: round-toward-nearest, round-half-up, round-half-down, round-half-odd, round-toward-zero, truncation, etc. (For examples of the many glorious ways in which you can round a number, see the website http://www.diycalculator.com/sp-round.shtml which takes the time to delve into each one in mind-numbing detail.)
So, the next logical question is: "which rounding method should be used?"
In previous versions (the version 1.x series), Modular Merchant used "bankers rounding", in which the decimal number is rounded up or down depending not only on its numerical value, but also whether it is an odd or even number. Yes, it was as exciting to program as it is to describe.
However, we soon discovered a problem. Sales tax rules vary from state to state (and country to county). Many of our clients soon found that they were sometimes undercharging sales tax.
So that's why, to err on the side of caution, Modular Merchant now always rounds partial cents in tax calculations up to the nearest whole cent. That way, stores are sure to charge enough tax to make Uncle Sam happy.
In a future update, it may be possible to add an option to the system, which would allow store administrators to set the rounding behavior for their store. I have added this item to our Development Schedule as an official feature request. As this request is currently "under consideration", no development or release date has been set for it yet.
I hope this information is helpful. If you have any additional questions on this issue, please let us know. _________________ Modular Merchant Mail Bag
Answering your questions, queries and puzzlers.
Modular Merchant shopping cart software, website hosting, and custom programming. |
|