Magento税收四舍五入问题

Jar*_*aro 7 magento magento-1.9

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

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

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

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

Jar*_*aro 9

最后我找到了解决方案.我将系统>增值税>税率计算方法基于单位价格更改为行总计,它更有效,详情请点击此处

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

public function roundPrice($price)
{
   return round($price, 4);
}
Run Code Online (Sandbox Code Playgroud)


Vic*_* S. 6

信息

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

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;
}
Run Code Online (Sandbox Code Playgroud)

有时,由于高delta计算错误($this->_calculator->round($price)),这可能会导致错误.例如,由于这个原因,一些价格可能在±1美分的范围内变化.

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

更改

$this->_roundingDeltas[$type][$rate] = $price - $this->_calculator->round($price);
Run Code Online (Sandbox Code Playgroud)

$this->_roundingDeltas[$type][$rate] = $price - round($price, 4);
Run Code Online (Sandbox Code Playgroud)

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

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上进行了测试,但这可能适用于早期版本.

PS

roundPrice如下所示,更改功能可以解决舍入错误问题,但它可能会导致其他问题(例如,某些平台需要舍入最多2个小数位).

应用程序/代码/核心/法师/核心/型号/ Store.php:995

public function roundPrice($price)
{
    return round($price, 4);
}
Run Code Online (Sandbox Code Playgroud)