Skip to content

Commit b9d71a7

Browse files
committed
ACP2E-1080: Tax Summary not rendered correctly when there are multiple taxes applied
1 parent eb1e3a0 commit b9d71a7

File tree

8 files changed

+265
-31
lines changed

8 files changed

+265
-31
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminInvoiceCheckingWithMultishipmentWithMultipleTaxTest">
12+
<annotations>
13+
<features value="Multishipment"/>
14+
<stories value="Checking that multiple taxes in invoice after multishipping are shown preperly"/>
15+
<title value="Checking multiple taxes in invoice after multishipping are shown preperly"/>
16+
<description value="Multiple taxes are shown accurately on Invoice page after multishipping"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-6692"/>
19+
<useCaseId value="ACP2E-1080"/>
20+
<group value="Multishipment"/>
21+
</annotations>
22+
23+
<before>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25+
<!-- Create Tax Rates & Rules -->
26+
<createData entity="USFullTaxRate" stepKey="initialTaxRate"/>
27+
<createData entity="USFullTaxRate" stepKey="initialTaxRate2"/>
28+
29+
<actionGroup ref="AdminCreateTaxRuleActionGroup" stepKey="createTaxRule">
30+
<argument name="taxRate" value="$$initialTaxRate$$"/>
31+
<argument name="taxRule" value="SimpleTaxRule"/>
32+
</actionGroup>
33+
<actionGroup ref="AdminCreateTaxRuleActionGroup" stepKey="createSecondTaxRule">
34+
<argument name="taxRate" value="$$initialTaxRate2$$"/>
35+
<argument name="taxRule" value="SimpleTaxRule2"/>
36+
</actionGroup>
37+
38+
<!-- Create Category and Products -->
39+
<createData stepKey="category" entity="SimpleSubCategory"/>
40+
<createData stepKey="product1" entity="SimpleProduct"/>
41+
<createData stepKey="product2" entity="SimpleProduct"/>
42+
43+
<!-- Create Customer -->
44+
<createData entity="Simple_US_Customer_Two_Addresses" stepKey="customer"/>
45+
46+
<!-- Enable Payment and Shipping Methods -->
47+
<createData entity="FreeShippinMethodConfig" stepKey="enableFreeShipping"/>
48+
<createData entity="FlatRateShippingMethodConfig" stepKey="enableFlatRateShipping"/>
49+
<actionGroup ref="CliEnableCheckMoneyOrderPaymentMethodActionGroup" stepKey="enableCheckMoneyOrderPaymentMethod"/>
50+
51+
<!-- Enable Full Tax Summary for Orders, Invoices, Credit Memos -->
52+
<magentoCLI command="config:set {{EnableDisplayFullTaxSummarySales.path}} {{EnableDisplayFullTaxSummarySales.value}}" stepKey="enableFullTaxSummary"/>
53+
</before>
54+
55+
<after>
56+
<!-- Delete created Tax Rate & Rule -->
57+
<actionGroup ref="AdminDeleteTaxRule" stepKey="deleteTaxRule">
58+
<argument name="taxRuleCode" value="{{SimpleTaxRule.code}}"/>
59+
</actionGroup>
60+
<actionGroup ref="AdminDeleteTaxRule" stepKey="deleteTaxRule2">
61+
<argument name="taxRuleCode" value="{{SimpleTaxRule2.code}}"/>
62+
</actionGroup>
63+
<deleteData createDataKey="initialTaxRate" stepKey="deleteInitialTaxRate"/>
64+
<deleteData createDataKey="initialTaxRate2" stepKey="deleteInitialTaxRate2"/>
65+
66+
<!-- Delete created Category, Products, Customer -->
67+
<deleteData stepKey="deleteCategory" createDataKey="category"/>
68+
<deleteData stepKey="deleteProduct1" createDataKey="product1"/>
69+
<deleteData stepKey="deleteProduct2" createDataKey="product2"/>
70+
<deleteData stepKey="deleteCustomer" createDataKey="customer"/>
71+
72+
<!-- Disable extra Shipment and Payment Methods enabled -->
73+
<createData entity="FreeShippinMethodDefault" stepKey="disableFreeShipping"/>
74+
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/>
75+
76+
<!-- Disable Full Tax Summary for Orders, Invoices, Credit Memos -->
77+
<magentoCLI command="config:set {{DisableDisplayFullTaxSummarySales.path}} {{DisableDisplayFullTaxSummarySales.value}}" stepKey="disableFullTaxSummary"/>
78+
79+
<!-- Logout Admin -->
80+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
81+
</after>
82+
83+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount">
84+
<argument name="Customer" value="$$customer$$"/>
85+
</actionGroup>
86+
87+
<!-- Creating Order using multishipping and get Order ID -->
88+
<amOnPage url="$$product1.custom_attributes[url_key]$$.html" stepKey="goToProduct1"/>
89+
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addToCartFromStorefrontProduct1">
90+
<argument name="productName" value="$$product1.name$$"/>
91+
</actionGroup>
92+
<amOnPage url="$$product2.custom_attributes[url_key]$$.html" stepKey="goToProduct2"/>
93+
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addToCartFromStorefrontProduct2">
94+
<argument name="productName" value="$$product2.name$$"/>
95+
</actionGroup>
96+
<actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/>
97+
<actionGroup ref="CheckingWithMultipleAddressesActionGroup" stepKey="checkoutWithMultipleAddresses"/>
98+
<actionGroup ref="SelectMultiShippingInfoActionGroup" stepKey="checkoutWithMultipleShipping"/>
99+
<actionGroup ref="SelectBillingInfoActionGroup" stepKey="checkoutWithPaymentMethod"/>
100+
<actionGroup ref="ReviewOrderForMultiShipmentActionGroup" stepKey="reviewOrderForMultiShipment"/>
101+
<actionGroup ref="PlaceOrderActionGroup" stepKey="placeOrder"/>
102+
<see selector="{{StorefrontMultipleShippingMethodSection.successMessage}}" userInput="Successfully ordered" stepKey="seeSuccessMessage"/>
103+
<grabTextFrom selector="{{StorefrontMultipleShippingMethodSection.orderId('1')}}" stepKey="grabOrderNumber"/>
104+
105+
<!-- Creating Invoice -->
106+
<actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderGridById">
107+
<argument name="orderId" value="$grabOrderNumber"/>
108+
</actionGroup>
109+
<actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/>
110+
<actionGroup ref="GoToInvoiceIntoOrderActionGroup" stepKey="goToInvoiceIntoOrderPage"/>
111+
<actionGroup ref="SubmitInvoiceActionGroup" stepKey="submitInvoice"/>
112+
113+
<!-- Open Invoice -->
114+
<actionGroup ref="AdminOpenInvoiceFromOrderPageActionGroup" stepKey="openInvoiceFromOrder"/>
115+
116+
<!-- Expand detailed Taxes description -->
117+
<scrollTo selector="{{AdminInvoiceTaxSection.sectionHeader}}" stepKey="scrollToTaxSection"/>
118+
<click selector="{{AdminInvoiceTaxSection.sectionHeader}}" stepKey="expandSection"/>
119+
120+
<!-- Check that Total Tax is shown correctly -->
121+
<actionGroup ref="AssertAdminInvoiceTotalTaxActionGroup" stepKey="assertTotalTax">
122+
<argument name="expectedTotalTax" value="$24.60"/>
123+
</actionGroup>
124+
125+
<!-- Check that correct value is shown for detailed tax -->
126+
<actionGroup ref="AdminAssertInvoiceSingleTaxActionGroup" stepKey="assertSingleTax"/>
127+
</test>
128+
</tests>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminAssertInvoiceSingleTaxActionGroup">
12+
<annotations>
13+
<description>Admin assert invoice single tax in detailed taxes</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="expectedSingleTax" type="string" defaultValue="$12.30"/>
17+
</arguments>
18+
<grabTextFrom selector="{{AdminInvoiceTaxSection.singleTaxFirst}}" stepKey="getSingleTax"/>
19+
<assertEquals stepKey="assertSingleTaxValue">
20+
<actualResult type="variable">getSingleTax</actualResult>
21+
<expectedResult type="string">{{expectedSingleTax}}</expectedResult>
22+
</assertEquals>
23+
</actionGroup>
24+
</actionGroups>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminInvoiceTotalTaxActionGroup">
12+
<annotations>
13+
<description>Admin assert invoice total tax</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="expectedTotalTax" type="string" defaultValue="$8.25"/>
17+
</arguments>
18+
<grabTextFrom selector="{{AdminInvoiceTotalSection.totalTax}}" stepKey="getTotalTax"/>
19+
<assertEquals stepKey="assertTotalTaxValue">
20+
<actualResult type="variable">getTotalTax</actualResult>
21+
<expectedResult type="string">{{expectedTotalTax}}</expectedResult>
22+
</assertEquals>
23+
</actionGroup>
24+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="AdminInvoiceTaxSection">
11+
<element name="sectionHeader" type="button" selector=".summary-collapse" timeout="30"/>
12+
<element name="singleTaxFirst" type="text" selector=".summary-details-first .price"/>
13+
</section>
14+
</sections>

