Magento - 发票中的小数点/be

发布于 2024-09-15 10:29:23 字数 1476 浏览 7 评论 0原文

我的商店需要最多 4 位小数。到目前为止,我跟随了一些人,他们在前面和后面工作得很好。产品后端。仅在销售/发票价格中,税金和总计仍四舍五入至小数点后两位。

我已经编辑/覆盖了以下文件:

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

在第 283 行附近我改变了 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 

与 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

magento round issues

(抱歉图片中的德语)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

揪着可爱 2024-09-22 10:29:23

我的第一个建议是打开前端和后端提示(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. The formatPrice 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 in var/cache.

梦冥 2024-09-22 10:29:23

“总计”是一个很好的提示,感谢 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 行:

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

我知道它很脏,但它工作得很好:)

"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 :)

情释 2024-09-22 10:29:23

在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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文