Skip to content

Tax discount compensation amount not populated if product prices are configured excl. tax #26597

Open
@moloughlin

Description

@moloughlin

Preconditions

  1. Magento 2.3.4
  2. Configure Sales > Tax > Calculation Settings > Catalog Prices to Excluding Tax
  3. Create a shopping cart price rule which applies a discount

Steps to reproduce

  1. Add items to cart
  2. Apply discount code
  3. Place Order
  4. 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 |
+----------------+-----------------+------------+----------------------------------+

Metadata

Metadata

Assignees

Labels

Area: TaxComponent: DBIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: PR in progressReported on 2.3.4Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions