Skip to content

Commit e7cf3ec

Browse files
authored
Merge pull request #3222 from magento-earl-grey/MAGETWO-60034
[earl] MAGETWO-60034: Cannot ship remaining items in an order for several of one product if credit memo is made for some
2 parents e7b5fda + abe0bff commit e7cf3ec

File tree

11 files changed

+918
-497
lines changed

11 files changed

+918
-497
lines changed

app/code/Magento/Sales/Model/Order.php

Lines changed: 341 additions & 280 deletions
Large diffs are not rendered by default.

app/code/Magento/Sales/Model/Order/Item.php

Lines changed: 197 additions & 197 deletions
Large diffs are not rendered by default.

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@
9494
<click selector="{{AdminOrderFormItemsSection.addSelected}}" stepKey="clickAddSelectedProducts"/>
9595
</actionGroup>
9696

97+
<!--Add a simple product to order with user defined quantity-->
98+
<actionGroup name="addSimpleProductToOrderWithCustomQuantity">
99+
<arguments>
100+
<argument name="product" defaultValue="_defaultProduct"/>
101+
<argument name="quantity" type="string"/>
102+
</arguments>
103+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMastToDisappear"/>
104+
<waitForElementVisible selector="{{AdminOrderFormItemsSection.addProducts}}" stepKey="waitForAddProductButton"/>
105+
<click selector="{{AdminOrderFormItemsSection.addProducts}}" stepKey="clickAddProducts"/>
106+
<fillField selector="{{AdminOrderFormItemsSection.skuFilter}}" userInput="{{product.sku}}" stepKey="fillSkuFilter"/>
107+
<click selector="{{AdminOrderFormItemsSection.search}}" stepKey="clickSearch"/>
108+
<scrollTo selector="{{AdminOrderFormItemsSection.rowCheck('1')}}" x="0" y="-100" stepKey="scrollToCheckColumn"/>
109+
<checkOption selector="{{AdminOrderFormItemsSection.rowCheck('1')}}" stepKey="selectProduct"/>
110+
<fillField selector="{{AdminOrderFormItemsSection.rowQty('1')}}" userInput="{{quantity}}" stepKey="fillProductQty"/>
111+
<scrollTo selector="{{AdminOrderFormItemsSection.addSelected}}" x="0" y="-100" stepKey="scrollToAddSelectedButton"/>
112+
<click selector="{{AdminOrderFormItemsSection.addSelected}}" stepKey="clickAddSelectedProducts"/>
113+
</actionGroup>
114+
97115
<!--Add configurable product to order -->
98116
<actionGroup name="addConfigurableProductToOrder">
99117
<arguments>
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
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="AdminAbleToShipPartiallyInvoicedItemsTest">
11+
<annotations>
12+
<title value="Ship Action is available for remaining of the partially invoiced items "/>
13+
<description value="Admin should be able to ship remaining ordered items if some of them are already refunded"/>
14+
<severity value="CRITICAL"/>
15+
<testCaseId value="MAGETWO-93030"/>
16+
<group value="sales"/>
17+
18+
</annotations>
19+
<before>
20+
<createData entity="_defaultCategory" stepKey="createCategory"/>
21+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
22+
<requiredEntity createDataKey="createCategory"/>
23+
</createData>
24+
</before>
25+
<after>
26+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
27+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
28+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
29+
</after>
30+
31+
<!--login to Admin-->
32+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
33+
<comment userInput="Admin creates order" stepKey="adminCreateOrderComment"/>
34+
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="navigateToOrderIndexPage"/>
35+
<waitForPageLoad stepKey="waitForIndexPageLoad"/>
36+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="Orders" stepKey="seeIndexPageTitle"/>
37+
38+
<!--Create new order-->
39+
<click selector="{{AdminOrdersGridSection.createNewOrder}}" stepKey="clickCreateNewOrder"/>
40+
<click selector="{{AdminOrderFormActionSection.CreateNewCustomer}}" stepKey="clickCreateCustomer"/>
41+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="Create New Order" stepKey="seeNewOrderPageTitle"/>
42+
<actionGroup ref="addSimpleProductToOrderWithCustomQuantity" stepKey="addSimpleProductToOrderWithUserDefinedQty">
43+
<argument name="product" value="_defaultProduct"/>
44+
<argument name="quantity" value="10"/>
45+
</actionGroup>
46+
47+
<!--Fill customer group and customer email which both are now required fields-->
48+
<selectOption selector="{{AdminOrderFormAccountSection.group}}" userInput="{{GeneralCustomerGroup.code}}" stepKey="selectCustomerGroup" after="addSimpleProductToOrderWithUserDefinedQty"/>
49+
<fillField selector="{{AdminOrderFormAccountSection.email}}" userInput="{{Simple_US_Customer.email}}" stepKey="fillCustomerEmail" after="selectCustomerGroup"/>
50+
51+
<!--Fill customer address information-->
52+
<actionGroup ref="fillOrderCustomerInformation" stepKey="fillCustomerAddress" after="fillCustomerEmail">
53+
<argument name="customer" value="Simple_US_Customer"/>
54+
<argument name="address" value="US_Address_TX"/>
55+
</actionGroup>
56+
<!-- Select shipping -->
57+
<actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRateShipping" after="fillCustomerAddress"/>
58+
59+
<!--Verify totals on Order page-->
60+
<see selector="{{AdminOrderFormTotalSection.total('Subtotal')}}" userInput="$1,230.00" stepKey="seeOrderSubTotal" after="selectFlatRateShipping"/>
61+
<see selector="{{AdminOrderFormTotalSection.total('Shipping')}}" userInput="$50.00" stepKey="seeOrderShipping" after="seeOrderSubTotal"/>
62+
<scrollTo selector="{{AdminOrderFormTotalSection.grandTotal}}" stepKey="scrollToOrderGrandTotal"/>
63+
<see selector="{{AdminOrderFormTotalSection.grandTotal}}" userInput="$1,280.00" stepKey="seeCorrectGrandTotal" after="scrollToOrderGrandTotal"/>
64+
65+
<!--Submit Order and verify information-->
66+
<click selector="{{AdminOrderFormActionSection.SubmitOrder}}" stepKey="clickSubmitOrder" after="seeCorrectGrandTotal"/>
67+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskTodisappear"/>
68+
<waitForPageLoad stepKey="waitForOrderToProcess"/>
69+
<seeInCurrentUrl url="{{AdminOrderDetailsPage.url}}" stepKey="seeViewOrderPage" after="clickSubmitOrder"/>
70+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="You created the order." stepKey="seeSuccessMessage" after="seeViewOrderPage"/>
71+
<grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId" after="seeSuccessMessage"/>
72+
<scrollTo selector="{{AdminOrderItemsOrderedSection.qtyColumn}}" stepKey="scrollToItemsOrdered" after="getOrderId"/>
73+
<see selector="{{AdminOrderItemsOrderedSection.itemQty('1')}}" userInput="Ordered 10" stepKey="seeQtyOfItemsOrdered" after="scrollToItemsOrdered"/>
74+
75+
<!--Create order invoice for first half of ordered items-->
76+
<comment userInput="Admin creates invoice for order" stepKey="adminCreateInvoiceComment" />
77+
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceActionButton"/>
78+
<!--<seeInCurrentUrl url="{{AdminInvoiceNewPage.url}}" stepKey="seeOrderInvoiceUrl" after="clickInvoiceAction"/>-->
79+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seePageNameNewInvoicePage" after="clickInvoiceActionButton"/>
80+
<scrollTo selector="{{AdminInvoiceItemsSection.itemQtyToInvoice('1')}}" stepKey="scrollToItemsInvoiced"/>
81+
82+
<!--Verify items invoiced information-->
83+
<fillField selector="{{AdminInvoiceItemsSection.itemQtyToInvoice('1')}}" userInput="5" stepKey="invoiceHalfTheItems"/>
84+
<click selector="{{AdminInvoiceItemsSection.updateQty}}" stepKey="updateQtyToBeInvoiced"/>
85+
<waitForLoadingMaskToDisappear stepKey="WaitForQtyToUpdate"/>
86+
<waitForElementVisible selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="waitforSubmitInvoiceBtn"/>
87+
88+
<!--Submit Invoice-->
89+
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="submitInvoice"/>
90+
<waitForLoadingMaskToDisappear stepKey="WaitForInvoiceToSubmit"/>
91+
<!--<waitForElementVisible selector="{{AdminOrderDetailsMessagesSection.successMessage}}" stepKey="waitUntilInvoiceSucesssMsg"/>-->
92+
93+
<!--Invoice created successfully-->
94+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The invoice has been created." stepKey="seeInvoiceSuccessMessage"/>
95+
<click selector="{{AdminOrderDetailsOrderViewSection.invoices}}" stepKey="clickInvoicesTab"/>
96+
<waitForLoadingMaskToDisappear stepKey="waitForInvoiceGridToLoad" after="clickInvoicesTab"/>
97+
<see selector="{{AdminOrderInvoicesTabSection.gridRow('1')}}" userInput="$665.00" stepKey="seeOrderInvoiceTabInGrid" after="waitForInvoiceGridToLoad"/>
98+
<click selector="{{AdminOrderInvoicesTabSection.viewGridRow('1')}}" stepKey="clickToViewInvoice" after="seeOrderInvoiceTabInGrid"/>
99+
<click selector="{{AdminInvoiceOrderInformationSection.orderId}}" stepKey="clickOrderIdLinkOnInvoice"/>
100+
101+
<!--Ship Order-->
102+
<comment userInput="Admin creates shipment" stepKey="adminCreatesShipmentComment" before="clickShip"/>
103+
<click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShip" after="clickOrderIdLinkOnInvoice"/>
104+
<seeInCurrentUrl url="{{AdminShipmentNewPage.url}}" stepKey="OrderShipmentUrl" after="clickShip"/>
105+
<scrollTo selector="{{AdminShipmentItemsSection.itemQtyToShip('1')}}" stepKey="scrollToItemsToShip"/>
106+
<see selector="{{AdminShipmentItemsSection.itemQty('1')}}" userInput="Invoiced 5" stepKey="see5itemsInvoiced"/>
107+
<fillField selector="{{AdminShipmentItemsSection.itemQtyToShip('1')}}" userInput="5" stepKey="fillQtyOfItemsToShip"/>
108+
109+
<!--Submit Shipment-->
110+
<click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="submitShipment" after="fillQtyOfItemsToShip"/>
111+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The shipment has been created." stepKey="successfullShipmentCreation" after="submitShipment"/>
112+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="$getOrderId" stepKey="seeOrderIdInPageTitleAfterShip"/>
113+
114+
<!--Verify Items Status and Shipped Qty in the Items Ordered section-->
115+
<scrollTo selector="{{AdminOrderItemsOrderedSection.itemStatus('1')}}" stepKey="scrollToItemsShipped"/>
116+
<see selector="{{AdminOrderItemsOrderedSection.itemQty('1')}}" userInput="Shipped 5" stepKey="see5itemsShipped"/>
117+
118+
<!--Create Credit Memo-->
119+
<comment userInput="Admin creates credit memo" stepKey="createCreditMemoComment"/>
120+
<click selector="{{AdminOrderDetailsMainActionsSection.creditMemo}}" stepKey="clickCreateCreditMemo" after="createCreditMemoComment"/>
121+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Memo" stepKey="seeNewMemoInPageTitle"/>
122+
123+
<!--Submit refund-->
124+
<scrollTo selector="{{AdminCreditMemoItemsSection.itemQtyToRefund('1')}}" stepKey="scrollToItemsToRefund"/>
125+
<!--<fillField selector="{{AdminCreditMemoItemsSection.itemQtyToRefund('1')}}" userInput="5" stepKey="fillQtyOfItemsToRefund" after="scrollToItemsToRefund"/>-->
126+
<!--<click selector="{{AdminCreditMemoItemsSection.updateQty}}" stepKey="updateRefundQty"/>-->
127+
<waitForLoadingMaskToDisappear stepKey="waitForRefundQtyToUpdate"/>
128+
<waitForElementVisible selector="{{AdminCreditMemoTotalSection.submitRefundOffline}}" stepKey="seeSubmitRefundBtn"/>
129+
<click selector="{{AdminCreditMemoTotalSection.submitRefundOffline}}" stepKey="submitRefundOffline"/>
130+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="You created the credit memo." stepKey="seeCreditMemoSuccessMsg" after="submitRefundOffline"/>
131+
132+
<!--Create invoice for rest of the ordered items-->
133+
<comment userInput="Admin creates invoice for rest of the items" stepKey="adminCreateInvoiceComment2" />
134+
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceActionForRestOfItems"/>
135+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seePageNameNewInvoicePage2" after="clickInvoiceActionForRestOfItems"/>
136+
137+
<comment userInput="Qty To Invoice is 5" stepKey="seeRemainderInQtyToInvoice"/>
138+
<scrollTo selector="{{AdminInvoiceItemsSection.itemQtyToInvoice('1')}}" stepKey="scrollToItemsInvoiced2"/>
139+
<!--<see selector="{{AdminInvoiceItemsSection.itemQtyToInvoice('1')}}" stepKey="scrollToItemsInvoiced2"/>-->
140+
<seeInField userInput="5" selector="{{AdminInvoiceItemsSection.itemQtyToInvoice('1')}}" stepKey="see5InTheQtyToInvoice"/>
141+
142+
<!--Verify items invoiced information-->
143+
<see selector="{{AdminInvoiceItemsSection.itemQty('1')}}" userInput="Refunded 5" stepKey="seeQtyOfItemsRefunded"/>
144+
145+
<!--Submit Invoice-->
146+
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="submitInvoice2" />
147+
148+
<!--Invoice created successfully for the rest of the ordered items-->
149+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The invoice has been created." stepKey="seeInvoiceSuccessMessage2" after="submitInvoice2"/>
150+
151+
<!--Verify Ship Action can be done for the rest of the invoiced items -->
152+
<click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipActionForRestOfItems" after="seeInvoiceSuccessMessage2"/>
153+
154+
<!--Verify Items To Ship section -->
155+
<scrollTo selector="{{AdminShipmentItemsSection.itemQtyToShip('1')}}" stepKey="scrollToItemsToShip2"/>
156+
<see selector="{{AdminShipmentItemsSection.itemQty('1')}}" userInput="Invoiced 10" stepKey="SeeAll10ItemsInvoiced"/>
157+
<fillField selector="{{AdminShipmentItemsSection.itemQtyToShip('1')}}" userInput="5" stepKey="fillRestOfItemsToShip"/>
158+
159+
<!--Submit Shipment-->
160+
<click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="submitShipment2" after="fillRestOfItemsToShip"/>
161+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The shipment has been created." stepKey="successfullyCreatedShipment" after="submitShipment2"/>
162+
163+
<!--Verify Items Status and Shipped Qty in the Items Ordered section-->
164+
<scrollTo selector="{{AdminOrderItemsOrderedSection.itemStatus('1')}}" stepKey="scrollToItemsOrdered2"/>
165+
<see selector="{{AdminOrderItemsOrderedSection.itemQty('1')}}" userInput="Shipped 10" stepKey="seeAllItemsShipped"/>
166+
</test>
167+
</tests>
168+

