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

Page 1 of 5
1.6.0.0 price rounding issues, wrong price displayed on grid and product view
 
onepack
Sr. Member
 
Total Posts:  98
Joined:  2008-06-02
Amsterdam
 

I’m setting up a new webshop using Magento and this is not the first one that I built but this is the first time I ran into this strange bug.

None of my prices displayed in the grid is right.

System: Magento 1.6.0.0
Product Price: Inc. vat
Vat: 19% (Dutch)
Type of products: Simple products
Currency: Euro

When I give a simple product a price of 15 Euros the price that is displayed in the grid and product view is 15,01 !!!!!!

When I give a price of 14 euros the price displayed in the grid and product view is 13,99!!!!

When I add this product to my cart the price displayed is correct again.

This is really bad because it affects the most basic thing of a webshop: The prices that you want your customers to see.
I know about the rounding-vat-issue is this related?

Anyone? Maybe even somebody from the Magento team/support???

 
Magento Community Magento Community
Magento Community
Magento Community
 
onepack
Sr. Member
 
Total Posts:  98
Joined:  2008-06-02
Amsterdam
 

Looking into all these calculation issues but I don’t see anyone with this issue on a simple product without any discount rules applied.

 
Magento Community Magento Community
Magento Community
Magento Community
 
onepack
Sr. Member
 
Total Posts:  98
Joined:  2008-06-02
Amsterdam
 

I tried to clear all cache, sessions and indexes and reinstalled the mage_all_latest but nothing helps. It appears that this is a bug in the core functionality of magento 1.6.0.0
When I change the price to 12 euro the price on the frontend is also 12 euro but 13 (12,99) 14 (13,99) and 15 (15,01) are all useless to use in the shop now as a price.

I\’m afraid that one tax fix caused a new major bug in 1.6.0.0

By the way, in the cart the prices are always displayed correctly. This only happens with grid-view and product-view.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kdtips
Member
 
Avatar
Total Posts:  73
Joined:  2011-08-13
Auckland New Zealand
 

I havent tryied in Magento 1.6 but it wont suppose to happen.

Have a look on the database? what it is return?

Or on product page you can try

echo Mage::getModel('catalog/product')->load(PRODUCT_ID)->getPrice();
 
Magento Community Magento Community
Magento Community
Magento Community
 
satish
Enthusiast
 
Avatar
Total Posts:  812
Joined:  2008-03-24
34,mantri Sadan,Shivaji Nagar,Nagpur,MS,India 4400
 
onePack - 01 September 2011 01:58 PM

I tried to clear all cache, sessions and indexes and reinstalled the mage_all_latest but nothing helps. It appears that this is a bug in the core functionality of magento 1.6.0.0
When I change the price to 12 euro the price on the frontend is also 12 euro but 13 (12,99) 14 (13,99) and 15 (15,01) are all useless to use in the shop now as a price.

I\’m afraid that one tax fix caused a new major bug in 1.6.0.0

By the way, in the cart the prices are always displayed correctly. This only happens with grid-view and product-view.

Are you using a fresh Magento or some template.
Also are you displaying cost inclusive of price.

This will come from rounding effect.

Eg your cost with 19% vat is 15.

so youplace cost as 12.60 ( Should be 12.605) not to this we add 19% and it comes to 14.994 rounded to 14.99
or if you define it as 12.61then it comes to 15.0059 rounded to 15.01

so the way out is define cost price by one extra devimal to what you want final price.
That is is you want final price in 2 digits then add cost price as three digits or let final price berounded to 1 digit.

This is all because you have tax as 19% which will result in an extra decimal value.

Satish

Satish

 
Magento Community Magento Community
Magento Community
Magento Community
 
onepack
Sr. Member
 
Total Posts:  98
Joined:  2008-06-02
Amsterdam
 

Hi Satish,

Thank you so much for your time! I\’m building my own theme like always and it\’s an upgraded version starting from 1.5.0.0. As I remember 1.6.0.0 is the first time that I see this behavior.
I have made quite some webshops and I always have 19% vat for Holland and in the backend the price entered is always including 19% vat. However this is the first time that I see the price on the frontend being affected by a rounding issue.
No theme file adjustments would affect this price and changing my theme to be the default magento theme doesn\’t change the frontend prices, they are still incorrect, so it must be in the core.

I will try your option but it is an time consuming hassle because I will need to change the prices of all the products now in the backend.

Maybe I´ll have to file this as a core bug.

 
Magento Community Magento Community
Magento Community
Magento Community
 
d0tc0m
Jr. Member
 
Total Posts:  6
Joined:  2011-07-22
 

Has anyone got a solution for this issue?
We are having the same problems as described.

Many thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Andreas Weis
Jr. Member
 
Total Posts:  1
Joined:  2010-07-04
 

Hello,

I have exactly the same issue after updating to 1.6.0.0

Is there a solution available, yet?

Thank you

 
Magento Community Magento Community
Magento Community
Magento Community
 
onepack
Sr. Member
 
Total Posts:  98
Joined:  2008-06-02
Amsterdam
 

Pretty lame but I changed the affected prices from 15 to 14.95 - When you are building a store for a client this might not be a possibility.
So I suggest to always have a development environment and test the backend and fronend output before upgrading the live environment. This is the only way to have a stable webshop and is less time and money consuming for both parties (clients and developers)
So in this case stick to the older verion before upgrading and solve it in the development version. As for the solution. I’m a bit short of time to try and solve this kind of issues lately. Maybe call the price that the shopping cart uses to display the product price as the cart prices doesn’t seem to be affected by the rounding issue.

 
Magento Community Magento Community
Magento Community
Magento Community
 
R O B
Jr. Member
 
Avatar
Total Posts:  11
Joined:  2009-06-26
the Netherlands
 

Is there a solution available, yet?
I have exactly the same issue after updating to 1.6.0.0

 
Magento Community Magento Community
Magento Community
Magento Community
 
R O B
Jr. Member
 
Avatar
Total Posts:  11
Joined:  2009-06-26
the Netherlands
 

I hAve found a solution:

Change app/code/core/Mage/Tax/Helper/Data.php

protected function _calculatePrice($price$percent$type)
    
{
        $calculator 
Mage::getSingleton('tax/calculation');
        if (
$type{
            $taxAmount 
$calculator->calcTaxAmount($price$percentfalsefalse);
            return 
$price $taxAmount;
        
else {
            $taxAmount 
$calculator->calcTaxAmount($price$percenttruefalse);
            return 
$price $taxAmount;
        
}
    }

Put in the last param (round = false)

 
Magento Community Magento Community
Magento Community
Magento Community
 
tingwang
Jr. Member
 
Total Posts:  3
Joined:  2011-06-18
 

This is a rounding error:

The error happens just when the program runs into line 501 (in class Mage_Tax_Helper_Data and method getPrice()), which means
$includingTax = null (I’m not sure what this parameter means) and $priceIncludesTax = true (which means the price in your store includes the tax)

case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX:
                
$price $this->_calculatePrice($price$includingPercentfalse);
                
$price $this->_calculatePrice($price$percenttrue);
                 break;

Here the price is calculated twice, i don’t know why (I don’t think it is necessary. If the price in my store already includes the tax and i want to show the price with tax, why it needs to be calculated it?). However it would be fine if there is no round().

Unfortunately there HAS “round()” when the price is calculated

in the class Mage_Tax_Model_Calculation

public function calcTaxAmount($price$taxRate$priceIncludeTax=false$round=true)
    
{
        $taxRate 
$taxRate/100;

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

        
if ($round{
            
return $this->round($amount);
        
}

        
return $amount;
    
}

The default value of $round is true. so the tax is no more precise. It is ok for just showing the tax. But using this rounded tax to calculate the price causes round error

A simple code to reproduce the error like:

<?php

function calcTaxAmount($price$taxRate$priceIncludeTax=false$round=true)
{
    $taxRate 
$taxRate/100;

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

    
if ($round{
        
return round($amount2);
    
}

    
return $amount;
}
function calcPrice($price$percent$type)
{
    
if ($type{
        $taxAmount 
calcTaxAmount($price$percentfalse);
        return 
$price $taxAmount;
    
else {
        $taxAmount 
calcTaxAmount($price$percenttrue);
        return 
$price $taxAmount;
    
}
}
$price 
calcPrice(15.5019false);
$finalPrice calcPrice($price19true);
var_dump($finalPrice);

Which will output float(15.51)

The solution may be return the price directly without calculating or set $round as false.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tingwang
Jr. Member
 
Total Posts:  3
Joined:  2011-06-18
 

I have added a new Issue #26457

 
Magento Community Magento Community
Magento Community
Magento Community
 
adamhw
Member
 
Total Posts:  51
Joined:  2009-12-22
 

I’m using 1.6 too and not only is it returning 4 decimal places on the product grid pages, but it won’t change the default currency from USD to anything else even though it’s set to GBP in admin.

On the actual individual product pages it’s not showing up a price at all!

 
Magento Community Magento Community
Magento Community
Magento Community
 
krzaczek
Jr. Member
 
Avatar
Total Posts:  10
Joined:  2010-10-08
Warsaw, Poland
 

Had the same problem ... changed

core/Mage/Tax/Helpers/Data.php

line 439: $price = $this->_calculatePrice($price, $includingPercent, false);
line 494: $price = $this->_calculatePrice($price, $percent, true);
to
line 439: $price = $this->_calculatePrice($price, $includingPercent, true);
line 494: $price = $this->_calculatePrice($price, $percent, false);

Worked like a charm smile

Ver 1.6.0.0

Pawel

 
Magento Community Magento Community
Magento Community
Magento Community
 
skekum
Jr. Member
 
Total Posts:  5
Joined:  2010-07-29
 

krzaczek,

I was wondering if you could be more specific, the phrase:

_calculatePrice($price$includingPercentfalse);
occurs 4 times in that general area but you indicated you only changed it once.

Which one/ones did you change?

Thanks
Glenn

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 5