Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
including_tax_apply_tax_after_discount.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
11 
12 $taxCalculationData['including_tax_apply_tax_after_discount'] = [
13  'config_data' => [
14  SetupUtil::CONFIG_OVERRIDES => [
15  Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
16  Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
17  Config::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX => 1,
18  Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS => SetupUtil::SHIPPING_TAX_CLASS,
19  Config::XML_PATH_ALGORITHM => Calculation::CALC_ROW_BASE,
20  ],
21  SetupUtil::TAX_RATE_OVERRIDES => [
22  SetupUtil::TAX_RATE_TX => 10,
23  SetupUtil::TAX_STORE_RATE => 10,
24  SetupUtil::TAX_RATE_SHIPPING => 10,
25  ],
26  SetupUtil::TAX_RULE_OVERRIDES => [
27  [
28  //tax rule for product
29  'code' => 'Product Tax Rule',
30  'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
31  ],
32  [
33  //tax rule for shipping
34  'code' => 'Shipping Tax Rule',
35  'product_tax_class_ids' => [SetupUtil::SHIPPING_TAX_CLASS],
36  'tax_rate_ids' => [SetupUtil::TAX_RATE_SHIPPING],
37  ],
38  ],
39  ],
40  'quote_data' => [
41  'billing_address' => [
42  'region_id' => SetupUtil::REGION_TX,
43  ],
44  'shipping_address' => [
45  'region_id' => SetupUtil::REGION_TX,
46  ],
47  'items' => [
48  [
49  'sku' => 'simple1',
50  'price' => 29,
51  'qty' => 1,
52  ],
53  ],
54  'shipping_method' => 'flatrate_flatrate',
55  'shopping_cart_rules' => [
56  [
57  'discount_amount' => 50,
58  'apply_to_shipping' => 1,
59  ],
60  ],
61  ],
62  'expected_results' => [
63  'address_data' => [
64  'subtotal' => 26.36,
65  'base_subtotal' => 26.36,
66  'subtotal_incl_tax' => 29,
67  'base_subtotal_incl_tax' => 29,
68  'tax_amount' => 1.69,
69  'base_tax_amount' => 1.69,
70  'shipping_amount' => 4.55,
71  'base_shipping_amount' => 4.55,
72  'shipping_incl_tax' => 5,
73  'base_shipping_incl_tax' => 5,
74  'shipping_tax_amount' => 0.25,
75  'base_shipping_tax_amount' => 0.25,
76  'discount_amount' => -15.455,
77  'base_discount_amount' => -15.455,
78  'discount_tax_compensation_amount' => 1.2,
79  'base_discount_tax_compensation_amount' => 1.2,
80  'shipping_discount_tax_compensation_amount' => 0.2,
81  'base_shipping_discount_tax_compensation_amount' => 0.2,
82  'grand_total' => 18.545,
83  'base_grand_total' => 18.545,
84  'applied_taxes' => [
85  SetupUtil::TAX_RATE_TX => [
86  'percent' => 10,
87  'amount' => 1.44,
88  'base_amount' => 1.44,
89  'rates' => [
90  [
91  'code' => SetupUtil::TAX_RATE_TX,
92  'title' => SetupUtil::TAX_RATE_TX,
93  'percent' => 10,
94  ],
95  ],
96  ],
97  SetupUtil::TAX_RATE_SHIPPING => [
98  'percent' => 10,
99  'amount' => 0.25,
100  'base_amount' => 0.25,
101  'rates' => [
102  [
103  'code' => SetupUtil::TAX_RATE_SHIPPING,
104  'title' => SetupUtil::TAX_RATE_SHIPPING,
105  'percent' => 10,
106  ],
107  ],
108  ],
109  ],
110  ],
111  'items_data' => [
112  'simple1' => [
113  'row_total' => 26.36,
114  'base_row_total' => 26.36,
115  'tax_percent' => 10,
116  'price' => 26.36,
117  'base_price' => 26.36,
118  'price_incl_tax' => 29,
119  'base_price_incl_tax' => 29,
120  'row_total_incl_tax' => 29,
121  'base_row_total_incl_tax' => 29,
122  'tax_amount' => 1.44,
123  'base_tax_amount' => 1.44,
124  'discount_amount' => 13.18,
125  'base_discount_amount' => 13.18,
126  'discount_percent' => 50,
127  'discount_tax_compensation_amount' => 1.2,
128  'base_discount_tax_compensation_amount' => 1.2,
129  ],
130  ],
131  ],
132 ];
$taxCalculationData['including_tax_apply_tax_after_discount']