在我的商店,CE1.9.2.2,我想在税务申请后四舍五入价格。例子::我有一个价格为160.50的产品,不含税。对于一些客户,商店适用税收规则,增加其22%的价格。因此,在税收计算之后,该特定产品的价格变为195.81。对于那些客户,我希望产品价格为196.00,而对于没有应用税收计算的客户,则为160.50。

是否有可能在Magento中以某种方式实现这一点?

有帮助吗?

解决方案

我设法做到了。这就是我实现它的方式。

我不得不延长 Mage_Tax_Model_Calculation 类和重写逻辑在 calcTaxAmount 方法。

public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
{
    $taxRate = $taxRate / 100;

    if ($priceIncludeTax) {
        $amount = $price * (1 - 1 / (1 + $taxRate));
    } else {
        $amount = $price * $taxRate;
    }

    $taxedPrice = $price + $amount;
    $amount += round($taxedPrice) - $taxedPrice;

    if ($round) {
        return $this->round($amount);
    }

    return $amount;
}

我只是添加了两行:

$taxedPrice = $price + $amount;
$amount += round($taxedPrice) - $taxedPrice;

将课税价格与四舍五入课税价格之间的差额与税额相加.

许可以下: CC-BY-SA归因
scroll top