app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ public function getItemQtyVariants()
295295
'qty_ordered' => 12, 'qty_invoiced' => 5, 'qty_refunded' => 5, 'qty_shipped' => 0,
296296
'qty_canceled' => 0,
297297
],
298-
'expectedResult' => ['to_ship' => 7.0, 'to_invoice' => 7.0]
298+
'expectedResult' => ['to_ship' => 12.0, 'to_invoice' => 7.0]
299299
],
300300
'partially_refunded' => [
301301
'options' => [
302302
'qty_ordered' => 12, 'qty_invoiced' => 12, 'qty_refunded' => 5, 'qty_shipped' => 0,
303303
'qty_canceled' => 0,
304304
],
305-
'expectedResult' => ['to_ship' => 7.0, 'to_invoice' => 0.0]
305+
'expectedResult' => ['to_ship' => 12.0, 'to_invoice' => 0.0]
306306
],
307307
'partially_shipped' => [
308308
'options' => [
@@ -316,7 +316,7 @@ public function getItemQtyVariants()
316316
'qty_ordered' => 12, 'qty_invoiced' => 12, 'qty_refunded' => 5, 'qty_shipped' => 4,
317317
'qty_canceled' => 0
318318
],
319-
'expectedResult' => ['to_ship' => 3.0, 'to_invoice' => 0.0]
319+
'expectedResult' => ['to_ship' => 8.0, 'to_invoice' => 0.0]
320320
],
321321
'complete' => [
322322
'options' => [
@@ -337,7 +337,7 @@ public function getItemQtyVariants()
337337
'qty_ordered' => 4.4, 'qty_invoiced' => 0.4, 'qty_refunded' => 0.4, 'qty_shipped' => 4,
338338
'qty_canceled' => 0,
339339
],
340-
'expectedResult' => ['to_ship' => 0.0, 'to_invoice' => 4.0]
340+
'expectedResult' => ['to_ship' => 0.4, 'to_invoice' => 4.0]
341341
],
342342
'completely_invoiced_using_decimals' => [
343343
'options' => [

0 commit comments

Comments
 (0)