Search code examples
phpmagentodecimal-point

Magento - decimal points in invoice/be


I need for my shop up to 4 decimal points. So far I followed some tuts and theyre working fine in front & backend for products. Only in sales/invoice prices,tax and totals are still rounded to 2 decimal points.

I've edited/overwrote following files:

\app\code\local\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php

somewhere around line 283 i changed return number_format($value, 2, null, ''); in return number_format($value, 4, null, '');

\app\code\local\Mage\Adminhtml\Block\Catalog\Product\Helper\Form\Price.php 

same as in Option.php

\app\code\local\Mage\Core\Model\Store.php* changed output of function roundPrice() line 740 into return round($price, 4);

\app\code\local\Mage\Directory\Model\Currency.php in function format() changed formatPrecision from 2 to 4 in line 197.

\lib\Zend\Currency.php $_options['precision'] changed from 2 to 4

\app\design\adminhtml\default\default\template\catalog\product\edit\price\tier.phtml echo sprintf('%.2f', $_item['price']); changed to sprintf('%.4f', $_item['price'])

Ive looked into some core files like invoice.php or in adminhtml files if there are rounding stuff. But I couldnt find anything useful.

used extensions: (Magento 1.4.1.0)  
Asperience_DeleteAllOrders  
Flagbit_ChangeAttributeSet  
Mxperts_Invoice  
de_DE languagepack  

thanks, greetz Rito

magento round issue

(sorry for german in picture)


Solution

  • "totals" was a good hint, thx to Jonathan Day

    Heres the solution for sales/invoice with four decimal points.

    \app\code\local\Mage\Adminhtml\Block\Sales\Items\Abstract.php
    change following code:
    Line 292: function displayPrices() change to return $this->displayRoundedPrices($basePrice, $price, 4, $strong, $separator);
    Line 305: $precision=2 into $precision

    \app\code\local\Mage\Sales\Model\Order.php line 1358:

    public function formatPrice($price, $addBrackets = false)
        {
            return $this->formatPricePrecision($price, 4, $addBrackets);
        }
    

    I know its very dirty, but it works fine :)