Author Topic: Problem with prices and rounding in VM1.1.6  (Read 2757 times)

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3533
  • using Matomo instead of Google Analytics
Problem with prices and rounding in VM1.1.6
« on: November 25, 2010, 21:50:57 pm »
I had a look in at the product prices in my database table jos_vm_product_price and noticed some inconsistencies. Most of my prices seem to be rounded to 2 decimals plus three zeros. Some (I suppose products entered in an older version of VM 1.1.x) seem to be rounded to 5 decimals. And if I enter a gross price of i.e. 229 for a new product in VM 1.1.6, it shows 249,9999 after clicking on 'Save'. If I enter a gross price of 250, it still shows 250 after clicking 'Save'.

I've attachted a screenshot from jos_vm_product_price showing two different net prices for the same gross price (156 Euro)    

I guess the above is also related to this:
https://forum.virtuemart.net/index.php?topic=78621.0
      
PS: Something I see most of the day when trying to access VirtueMart.net recently is:
"The connection has timed out
The server at forum.virtuemart.net is taking too long to respond."
Would be nice if somebody would check the server. For some reason it apparently has quite a lot of hickups. ;)

[update}
The two different net prices for the same gross price happened because I forgot to apply my old fix for this (see next post) while using VM 1.1.5

      
        
        

          


[attachment cleanup by admin]
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3533
  • using Matomo instead of Google Analytics
Re: Problem with prices and rounding in VM1.1.6
« Reply #1 on: November 25, 2010, 22:26:18 pm »
I just discovered that I had the problem with the gross price sometimes showing 1/10000 wrong already 2 1/2 years ago. My personal simple stupid solution was this (lines adapted to vm1.1.6):

In the file .../administrator/components/com_virtuemart/html/product.product_form.php

line 1342:      ...document.adminForm.product_price_incl_tax.value = doRound(grossValue, 5);
line 1359:      ...document.adminForm.product_price.value = doRound(netValue, 5);

change from "5" to "2"

and in the file .../administrator/components/com_virtuemart/html/product.product_price_form.php

line 179:      ...document.adminForm.product_price_incl_tax.value = doRound(grossValue, 5);
line 194:      ...  document.adminForm.product_price.value = doRound(netValue, 5);

change from "5" to "2"

And using phpadmin change 'table jos_vm_product_price -> Structure -> product price' from:
product price decimal(12,5)
to
product price decimal(12,2)
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations