Open
Description
Preconditions
- Magento 2.3.4
- Configure Sales > Tax > Calculation Settings > Catalog Prices to Excluding Tax
- Create a shopping cart price rule which applies a discount
Steps to reproduce
- Add items to cart
- Apply discount code
- Place Order
- Inspect sales_order and sales_order_item tables, noting the 0.0000 for discount_tax_compensation_amount
Expected result
sales_order
and sales_order_item
tables should include non-zero discount_tax_compensation_amount
values for orders where a discount amount was applied (e.g. coupon code).
This behaves correctly only if tax/calculation/price_includes_tax
is set to Including Tax, example below when prices are configured to be Including Tax
MariaDB [magento2]> select entity_id, coupon_code, discount_amount, discount_tax_compensation_amount from sales_order order by entity_id desc limit 1;
+-----------+--------------+-----------------+----------------------------------+
| entity_id | coupon_code | discount_amount | discount_tax_compensation_amount |
+-----------+--------------+-----------------+----------------------------------+
| 1088 | 40PERCENTOFF | -6.7800 | 0.6200 |
+-----------+--------------+-----------------+----------------------------------+
1 row in set (0.00 sec)
MariaDB [magento2]> select price_incl_tax, discount_amount,tax_amount, discount_tax_compensation_amount from sales_order_item where order_id=1088;
+----------------+-----------------+------------+----------------------------------+
| price_incl_tax | discount_amount | tax_amount | discount_tax_compensation_amount |
+----------------+-----------------+------------+----------------------------------+
| 16.9500 | 6.7800 | 0.9200 | 0.6200 |
+----------------+-----------------+------------+----------------------------------+
Actual result
The discount_tax_compensation_amount is not calculated and saved to the DB; example below when prices are configured to be Excluding Tax:
MariaDB [magento2]> select entity_id, coupon_code, discount_amount, discount_tax_compensation_amount from sales_order order by entity_id desc limit 1;
+-----------+--------------+-----------------+----------------------------------+
| entity_id | coupon_code | discount_amount | discount_tax_compensation_amount |
+-----------+--------------+-----------------+----------------------------------+
| 1089 | 40PERCENTOFF | -7.4600 | 0.0000 |
+-----------+--------------+-----------------+----------------------------------+
MariaDB [magento2]> select price_incl_tax, discount_amount,tax_amount, discount_tax_compensation_amount from sales_order_item where order_id=1089;
+----------------+-----------------+------------+----------------------------------+
| price_incl_tax | discount_amount | tax_amount | discount_tax_compensation_amount |
+----------------+-----------------+------------+----------------------------------+
| 18.6500 | 7.4600 | 0.9500 | 0.0000 |
+----------------+-----------------+------------+----------------------------------+