VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Tom Goedhart on February 15, 2012, 15:40:25 PM

Title: End-price rounded wrong
Post by: Tom Goedhart on February 15, 2012, 15:40:25 PM
Hi all, I've been lead to this forum because of this post:

QuoteHi all,

I have a problem with a calculation rule for adding the tax to a net price.
Because all price values are rounded BEFORE the calculation is processed, I get rounding errors.

An example:
I want to have a gross price of 8.80€ (should be the salesPrice).
The net price is: 7.39496, and I have a calculation rule (type Tax) with a value of 19 (+%).

The problem:
In calculation.php (function getProductPrices(...)) all prices are rounded to 2 decimal places. Also the incoming price of the calculation!
So the following is done in method interpreteMathOp(...): (7.39 * 19 / 100) + 7.39 = 8.79€ -> not the expected result!

What is my mistake? Seems to be incorrect!?

Thank to all in advance

It's my exact problem. Only I'm using virtuemart 2.0 and he is using 1.14. My end prices should be prices like: 50,00 75,00 10,00 72,50 etc.

How can i solve this? No my prices are showing like 50,01, 74,99 etc. When i raise the tax with 1 cent my end-price raises two. So i can choose between 72,49 or 72,51. But not 72,50.

Somebody knows how to solve this?
Title: Re: End-price rounded wrong
Post by: bluesheep on February 15, 2012, 15:49:08 PM
Do you need 1 Cent prices or only 5 Cent?

Beste Grüsse
bluesheep
Title: Re: End-price rounded wrong
Post by: Tom Goedhart on February 15, 2012, 16:05:43 PM
1 cent prices would be best, but if it really isn't posible 5 cent would be oke, i think.
Title: Re: End-price rounded wrong
Post by: bluesheep on February 15, 2012, 16:19:29 PM
Okey.

for 5 Cent -> in administrator\components\com_virtuemart\helpers\calclationh.php on line 1043 change this

function roundDisplay($value) {
                       return round($value, 2);
                }

to this

function roundDisplay($value) {
                       return round($value*2, 1)/2;
                }

for 1 Cent try this on the same line

function roundDisplay($value) {
                       return round($value, 4);
                }

It's not a good solution, but it maybe work.
Title: Re: End-price rounded wrong
Post by: Tom Goedhart on February 15, 2012, 16:45:51 PM
Your my hero!  ;D
Title: Re: End-price rounded wrong
Post by: chiappa on April 27, 2012, 10:55:05 AM
In VirtueMart 2.0.6, calculationh.php, line 1120

it's commented out:

/*              function roundDisplay($value) {
                        return round($value, 4);
                }*/


changing it to:

function roundDisplay($value) {
                       return round($value*2, 1)/2;
                }


has no effect.
Title: Re: End-price rounded wrong
Post by: Tom Goedhart on May 02, 2012, 15:14:05 PM
in virtuemart 2.06 there's a build in function to fill in the end-price
Title: Re: End-price rounded wrong
Post by: dbamacmac on June 18, 2012, 11:21:12 AM
To have 5 cent rounding change on line 1107

return round($value, $this->_internalDigits);

TO

return round($value*2, 1)/2;
Title: Re: End-price rounded wrong
Post by: Kub on September 24, 2012, 08:39:31 AM
Thanks Virtuemart Team for Fix this Bug 8) good Job @ Max Milber and Team for this great Virtuemart Shopsystem
Title: Re: End-price rounded wrong
Post by: lindapowers on December 27, 2012, 13:04:25 PM
They fixed the bug???

I'm having this same issue due to shipping tax getting rounded:

https://forum.virtuemart.net/index.php?topic=111435.0

How did you solve it in latest vm 2.016?

I'm looking at calculationh.php and I have tried changing the code as suggested here with no effect. Actually there are 2 instances and don't really know where to change it, tried both but our price still showed 14.01 instead of 14.00.

I still either get 14.01 or 13.99 as final price due to the fact that the shipping cost tax gets rounded to 2 decimals instead of 4.

So how can I either round the final price or make the checkout use 4 decimals for shipping VAT and 2 for final price. They seem to act together.

Please help, we are getting mad trying to set up shipping costs, half get rounded and show incorrect final price.

Regards