VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: maxxer on February 11, 2013, 16:53:37 PM

Title: Totals mismatch
Post by: maxxer on February 11, 2013, 16:53:37 PM
Hi.

In a shop of ours we're having problems with totals: decimals mismatch...
Given the summary in the attached table, at first you can see that tax sum doesn't match.

On the background, I have a taxable amount of 312,53369, which summed to the tax amount (65,5837) results in a total of 378,11739, which is the unrounded total. But if I consider the taxable amount and apply VAT (21% in our case), the result is 378,16576, which is a 0.04€ gap from the printed value on the order or invoice. This difference is too much, and customers are complaining.

How can I make the visual values being usable in manual calculations? Should I set in configuration all prices to 2 decimals?
thanks

[attachment cleanup by admin]
Title: Re: Totals mismatch
Post by: GJC Web Design on February 11, 2013, 17:35:19 PM
but 21% of 312,53369 = 65,632074 (not 65,5837) = 378,16576 (there's the 4 cents)

where does the 65,5837 come from?

312.53    add VAT 21% (65.63 ) =   378.16

Title: Re: Totals mismatch
Post by: maxxer on February 11, 2013, 17:41:41 PM
Quote from: GJC Web Design on February 11, 2013, 17:35:19 PM
where does the 65,5837 come from?

Taxable (288.56369) + Shipping taxable (23.97) = 312.53369

These are from vm database...
thanks
Title: Re: Totals mismatch
Post by: maxxer on February 11, 2013, 18:01:14 PM
I tried placing the same order with 2 decimals calc all over the config but still having problems. Now in the database I have:
Taxable: 288.57000
Shipment: 23.97
SUM: 312,54
SUM + 21% -> 378,1734
SUM + 65.58 = 378,12

Order tax: 60.55000
Shipment tax: 5.03000
SUM: 65.58

Order total: 378,12


So I still have a mismatch in manual calc....
Title: Re: Totals mismatch
Post by: GJC Web Design on February 11, 2013, 18:11:42 PM
Order tax: 60.55000

this is wrong - it should be 60.5997

ship tax correct

can you display all the pricing on your product pages to find out at which stage this is happening?

i.e is the tax incl. price correct on the product details - in the cart etc etc -
do a simple round number product so any error is easy to see..
Title: Re: Totals mismatch
Post by: maxxer on February 11, 2013, 18:26:12 PM
From a quick search in the db I have one row which could be the culprit:
Product item price: 4.54545
Product tax: 0.95
product_item_price+product_tax: 5.49545
product_quantity: 6
(product_item_price+product_tax)*product_quantity: 32.97270
product_subtotal_with_tax: 33.00

Now the problem is to understand why...
Other lines are ok, even other lines with qty>1
Title: Re: Totals mismatch
Post by: maxxer on February 11, 2013, 18:30:22 PM
Apparently item tax is calculated using all the decimals, while doing the same with only two decimals returns the 3 missing €cents ...
Title: Re: Totals mismatch
Post by: GJC Web Design on February 11, 2013, 19:08:01 PM
is this only happening on multi item orders?
Title: Re: Totals mismatch
Post by: maxxer on February 12, 2013, 11:09:48 AM
Quote from: GJC Web Design on February 11, 2013, 19:08:01 PM
is this only happening on multi item orders?
Apparently it's a matter of quantity.
Given the following constants:
Product item price: 4.54545
Product tax: 0.95000
Price + tax: 5.49545 (A)

For the different quantities:





QTYA * QTYproduct_subtotal_with_tax
15.495455.50000
210.9909011.00000
316.4863516.50000

As you can see starting from 3 items the issue is raised. While a 0.01 is acceptable, increasing the quantity increases the error...
How can I mitigate it?
thanks!
Title: Re: Totals mismatch
Post by: GJC Web Design on February 12, 2013, 16:10:46 PM
this is all done in administrator/components/com_virtuemart/helpers/calculationh.php &
administrator/components/com_virtuemart/models/product.php

you need to start echoing out each stage to try and get an idea where the rounding errors are occurring

e.g. in the function getProductPrices() etc...
Title: Re: Totals mismatch
Post by: maxxer on February 12, 2013, 17:16:52 PM
I will, but it looks strange to me that nobody else ever experienced this issue...