Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

1.6.0.0 price rounding issues, wrong price displayed on grid and product view
 
Adam Moss
Sr. Member
 
Avatar
Total Posts:  248
Joined:  2009-02-11
Birmingham, UK
 
nspacex - 12 October 2011 11:22 AM

Hi,

i had the same problem. i solved this with the following simple change:

app/local/Mage/Core/Model/Store.php, function roundPrice(), Line: ~805

return round($price4);


regards,

This fix worked for me, thanks! I’d love an explanation as to why this fixes it!

 
Magento Community Magento Community
Magento Community
Magento Community
 
tyveris
Jr. Member
 
Total Posts:  28
Joined:  2010-05-17
 

I found a solution for Magento 1.6.2.0, I have 19% tax and the problem with the 1 Cent difference with PayPal!

Changing the Round-Function app/code/core/Mage/Core/Store.php didn’t work for me, because I have Shipping Costs, and this will bring the 1 cent difference to PayPal.

With changing the the file app/code/core/Mage/Shipping/Model/Carrier/Abstract.php at line 424 (ca.)

return $finalMethodPrice;
to
return round($finalMethodPrice,2);
works for me perfectly!

Now I have no problems with prices like 69,99 EUR incl. tax and shipping costs of 4,90 EUR incl. tax and PayPal!

Both calculates it right for me.

I hope somebody helps it (like me!)

Tyv.

 
Magento Community Magento Community
Magento Community
Magento Community
 
benbob79
Jr. Member
 
Total Posts:  9
Joined:  2010-12-16
 

Found the issue with my 1.7.0.0 store. Seems some of the fixes listed here have been applied but the issue remains.

return round($price4);

Worked for some instances but in particular paypal express checkout would still occasionally spit out errors. My guess is that the round function that is being edited rounds to the nearest number, whilst paypal uses the accounting method of always rounding up. Leaving us with the option of using the command ceil rather than round. The problem being that ceil only rounds up to whole numbers, there is a ceil_dec for decimals but I couldn\\\’t get this to work. My crude workaround was copy /app/code/core/Mage/Core/Model/Store.php to /app/code/local/Mage/Core/Model/Store.php and change line 944 from

return round($price2);

to

return (ceil(100*$price))/100;

Seems to be working so far…

Edit.... Scratch that. Already fallen over. Surely this a common problem. Getting really frustrated by lack of official fix.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Paul_Wilson
Jr. Member
 
Total Posts:  1
Joined:  2009-05-19
 

Bumping this thread…

We are still experiencing issues in Enterprise Edition 1.11.0.0… did anyone get an official working fix that:

a) Works with PayPal (Standard, PayFlow, Express)
b) Displays correct prices in roduct listing and individual product pages (without extra one cent less/more)
c) Displays correct grand total in checkout (without extra one cent less/more)

EDIT:

Add to that list

d) Multiple currencies
e) Multiple taxrates
f) Multiple shipping methods

Cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
a1anm
Guru
 
Total Posts:  318
Joined:  2009-10-08
 

Would love to hear if anyone has found a solution to this as well.

We are still experiencing problems with multi currency.  We are finding discrepancies of 0.01 between listings and the cart.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ninjured
Jr. Member
 
Total Posts:  24
Joined:  2010-06-21
 

tried all the soultions some work in some cases but not in others. argh!! tearing my hair out. 1.7

 
Magento Community Magento Community
Magento Community
Magento Community
 
MikeNatty
Jr. Member
 
Total Posts:  5
Joined:  2012-10-07
 

***SOLVED***

Guys I think I’ve found the issue (at least if your product prices INCLUDE tax).

In Mage_Tax_Model_Calculation::calcTaxAmount()

if ($priceIncludeTax) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}

If your price includes tax this is totally backwards!

If price INCLUDES tax the calc should be:  $amount = $price*$taxRate;

So change to read (add NOT (!) to condition to reverse it):

if ( ! $priceIncludeTax ) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}

This drove me nuts and I’ve wasted a lot of hours tracking this down. Hope this helps you all.

NOTE: I have not tested tax calcs for products that do not include Tax. I’ll leave that for someone else.

As per usual do not modify the core files directly, extend with a custom module in ‘local’.

MIke

 
Magento Community Magento Community
Magento Community
Magento Community
 
ninjured
Jr. Member
 
Total Posts:  24
Joined:  2010-06-21
 
MikeNatty - 22 October 2012 09:16 PM

***SOLVED***

Guys I think I’ve found the issue (at least if your product prices INCLUDE tax).

In Mage_Tax_Model_Calculation::calcTaxAmount()

if ($priceIncludeTax) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}


If your price includes tax this is totally backwards!

If price INCLUDES tax the calc should be:  $amount = $price*$taxRate;

So change to read (add NOT (!) to condition to reverse it):

