Skip to content

Commit 431224c

Browse files
committed
MC-21699: Tax does not change when changing the billing address from Admin Panel
- Fix shipping_as_billing is set to 0 when shipping_method is changed
1 parent ab19a3d commit 431224c

File tree

5 files changed

+101
-8
lines changed

5 files changed

+101
-8
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ protected function _processActionData($action = null)
188188
&& $this->_getOrderCreateModel()->getShippingAddress()->getSameAsBilling() && empty($shippingMethod)
189189
) {
190190
$this->_getOrderCreateModel()->setShippingAsBilling(1);
191-
} else {
191+
} elseif ($syncFlag !== null) {
192192
$this->_getOrderCreateModel()->setShippingAsBilling((int)$syncFlag);
193193
}
194194
}

app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<annotations>
9393
<description>Clears the Email, First Name, Last Name, Street Line 1, City, Postal Code and Phone fields when adding an Order and then verifies that they are required after attempting to Save.</description>
9494
</annotations>
95-
95+
9696
<seeElement selector="{{AdminOrderFormAccountSection.requiredGroup}}" stepKey="seeCustomerGroupRequired"/>
9797
<seeElement selector="{{AdminOrderFormAccountSection.requiredEmail}}" stepKey="seeEmailRequired"/>
9898
<clearField selector="{{AdminOrderFormAccountSection.email}}" stepKey="clearEmailField"/>
@@ -181,7 +181,7 @@
181181
<annotations>
182182
<description>EXTENDS: addConfigurableProductToOrder. Selects the provided Option to the Configurable Product.</description>
183183
</annotations>
184-
184+
185185
<waitForElementVisible selector="{{AdminOrderFormConfigureProductSection.optionSelect(attribute.default_frontend_label)}}" stepKey="waitForConfigurablePopover"/>
186186
<selectOption selector="{{AdminOrderFormConfigureProductSection.optionSelect(attribute.default_frontend_label)}}" userInput="{{option.label}}" stepKey="selectionConfigurableOption"/>
187187
</actionGroup>
@@ -195,7 +195,7 @@
195195
<argument name="option"/>
196196
<argument name="quantity" type="string"/>
197197
</arguments>
198-
198+
199199
<click selector="{{AdminOrderFormItemsSection.configure}}" stepKey="clickConfigure"/>
200200
<waitForElementVisible selector="{{AdminOrderFormConfigureProductSection.optionSelect(attribute.default_frontend_label)}}" stepKey="waitForConfigurablePopover"/>
201201
<wait time="2" stepKey="waitForOptionsToLoad"/>
@@ -213,7 +213,7 @@
213213
<argument name="product"/>
214214
<argument name="quantity" type="string" defaultValue="1"/>
215215
</arguments>
216-
216+
217217
<click selector="{{AdminOrderFormItemsSection.addProducts}}" stepKey="clickAddProducts"/>
218218
<fillField selector="{{AdminOrderFormItemsSection.skuFilter}}" userInput="{{product.sku}}" stepKey="fillSkuFilterBundle"/>
219219
<click selector="{{AdminOrderFormItemsSection.search}}" stepKey="clickSearchBundle"/>
@@ -235,7 +235,7 @@
235235
<arguments>
236236
<argument name="price" type="string"/>
237237
</arguments>
238-
238+
239239
<grabTextFrom selector="{{AdminOrderFormItemsSection.rowPrice('1')}}" stepKey="grabProductPriceFromGrid" after="clickOk"/>
240240
<assertEquals stepKey="assertProductPriceInGrid" message="Bundle product price in grid should be equal {{price}}" after="grabProductPriceFromGrid">
241241
<expectedResult type="string">{{price}}</expectedResult>
@@ -320,6 +320,22 @@
320320
<selectOption selector="{{AdminOrderFormPaymentSection.flatRateOption}}" userInput="flatrate_flatrate" stepKey="checkFlatRate"/>
321321
</actionGroup>
322322

323+
<actionGroup name="changeShippingMethod">
324+
<annotations>
325+
<description>Change Shipping Method on the Admin 'Create New Order for' page.</description>
326+
</annotations>
327+
<arguments>
328+
<argument name="shippingMethod" defaultValue="flatrate_flatrate" type="string"/>
329+
</arguments>
330+
<click selector="{{AdminOrderFormPaymentSection.header}}" stepKey="unfocus"/>
331+
<waitForPageLoad stepKey="waitForJavascriptToFinish"/>
332+
<click selector="{{AdminOrderFormPaymentSection.getShippingMethods}}" stepKey="clickShippingMethods1"/>
333+
<waitForElementVisible selector="{{AdminOrderFormPaymentSection.getShippingMethods}}" stepKey="waitForChangeShippingMethod"/>
334+
<click selector="{{AdminOrderFormPaymentSection.getShippingMethods}}" stepKey="clickShippingMethods2"/>
335+
<waitForElementVisible selector="{{AdminOrderFormPaymentSection.shippingMethod}}" stepKey="waitForShippingOptions2"/>
336+
<selectOption selector="{{AdminOrderFormPaymentSection.shippingMethod}}" userInput="{{shippingMethod}}" stepKey="checkFlatRate"/>
337+
</actionGroup>
338+
323339
<!--Select free shipping method-->
324340
<actionGroup name="orderSelectFreeShipping">
325341
<annotations>
@@ -516,7 +532,7 @@
516532
<argument name="product"/>
517533
<argument name="customer"/>
518534
</arguments>
519-
535+
520536
<amOnPage stepKey="navigateToNewOrderPage" url="{{AdminOrderCreatePage.url}}"/>
521537
<waitForPageLoad stepKey="waitForNewOrderPageOpened"/>
522538
<click stepKey="chooseCustomer" selector="{{AdminOrdersGridSection.customerInOrdersSection(customer.firstname)}}"/>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminOrderFormBillingAddressSection">
12+
<element name="selectAddress" type="select" selector="//select[@id='order-billing_address_customer_address_id']"/>
1213
<element name="NamePrefix" type="input" selector="#order-billing_address_prefix" timeout="30"/>
1314
<element name="FirstName" type="input" selector="#order-billing_address_firstname" timeout="30"/>
1415
<element name="MiddleName" type="input" selector="#order-billing_address_middlename" timeout="30"/>
@@ -38,4 +39,4 @@
3839
<element name="postalCodeError" type="text" selector="#order-billing_address_postcode-error"/>
3940
<element name="phoneError" type="text" selector="#order-billing_address_telephone-error"/>
4041
</section>
41-
</sections>
42+
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminOrderFormPaymentSection">
12+
<element name="shippingMethod" type="radio" selector="//input[@name='order[shipping_method]']"/>
1213
<element name="header" type="text" selector="#order-methods span.title"/>
1314
<element name="getShippingMethods" type="text" selector="#order-shipping_method a.action-default" timeout="30"/>
1415
<element name="flatRateOption" type="radio" selector="#s_method_flatrate_flatrate" timeout="30"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminCreateOrderForCustomerWithTwoAddressesTaxableAndNonTaxableTest">
11+
<annotations>
12+
<title value="Tax should not be displayed for non taxable address"/>
13+
<stories value="MC-21699: Tax does not change when changing the billing address from Admin Panel"/>
14+
<description value="Tax should not be displayed for non taxable address when switching from taxable address"/>
15+
<testCaseId value="MC-21721"/>
16+
<features value="Sales"/>
17+
<severity value="MAJOR"/>
18+
<group value="Sales"/>
19+
</annotations>
20+
<before>
21+
<!--Enable flat rate shipping-->
22+
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/>
23+
<!--Enable free shipping method -->
24+
<magentoCLI command="config:set {{EnableFreeShippingConfigData.path}} {{EnableFreeShippingConfigData.value}}" stepKey="enableFreeShipping"/>
25+
<!--Create customer-->
26+
<createData entity="Customer_With_Different_Default_Billing_Shipping_Addresses" stepKey="simpleCustomer"/>
27+
<!--Create category-->
28+
<createData entity="_defaultCategory" stepKey="category1"/>
29+
<!--Create product1-->
30+
<createData entity="_defaultProduct" stepKey="product1">
31+
<requiredEntity createDataKey="category1"/>
32+
</createData>
33+
<!--Create tax rule for US-CA-->
34+
<createData entity="defaultTaxRule" stepKey="createTaxRule"/>
35+
<!--Login as admin-->
36+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
37+
</before>
38+
<!--Step 1: Create new order for customer-->
39+
<actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderWithExistingCustomer">
40+
<argument name="customer" value="$$simpleCustomer$$"/>
41+
</actionGroup>
42+
<!--Step 2: Add product1 to the order-->
43+
<actionGroup ref="addSimpleProductToOrder" stepKey="addSimpleProductToOrder">
44+
<argument name="product" value="$$product1$$"/>
45+
</actionGroup>
46+
<!--Step 2: Select taxable address as billing address-->
47+
<selectOption selector="{{AdminOrderFormBillingAddressSection.selectAddress}}" userInput="{{US_Address_CA.state}}" stepKey="selectTaxableAddress" />
48+
<!--Step 3: Select FlatRate shipping method-->
49+
<actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRateShippingMethod"/>
50+
<!--Step 4: Verify that tax is applied to the order-->
51+
<seeElement selector="{{AdminOrderFormTotalSection.total('Tax')}}" stepKey="seeTax" />
52+
<!--Step 5: Select non taxable address as billing address-->
53+
<selectOption selector="{{AdminOrderFormBillingAddressSection.selectAddress}}" userInput="{{US_Address_TX.state}}" stepKey="selectNonTaxableAddress" />
54+
<!--Step 6: Change shipping method to Free-->
55+
<actionGroup ref="changeShippingMethod" stepKey="changeShippingMethod">
56+
<argument name="shippingMethod" value="freeshipping_freeshipping"/>
57+
</actionGroup>
58+
<!--Step 7: Verify that tax is not applied to the order-->
59+
<dontSeeElement selector="{{AdminOrderFormTotalSection.total('Tax')}}" stepKey="dontSeeTax" />
60+
<after>
61+
<!--Delete product1-->
62+
<deleteData createDataKey="product1" stepKey="deleteProduct1"/>
63+
<!--Delete category-->
64+
<deleteData createDataKey="category1" stepKey="deleteCategory1"/>
65+
<!--Delete customer-->
66+
<deleteData createDataKey="simpleCustomer" stepKey="deleteSimpleCustomer"/>
67+
<!--Delete tax rule-->
68+
<deleteData createDataKey="createTaxRule" stepKey="deleteTaxRule"/>
69+
<!--Logout-->
70+
<actionGroup ref="logout" stepKey="logout"/>
71+
<!--Disable free shipping method -->
72+
<magentoCLI command="config:set {{DisableFreeShippingConfigData.path}} {{DisableFreeShippingConfigData.value}}" stepKey="disableFreeShipping"/>
73+
</after>
74+
</test>
75+
</tests>

0 commit comments

Comments
 (0)