Author Topic: Round errors  (Read 5400 times)

ugriecu

  • Beginner
  • *
  • Posts: 27
Round errors
« 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?

aravot

  • Peter
  • Moderator
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: Round errors
« Reply #1 on: May 10, 2008, 23:08:13 pm »
I tried it on my site it shows $1.23

ugriecu

  • Beginner
  • *
  • Posts: 27
Re: Round errors
« Reply #2 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?

aravot

  • Peter
  • Moderator
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: Round errors
« Reply #3 on: May 11, 2008, 02:32:55 am »
I am using Joomla 1.5.3 and VirtueMart 1.1

ugriecu

  • Beginner
  • *
  • Posts: 27
Re: Round errors
« Reply #4 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

willowtree

  • Full Member
  • ***
  • Posts: 542
    • Willow Tree Crafts
Re: Round errors
« Reply #5 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
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

ugriecu

  • Beginner
  • *
  • Posts: 27
Re: Round errors
« Reply #6 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???!!!!!!

willowtree

  • Full Member
  • ***
  • Posts: 542
    • Willow Tree Crafts
Re: Round errors
« Reply #7 on: May 11, 2008, 12:56:04 pm »
mine shows 1.29?
Please add your VM and Joomla Version to your signature to make it easier to help you:

Most of my code posted in the forum is for VirtueMart 1.0  -  not for 1.1

ugriecu

  • Beginner
  • *
  • Posts: 27
Re: Round errors
« Reply #8 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

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3452
  • using Matomo instead of Google Analytics
Re: Round errors
« Reply #9 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
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations