From 177b61da4e5cfa9c279add03abc57e469755f59f Mon Sep 17 00:00:00 2001 From: Joan He Date: Thu, 14 Jun 2018 11:57:57 -0500 Subject: [PATCH 1/8] MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping --- .../Model/Order/Creditmemo/Total/Discount.php | 19 ++++- .../Order/Creditmemo/Total/DiscountTest.php | 78 ++++++++++++++++++- 2 files changed, 95 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php index bb173f401031..0cc4143e569d 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php @@ -25,7 +25,7 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo) * Calculate how much shipping discount should be applied * basing on how much shipping should be refunded. */ - $baseShippingAmount = (float)$creditmemo->getBaseShippingAmount(); + $baseShippingAmount = $this->getBaseShippingAmount($creditmemo); if ($baseShippingAmount) { $baseShippingDiscount = $baseShippingAmount * $order->getBaseShippingDiscountAmount() / @@ -75,4 +75,21 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo) $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount); return $this; } + + /** + * Get base shipping amount + * + * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo + * @return float + */ + private function getBaseShippingAmount(\Magento\Sales\Model\Order\Creditmemo $creditmemo): float + { + $baseShippingAmount = (float)$creditmemo->getBaseShippingAmount(); + if (!$baseShippingAmount) { + $baseShippingInclTax = (float)$creditmemo->getBaseShippingInclTax(); + $baseShippingTaxAmount = (float)$creditmemo->getBaseShippingTaxAmount(); + $baseShippingAmount = $baseShippingInclTax - $baseShippingTaxAmount; + } + return $baseShippingAmount; + } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php index 2531a26321d6..18efef38b204 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php @@ -48,7 +48,7 @@ protected function setUp() ]); $this->creditmemoMock = $this->createPartialMock(\Magento\Sales\Model\Order\Creditmemo::class, [ 'setBaseCost', 'getAllItems', 'getOrder', 'getBaseShippingAmount', 'roundPrice', - 'setDiscountAmount', 'setBaseDiscountAmount' + 'setDiscountAmount', 'setBaseDiscountAmount', 'getBaseShippingInclTax', 'getBaseShippingTaxAmount' ]); $this->creditmemoItemMock = $this->createPartialMock(\Magento\Sales\Model\Order\Creditmemo\Item::class, [ 'getHasChildren', 'getBaseCost', 'getQty', 'getOrderItem', 'setDiscountAmount', @@ -127,6 +127,82 @@ public function testCollect() $this->assertEquals($this->total, $this->total->collect($this->creditmemoMock)); } + public function testCollectNoBaseShippingAmount() + { + $this->creditmemoMock->expects($this->exactly(2)) + ->method('setDiscountAmount') + ->willReturnSelf(); + $this->creditmemoMock->expects($this->exactly(2)) + ->method('setBaseDiscountAmount') + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('getOrder') + ->willReturn($this->orderMock); + $this->creditmemoMock->expects($this->once()) + ->method('getBaseShippingAmount') + ->willReturn(0); + $this->creditmemoMock->expects($this->once()) + ->method('getBaseShippingInclTax') + ->willReturn(1); + $this->creditmemoMock->expects($this->once()) + ->method('getBaseShippingTaxAmount') + ->willReturn(0); + $this->orderMock->expects($this->once()) + ->method('getBaseShippingDiscountAmount') + ->willReturn(1); + $this->orderMock->expects($this->exactly(2)) + ->method('getBaseShippingAmount') + ->willReturn(1); + $this->orderMock->expects($this->once()) + ->method('getShippingAmount') + ->willReturn(1); + $this->creditmemoMock->expects($this->once()) + ->method('getAllItems') + ->willReturn([$this->creditmemoItemMock]); + $this->creditmemoItemMock->expects($this->atLeastOnce()) + ->method('getOrderItem') + ->willReturn($this->orderItemMock); + $this->orderItemMock->expects($this->once()) + ->method('isDummy') + ->willReturn(false); + $this->orderItemMock->expects($this->once()) + ->method('getDiscountInvoiced') + ->willReturn(1); + $this->orderItemMock->expects($this->once()) + ->method('getBaseDiscountInvoiced') + ->willReturn(1); + $this->orderItemMock->expects($this->once()) + ->method('getQtyInvoiced') + ->willReturn(1); + $this->orderItemMock->expects($this->once()) + ->method('getDiscountRefunded') + ->willReturn(1); + $this->orderItemMock->expects($this->once()) + ->method('getQtyRefunded') + ->willReturn(0); + $this->creditmemoItemMock->expects($this->once()) + ->method('isLast') + ->willReturn(false); + $this->creditmemoItemMock->expects($this->atLeastOnce()) + ->method('getQty') + ->willReturn(1); + $this->creditmemoItemMock->expects($this->exactly(1)) + ->method('setDiscountAmount') + ->willReturnSelf(); + $this->creditmemoItemMock->expects($this->exactly(1)) + ->method('setBaseDiscountAmount') + ->willReturnSelf(); + $this->creditmemoMock->expects($this->exactly(2)) + ->method('roundPrice') + ->willReturnMap( + [ + [1, 'regular', true, 1], + [1, 'base', true, 1] + ] + ); + $this->assertEquals($this->total, $this->total->collect($this->creditmemoMock)); + } + public function testCollectZeroShipping() { $this->creditmemoMock->expects($this->exactly(2)) From 647b83f76b4977432dba1befa894e00704569331 Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Fri, 22 Jun 2018 10:04:05 -0500 Subject: [PATCH 2/8] MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping - added functional test to cover the bug fix --- .../ConfigSalesTaxClassActionGroup.xml | 31 +++++ .../Config/Page/AdminConfigPage.xml | 3 + .../Config/Section/SalesConfigSection.xml | 17 +++ ...editMemoTotalAfterShippingDiscountTest.xml | 129 ++++++++++++++++++ .../AdminCartPriceRulesFormSection.xml | 2 + 5 files changed, 182 insertions(+) create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigSalesTaxClassActionGroup.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/SalesConfigSection.xml create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigSalesTaxClassActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigSalesTaxClassActionGroup.xml new file mode 100644 index 000000000000..e6de70810b70 --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigSalesTaxClassActionGroup.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Page/AdminConfigPage.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Page/AdminConfigPage.xml index 9ae1ecab1c26..13c06cb34c6f 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Page/AdminConfigPage.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Page/AdminConfigPage.xml @@ -12,4 +12,7 @@
+ +
+ diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/SalesConfigSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/SalesConfigSection.xml new file mode 100644 index 000000000000..9c22425b15ed --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/SalesConfigSection.xml @@ -0,0 +1,17 @@ + + + + +
+ + + + +
+
\ No newline at end of file diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml new file mode 100644 index 000000000000..38cba21ab34c --- /dev/null +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -0,0 +1,129 @@ + + + + + + + + + <description value="Verify credit memo grand total after shipping discount is applied via Cart Price Rule"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-91710"/> + <group value="sales"/> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="SetTaxClassForShipping" stepKey="setShippingTaxClass"/> + </before> + <after> + <actionGroup ref="ResetTaxClassForShipping" stepKey="resetTaxClassForShipping"/> + <actionGroup ref="DeleteCartPriceRuleByName" stepKey="deleteSalesRule"> + <argument name="ruleName" value="{{ApiSalesRule.name}}"/> + </actionGroup> + <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <deleteData createDataKey="createCategory" stepKey="deleteProduct1"/> + <deleteData createDataKey="createProduct" stepKey="deleteCategory1"/> + </after> + + <!-- Create a cart price rule for $10 Fixed amount discount --> + <amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/> + <waitForPageLoad stepKey="waitForRulesPage"/> + <click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/> + <fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{ApiSalesRule.name}}" stepKey="fillRuleName"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" userInput="General" stepKey="selectCustomerGroup"/> + <click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount" stepKey="selectActionType"/> + <fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="10" stepKey="fillDiscountAmount"/> + <scrollTo selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="scrollToShippingLabel"/> + <click selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="enableApplyDiscountToShiping"/> + <seeCheckboxIsChecked selector="{{AdminCartPriceRulesFormSection.applyDiscountToShipping}}" stepKey="DiscountIsAppliedToShiping"/> + <click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/> + <see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/> + <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + + <!-- Place an order from Storefront as a Guest --> + <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="onCategoryPage"/> + <waitForPageLoad stepKey="waitForPageLoad1"/> + <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverOverProduct"/> + <click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/> + <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductToAdd"/> + <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/> + <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/> + <waitForPageLoad stepKey="waitForPageLoad2"/> + <!-- fill out customer information --> + <fillField selector="{{CheckoutShippingGuestInfoSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="enterEmail"/> + <fillField selector="{{CheckoutShippingGuestInfoSection.firstName}}" userInput="{{CustomerEntityOne.firstname}}" stepKey="enterFirstName"/> + <fillField selector="{{CheckoutShippingGuestInfoSection.lastName}}" userInput="{{CustomerEntityOne.lastname}}" stepKey="enterLastName"/> + <fillField selector="{{CheckoutShippingGuestInfoSection.street}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="enterStreet"/> + <fillField selector="{{CheckoutShippingGuestInfoSection.city}}" userInput="{{CustomerAddressSimple.city}}" stepKey="enterCity"/> + <selectOption selector="{{CheckoutShippingGuestInfoSection.region}}" userInput="{{CustomerAddressSimple.state}}" stepKey="selectRegion"/> + <fillField selector="{{CheckoutShippingGuestInfoSection.postcode}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="enterPostcode"/> + <fillField selector="{{CheckoutShippingGuestInfoSection.telephone}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="enterTelephone"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> + + <!-- Choose Shippping - Flat Rate Shipping --> + <click selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask2"/> + <waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForNextButton"/> + <click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext"/> + <waitForElement selector="{{CheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton"/> + <click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder"/> + <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="grabOrderNumber"/> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> + + <!-- Search for Order in the order grid --> + <amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask3"/> + <fillField selector="{{AdminOrdersGridSection.search}}" userInput="{$grabOrderNumber}" stepKey="searchOrderNum"/> + <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearch"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/> + + <!-- Create invoice --> + <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> + <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/> + <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/> + + <!-- Verify Invoice Totals including subTotal Shipping Discount and GrandTotal --> + <see selector="{{AdminInvoiceTotalSection.total('Subtotal')}}" userInput="${{AdminOrderSimpleProduct.subtotal}}" stepKey="seeInvoiceSubTotal"/> + <comment userInput="Shipping and Handling" stepKey="commentViewShippingAndHandling" after="seeInvoiceSubTotal"/> + <see selector="{{AdminInvoiceTotalSection.total('Shipping')}}" userInput="${{AdminOrderSimpleProduct.shipping}}" stepKey="seeShippingAndHandling"/> + <scrollTo selector="{{AdminInvoiceTotalSection.total('Shipping')}}" stepKey="scrollToInvoiceTotals"/> + <grabTextFrom selector="{{AdminInvoiceTotalSection.total('Shipping')}}" stepKey="grabShippingCost"/> + <assertEquals expected='$5.00' expectedType="string" actual="($grabShippingCost)" message="ExpectedShipping" stepKey="assertShippingAndHandling"/> + + <see selector="{{AdminInvoiceTotalSection.total('Discount')}}" userInput="-$10.00" stepKey="seeShippingAndHandling2"/> + <grabTextFrom selector="{{AdminInvoiceTotalSection.total('Discount')}}" stepKey="grabInvoiceDiscount"/> + <assertEquals expected='-$10.00' expectedType="string" actual="($grabInvoiceDiscount)" message="ExpectedDiscount" stepKey="assertDiscountValue"/> + + <see selector="{{AdminInvoiceTotalSection.grandTotal}}" userInput="$118.00" stepKey="seeCorrectGrandTotal"/> + <grabTextFrom selector="{{AdminInvoiceTotalSection.grandTotal}}" stepKey="grabInvoiceGrandTotal" after="seeCorrectGrandTotal"/> + + <click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/> + <see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The invoice has been created." stepKey="seeSuccessMessage1"/> + + <!--Create Credit Memo--> + <comment userInput="Admin creates credit memo" stepKey="createCreditMemoComment"/> + <click selector="{{AdminOrderDetailsMainActionsSection.creditMemo}}" stepKey="clickCreateCreditMemo" after="createCreditMemoComment"/> + <seeInCurrentUrl url="{{AdminCreditMemoNewPage.url}}" stepKey="seeNewCreditMemoPage" after="clickCreateCreditMemo"/> + <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Memo" stepKey="seeNewMemoInPageTitle" after="seeNewCreditMemoPage"/> + + <!-- Verify Refund Totals --> + <see selector="{{AdminCreditMemoTotalSection.total('Subtotal')}}" userInput="${{AdminOrderSimpleProduct.subtotal}}" stepKey="seeRefundSubTotal"/> + <grabTextFrom selector="{{AdminCreditMemoTotalSection.total('Discount')}}" stepKey="grabRefundDiscountValue"/> + <assertEquals expected='-$10.00' expectedType="string" actual="($grabRefundDiscountValue)" message="notExpectedDiscountOnRefundPage" stepKey="assertDiscountValue1"/> + <grabTextFrom selector="{{AdminInvoiceTotalSection.grandTotal}}" stepKey="grabRefundGrandTotal"/> + <assertEquals expected="($grabInvoiceGrandTotal)" actual="($grabRefundGrandTotal)" message="RefundGrandTotalMatchesWithInvoiceGrandTotal" stepKey="compareRefundGrandTotalAndInvoiceGrandTotal"/> + </test> +</tests> + diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Section/AdminCartPriceRulesFormSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Section/AdminCartPriceRulesFormSection.xml index 3912a6ab31e8..dcb9f63aa7f4 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Section/AdminCartPriceRulesFormSection.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Section/AdminCartPriceRulesFormSection.xml @@ -25,6 +25,8 @@ <!-- Actions sub-form --> <element name="actionsHeader" type="button" selector="div[data-index='actions']" timeout="30"/> <element name="apply" type="select" selector="select[name='simple_action']"/> + <element name="applyDiscountToShipping" type="checkbox" selector="input[name='apply_to_shipping']"/> + <element name="applyDiscountToShippingLabel" type="checkbox" selector="input[name='apply_to_shipping']+label"/> <element name="discountAmount" type="input" selector="input[name='discount_amount']"/> <element name="discountStep" type="input" selector="input[name='discount_step']"/> From d7998b59f3b750cdcd4f6e98787f21ee10e487d6 Mon Sep 17 00:00:00 2001 From: Deepty Thampy <dthampy@magento.com> Date: Fri, 22 Jun 2018 11:09:09 -0500 Subject: [PATCH 3/8] MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping - updated correct testCaseId --- .../Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml index 38cba21ab34c..b4332bd25241 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -14,7 +14,7 @@ <title value="Verify credit memo grand total after shipping discount is applied via Cart Price Rule"/> <description value="Verify credit memo grand total after shipping discount is applied via Cart Price Rule"/> <severity value="MAJOR"/> - <testCaseId value="MAGETWO-91710"/> + <testCaseId value="MAGETWO-92924"/> <group value="sales"/> </annotations> <before> From 2a3835c366db73c201b639c671f141f0d1f39fad Mon Sep 17 00:00:00 2001 From: Deepty Thampy <dthampy@magento.com> Date: Thu, 5 Jul 2018 12:01:20 -0500 Subject: [PATCH 4/8] MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping - fixed test --- .../Test/CreditMemoTotalAfterShippingDiscountTest.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml index b4332bd25241..a59759c30339 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -41,7 +41,7 @@ <click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/> <fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{ApiSalesRule.name}}" stepKey="fillRuleName"/> <selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/> - <selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" userInput="General" stepKey="selectCustomerGroup"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" userInput="NOT LOGGED IN" stepKey="selectCustomerGroup"/> <click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/> <selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount" stepKey="selectActionType"/> <fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="10" stepKey="fillDiscountAmount"/> @@ -102,11 +102,11 @@ <grabTextFrom selector="{{AdminInvoiceTotalSection.total('Shipping')}}" stepKey="grabShippingCost"/> <assertEquals expected='$5.00' expectedType="string" actual="($grabShippingCost)" message="ExpectedShipping" stepKey="assertShippingAndHandling"/> - <see selector="{{AdminInvoiceTotalSection.total('Discount')}}" userInput="-$10.00" stepKey="seeShippingAndHandling2"/> + <see selector="{{AdminInvoiceTotalSection.total('Discount')}}" userInput="-$15.00" stepKey="seeShippingAndHandling2"/> <grabTextFrom selector="{{AdminInvoiceTotalSection.total('Discount')}}" stepKey="grabInvoiceDiscount"/> - <assertEquals expected='-$10.00' expectedType="string" actual="($grabInvoiceDiscount)" message="ExpectedDiscount" stepKey="assertDiscountValue"/> + <assertEquals expected='-$15.00' expectedType="string" actual="($grabInvoiceDiscount)" message="ExpectedDiscount" stepKey="assertDiscountValue"/> - <see selector="{{AdminInvoiceTotalSection.grandTotal}}" userInput="$118.00" stepKey="seeCorrectGrandTotal"/> + <see selector="{{AdminInvoiceTotalSection.grandTotal}}" userInput="$113.00" stepKey="seeCorrectGrandTotal"/> <grabTextFrom selector="{{AdminInvoiceTotalSection.grandTotal}}" stepKey="grabInvoiceGrandTotal" after="seeCorrectGrandTotal"/> <click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/> @@ -121,7 +121,7 @@ <!-- Verify Refund Totals --> <see selector="{{AdminCreditMemoTotalSection.total('Subtotal')}}" userInput="${{AdminOrderSimpleProduct.subtotal}}" stepKey="seeRefundSubTotal"/> <grabTextFrom selector="{{AdminCreditMemoTotalSection.total('Discount')}}" stepKey="grabRefundDiscountValue"/> - <assertEquals expected='-$10.00' expectedType="string" actual="($grabRefundDiscountValue)" message="notExpectedDiscountOnRefundPage" stepKey="assertDiscountValue1"/> + <assertEquals expected='-$15.00' expectedType="string" actual="($grabRefundDiscountValue)" message="notExpectedDiscountOnRefundPage" stepKey="assertDiscountValue1"/> <grabTextFrom selector="{{AdminInvoiceTotalSection.grandTotal}}" stepKey="grabRefundGrandTotal"/> <assertEquals expected="($grabInvoiceGrandTotal)" actual="($grabRefundGrandTotal)" message="RefundGrandTotalMatchesWithInvoiceGrandTotal" stepKey="compareRefundGrandTotalAndInvoiceGrandTotal"/> </test> From 9b1cc7c7d87c19846a649008639d2fcea68fc487 Mon Sep 17 00:00:00 2001 From: Deepty Thampy <dthampy@magento.com> Date: Fri, 6 Jul 2018 11:21:20 -0500 Subject: [PATCH 5/8] MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping - fixed failures --- .../Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml | 1 + .../Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml index 49f0e9e362ce..16a7f5a7da9b 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml @@ -34,6 +34,7 @@ <!--Create Store view --> <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <waitForElementVisible selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="waitForStoreViewBtn"/> <click selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="createStoreViewButton"/> <waitForPageLoad stepKey="waitForProductPageLoad"/> <selectOption userInput="Second Store" selector="{{AdminNewStoreSection.storeGrpDropdown}}" stepKey="selectStoreGroup"/> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml index a59759c30339..4d302d250ba0 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -41,7 +41,8 @@ <click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/> <fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{ApiSalesRule.name}}" stepKey="fillRuleName"/> <selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/> - <selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" userInput="NOT LOGGED IN" stepKey="selectCustomerGroup"/> + <actionGroup ref="selectNotLoggedInCustomerGroup" stepKey="chooseNotLoggedInCustomerGroup"/> + <!--<selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" userInput="NOT LOGGED IN" stepKey="selectCustomerGroup"/>--> <click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/> <selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount" stepKey="selectActionType"/> <fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="10" stepKey="fillDiscountAmount"/> From e27692a355a9abd1cb7cb3c5ee77377035dd3a71 Mon Sep 17 00:00:00 2001 From: Deepty Thampy <dthampy@magento.com> Date: Fri, 6 Jul 2018 11:44:30 -0500 Subject: [PATCH 6/8] MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping - fixed mftf path --- .../Mftf}/Test/CreditMemoTotalAfterShippingDiscountTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales => app/code/Magento/Sales/Test/Mftf}/Test/CreditMemoTotalAfterShippingDiscountTest.xml (98%) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml similarity index 98% rename from dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml rename to app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml index 4d302d250ba0..9b03aea6a91c 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Sales/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> <test name="CreditMemoTotalAfterShippingDiscountTest"> <annotations> <features value="Credit memo"/> From 14fa2be48189881d5df8a9ed4570631f7d3ebfdd Mon Sep 17 00:00:00 2001 From: Deepty Thampy <dthampy@magento.com> Date: Fri, 6 Jul 2018 12:16:14 -0500 Subject: [PATCH 7/8] MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping - fixed mftf path from new files --- .../Test/Mftf}/ActionGroup/ConfigSalesTaxClassActionGroup.xml | 2 +- .../Magento/Config/Test/Mftf}/Section/SalesConfigSection.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename {dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config => app/code/Magento/Config/Test/Mftf}/ActionGroup/ConfigSalesTaxClassActionGroup.xml (90%) rename {dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config => app/code/Magento/Config/Test/Mftf}/Section/SalesConfigSection.xml (77%) diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigSalesTaxClassActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigSalesTaxClassActionGroup.xml similarity index 90% rename from dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigSalesTaxClassActionGroup.xml rename to app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigSalesTaxClassActionGroup.xml index e6de70810b70..7bb2441a6a52 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/ActionGroup/ConfigSalesTaxClassActionGroup.xml +++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigSalesTaxClassActionGroup.xml @@ -7,7 +7,7 @@ --> <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> + xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> <actionGroup name="SetTaxClassForShipping"> <amOnPage url="{{AdminSalesTaxClassPage.url}}" stepKey="navigateToSalesTaxPage"/> <waitForPageLoad stepKey="waitForPageLoad"/> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/SalesConfigSection.xml b/app/code/Magento/Config/Test/Mftf/Section/SalesConfigSection.xml similarity index 77% rename from dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/SalesConfigSection.xml rename to app/code/Magento/Config/Test/Mftf/Section/SalesConfigSection.xml index 9c22425b15ed..f1520f5813e6 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Config/Section/SalesConfigSection.xml +++ b/app/code/Magento/Config/Test/Mftf/Section/SalesConfigSection.xml @@ -7,7 +7,7 @@ --> <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> + xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> <section name="SalesConfigSection"> <element name="TaxClassesTab" type="button" selector="#tax_classes-head"/> <element name="CheckIfTaxClassesTabExpand" type="button" selector="#tax_classes-head:not(.open)"/> From 0c01f793afb06d8565d707695b63e5ab9eb84194 Mon Sep 17 00:00:00 2001 From: Deepty Thampy <dthampy@magento.com> Date: Fri, 6 Jul 2018 17:25:43 -0500 Subject: [PATCH 8/8] MAGETWO-91710: Creditmemo Grand Total is incorrect if discount is applied on shipping - fixed failures --- ...veProductWithCustomOptionsSecondWebsiteTest.xml | 1 + .../Config/Test/Mftf/Page/AdminConfigPage.xml | 3 +++ .../CreditMemoTotalAfterShippingDiscountTest.xml | 14 ++++++++++---- .../Section/AdminCartPriceRulesFormSection.xml | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml index 0166d15e226c..5ed2bd5f75c0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml @@ -34,6 +34,7 @@ <!--Create Store view --> <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <waitForElementVisible selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="waitForStoreViewBtn"/> <click selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="createStoreViewButton"/> <waitForPageLoad stepKey="waitForProductPageLoad"/> <selectOption userInput="Second Store" selector="{{AdminNewStoreSection.storeGrpDropdown}}" stepKey="selectStoreGroup"/> diff --git a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml index e517f6ef62c7..c24e578c9109 100644 --- a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml +++ b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml @@ -12,4 +12,7 @@ <page name="AdminContentManagementPage" url="admin/system_config/edit/section/cms/" area="admin" module="Magento_Config"> <section name="ContentManagementSection"/> </page> + <page name="AdminSalesTaxClassPage" url="admin/system_config/edit/section/tax/" area="admin" module="Magento_Config"> + <section name="SalesTaxClassSection"/> + </page> </pages> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml index 9b03aea6a91c..26139f7182ba 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -40,15 +40,21 @@ <waitForPageLoad stepKey="waitForRulesPage"/> <click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/> <fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{ApiSalesRule.name}}" stepKey="fillRuleName"/> - <selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsites"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="Main Website" stepKey="selectWebsite"/> <actionGroup ref="selectNotLoggedInCustomerGroup" stepKey="chooseNotLoggedInCustomerGroup"/> <!--<selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" userInput="NOT LOGGED IN" stepKey="selectCustomerGroup"/>--> + + <!-- Open the Actions Tab in the Rules Edit page --> <click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/> - <selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount" stepKey="selectActionType"/> - <fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="10" stepKey="fillDiscountAmount"/> - <scrollTo selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="scrollToShippingLabel"/> + <waitForElementVisible selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="waitForElementToBeVisible"/> <click selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="enableApplyDiscountToShiping"/> <seeCheckboxIsChecked selector="{{AdminCartPriceRulesFormSection.applyDiscountToShipping}}" stepKey="DiscountIsAppliedToShiping"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount" stepKey="selectActionType"/> + <fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="10" stepKey="fillDiscountAmount"/> + + <!--<scrollTo selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="scrollToShippingLabel"/>--> + <!--<click selector="{{AdminCartPriceRulesFormSection.applyDiscountToShippingLabel}}" stepKey="enableApplyDiscountToShiping"/>--> + <!--<seeCheckboxIsChecked selector="{{AdminCartPriceRulesFormSection.applyDiscountToShipping}}" stepKey="DiscountIsAppliedToShiping"/>--> <click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/> <see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/> <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml index 87408aac2c0c..f31ff1a45689 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml @@ -25,6 +25,8 @@ <!-- Actions sub-form --> <element name="actionsHeader" type="button" selector="div[data-index='actions']" timeout="30"/> <element name="apply" type="select" selector="select[name='simple_action']"/> + <element name="applyDiscountToShipping" type="checkbox" selector="input[name='apply_to_shipping']"/> + <element name="applyDiscountToShippingLabel" type="checkbox" selector="input[name='apply_to_shipping']+label"/> <element name="discountAmount" type="input" selector="input[name='discount_amount']"/> <element name="discountStep" type="input" selector="input[name='discount_step']"/>