VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Virtuemart 1.1 Development (Archiv) => Quality & Testing VirtueMart 1.1.x => Topic started by: ugriecu on May 10, 2008, 15:34:41 PM

Title: Round errors
Post by: ugriecu on May 10, 2008, 15:34:41 PM
try to add a new product with a gross price of 1.75 and apply a discount of 30%, the correct result is (1.225) 1.23 rounded but vm gives 1.22...anybody knows this problem/bug?
Title: Re: Round errors
Post by: aravot on May 10, 2008, 23:08:13 PM
I tried it on my site it shows $1.23
Title: Re: Round errors
Post by: ugriecu on May 11, 2008, 00:09:11 AM
I also tried it in demo shop of virtuemart and showes 1.22.....what version do you use?
Title: Re: Round errors
Post by: aravot on May 11, 2008, 02:32:55 AM
I am using Joomla 1.5.3 and VirtueMart 1.1
Title: Re: Round errors
Post by: ugriecu on May 11, 2008, 10:47:31 AM
I'm sorry, but I've tried all version of vm and all have this bug, repeat:

-Insert ad product with a gross price of 1.75
-apply a discount of 30%
-(any tax if you want)
-click on save
-THE RESULT IS 1.22 AND NOT 1.23

ps: I also checked the flag to calculate the discount before tax and the bug persists
Title: Re: Round errors
Post by: willowtree on May 11, 2008, 10:55:13 AM
I have the same error (1.22) on the following clean install:
Joomla! 1.5.3 Production/Stable [ Vahi *eCommerce Edition* ] 22-April-2008 22:00 GMT

VM 1.1
Title: Re: Round errors
Post by: ugriecu on May 11, 2008, 12:38:35 PM
strange error, but discontinuos try:

gross price: 1.85
discount: 30%
result: 1.30 RIGHT!!!!!!!!!!!!!!!!!!(1.295)?????????????????????????????????????????

ANYBODY EXPLAINS  TO ME THIS???!!!!!!
Title: Re: Round errors
Post by: willowtree on May 11, 2008, 12:56:04 PM
mine shows 1.29?
Title: Re: Round errors
Post by: ugriecu on May 11, 2008, 13:53:08 PM
another strange thing:

tax: 10%
gross price: 1.65
discount: 30%
CLICK ON SAVE RETURN TO CHECK THE PRODUCT AND:
final price: (1.155) 1.16 BUT VM GIVES ME 1.15???!!!!

I SUPPOSE IN A REAL BIG BUG
Title: Re: Round errors
Post by: jjk on May 11, 2008, 19:13:58 PM
Not shure yet, but I think this problem is related to the variable jos_vm_product_price and its setting in the mysql table.
It is set to the total number of 12 digits (the precision) and the number of 5 digits after the decimal point (the scale).

(Don't know where the rounding to two digits takes place - in MySQL or VM?)

One example from my installation:

If I type a product price (Gross) of 198.00 into the product information form, VM displays 166.38655 (VAT set to 19 percent) for the product price (Net). The last digit (5) is rounded - the numbers behind it are truncated. When I save this price, VM obviously recalculates the Gross price and changes my 198.00 to 197,99999 in the product information form, which is the result of taking the Net product price including its five digits after the decimal point x 1.19.

The 197,9999 has annoyed me for quite a while already although I didn't complain about it yet. Would be nice if I could see 198.00 in the administration product information form some time in the future. ;D

MySQL changed the handling of Decimal Data Types in MySQL 5.03. Maybe this is causing the output described in the first post of this thread.

Joerg
Joomla 1.5.3, VM 1.1