Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

osCommerce Truncates Tax?


Guest

Recommended Posts

I have installed the County Sales Tax Mod

http://www.oscommerce.com/community/contributions,1660/

 

 

BUT! it seems that oscommerce is rounding the tax down instead of up..

 

here is what my cart says..

 

Sub-Total:  $274.75

Table Rate (Best Way):  $27.48

Philadelphia Co. Sales Tax 7%:  $21.15  <--  County Sales Tax Mod

Total:  $323.38

 

 

nowthe sub total adds up correctly, and the shipping module is working correctly, but it should calculate the tax on $302.23 sub-total + Shipping Rate.

 

so far so good..

now we calculate 7% sales tax on top of this...

302.23 * .07 = 21.1561

 

now that should round up to 21.16 not down to 21.15

 

currently the total is calculated to 323.38 but it should be 323.39

 

I know this is only a penny, but a penny is a penny.

I have looked through anything i could find attributed to this, but i can not find where oscommerce does its rounding. Initially i thought it was the MOD i installed but after close review of its code, it is building and rounding its numbers from inside oscommerce, now, the problem becomes... where does it round the tax?? or does it not even round the tax and in turn just truncates it to 2 decimal places?

 

TIA

Mike

Link to comment
Share on other sites

  • 3 weeks later...

i believe the tax 'places' just gets trunctuated to two (or however many you set it to - which you can change), because it's handled in cells of your database. One may be able to make a small script to take the numbers, and before passing them into the database's data holding cell, 'rould-up' and simply pass the 2 rounded-up numbers to the DB.

 

But unfortunately i'm not the one to ask 'how' because i wouldn't know how to do it. Simply dont know php. sorry

Link to comment
Share on other sites

Mike-

 

Check the PHP manual in regards to this. There is some raw PHP you can use to round if need be.

 

osC rounds up at some point but obviously not the entire way. hehe This annoys me a bit as well so lmk if you get anywhere with this.

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...

I hired a coder to fix my problem, cost me $50 but could of got it cheaper. This is what i was told my problem was:

I think I discovered the problem.  Here is the offending line:

 

display_price($products[$i]['final_price'],

tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity'] [Line 163 of shopping_cart.php]

 

If you look at the code it calculates the price by taking the product price and multiplying in by the tax rate. In the example you provided the (product and options) values passed to the display_price routine above are 688, 17.5,

1 or 688 * .175 * 1 which equals 808.40.  The sub-totals displayed on the left and bottom are calculated by adding up the product price and option price from the shopping page. These prices have the taxes already calculated in.  As a result there will sometimes be rounding errors.

 

Ie.

Product price 799

Option 1 3.53

Option 2 5.88

 

Total 808.41

 

Option 1 price is calculated as 3.00 * .175 = 3.525 rounded up to 3.53 Option 2 price is calculated as 5.00 * .175 = 5.875 rounded up to 5.88 But...

799 + 3.53 + 5.88 =    808.41

799 + 3.525 + 5.875 = 809.40

 

So the rounding accounts for the penny difference.

Link to comment
Share on other sites

Can an example case be provided where the rounding is not correct? For this the following is needed:

 

* Exact price of products involved (to 4 decimal places (the value in the database))

* Exact price of product attributes involved (also to 4 decimal places)

* Tax rate value (to 4 decimal places)

* Are the tax rates added to the products price or only shown on the checkout page? (Administration Tool -> Configuration -> My Store -> Display Prices With Tax)

* A flat fee shipping rate value (optional)

:heart:, osCommerce

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

I have the same problem.

 

Its truncating the taxes.

 

ie.

Cart is showing

 

Sub-Total: $59.99

Zone Rates (Shipping to CA : 1 lb(s)): $4.00

PST + GST: $9.33 (15%)

Total: $73.32

 

But taxes should $9.59

 

I tried fooling around with the new tax/decimal field in the admin-> COnfiguration - to no avail.

 

I cant even logicaly make out where it reduces the tax by 26 cents!

 

Any help would be apreicated.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...