app/code/Magento/Sales/Test/Mftf/Section/AdminInvoiceTotalSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
<element name="itemQty" type="text" selector="td.col-qty"/>
1717
<element name="itemName" type="text" selector=".col-product .product-title"/>
1818
<element name="itemTotalPrice" type="text" selector=".col-total .price"/>
19+
<element name="totalTax" type="text" selector=".summary-total .price"/>
1920
</section>
20-
</sections>
21+
</sections>

app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,61 +37,63 @@ class CommonTaxCollector extends AbstractTotal
3737
/**#@+
3838
* Constants defined for type of items
3939
*/
40-
const ITEM_TYPE_SHIPPING = 'shipping';
41-
const ITEM_TYPE_PRODUCT = 'product';
40+
public const ITEM_TYPE_SHIPPING = 'shipping';
41+
public const ITEM_TYPE_PRODUCT = 'product';
4242
/**#@-*/
4343

4444
/**
4545
* Constant for shipping item code
4646
*/
47-
const ITEM_CODE_SHIPPING = 'shipping';
47+
public const ITEM_CODE_SHIPPING = 'shipping';
4848

4949
/**#@+
5050
* Constants for array keys
5151
*/
52-
const KEY_ITEM = 'item';
53-
const KEY_BASE_ITEM = 'base_item';
52+
public const KEY_ITEM = 'item';
53+
public const KEY_BASE_ITEM = 'base_item';
5454
/**#@-*/
5555

