VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: moose999 on May 14, 2015, 11:54:34 AM

Title: Rounding error with coupon
Post by: moose999 on May 14, 2015, 11:54:34 AM
Hi there,

If i have a product for 0.75 and i buy 3 of them that is 2.25. If i then use a 10% discount code VM removes 0.23 (10% of 2.25, rounded up). However, it (the cart) then shows the wrong overall total, 2.03.

2.03+0.23=2.26, not 2.25.

My problem with this is that numbers across the invoice don't tally. Personally I don't care if I get the 0.01 or if the shopper gets it, but the numbers need to be consistent.

I have attached a screengrab of the cart showing the problem.

Many thanks,
Justin

VM 3.0.9, J3.4.1
Title: Re: Rounding error with coupon
Post by: moose999 on May 27, 2015, 09:53:55 AM
Hi there,

Has anyone else got any experience with these rounding errors?

Justin
Title: Re: Rounding error with coupon
Post by: Milbo on May 27, 2015, 12:47:04 PM
http://en.wikipedia.org/wiki/Distributive_property#Distributivity_and_rounding
Title: Re: Rounding error with coupon
Post by: moose999 on May 27, 2015, 14:57:42 PM
Hi I think I understand why the numbers round like that, my problem with this is that numbers displayed on the invoice don't tally. Personally I don't care if I get the 0.01 or if the shopper gets it, but I need the numbers need to be consistent.

In my example the customer sees 2.25 - 0.23 = 2.03 and then complains :)

I am writing a plugin to integrate Virtuemart and the Xero accounting application, and due to the 2 decimal place limit on their systems, these rounded transactions are declared invalid because their totals do not add up. If VM could have a setting to calculate the grand total based on the 2 decimal place total of all the line items, then perhaps the (very common in the forums) complaints from people with confusion around rounding would go away?

Many thanks,
Justin