Skip to content

Commit 1353a54

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

File tree

11 files changed

+74
-109
lines changed

11 files changed

+74
-109
lines changed

app/code/Magento/BundleGraphQl/etc/graphql/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@
8686
</argument>
8787
</arguments>
8888
</type>
89+
<type name="Magento\SalesGraphQl\Model\TypeResolver\CreditMemoItem">
90+
<arguments>
91+
<argument name="productTypeMap" xsi:type="array">
92+
<item name="bundle" xsi:type="string">BundleCreditMemoItem</item>
93+
</argument>
94+
</arguments>
95+
</type>
8996
<type name="Magento\SalesGraphQl\Model\Shipment\ItemProvider">
9097
<arguments>
9198
<argument name="formatters" xsi:type="array">

app/code/Magento/SalesGraphQl/Model/CreditmemoItemInterfaceTypeResolverComposite.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

app/code/Magento/SalesGraphQl/Model/CreditmemoItemTypeResolver.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

app/code/Magento/SalesGraphQl/Model/Resolver/CreditMemo/CreditMemoComments.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Framework\GraphQl\Query\ResolverInterface;
1313
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1414
use Magento\Sales\Api\Data\CreditmemoInterface;
15-
use Magento\Sales\Api\Data\OrderInterface;
1615

1716
/**
1817
* Resolve credit memo comments

app/code/Magento/SalesGraphQl/Model/Resolver/CreditMemo/CreditMemoItems.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,24 @@ public function resolve(
8282
*/
8383
private function getCreditMemoItems(OrderInterface $order, array $creditMemoItems): \Closure
8484
{
85-
$items = [];
85+
$orderItems = [];
8686
foreach ($creditMemoItems as $item) {
8787
$this->orderItemProvider->addOrderItemId((int)$item->getOrderItemId());
8888
}
8989

90-
return function () use ($order, $creditMemoItems, $items): array {
90+
return function () use ($order, $creditMemoItems, $orderItems): array {
9191
foreach ($creditMemoItems as $creditMemoItem) {
9292
$orderItem = $this->orderItemProvider->getOrderItemById((int)$creditMemoItem->getOrderItemId());
9393
/** @var OrderItemInterface $orderItemModel */
9494
$orderItemModel = $orderItem['model'];
9595
if (!$orderItemModel->getParentItem()) {
9696
$creditMemoItemData = $this->getCreditMemoItemData($order, $creditMemoItem);
9797
if (isset($creditMemoItemData)) {
98-
$items[$creditMemoItem->getOrderItemId()] = $creditMemoItemData;
98+
$orderItems[$creditMemoItem->getOrderItemId()] = $creditMemoItemData;
9999
}
100100
}
101101
}
102-
return $items;
102+
return $orderItems;
103103
};
104104
}
105105

@@ -138,7 +138,7 @@ private function getCreditMemoItemData(OrderInterface $order, CreditmemoItemInte
138138
private function formatDiscountDetails(
139139
OrderInterface $associatedOrder,
140140
CreditmemoItemInterface $creditmemoItem
141-
) : array {
141+
): array {
142142
if ($associatedOrder->getDiscountDescription() === null
143143
&& $creditmemoItem->getDiscountAmount() == 0
144144
&& $associatedOrder->getDiscountAmount() == 0

app/code/Magento/SalesGraphQl/Model/Resolver/CreditMemo/CreditMemoTotal.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function resolve(
108108
'adjustment' => [
109109
'value' => abs($creditMemo->getAdjustment()),
110110
'currency' => $currency
111-
],
111+
]
112112
];
113113
}
114114

@@ -119,7 +119,7 @@ public function resolve(
119119
* @param OrderInterface $orderModel
120120
* @return array
121121
*/
122-
private function getShippingDiscountDetails(CreditmemoInterface $creditmemoModel, $orderModel)
122+
private function getShippingDiscountDetails(CreditmemoInterface $creditmemoModel, $orderModel): array
123123
{
124124
$creditmemoShippingAmount = (float)$creditmemoModel->getShippingAmount();
125125
$orderShippingAmount = (float)$orderModel->getShippingAmount();
@@ -146,7 +146,7 @@ private function getShippingDiscountDetails(CreditmemoInterface $creditmemoModel
146146
* @param CreditmemoInterface $creditmemo
147147
* @return array
148148
*/
149-
private function getDiscountDetails(CreditmemoInterface $creditmemo)
149+
private function getDiscountDetails(CreditmemoInterface $creditmemo): array
150150
{
151151
$discounts = [];
152152
if (!($creditmemo->getDiscountDescription() === null && $creditmemo->getDiscountAmount() == 0)) {
@@ -168,7 +168,7 @@ private function getDiscountDetails(CreditmemoInterface $creditmemo)
168168
* @param array $appliedTaxes
169169
* @return array
170170
*/
171-
private function formatTaxes(OrderInterface $order, array $appliedTaxes)
171+
private function formatTaxes(OrderInterface $order, array $appliedTaxes): array
172172
{
173173
$taxes = [];
174174
foreach ($appliedTaxes as $appliedTax) {

app/code/Magento/SalesGraphQl/Model/Resolver/Invoice/InvoiceTotal.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ public function resolve(
116116
* @param OrderInterface $orderModel
117117
* @return array
118118
*/
119-
private function getShippingDiscountDetails(InvoiceInterface $invoiceModel, OrderInterface $orderModel)
119+
private function getShippingDiscountDetails(InvoiceInterface $invoiceModel, OrderInterface $orderModel): array
120120
{
121121
$invoiceShippingAmount = (float)$invoiceModel->getShippingAmount();
122122
$orderShippingAmount = (float)$orderModel->getShippingAmount();
123123
$calculatedShippingRatioFromOriginal = $invoiceShippingAmount != 0 && $orderShippingAmount != 0 ?
124-
( $invoiceShippingAmount / $orderShippingAmount) : 0;
124+
($invoiceShippingAmount / $orderShippingAmount) : 0;
125125
$orderShippingDiscount = (float)$orderModel->getShippingDiscountAmount();
126126
$calculatedInvoiceShippingDiscount = $orderShippingDiscount * $calculatedShippingRatioFromOriginal;
127127
$shippingDiscounts = [];
@@ -143,7 +143,7 @@ private function getShippingDiscountDetails(InvoiceInterface $invoiceModel, Orde
143143
* @param InvoiceInterface $invoice
144144
* @return array
145145
*/
146-
private function getDiscountDetails(InvoiceInterface $invoice)
146+
private function getDiscountDetails(InvoiceInterface $invoice): array
147147
{
148148
$discounts = [];
149149
if (!($invoice->getDiscountDescription() === null && $invoice->getDiscountAmount() == 0)) {
@@ -165,7 +165,7 @@ private function getDiscountDetails(InvoiceInterface $invoice)
165165
* @param array $appliedTaxes
166166
* @return array
167167
*/
168-
private function formatTaxes(OrderInterface $order, array $appliedTaxes)
168+
private function formatTaxes(OrderInterface $order, array $appliedTaxes): array
169169
{
170170
$taxes = [];
171171
foreach ($appliedTaxes as $appliedTax) {

app/code/Magento/SalesGraphQl/Model/Resolver/OrderTotal.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function resolve(
3838
$baseCurrency = $order->getBaseCurrencyCode();
3939

4040
return [
41-
'base_grand_total' => ['value' => $order->getBaseGrandTotal(), 'currency' => $currency],
42-
'grand_total' => ['value' => $order->getGrandTotal(), 'currency' => $baseCurrency],
41+
'base_grand_total' => ['value' => $order->getBaseGrandTotal(), 'currency' => $baseCurrency],
42+
'grand_total' => ['value' => $order->getGrandTotal(), 'currency' => $currency],
4343
'subtotal' => ['value' => $order->getSubtotal(), 'currency' => $currency],
4444
'total_tax' => ['value' => $order->getTaxAmount(), 'currency' => $currency],
4545
'taxes' => $this->getAppliedTaxesDetails($order),
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\SalesGraphQl\Model\TypeResolver;
9+
10+
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;
11+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
12+
13+
/**
14+
* Resolve concrete type for CreditMemoItemInterface
15+
*/
16+
class CreditMemoItem implements TypeResolverInterface
17+
{
18+
/**
19+
* @var array
20+
*/
21+
private $productTypeMap;
22+
23+
/**
24+
* @param array $productTypeMap
25+
*/
26+
public function __construct($productTypeMap = [])
27+
{
28+
$this->productTypeMap = $productTypeMap;
29+
}
30+
31+
/**
32+
* @inheritDoc
33+
*/
34+
public function resolveType(array $data): string
35+
{
36+
if (!isset($data['product_type'])) {
37+
throw new GraphQlInputException(__('Missing key %1 in sales item data', ['product_type']));
38+
}
39+
if (isset($this->productTypeMap[$data['product_type']])) {
40+
return $this->productTypeMap[$data['product_type']];
41+
}
42+
return $this->productTypeMap['default'];
43+
}
44+
}

app/code/Magento/SalesGraphQl/etc/graphql/di.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
</argument>
2121
</arguments>
2222
</type>
23+
<type name="Magento\SalesGraphQl\Model\TypeResolver\CreditMemoItem">
24+
<arguments>
25+
<argument name="productTypeMap" xsi:type="array">
26+
<item name="default" xsi:type="string">CreditMemoItem</item>
27+
</argument>
28+
</arguments>
29+
</type>
2330
<type name="Magento\SalesGraphQl\Model\TypeResolver\ShipmentItem">
2431
<arguments>
2532
<argument name="productTypeMap" xsi:type="array">
@@ -35,11 +42,4 @@
3542
</argument>
3643
</arguments>
3744
</type>
38-
<type name="Magento\SalesGraphQl\Model\CreditmemoItemInterfaceTypeResolverComposite">
39-
<arguments>
40-
<argument name="creditMemoItemTypeResolvers" xsi:type="array">
41-
<item name="creditmemo_catalog_item_type_resolver" xsi:type="object">Magento\SalesGraphQl\Model\CreditmemoItemTypeResolver</item>
42-
</argument>
43-
</arguments>
44-
</type>
4545
</config>

0 commit comments

Comments
 (0)