News:

Looking for documentation? Take a look on our wiki

Main Menu

End-price rounded wrong

Started by Tom Goedhart, February 15, 2012, 15:40:25 PM

Previous topic - Next topic

Tom Goedhart

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?

bluesheep

Do you need 1 Cent prices or only 5 Cent?

Beste Grüsse
bluesheep

Tom Goedhart

1 cent prices would be best, but if it really isn't posible 5 cent would be oke, i think.

bluesheep

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.

Tom Goedhart


chiappa

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.

Tom Goedhart

in virtuemart 2.06 there's a build in function to fill in the end-price

dbamacmac

To have 5 cent rounding change on line 1107

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

TO

return round($value*2, 1)/2;

Kub

#8
Thanks Virtuemart Team for Fix this Bug 8) good Job @ Max Milber and Team for this great Virtuemart Shopsystem

lindapowers

#9
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