if ( ! $priceIncludeTax ) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}


This drove me nuts and I’ve wasted a lot of hours tracking this down. Hope this helps you all.

NOTE: I have not tested tax calcs for products that do not include Tax. I’ll leave that for someone else.

As per usual do not modify the core files directly, extend with a custom module in ‘local’.

MIke

have my babies

 
Magento Community Magento Community
Magento Community
Magento Community
 
chrisandy
Sr. Member
 
Total Posts:  92
Joined:  2007-10-17
 

Can anybody tell me in which file I would find the following:

if ($priceIncludeTax) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
chrisandy
Sr. Member
 
Total Posts:  92
Joined:  2007-10-17
 
MikeNatty - 22 October 2012 09:16 PM

***SOLVED***

Guys I think I’ve found the issue (at least if your product prices INCLUDE tax).

In Mage_Tax_Model_Calculation::calcTaxAmount()

if ($priceIncludeTax) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}


If your price includes tax this is totally backwards!

If price INCLUDES tax the calc should be:  $amount = $price*$taxRate;

So change to read (add NOT (!) to condition to reverse it):

if ( ! $priceIncludeTax ) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}


This drove me nuts and I’ve wasted a lot of hours tracking this down. Hope this helps you all.

NOTE: I have not tested tax calcs for products that do not include Tax. I’ll leave that for someone else.

As per usual do not modify the core files directly, extend with a custom module in ‘local’.

MIke

This method didn’t work for me - as such. It works in terms of the totals in the shopping cart but the prices in the catalog all go wrong - prices that were 1.50 become 1.40

 
Magento Community Magento Community
Magento Community
Magento Community
 
pixelfreezer
Jr. Member
 
Total Posts:  1
Joined:  2012-03-17
 
MikeNatty - 22 October 2012 09:16 PM

***SOLVED***

Guys I think I’ve found the issue (at least if your product prices INCLUDE tax).

In Mage_Tax_Model_Calculation::calcTaxAmount()

if ($priceIncludeTax) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}


If your price includes tax this is totally backwards!

If price INCLUDES tax the calc should be:  $amount = $price*$taxRate;

So change to read (add NOT (!) to condition to reverse it):

if ( ! $priceIncludeTax ) {
$amount = $price*(1-1/(1+$taxRate));
} else {
$amount = $price*$taxRate;
}


This drove me nuts and I’ve wasted a lot of hours tracking this down. Hope this helps you all.

NOTE: I have not tested tax calcs for products that do not include Tax. I’ll leave that for someone else.

As per usual do not modify the core files directly, extend with a custom module in ‘local’.

MIke

This doesn’t work for me on 1.7.0.2. The rounding error is still there in the shopping cart and checkout and it completely messes up the tax amount (which I have to have displayed to comply with German law).

 
Magento Community Magento Community
Magento Community
Magento Community
 
SimonLindner
Member
 
Avatar
Total Posts:  31
Joined:  2011-09-08
Bremen
 

Okay, here is what I found out:

Do not modify code wink Go to System->Configuration->Taxes and change calculation method to “Single Price” (or whatever the English thing is, my shops are German)

Worked after first tests in German shops. How about yours?

 
Magento Community Magento Community
Magento Community
Magento Community
 
wardown
Jr. Member
 
Total Posts:  4
Joined:  2010-01-28
 

these solutions are not working in m1.7.0.2. In case, all prices (order, invoice, pdf invoice) are correct, paypal use to write \"suspected fraud\”, same with 4 digits rounding tax calculation. Mostly it\’s counting bad price when using discounts. seems to be never ending story

 
Magento Community Magento Community
Magento Community
Magento Community
 
Spez86
Jr. Member
 
Total Posts:  22
Joined:  2010-02-14
 

Hi all.

I’ve managed to sort of fix this on my setup 1.7.0.2 as below:

1. All my prices all include tax
2. I apply tax after discounts and discount on prices including tax.
3. I’ve set Tax Calculation based on Row Total.

I’ve copied the file: app/code/core/Mage/Core/Model/Store.php to the app/code/local with the same directory structure so I don’t override core files and I’ve simply done what the other says above which is to change:

return round($price2);
to
return round($price4);

However, exactly how it rounds seems to still be a mystery to me as it seems to be rounding 0.8333 pence up to 0.84 pence.

 
Magento Community Magento Community
Magento Community
Magento Community
 
yaro
Jr. Member
 
Total Posts:  3
Joined:  2007-12-18
 
Ente - 11 November 2012 03:20 AM

Okay, here is what I found out:

Do not modify code ;) Go to System->Configuration->Taxes and change calculation method to “Single Price” (or whatever the English thing is, my shops are German)

Worked after first tests in German shops. How about yours?

Yes, this is the solution. I changed it to Row Total

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top