3

I can set Catalog Prices to Exclude Tax or Include Tax from System > Configuration > [Sales] Tax. I notices that the formula to calculate tax based on this configuration is in app/code/core/Mage/Tax/Model/Calculation.php:645:

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

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

    return $amount;
}

My problem is I can't understand the formula ($price * (1 - 1 / (1 + $taxRate))). What does it mean to include tax in catalog prices?

  • Well basically when you select price include tax at that time whatever price you include as product price magento thinks that tax is already included in that price. Like if you enter 150 and tax is 10% then magento thinks original product price is 136.36 – Kingshuk Deb Jun 13 '17 at 6:22
6

If you set the prices to include tax it means that the price you fill in the backend for a product already contains the tax.
Let's say you have a tax rule set up for 20%
If you fill in the price for a product 60 and this includes tax, the product price will be 50 and the tax amount will be 10.
Because 10 is 20% of 50.
To get a better view.

Total: 60 ...... means 120%  
Tax : X ........means 20%  

you need to calculate X. Using the proportion rule you get X = 60 * 20 / 120 = 10.
If you got the tax value you can calculate the price without tax by subtracting the tax from the total price. Price Excl Tax = 60 - 10 = 50.

To explain the formula:

Let's use the notation for the price filled in the backend as price. notation for tax percentage is tax_percent (which is below 1...as percentage). and for price excl tax is price_excl_tax.
And you need to get the tax_value which is price_excl_tax * tax_percent

We get the formula.

price = price_excl_tax + tax_percent * price_excl_tax  

but

price_excl_tax = price - tax_value.  

We need the tax_value from the 2 above.
Replacing price_excl_tax in the first one we get.

price = price - tax_value + tax_percent * (price - tax_value)  

Reducing price from both sides

tax_percent * price - tax_value * tax_percent - tax_value = 0  

which is equivalent to

tax_percent * price = tax_value * (tax_percent + 1)  

trying to solve for tax_value we get

 tax_value = tax_percent * price / (tax_percent + 1)  

rearranging it ...

 tax_value = price * (tax_percent / (1 + tax_percent))  

which is equivalent to

 tax_value = price * ((tax_percent + 1 - 1) / (1 + tax_percent))  

going further

 tax_value = price * (1 - 1 / (1 + tax_percent))  

which is the formula you need.

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.