Skip to content

Commit 91dbe14

Browse files
committed
MC-20636: Order Details : Order Details by Order Number
- fix static
1 parent c3fa41f commit 91dbe14

File tree

6 files changed

+48
-39
lines changed

6 files changed

+48
-39
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function resolve(
3434
}
3535

3636
if (!(($value['order'] ?? null) instanceof OrderInterface)) {
37-
throw new LocalizedException(__('"order" value should be specified'));
37+
throw new LocalizedException(__('"order" value should be specified'));
3838
}
3939

4040
/** @var OrderInterface $orderModel */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Magento\Framework\GraphQl\Query\ResolverInterface;
1313
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1414
use Magento\Sales\Api\Data\OrderInterface;
15-
use Magento\Sales\Api\Data\InvoiceInterface as Invoice;
15+
use Magento\Sales\Api\Data\InvoiceInterface;
1616

1717
/**
1818
* Resolver for Invoice
@@ -36,7 +36,7 @@ public function resolve(
3636
/** @var OrderInterface $orderModel */
3737
$orderModel = $value['model'];
3838
$invoices = [];
39-
/** @var Invoice $invoice */
39+
/** @var InvoiceInterface $invoice */
4040
foreach ($orderModel->getInvoiceCollection() as $invoice) {
4141
$invoices[] = [
4242
'id' => base64_encode($invoice->getEntityId()),

app/code/Magento/SalesGraphQl/Model/Resolver/OrderItem/DataProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ private function fetch()
137137
'product_sku' => $orderItem->getSku(),
138138
'product_url_key' => $associatedProduct ? $associatedProduct->getUrlKey() : null,
139139
'product_type' => $orderItem->getProductType(),
140+
'status' => $orderItem->getStatus(),
140141
'discounts' => $this->getDiscountDetails($associatedOrder, $orderItem),
141142
'product_sale_price' => [
142143
'value' => $orderItem->getPrice(),
@@ -224,7 +225,7 @@ private function getDiscountDetails(OrderInterface $associatedOrder, OrderItemIn
224225
$discounts = [];
225226
} else {
226227
$discounts [] = [
227-
'label' => $associatedOrder->getDiscountDescription() ?? "null",
228+
'label' => $associatedOrder->getDiscountDescription() ?? _('Discount'),
228229
'amount' => [
229230
'value' => $orderItem->getDiscountAmount() ?? 0,
230231
'currency' => $associatedOrder->getOrderCurrencyCode()

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ public function resolve(
3535
$currency = $order->getOrderCurrencyCode();
3636
$extensionAttributes = $order->getExtensionAttributes();
3737

38-
$allAppliedTaxesForItemsData = $this->getAllAppliedTaxesForItemsData($extensionAttributes);
39-
$appliedShippingTaxesForItemsData = $this->getAppliedShippingTaxesForItemsData($extensionAttributes);
38+
$allAppliedTaxesForItemsData = $this->getAllAppliedTaxesForItems(
39+
$extensionAttributes->getItemAppliedTaxes() ?? []
40+
);
41+
$appliedShippingTaxesForItemsData = $this->getAppliedShippingTaxesForItems(
42+
$extensionAttributes->getItemAppliedTaxes() ?? []
43+
);
4044

4145
return [
4246
'base_grand_total' => ['value' => $order->getBaseGrandTotal(), 'currency' => $currency],
@@ -66,13 +70,15 @@ public function resolve(
6670
}
6771

6872
/**
69-
* @param OrderExtensionInterface $extensionAttributes
73+
* Retrieve applied taxes that apply to items
74+
*
75+
* @param \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface[] $itemAppliedTaxes
7076
* @return array
7177
*/
72-
private function getAllAppliedTaxesForItemsData(OrderExtensionInterface $extensionAttributes): array
78+
private function getAllAppliedTaxesForItems(array $itemAppliedTaxes): array
7379
{
7480
$allAppliedTaxesForItemsData = [];
75-
foreach ($extensionAttributes->getItemAppliedTaxes() ?? [] as $taxItemIndex => $appliedTaxForItem) {
81+
foreach ($itemAppliedTaxes as $taxItemIndex => $appliedTaxForItem) {
7682
foreach ($appliedTaxForItem->getAppliedTaxes() ?? [] as $taxLineItem) {
7783
$allAppliedTaxesForItemsData[$taxItemIndex][$taxItemIndex] = [
7884
'title' => $taxLineItem->getDataByKey('title'),
@@ -85,13 +91,15 @@ private function getAllAppliedTaxesForItemsData(OrderExtensionInterface $extensi
8591
}
8692

8793
/**
88-
* @param OrderExtensionInterface $extensionAttributes
94+
* Retrieve applied taxes that apply to shipping
95+
*
96+
* @param \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface $extensionAttributes
8997
* @return array
9098
*/
91-
private function getAppliedShippingTaxesForItemsData(OrderExtensionInterface $extensionAttributes): array
99+
private function getAppliedShippingTaxesForItems(array $itemAppliedTaxes): array
92100
{
93101
$appliedShippingTaxesForItemsData = [];
94-
foreach ($extensionAttributes->getItemAppliedTaxes() ?? [] as $taxItemIndex => $appliedTaxForItem) {
102+
foreach ($itemAppliedTaxes as $taxItemIndex => $appliedTaxForItem) {
95103
foreach ($appliedTaxForItem->getAppliedTaxes() ?? [] as $taxLineItem) {
96104
if ($appliedTaxForItem->getType() === "shipping") {
97105
$appliedShippingTaxesForItemsData[$taxItemIndex][$taxItemIndex] = [

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function testCustomerOrdersSimpleProductWithTaxesAndDiscounts()
164164
$customerOrderResponse[0]['items'][0]['discounts'][0]['amount']['currency']
165165
);
166166
$this->assertEquals(
167-
'null',
167+
'Discount',
168168
$customerOrderResponse[0]['items'][0]['discounts'][0]['label']
169169
);
170170
$customerOrderItem = $customerOrderResponse[0];
@@ -204,7 +204,7 @@ private function assertTotalsWithTaxesAndDiscounts2(array $customerOrderItemTota
204204
'total_amount' => ['value' => 20, 'currency' =>'USD'],
205205
'discounts' => [
206206
0 => ['amount'=>['value'=> 2, 'currency' =>'USD'],
207-
'label' => 'null'
207+
'label' => 'Discount'
208208
]
209209
],
210210
'taxes'=> [
@@ -217,7 +217,7 @@ private function assertTotalsWithTaxesAndDiscounts2(array $customerOrderItemTota
217217
],
218218
'discounts' => [
219219
0 => ['amount' => [ 'value' => -6, 'currency' =>'USD'],
220-
'label' => 'null'
220+
'label' => 'Discount'
221221
]
222222
]
223223
];

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Magento\TestFramework\TestCase\GraphQlAbstract;
2020

2121
/**
22-
* Class RetrieveOrdersWithBundleProductByOrderNumberTest
22+
* Test for orders that have a bundle product
2323
*/
2424
class RetrieveOrdersWithBundleProductByOrderNumberTest extends GraphQlAbstract
2525
{
@@ -155,7 +155,7 @@ public function testGetCustomerOrderBundleProductWithTaxesAndDiscounts()
155155
$this->assertEquals('simple1', $childItemsInTheOrder[0]['values'][0]['product_sku']);
156156
$this->assertEquals('simple2', $childItemsInTheOrder[1]['values'][0]['product_sku']);
157157

158-
//$this->assertTotalsOnBundleProductWithTaxesAndDiscounts($customerOrderItems);
158+
$this->assertTotalsOnBundleProductWithTaxesAndDiscounts($customerOrderItems);
159159
$this->assertTotalsOnBundleProductWithTaxesAndDiscounts2($customerOrderItems['total']);
160160
$this->deleteOrder();
161161
}
@@ -187,28 +187,28 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts2(array $custom
187187
'total_tax' => ['value' => 5.4, 'currency' =>'USD'],
188188
'total_shipping' => ['value' => 20, 'currency' =>'USD'],
189189
'shipping_handling' => [
190-
'amount_including_tax' => ['value' => 21.5],
191-
'amount_excluding_tax' => ['value' => 20],
192-
'total_amount' => ['value' => 20],
193-
'discounts' => [
194-
0 => ['amount'=>['value'=>2],
195-
'label' => 'null'
196-
]
190+
'amount_including_tax' => ['value' => 21.5],
191+
'amount_excluding_tax' => ['value' => 20],
192+
'total_amount' => ['value' => 20],
193+
'discounts' => [
194+
0 => ['amount'=>['value'=>2],
195+
'label' => 'Discount'
196+
]
197197
],
198-
'taxes'=> [
199-
0 => [
200-
'amount'=>['value' => 1.35],
201-
'title' => 'US-TEST-*-Rate-1',
202-
'rate' => 7.5
203-
]
198+
'taxes'=> [
199+
0 => [
200+
'amount'=>['value' => 1.35],
201+
'title' => 'US-TEST-*-Rate-1',
202+
'rate' => 7.5
203+
]
204+
]
205+
],
206+
'discounts' => [
207+
0 => ['amount' => [ 'value' => -8, 'currency' =>'USD'],
208+
'label' => 'Discount'
209+
]
204210
]
205-
],
206-
'discounts' => [
207-
0 => ['amount' => [ 'value' => -8, 'currency' =>'USD'],
208-
'label' => 'null'
209-
]
210-
]
211-
];
211+
];
212212
$this->assertResponseFields($customerOrderItemTotal, $assertionMap);
213213
}
214214

@@ -306,7 +306,7 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts(array $custome
306306
$customerOrderItem['total']['shipping_handling']['discounts'][0]['amount']['value']
307307
);
308308
$this->assertEquals(
309-
'null',
309+
'Discount',
310310
$customerOrderItem['total']['shipping_handling']['discounts'][0]['label']
311311
);
312312
$this->assertEquals(
@@ -318,7 +318,7 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts(array $custome
318318
$customerOrderItem['total']['discounts'][0]['amount']['currency']
319319
);
320320
$this->assertEquals(
321-
'null',
321+
'Discount',
322322
$customerOrderItem['total']['discounts'][0]['label']
323323
);
324324
}

0 commit comments

Comments
 (0)