5656
/**#@+
5757
* Constants for fields in associated taxables array
5858
*/
59-
const KEY_ASSOCIATED_TAXABLE_TYPE = 'type';
60-
const KEY_ASSOCIATED_TAXABLE_CODE = 'code';
61-
const KEY_ASSOCIATED_TAXABLE_UNIT_PRICE = 'unit_price';
62-
const KEY_ASSOCIATED_TAXABLE_BASE_UNIT_PRICE = 'base_unit_price';
63-
const KEY_ASSOCIATED_TAXABLE_QUANTITY = 'quantity';
64-
const KEY_ASSOCIATED_TAXABLE_TAX_CLASS_ID = 'tax_class_id';
65-
const KEY_ASSOCIATED_TAXABLE_PRICE_INCLUDES_TAX = 'price_includes_tax';
66-
const KEY_ASSOCIATED_TAXABLE_ASSOCIATION_ITEM_CODE = 'associated_item_code';
59+
public const KEY_ASSOCIATED_TAXABLE_TYPE = 'type';
60+
public const KEY_ASSOCIATED_TAXABLE_CODE = 'code';
61+
public const KEY_ASSOCIATED_TAXABLE_UNIT_PRICE = 'unit_price';
62+
public const KEY_ASSOCIATED_TAXABLE_BASE_UNIT_PRICE = 'base_unit_price';
63+
public const KEY_ASSOCIATED_TAXABLE_QUANTITY = 'quantity';
64+
public const KEY_ASSOCIATED_TAXABLE_TAX_CLASS_ID = 'tax_class_id';
65+
public const KEY_ASSOCIATED_TAXABLE_PRICE_INCLUDES_TAX = 'price_includes_tax';
66+
public const KEY_ASSOCIATED_TAXABLE_ASSOCIATION_ITEM_CODE = 'associated_item_code';
6767
/**#@-*/
6868

6969
/**
7070
* When an extra taxable item is associated with quote and not with an item, this value
7171
* is used as associated item code
7272
*/
73-
const ASSOCIATION_ITEM_CODE_FOR_QUOTE = 'quote';
73+
public const ASSOCIATION_ITEM_CODE_FOR_QUOTE = 'quote';
7474

7575
/**#@+
7676
* Constants for fields in tax details for associated taxable items
7777
*/
78-
const KEY_TAX_DETAILS_TYPE = 'type';
79-
const KEY_TAX_DETAILS_CODE = 'code';
80-
const KEY_TAX_DETAILS_PRICE_EXCL_TAX = 'price_excl_tax';
81-
const KEY_TAX_DETAILS_BASE_PRICE_EXCL_TAX = 'base_price_excl_tax';
82-
const KEY_TAX_DETAILS_PRICE_INCL_TAX = 'price_incl_tax';
83-
const KEY_TAX_DETAILS_BASE_PRICE_INCL_TAX = 'base_price_incl_tax';
84-
const KEY_TAX_DETAILS_ROW_TOTAL = 'row_total_excl_tax';
85-
const KEY_TAX_DETAILS_BASE_ROW_TOTAL = 'base_row_total_excl_tax';
86-
const KEY_TAX_DETAILS_ROW_TOTAL_INCL_TAX = 'row_total_incl_tax';
87-
const KEY_TAX_DETAILS_BASE_ROW_TOTAL_INCL_TAX = 'base_row_total_incl_tax';
88-
const KEY_TAX_DETAILS_TAX_PERCENT = 'tax_percent';
89-
const KEY_TAX_DETAILS_ROW_TAX = 'row_tax';
90-
const KEY_TAX_DETAILS_BASE_ROW_TAX = 'base_row_tax';
91-
const KEY_TAX_DETAILS_APPLIED_TAXES = 'applied_taxes';
78+
public const KEY_TAX_DETAILS_TYPE = 'type';
79+
public const KEY_TAX_DETAILS_CODE = 'code';
80+
public const KEY_TAX_DETAILS_PRICE_EXCL_TAX = 'price_excl_tax';
81+
public const KEY_TAX_DETAILS_BASE_PRICE_EXCL_TAX = 'base_price_excl_tax';
82+
public const KEY_TAX_DETAILS_PRICE_INCL_TAX = 'price_incl_tax';
83+
public const KEY_TAX_DETAILS_BASE_PRICE_INCL_TAX = 'base_price_incl_tax';
84+
public const KEY_TAX_DETAILS_ROW_TOTAL = 'row_total_excl_tax';
85+
public const KEY_TAX_DETAILS_BASE_ROW_TOTAL = 'base_row_total_excl_tax';
86+
public const KEY_TAX_DETAILS_ROW_TOTAL_INCL_TAX = 'row_total_incl_tax';
87+
public const KEY_TAX_DETAILS_BASE_ROW_TOTAL_INCL_TAX = 'base_row_total_incl_tax';
88+
public const KEY_TAX_DETAILS_TAX_PERCENT = 'tax_percent';
89+
public const KEY_TAX_DETAILS_ROW_TAX = 'row_tax';
90+
public const KEY_TAX_DETAILS_BASE_ROW_TAX = 'base_row_tax';
91+
public const KEY_TAX_DETAILS_APPLIED_TAXES = 'applied_taxes';
9292
/**#@-*/
9393

94-
/**#@-*/
94+
/**
95+
* @var \Magento\Tax\Model\Config
96+
*/
9597
protected $_config;
9698

9799
/**
@@ -667,7 +669,7 @@ protected function processAppliedTaxes(
667669
$associatedItemId = null;
668670
if ($itemType == self::ITEM_TYPE_PRODUCT) {
669671
//Use item id instead of tax calculation id
670-
$itemId = $keyedAddressItems[$itemTaxCalculationId]->getId();
672+
$itemId = $this->getQuoteItemId($keyedAddressItems, $itemTaxCalculationId);
671673
} else {
672674
if ($taxDetails->getAssociatedItemCode()
673675
&& $taxDetails->getAssociatedItemCode() != self::ASSOCIATION_ITEM_CODE_FOR_QUOTE) {
@@ -953,4 +955,21 @@ protected function getNextIncrement()
953955
{
954956
return ++$this->counter;
955957
}
958+
959+
/**
960+
* Returns quote_item_id, as structure differs for usual shipping and multishipping approaches
961+
*
962+
* @param AbstractItem[] $keyedAddressItems
963+
* @param string $itemTaxCalculationId
964+
*
965+
* @return mixed
966+
*/
967+
private function getQuoteItemId(array $keyedAddressItems, string $itemTaxCalculationId)
968+
{
969+
if (isset($keyedAddressItems[$itemTaxCalculationId]["quote_item"])) {
970+
return $keyedAddressItems[$itemTaxCalculationId]["quote_item"]->getId();
971+
} else {
972+
return $keyedAddressItems[$itemTaxCalculationId]->getId();
973+
}
974+
}
956975
}

app/code/Magento/Tax/Test/Mftf/Data/TaxConfigData.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,12 @@
8585
<data key="label">Yes</data>
8686
<data key="value">2</data>
8787
</entity>
88+
<entity name="EnableDisplayFullTaxSummarySales">
89+
<data key="path">tax/sales_display/full_summary</data>
90+
<data key="value">1</data>
91+
</entity>
92+
<entity name="DisableDisplayFullTaxSummarySales">
93+
<data key="path">tax/sales_display/full_summary</data>
94+
<data key="value">0</data>
95+
</entity>
8896
</entities>

app/code/Magento/Tax/Test/Mftf/Data/TaxRuleData.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@
3737
</array>
3838
<data key="calculate_subtotal">true</data>
3939
</entity>
40+
<entity name="SimpleTaxRule2" type="taxRule">
41+
<data key="code" unique="suffix">SecondSimpleTaxRule</data>
42+
<data key="position">0</data>
43+
<data key="priority">0</data>
44+
<array key="customer_tax_class_ids">
45+
<item>3</item>
46+
</array>
47+
<array key="product_tax_class_ids">
48+
<item>2</item>
49+
</array>
50+
<array key="tax_rate_ids">
51+
<item>1</item>
52+
<item>2</item>
53+
</array>
54+
<data key="calculate_subtotal">true</data>
55+
</entity>
4056
<entity name="taxRuleWithCustomPriorityPosition" type="taxRule">
4157
<data key="code" unique="suffix">TaxRule</data>
4258
<data key="position">1</data>

0 commit comments

Comments
 (0)