10

I see there is discount_tax_compensation_amount field in the sales_order_item table. For what purposes this attribute is?

2 Answers 2

13

It is used by Magento to calculate the amount of tax that is not originally calculated when a product that has a tax is under discount. For example. Let’s suppose you have a product named “Pencil”. Ant this “Pencil” has a price of $100.00 and a tax of 16%, then the final price will be $116. Now for example you decided to create a coupon code with 10% off in all the Pencils and (This is important) your store is configured to calculate the discount after tax. The user will see a final price including tax of 104.4 that is the result of 116 – 11.6. And that is correct. But legally you can’t discount any amount from tax because your base tax is still 100 and not 104.4. Then Magento hides that quantity of money in hidden_tax_amount. For accounting purposes this process is correct. Then you can show that value as Tax.

In Magento 2, they renamed the fields to make more sense, from hidden_tax_amount to discount_tax_compensation_amount.

1
  • Would this variable be more accurately named "merchant_paid_tax"? Should this field be filled with any taxes the merchant is paying for the item? How does Magento use this value once it is set?
    – Navarr
    Dec 6, 2019 at 18:46
1

Example

  • Full price of item, with tax included: $100
  • VAT at: 20%
  • Discount of 10% applied on item price-excluding taxes:

Valid Calculations

  • Full price of the item without taxes is: $100 / 1.2 = $83.33

  • VAT amount on the full item price is: $100 - $83.33 = $16.67

  • Can also be calculated as: $100 \ * (1 - 1/1.2).

  • Discount of 10% on $83.33 is: $8.33 (when we don't discount tax)

  • Discounted price of item with tax is: $100 - $8.33 = $91.67

  • Discounted price of the item without taxes is: $91.67 / 1.2 = $76.39

  • VAT amount on the discounted price is: $91.67 - $76.39 = $15.28 (valid)

  • Can also be calculated as: $91.67 \ * (1 - 1/1.2).

  • Hidden tax or Discount Tax Compensation is the difference between the VAT amount of the full price versus discounted price: $16.67 - $15.28 = $1.39

  • Another way to look at this: hidden tax is the VAT amount carried within the $8.33 discount: $8.33 * (1 - 1/1.2).

  • How the customer usually understands the discounted price (Order Total):

  • Full price of item including taxes less the discount amount: $100 - $8.33 = $91.67

  • How Commerce calculates the discounted price (see earlier for formula): $83.33 - $8.33 + 15.28 + 1.39 = $91.67*

Ref: https://experienceleague.adobe.com/docs/commerce-admin/stores-sales/site-store/taxes/hidden-tax-calculation.html?lang=en

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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