Skip to content

Commit d7b6bf8

Browse files
author
Prabhu Ram
committed
MC-20637: MyAccount :: Order Details :: Invoice Details by Order Number
- modified implementation to suit schema
1 parent 97b1004 commit d7b6bf8

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function resolveType(array $data): string
1818
{
1919
if (isset($data['product_type'])) {
2020
if ($data['product_type'] == 'bundle') {
21-
return 'InvoiceItemBundle';
21+
return 'BundleInvoiceItem';
2222
}
2323
}
2424
return 'InvoiceItem';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function resolveType(array $data): string
1818
{
1919
if (isset($data['product_type'])) {
2020
if ($data['product_type'] == 'bundle') {
21-
return 'OrderItemBundle';
21+
return 'BundleOrderItem';
2222
}
2323
}
2424
return 'OrderItem';

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,12 @@
1515
use Magento\GraphQl\Model\Query\ContextInterface;
1616
use Magento\Sales\Api\Data\InvoiceInterface as Invoice;
1717
use Magento\Sales\Model\Order;
18-
use Magento\SalesGraphQl\Model\SalesItem\SalesItemFactory;
1918

2019
/**
2120
* Resolver for Invoice Item
2221
*/
2322
class InvoiceItem implements ResolverInterface
2423
{
25-
/**
26-
* @var SalesItemFactory
27-
*/
28-
private $salesItemFactory;
29-
30-
public function __construct(SalesItemFactory $salesItemFactory)
31-
{
32-
$this->salesItemFactory = $salesItemFactory;
33-
}
34-
3524
/**
3625
* @inheritdoc
3726
*/
@@ -60,12 +49,15 @@ public function resolve(
6049
$invoiceItems = [];
6150
$parentOrder = $value['order'];
6251
foreach ($invoiceModel->getItems() as $invoiceItem) {
63-
$salesOrderItem = $this->salesItemFactory->create(
64-
$parentOrder->getItemById($invoiceItem->getOrderItemId()),
65-
$parentOrder,
66-
['quantity_invoiced' => $invoiceItem->getQty()]
67-
);
68-
$invoiceItems[] = $salesOrderItem->convertToArray();
52+
$invoiceItems[] = [
53+
'product_sku' => $invoiceItem->getSku(),
54+
'product_name' => $invoiceItem->getName(),
55+
'product_sale_price' => [
56+
'currency' => $parentOrder->getOrderCurrencyCode(),
57+
'value' => $invoiceItem->getPrice()
58+
],
59+
'quantity_invoiced' => $invoiceItem->getQty()
60+
];
6961
}
7062
return $invoiceItems;
7163
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type CustomerOrder @doc(description: "Contains details about each of the custome
4545
number: String! @doc(description: "The order number")
4646
items: [OrderItemInterface] @doc(description: "An array containing the items purchased in this order") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\OrderItems")
4747
total: OrderTotal @doc(description: "Contains details about the calculated totals for this order") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\OrderTotal")
48+
invoices: [Invoice]! @doc(description: "Invoice list for the order") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\Invoices")
4849
credit_memos: [CreditMemo] @doc(description: "credit memo list for the order")
4950
shipments: [OrderShipment] @doc(description: "shipment list for the order")
5051
payment_methods: [PaymentMethod] @doc(description: "payment details for the order")
@@ -113,8 +114,8 @@ type OrderTotal implements SalesTotalAmountInterface @doc(description: "Contains
113114
type Invoice @doc(description: "Invoice details") {
114115
id: ID! @doc(description: "The ID of the invoice, used for API purposes")
115116
number: String! @doc(description: "Sequential invoice number")
116-
total: InvoiceTotal @doc(description: "Invoice total amount details")
117-
items: [InvoiceItemInterface] @doc(description: "Invoiced product details")
117+
total: InvoiceTotal @doc(description: "Invoice total amount details") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\InvoiceTotal")
118+
items: [InvoiceItemInterface] @doc(description: "Invoiced product details") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\InvoiceItem")
118119
comments: [CommentItem] @doc(description: "Comments on the invoice")
119120
}
120121

0 commit comments

Comments
 (0)