Magento税收四舍五入问题

时间:2012-11-23 12:52:56

标签: magento magento-1.9

我在Magento的增值税问题上遇到了奇怪的问题。我的产品设置是  *产品价格含20%增值税是183.59

我在篮子中添加了30个项目,费用为30 * 183.59 = 5507.70。我可以在篮子/结账时看到这个值,所以没关系。如果我在篮子里只有一件物品就可以了。

最终的增值税也是5507.70 * 20/120 = 917.95,但我得到了918.00

你知道如何解决这个问题或者我会在哪里看看?提前谢谢。

2 个答案:

答案 0 :(得分:9)

最后我找到了解决方案。我改变了系统>增值税>税收计算方法基于从单位价格到行总计的工作,更多细节here

我发现的问题是core/store模型。我不得不重写roundPrice方法并改变那里的舍入精度。

public function roundPrice($price)
{
   return round($price, 4);
}

答案 1 :(得分:5)

信息

基于先前的舍入操作增量,Magento的整体价格。

  

app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php:1392   app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php:719

shared

有时,由于高增量计算错误(protected function _deltaRound($price, $rate, $direction, $type = 'regular') { if ($price) { $rate = (string)$rate; $type = $type . $direction; // initialize the delta to a small number to avoid non-deterministic behavior with rounding of 0.5 $delta = isset($this->_roundingDeltas[$type][$rate]) ? $this->_roundingDeltas[$type][$rate] : 0.000001; $price += $delta; $this->_roundingDeltas[$type][$rate] = $price - $this->_calculator->round($price); $price = $this->_calculator->round($price); } return $price; } ),这可能会导致错误。例如,出于这个原因,某些价格可能会在±1美分的范围内变化。

解决方案

为避免这种情况,您需要提高增量计算的准确性。

更改

$this->_calculator->round($price)

$this->_roundingDeltas[$type][$rate] = $price - $this->_calculator->round($price);

需要在两个文件中进行更改:

  

app/code/core/Mage/Tax/Model/Sales/Total/Quote/Tax.php:1392   app/code/core/Mage/Tax/Model/Sales/Total/Quote/Subtotal.php:719

不要修改或破解核心文件!重写一次!

该解决方案在不同版本的Magento 1.9.x上进行了测试,但这可能适用于早期版本。

P.S。

更改$this->_roundingDeltas[$type][$rate] = $price - round($price, 4); 函数,如下所示,可以解决舍入错误问题,但它可能会导致其他问题(例如,某些平台需要舍入最多2个小数位)。

  

app/code/core/Mage/Core/Model/Store.php:995

roundPrice
相关问题