Order total and credit card total are different

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
awhc
Ensign (ENS)
Ensign (ENS)
Posts: 18
Joined: Tue Sep 23, 2008 12:31 pm

Order total and credit card total are different

Post by awhc » Wed Jan 28, 2009 1:53 pm

I've just discovered that when I calculate sales tax for a zipcode that has 3 digits (ie. .0975) the amount that is sent to Authorize.net is different than the amount on the order. On the order receipt itself it shows 2 different amounts. For example:
Order Total: $1,396.27
Payment Amount: $1,396.26

It leaves an amount due.

I'm using my own sales tax provider which has been working fine, and still is. It is calculating correctly but I don't know what happens to the value when it gets pulled into the cart.

This looks like some kind of rounding error. Has anyone else had this issue? If so, how did you fix it? Is this a bug?

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Order total and credit card total are different

Post by AbleMods » Wed Jan 28, 2009 3:29 pm

awhc wrote:I've just discovered that when I calculate sales tax for a zipcode that has 3 digits (ie. .0975) the amount that is sent to Authorize.net is different than the amount on the order. On the order receipt itself it shows 2 different amounts. For example:
Order Total: $1,396.27
Payment Amount: $1,396.26
You shouldn't be allowing 3 decimal places in any calculated dollar amount. You'll get all sorts of weird rounding issues throughout AC7 if you do.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

awhc
Ensign (ENS)
Ensign (ENS)
Posts: 18
Joined: Tue Sep 23, 2008 12:31 pm

Re: Order total and credit card total are different

Post by awhc » Thu Jan 29, 2009 9:50 am

It's not that I'm allowing 3 decimal places. Maybe I described the problem wrong. I'm testing my site and found that when I place an order for a certain amount that is on the "rounding" line, I get different results.
For example:
part cost - $1,254
shipping - $20 (not taxed)
taxrate based on zipcode - .0975
tax amount - $122.265 (internal calc., note the 5) (this was what I meant by the 3 decimal places)

This produces a tax rate on the basket (before charging the card) of $122.26 and order total of $1,396.26.
After charge, the order receipt shows: Order Total - $1,396.27, Tax - $122.27, and Charge Amount - $1,396.26.
Which leaves a .01 discrepancy for the amounts.

I can't figure out how to fix this. I have tried rounding, converting to a string format, and other stuff in my tax class but nothing works. To make things worse, the email I get back from Authorize.net shows Order Total - $1,396.26 and Tax - $122.27, which is the total amount from the basket but the tax amount from the order receipt.

I was getting ready to launch this app when this was just discovered. Most of the time there isn't a rounding issue and everything looks fine.

I'm not using the tax class "Commit" function, only the "Calculate" function. Is it possible that the 2 different methods calculate or round differently?

Any ideas on what I can try?

Thanks for your response and help!

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Order total and credit card total are different

Post by AbleMods » Thu Jan 29, 2009 10:04 am

I'm not sure if I can be of much help. If you've written your own tax provider and the returned tax value is not getting rounded, wouldn't the issue be in your code?

Can you breakpoint the code in the tax provider you wrote and see how to round it correctly just before it returns the value back to AC7? There's a ton of documentation on the web for how to round numeric values in .Net.

I've had trouble with rounding a few times - took a while to figure it out but it definitely caused all sorts of weird things to happen in my storefront. Especially what you're seeing, where orders would show a .01 balance even after capture.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

awhc
Ensign (ENS)
Ensign (ENS)
Posts: 18
Joined: Tue Sep 23, 2008 12:31 pm

Re: Order total and credit card total are different

Post by awhc » Thu Jan 29, 2009 2:03 pm

Solunar, thanks for your response and help. I figured out the issue. The tax amount I was returning to the order class was rounding differently than the tax amount I was creating as a line item in the basket. I changed the basket item to midpoint round away from zero and everything aligned correctly. I still don't understand how it all works together but at least it is calculating correctly now.
Thanks again.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Order total and credit card total are different

Post by AbleMods » Thu Jan 29, 2009 2:06 pm

I don't know that I helped all that much but you're welcome - glad you got it working!
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply