0

In my store, CE 1.9.2.2, I would like to round prices after tax application. Example: I have a product with a price 160.50 without taxes applied. For some customers the store applies a tax rule which increases the price of its 22%. So, after the tax calculation, the price for that particular product becomes 195.81. For those customers I would like to have the product priced 196.00 while leaving 160.50 for customers which do not have the tax calculation applied.

Is it possible to achieve this in some way in Magento?

0

I managed to do it. This is how I achieved it.

I had to extend the Mage_Tax_Model_Calculation class and rewrite the logic in the calcTaxAmount method.

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;
}

I just added the two lines:

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

to sum to the tax amount the difference between taxed price and the rounded taxed price.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.