Skip to content

Commit a8a3737

Browse files
committed
MC-20639: MyAccount :: Order Details :: Refund (creditMemo) Details by Order Number
1 parent 1353a54 commit a8a3737

File tree

3 files changed

+138
-4
lines changed

3 files changed

+138
-4
lines changed

app/code/Magento/BundleGraphQl/Model/Resolver/Order/Item/BundleOptions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Sales\Api\Data\InvoiceItemInterface;
1717
use Magento\Sales\Api\Data\OrderItemInterface;
1818
use Magento\Sales\Api\Data\ShipmentItemInterface;
19+
use Magento\Sales\Api\Data\CreditmemoItemInterface;
1920

2021
/**
2122
* Resolve bundle options items for order item
@@ -56,12 +57,12 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5657
throw new LocalizedException(__('"model" value should be specified'));
5758
}
5859
if ($value['model'] instanceof OrderItemInterface) {
59-
/** @var OrderItemInterface $item */
6060
$item = $value['model'];
6161
return $this->getBundleOptions($item, $value);
6262
}
63-
if ($value['model'] instanceof InvoiceItemInterface || $value['model'] instanceof ShipmentItemInterface) {
64-
/** @var InvoiceItemInterface|ShipmentItemInterface $item */
63+
if ($value['model'] instanceof InvoiceItemInterface
64+
|| $value['model'] instanceof ShipmentItemInterface
65+
|| $value['model'] instanceof CreditmemoItemInterface) {
6566
$item = $value['model'];
6667
// Have to pass down order and item to map to avoid refetching all data
6768
return $this->getBundleOptions($item->getOrderItem(), $value);

app/code/Magento/BundleGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ type BundleShipmentItem implements ShipmentItemInterface {
101101
}
102102

103103
type BundleCreditMemoItem implements CreditMemoItemInterface {
104-
bundle_options: [ItemSelectedBundleOption] @doc(description: "A list of bundle options that are assigned to the bundle product")
104+
bundle_options: [ItemSelectedBundleOption] @doc(description: "A list of bundle options that are assigned to the bundle product") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Order\\Item\\BundleOptions")
105105
}
106106

107107
type ItemSelectedBundleOption @doc(description: "A list of options of the selected bundle product") {

dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/CreditmemoTest.php

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,46 @@ public function testCreditMemoForBundledProductsWithPartialRefund()
195195

196196
$this->creditMemoService->refund($creditMemo, true);
197197
$response = $this->getCustomerOrderWithCreditMemoQuery();
198+
$expectedInvoicesData = [
199+
[
200+
'items' => [
201+
[
202+
'product_name' => 'Bundle Product With Two dropdown options',
203+
'product_sku' => 'bundle-product-two-dropdown-options-simple1-simple2',
204+
'product_sale_price' => [
205+
'value' => 15
206+
],
207+
'discounts' => [],
208+
'bundle_options' => [
209+
[
210+
'label' => 'Drop Down Option 1',
211+
'values' => [
212+
[
213+
'product_name' => 'Simple Product1',
214+
'product_sku' => 'simple1',
215+
'quantity' => 1,
216+
'price' => ['value' => 1, 'currency' => 'USD']
217+
]
218+
]
219+
],
220+
[
221+
'label' => 'Drop Down Option 2',
222+
'values' => [
223+
[
224+
'product_name' => 'Simple Product2',
225+
'product_sku' => 'simple2',
226+
'quantity' => 2,
227+
'price' => ['value' => 2, 'currency' => 'USD']
228+
]
229+
]
230+
]
231+
],
232+
'quantity_invoiced' => 2
233+
],
234+
235+
]
236+
]
237+
];
198238
$expectedCreditMemoData = [
199239
[
200240
'comments' => [
@@ -208,6 +248,30 @@ public function testCreditMemoForBundledProductsWithPartialRefund()
208248
'value' => 15
209249
],
210250
'discounts' => [],
251+
'bundle_options' => [
252+
[
253+
'label' => 'Drop Down Option 1',
254+
'values' => [
255+
[
256+
'product_name' => 'Simple Product1',
257+
'product_sku' => 'simple1',
258+
'quantity' => 1,
259+
'price' => ['value' => 1, 'currency' => 'USD']
260+
]
261+
]
262+
],
263+
[
264+
'label' => 'Drop Down Option 2',
265+
'values' => [
266+
[
267+
'product_name' => 'Simple Product2',
268+
'product_sku' => 'simple2',
269+
'quantity' => 2,
270+
'price' => ['value' => 2, 'currency' => 'USD']
271+
]
272+
]
273+
]
274+
],
211275
'quantity_refunded' => 1
212276
],
213277

@@ -250,6 +314,11 @@ public function testCreditMemoForBundledProductsWithPartialRefund()
250314
]
251315
];
252316
$firstOrderItem = current($response['customer']['orders']['items'] ?? []);
317+
318+
$this->assertArrayHasKey('invoices', $firstOrderItem);
319+
$invoices = $firstOrderItem['invoices'];
320+
$this->assertResponseFields($invoices, $expectedInvoicesData);
321+
253322
$this->assertArrayHasKey('credit_memos', $firstOrderItem);
254323
$creditMemos = $firstOrderItem['credit_memos'];
255324
$this->assertResponseFields($creditMemos, $expectedCreditMemoData);
@@ -320,6 +389,30 @@ public function testCreditMemoForBundleProductWithTaxesAndDiscounts()
320389
'label' => 'Discount Label for 10% off'
321390
]
322391
],
392+
'bundle_options' => [
393+
[
394+
'label' => 'Drop Down Option 1',
395+
'values' => [
396+
[
397+
'product_name' => 'Simple Product1',
398+
'product_sku' => 'simple1',
399+
'quantity' => 1,
400+
'price' => ['value' => 1, 'currency' => 'USD']
401+
]
402+
]
403+
],
404+
[
405+
'label' => 'Drop Down Option 2',
406+
'values' => [
407+
[
408+
'product_name' => 'Simple Product2',
409+
'product_sku' => 'simple2',
410+
'quantity' => 2,
411+
'price' => ['value' => 2, 'currency' => 'USD']
412+
]
413+
]
414+
]
415+
],
323416
'quantity_refunded' => 1
324417
],
325418

@@ -453,6 +546,32 @@ private function getCustomerOrderWithCreditMemoQuery(): array
453546
customer {
454547
orders {
455548
items {
549+
invoices {
550+
items {
551+
product_name
552+
product_sku
553+
product_sale_price {
554+
value
555+
}
556+
... on BundleInvoiceItem {
557+
bundle_options {
558+
label
559+
values {
560+
product_sku
561+
product_name
562+
quantity
563+
price {
564+
value
565+
currency
566+
}
567+
}
568+
}
569+
}
570+
discounts { amount{value currency} label }
571+
quantity_invoiced
572+
discounts { amount{value currency} label }
573+
}
574+
}
456575
credit_memos {
457576
comments {
458577
message
@@ -463,6 +582,20 @@ private function getCustomerOrderWithCreditMemoQuery(): array
463582
product_sale_price {
464583
value
465584
}
585+
... on BundleCreditMemoItem {
586+
bundle_options {
587+
label
588+
values {
589+
product_sku
590+
product_name
591+
quantity
592+
price {
593+
value
594+
currency
595+
}
596+
}
597+
}
598+
}
466599
discounts { amount{value currency} label }
467600
quantity_refunded
468601
}

0 commit comments

Comments
 (0)