Skip to content

Commit 647b83f

Browse files
committed
MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping
- added functional test to cover the bug fix
1 parent d187b34 commit 647b83f

File tree

5 files changed

+182
-0
lines changed

5 files changed

+182
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="SetTaxClassForShipping">
12+
<amOnPage url="{{AdminSalesTaxClassPage.url}}" stepKey="navigateToSalesTaxPage"/>
13+
<waitForPageLoad stepKey="waitForPageLoad"/>
14+
<conditionalClick selector="{{SalesConfigSection.TaxClassesTab}}" dependentSelector="{{SalesConfigSection.CheckIfTaxClassesTabExpand}}" visible="true" stepKey="expandTaxClassesTab"/>
15+
<waitForElementVisible selector="{{SalesConfigSection.ShippingTaxClass}}" stepKey="seeShippingTaxClass"/>
16+
<uncheckOption selector="{{SalesConfigSection.EnableTaxClassForShipping}}" stepKey="uncheckUseSystemValue"/>
17+
<selectOption selector="{{SalesConfigSection.ShippingTaxClass}}" userInput="Taxable Goods" stepKey="setShippingTaxClass"/>
18+
<click selector="{{SalesConfigSection.TaxClassesTab}}" stepKey="collapseTaxClassesTab"/>
19+
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig" />
20+
</actionGroup>
21+
<actionGroup name="ResetTaxClassForShipping">
22+
<amOnPage url="{{AdminSalesTaxClassPage.url}}" stepKey="navigateToSalesTaxConfigPagetoReset"/>
23+
<waitForPageLoad stepKey="waitForPageLoad2"/>
24+
<conditionalClick selector="{{SalesConfigSection.TaxClassesTab}}" dependentSelector="{{SalesConfigSection.CheckIfTaxClassesTabExpand}}" visible="true" stepKey="openTaxClassTab"/>
25+
<waitForElementVisible selector="{{SalesConfigSection.ShippingTaxClass}}" stepKey="seeShippingTaxClass2"/>
26+
<selectOption selector="{{SalesConfigSection.ShippingTaxClass}}" userInput="None" stepKey="resetShippingTaxClass"/>
27+
<checkOption selector="{{SalesConfigSection.EnableTaxClassForShipping}}" stepKey="useSystemValue"/>
28+
<click selector="{{SalesConfigSection.TaxClassesTab}}" stepKey="collapseTaxClassesTab"/>
29+
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfiguration"/>
30+
</actionGroup>
31+
</actionGroups>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Page/AdminConfigPage.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@
1212
<page name="AdminContentManagementPage" url="admin/system_config/edit/section/cms/" area="admin" module="Magento_Config">
1313
<section name="ContentManagementSection"/>
1414
</page>
15+
<page name="AdminSalesTaxClassPage" url="admin/system_config/edit/section/tax/" area="admin" module="Magento_Config">
16+
<section name="SalesTaxClassSection"/>
17+
</page>
1518
</pages>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="SalesConfigSection">
12+
<element name="TaxClassesTab" type="button" selector="#tax_classes-head"/>
13+
<element name="CheckIfTaxClassesTabExpand" type="button" selector="#tax_classes-head:not(.open)"/>
14+
<element name="ShippingTaxClass" type="select" selector="#tax_classes_shipping_tax_class"/>
15+
<element name="EnableTaxClassForShipping" type="checkbox" selector="#tax_classes_shipping_tax_class_inherit"/>
16+
</section>
17+
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="CreditMemoTotalAfterShippingDiscountTest">
12+
<annotations>
13+
<features value="Credit memo"/>
14+
<title value="Verify credit memo grand total after shipping discount is applied via Cart Price Rule"/>
15+
<description value="Verify credit memo grand total after shipping discount is applied via Cart Price Rule"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-91710"/>
18+
<group value="sales"/>
19+
</annotations>
20+
<before>
21+
<createData entity="_defaultCategory" stepKey="createCategory"/>
22+
<createData entity="_defaultProduct" stepKey="createProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
<actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/>
26+
<actionGroup ref="SetTaxClassForShipping" stepKey="setShippingTaxClass"/>
27+
</before>
28+
<after>
29+
<actionGroup ref="ResetTaxClassForShipping" stepKey="resetTaxClassForShipping"/>
30+
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="deleteSalesRule">
31+
<argument name="ruleName" value="{{ApiSalesRule.name}}"/>
32+
</actionGroup>
33+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
34+
<deleteData createDataKey="createCategory" stepKey="deleteProduct1"/>
35+
<deleteData createDataKey="createProduct" stepKey="deleteCategory1"/>
36+
</after>
37+
38+
<!-- Create a cart price rule for $10 Fixed amount discount -->
39+
<amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/>
40+
<waitForPageLoad stepKey="waitForRulesPage"/>
41+
<click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/>
42+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{ApiSalesRule.name}}" stepKey="fillRuleName"/>
43+
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/>
44+
<selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" userInput="General" stepKey="selectCustomerGroup"/>
45+
<click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/>
46+
<selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount" stepKey="selectActionType"/>
47+
<fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="10" stepKey="fillDiscountAmount"/>
48+
<scrollTo selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="scrollToShippingLabel"/>
49+
<click selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="enableApplyDiscountToShiping"/>
50+
<seeCheckboxIsChecked selector="{{AdminCartPriceRulesFormSection.applyDiscountToShipping}}" stepKey="DiscountIsAppliedToShiping"/>
51+
<click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/>
52+
<see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
53+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
54+
55+
<!-- Place an order from Storefront as a Guest -->
56+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="onCategoryPage"/>
57+
<waitForPageLoad stepKey="waitForPageLoad1"/>
58+
<moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverOverProduct"/>
59+
<click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/>
60+
<waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductToAdd"/>
61+
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/>
62+
<click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/>
63+
<waitForPageLoad stepKey="waitForPageLoad2"/>
64+
<!-- fill out customer information -->
65+
<fillField selector="{{CheckoutShippingGuestInfoSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="enterEmail"/>
66+
<fillField selector="{{CheckoutShippingGuestInfoSection.firstName}}" userInput="{{CustomerEntityOne.firstname}}" stepKey="enterFirstName"/>
67+
<fillField selector="{{CheckoutShippingGuestInfoSection.lastName}}" userInput="{{CustomerEntityOne.lastname}}" stepKey="enterLastName"/>
68+
<fillField selector="{{CheckoutShippingGuestInfoSection.street}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="enterStreet"/>
69+
<fillField selector="{{CheckoutShippingGuestInfoSection.city}}" userInput="{{CustomerAddressSimple.city}}" stepKey="enterCity"/>
70+
<selectOption selector="{{CheckoutShippingGuestInfoSection.region}}" userInput="{{CustomerAddressSimple.state}}" stepKey="selectRegion"/>
71+
<fillField selector="{{CheckoutShippingGuestInfoSection.postcode}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="enterPostcode"/>
72+
<fillField selector="{{CheckoutShippingGuestInfoSection.telephone}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="enterTelephone"/>
73+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
74+
75+
<!-- Choose Shippping - Flat Rate Shipping -->
76+
<click selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
77+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask2"/>
78+
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForNextButton"/>
79+
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext"/>
80+
<waitForElement selector="{{CheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton"/>
81+
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder"/>
82+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="grabOrderNumber"/>
83+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
84+
85+
<!-- Search for Order in the order grid -->
86+
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage"/>
87+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask3"/>
88+
<fillField selector="{{AdminOrdersGridSection.search}}" userInput="{$grabOrderNumber}" stepKey="searchOrderNum"/>
89+
<click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearch"/>
90+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/>
91+
92+
<!-- Create invoice -->
93+
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/>
94+
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/>
95+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/>
96+
97+
<!-- Verify Invoice Totals including subTotal Shipping Discount and GrandTotal -->
98+
<see selector="{{AdminInvoiceTotalSection.total('Subtotal')}}" userInput="${{AdminOrderSimpleProduct.subtotal}}" stepKey="seeInvoiceSubTotal"/>
99+
<comment userInput="Shipping and Handling" stepKey="commentViewShippingAndHandling" after="seeInvoiceSubTotal"/>
100+
<see selector="{{AdminInvoiceTotalSection.total('Shipping')}}" userInput="${{AdminOrderSimpleProduct.shipping}}" stepKey="seeShippingAndHandling"/>
101+
<scrollTo selector="{{AdminInvoiceTotalSection.total('Shipping')}}" stepKey="scrollToInvoiceTotals"/>
102+
<grabTextFrom selector="{{AdminInvoiceTotalSection.total('Shipping')}}" stepKey="grabShippingCost"/>
103+
<assertEquals expected='$5.00' expectedType="string" actual="($grabShippingCost)" message="ExpectedShipping" stepKey="assertShippingAndHandling"/>
104+
105+
<see selector="{{AdminInvoiceTotalSection.total('Discount')}}" userInput="-$10.00" stepKey="seeShippingAndHandling2"/>
106+
<grabTextFrom selector="{{AdminInvoiceTotalSection.total('Discount')}}" stepKey="grabInvoiceDiscount"/>
107+
<assertEquals expected='-$10.00' expectedType="string" actual="($grabInvoiceDiscount)" message="ExpectedDiscount" stepKey="assertDiscountValue"/>
108+
109+
<see selector="{{AdminInvoiceTotalSection.grandTotal}}" userInput="$118.00" stepKey="seeCorrectGrandTotal"/>
110+
<grabTextFrom selector="{{AdminInvoiceTotalSection.grandTotal}}" stepKey="grabInvoiceGrandTotal" after="seeCorrectGrandTotal"/>
111+
112+
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/>
113+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The invoice has been created." stepKey="seeSuccessMessage1"/>
114+
115+
<!--Create Credit Memo-->
116+
<comment userInput="Admin creates credit memo" stepKey="createCreditMemoComment"/>
117+
<click selector="{{AdminOrderDetailsMainActionsSection.creditMemo}}" stepKey="clickCreateCreditMemo" after="createCreditMemoComment"/>
118+
<seeInCurrentUrl url="{{AdminCreditMemoNewPage.url}}" stepKey="seeNewCreditMemoPage" after="clickCreateCreditMemo"/>
119+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Memo" stepKey="seeNewMemoInPageTitle" after="seeNewCreditMemoPage"/>
120+
121+
<!-- Verify Refund Totals -->
122+
<see selector="{{AdminCreditMemoTotalSection.total('Subtotal')}}" userInput="${{AdminOrderSimpleProduct.subtotal}}" stepKey="seeRefundSubTotal"/>
123+
<grabTextFrom selector="{{AdminCreditMemoTotalSection.total('Discount')}}" stepKey="grabRefundDiscountValue"/>
124+
<assertEquals expected='-$10.00' expectedType="string" actual="($grabRefundDiscountValue)" message="notExpectedDiscountOnRefundPage" stepKey="assertDiscountValue1"/>
125+
<grabTextFrom selector="{{AdminInvoiceTotalSection.grandTotal}}" stepKey="grabRefundGrandTotal"/>
126+
<assertEquals expected="($grabInvoiceGrandTotal)" actual="($grabRefundGrandTotal)" message="RefundGrandTotalMatchesWithInvoiceGrandTotal" stepKey="compareRefundGrandTotalAndInvoiceGrandTotal"/>
127+
</test>
128+
</tests>
129+

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Section/AdminCartPriceRulesFormSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<!-- Actions sub-form -->
2626
<element name="actionsHeader" type="button" selector="div[data-index='actions']" timeout="30"/>
2727
<element name="apply" type="select" selector="select[name='simple_action']"/>
28+
<element name="applyDiscountToShipping" type="checkbox" selector="input[name='apply_to_shipping']"/>
29+
<element name="applyDiscountToShippingLabel" type="checkbox" selector="input[name='apply_to_shipping']+label"/>
2830
<element name="discountAmount" type="input" selector="input[name='discount_amount']"/>
2931
<element name="discountStep" type="input" selector="input[name='discount_step']"/>
3032

0 commit comments

Comments
 (0)