Magento - 发票中的小数点/be
我的商店需要最多 4 位小数。到目前为止,我跟随了一些人,他们在前面和后面工作得很好。产品后端。仅在销售/发票价格中,税金和总计仍四舍五入至小数点后两位。
我已经编辑/覆盖了以下文件:
\app\code\local\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php
在第 283 行附近我改变了
return number_format($value, 2, null, '');
inreturn number_format($value, 4, null, '');
\app\code\local\Mage\Adminhtml\Block\Catalog\Product\Helper\Form\Price.php
与 Option.php 中的相同
\app\code\local\Mage\Core\Model\Store.php* 更改了输出 函数
函数中的roundPrice()
第740行进入return round($price, 4);
\app\code\local\Mage\Directory\Model\Currency.php
format()
在第 197 行将formatPrecision
从 2 更改为 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']);
更改为sprintf('%.4f', $_item['价格'])
我已经研究了一些核心文件,例如invoice.php 或adminhtml 文件中是否存在舍入内容。但我找不到任何有用的东西。
used extensions: (Magento 1.4.1.0)
Asperience_DeleteAllOrders
Flagbit_ChangeAttributeSet
Mxperts_Invoice
de_DE languagepack
谢谢,greetz Rito
(抱歉图片中的德语)
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,
in
null, '');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
functionroundPrice()
line 740 intoreturn round($price, 4);
\app\code\local\Mage\Directory\Model\Currency.php in function
format()
changedformatPrecision
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 tosprintf('%.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
(sorry for german in picture)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的第一个建议是打开前端和后端提示(
System>Config>Advanced>Developer
),这样您就可以看到哪个块和哪个 phtml 视图负责渲染小数点后两位内容。如果您安装开发者工具栏扩展,您会发现这容易多了。看看你的屏幕截图,我认为它来自管理销售订单视图,因此
app/design/adminhtml/default/default/template/sales/order/create/totals
下的 phtml 文件和Blocks =Mage_Adminhtml_Block_Sales_Order_Create_Totals_Default
是一个值得一看的好地方。formatPrice
函数似乎正在使用您已覆盖的 Store.php 以及一些货币文件。我怀疑 @greg0ire 是正确的,这将需要一些远程调试来追踪。您的
$options[' precision']
可能在某个地方被覆盖,因此您需要在执行时查看它的值。祝你好运,
JD
附注我假设您已经清除并禁用了缓存...请注意,未在
System>Cache Management
GUI 中清除 adminhtml 缓存,您必须手动删除中的文件>var/cache
。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. If you install the Developer Toolbar extension, you'll find that much easier.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. TheformatPrice
function seems to be using Store.php that you have overridden, and some of the Currency files.I suspect that @greg0ire is correct, this one is going to take some remote debugging to track down. It's possible that your
$options['precision']
is being overwritten somewhere, so you need to see it's value at the time of execution.Good luck,
JD
P.S. 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 invar/cache
.“总计”是一个很好的提示,感谢 Jonathan Day,
这是带有四位小数的销售/发票的解决方案。
\app\code\local\Mage\Adminhtml\Block\Sales\Items\Abstract.php
更改以下代码:
第 292 行:
function displayPrices()
更改为return $this->displayRoundedPrices($basePrice, $price, 4, $strong, $separator);
第 305 行:将
$ precision=2
写入$ precision
\app\code\local\Mage\Sales\Model\Order.php
第 1358 行:
我知道它很脏,但它工作得很好:)
"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 toreturn $this->displayRoundedPrices($basePrice, $price, 4, $strong, $separator);
Line 305:
$precision=2
into$precision
\app\code\local\Mage\Sales\Model\Order.php
line 1358:
I know its very dirty, but it works fine :)
在magento 1.5.1中找到了一种不同的简单方法,
转到code/core/Mage/Directory/Model/Currency.php
更改行号194。
public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
{
返回 $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
}
0 - 表示价格的精度点。
Found out a different simple way in magento 1.5.1
Got to code/core/Mage/Directory/Model/Currency.php
change line number 194.
public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
{
return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
}
0 - Denotes the precision point for price.