简体   繁体   English

Magento-发票/ be中的小数点

[英]Magento - decimal points in invoice/be

I need for my shop up to 4 decimal points. 我的商店需要最多4个小数点。 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, ''); 我在第283行附近更改了return number_format($value, 2, null, ''); in return number_format($value, 4, null, ''); return number_format($value, 4, null, '');

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

same as in Option.php 与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 \\ Core \\ Model \\ Store.php *将功能roundPrice()第740行的输出更改为return round($price, 4);

\\app\\code\\local\\Mage\\Directory\\Model\\Currency.php in function format() changed formatPrecision from 2 to 4 in line 197. 函数format() \\ app \\ code \\ local \\ Mage \\ Directory \\ Model \\ Currency.php在197行中将formatPrecision从2更改为4。

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

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

Ive looked into some core files like invoice.php or in adminhtml files if there are rounding stuff. 我已经研究了一些核心文件,例如invoice.php或adminhtml文件(如果有四舍五入的东西)。 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 谢谢,greetz Rito

magento回合问题

(sorry for german in picture) (抱歉图片中的德语)

My first suggestion would be to turn on the Frontend and Backend Hints ( System>Config>Advanced>Developer ) so you can see which Block and which phtml View is responsible for rendering the 2 decimal place content. 我的第一个建议是打开“前端和后端提示”(“ System>Config>Advanced>Developer ),以便您可以看到哪个块和哪个phtml视图负责呈现两位小数的内容。 If you install the Developer Toolbar extension , you'll find that much easier. 如果安装Developer Toolbar扩展程序 ,您会发现这更加容易。

Looking at your screenshot, I think that comes from the Admin Sales Order view, and therefore the phtml files under app/design/adminhtml/default/default/template/sales/order/create/totals and the Blocks = Mage_Adminhtml_Block_Sales_Order_Create_Totals_Default are a good place to look. 查看您的屏幕截图,我认为这来自“管理员销售订单”视图,因此app/design/adminhtml/default/default/template/sales/order/create/totals下的phtml文件以及Blocks = Mage_Adminhtml_Block_Sales_Order_Create_Totals_Default是一个好地方看。 The formatPrice function seems to be using Store.php that you have overridden, and some of the Currency files. formatPrice函数似乎正在使用您已覆盖的Store.php和一些Currency文件。

I suspect that @greg0ire is correct, this one is going to take some remote debugging to track down. 我怀疑@ greg0ire是正确的,这一步将进行一些远程调试以进行跟踪。 It's possible that your $options['precision'] is being overwritten somewhere, so you need to see it's value at the time of execution. $options['precision']会在某处被覆盖,因此您需要在执行时查看其值。

Good luck, JD 祝你好运,JD

PS I assume you have cleared and disabled cache... Note that the adminhtml cache is not cleared in the System>Cache Management GUI, you must manually delete the files in var/cache . PS我假设您已经清除并禁用了缓存...请注意, System>Cache Management GUI中清除adminhtml缓存,您必须手动删除var/cache的文件。

"totals" was a good hint, thx to Jonathan Day 乔纳森·戴(Jonathan Day)表示“总计”是一个很好的提示

Heres the solution for sales/invoice with four decimal points. 这是具有四个小数点的销售/发票解决方案。

\\app\\code\\local\\Mage\\Adminhtml\\Block\\Sales\\Items\\Abstract.php \\ 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); 第292行: function displayPrices()更改为return $this->displayRoundedPrices($basePrice, $price, 4, $strong, $separator);
Line 305: $precision=2 into $precision 第305行:将$precision=2转换为$precision

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

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

I know its very dirty, but it works fine :) 我知道它很脏,但是效果很好:)

Found out a different simple way in magento 1.5.1 在magento 1.5.1中找到了另一种简单的方法

Got to code/core/Mage/Directory/Model/Currency.php 转到代码/核心/法师/目录/模型/Currency.php

change line number 194. 更改行号194。

public function format($price, $options=array(), $includeContainer = true, $addBrackets = false) { return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets); 公共函数format($ price,$ options = array(),$ includeContainer = true,$ addBrackets = false){返回$ this-> formatPrecision($ price,0,$ options,$ includeContainer,$ addBrackets); } }

0 - Denotes the precision point for price. 0-表示价格的精确点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM