Author Topic: End-price rounded wrong  (Read 6716 times)

Tom Goedhart

• Beginner
• Posts: 20
End-price rounded wrong
« on: February 15, 2012, 15:40:25 pm »
Hi all, I've been lead to this forum because of this post:

Quote
Hi 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

• Beginner
• Posts: 18
Re: End-price rounded wrong
« Reply #1 on: February 15, 2012, 15:49:08 pm »
Do you need 1 Cent prices or only 5 Cent?

Beste Grüsse
bluesheep

Tom Goedhart

• Beginner
• Posts: 20
Re: End-price rounded wrong
« Reply #2 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.

bluesheep

• Beginner
• Posts: 18
Re: End-price rounded wrong
« Reply #3 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
Code: [Select]
function roundDisplay(\$value) {
return round(\$value, 2);
}
to this
Code: [Select]
function roundDisplay(\$value) {
return round(\$value*2, 1)/2;
}
for 1 Cent try this on the same line
Code: [Select]
function roundDisplay(\$value) {
return round(\$value, 4);
}
It's not a good solution, but it maybe work.

Tom Goedhart

• Beginner
• Posts: 20
Re: End-price rounded wrong
« Reply #4 on: February 15, 2012, 16:45:51 pm »

chiappa

• Beginner
• Posts: 32
Re: End-price rounded wrong
« Reply #5 on: April 27, 2012, 10:55:05 am »
In VirtueMart 2.0.6, calculationh.php, line 1120

it's commented out:

Code: [Select]
/*              function roundDisplay(\$value) {
return round(\$value, 4);
}*/

changing it to:

Code: [Select]
function roundDisplay(\$value) {
return round(\$value*2, 1)/2;
}

has no effect.

Tom Goedhart

• Beginner
• Posts: 20
Re: End-price rounded wrong
« Reply #6 on: May 02, 2012, 15:14:05 pm »
in virtuemart 2.06 there's a build in function to fill in the end-price

dbamacmac

• Beginner
• Posts: 1
Re: End-price rounded wrong
« Reply #7 on: June 18, 2012, 11:21:12 am »
To have 5 cent rounding change on line 1107

Code: [Select]
return round(\$value, \$this->_internalDigits);
TO

Code: [Select]
return round(\$value*2, 1)/2;

Kub

• Beginner
• Posts: 14
Re: End-price rounded wrong
« Reply #8 on: September 24, 2012, 08:39:31 am »
Thanks Virtuemart Team for Fix this Bug good Job @ Max Milber and Team for this great Virtuemart Shopsystem

lindapowers

• Full Member
• Posts: 1335
• If you're going through hell, keep going.
• Skype Name: manu.gonzalez91
• VirtueMart Version: Latest avi
Re: End-price rounded wrong
« Reply #9 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