Skip to content

Commit 81f0504

Browse files
committed
MC:32658:MyAccount :: Order Details :: Order Details by Order Number Taxes and Discounts
- Added new test changes for discounts descriptions
1 parent ad6054d commit 81f0504

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private function getDiscountDetails(OrderInterface $associatedOrder, OrderItemIn
227227
$discounts [] = [
228228
'label' => $associatedOrder->getDiscountDescription() ?? __('Discount'),
229229
'amount' => [
230-
'value' => $orderItem->getDiscountAmount() ?? 0,
230+
'value' => abs($orderItem->getDiscountAmount()) ?? 0,
231231
'currency' => $associatedOrder->getOrderCurrencyCode()
232232
]
233233
];

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function testCustomerOrdersSimpleProductWithTaxesAndDiscounts()
157157
// Asserting discounts on order item level
158158
$this->assertEquals(4, $customerOrderResponse[0]['items'][0]['discounts'][0]['amount']['value']);
159159
$this->assertEquals('USD', $customerOrderResponse[0]['items'][0]['discounts'][0]['amount']['currency']);
160-
$this->assertEquals('Discount', $customerOrderResponse[0]['items'][0]['discounts'][0]['label']);
160+
$this->assertEquals('Discount Label for 10% off', $customerOrderResponse[0]['items'][0]['discounts'][0]['label']);
161161
$customerOrderItem = $customerOrderResponse[0];
162162
$this->assertTotalsWithTaxesAndDiscounts($customerOrderItem['total']);
163163
$this->deleteOrder();
@@ -188,7 +188,7 @@ private function assertTotalsWithTaxesAndDiscounts(array $customerOrderItemTotal
188188
'total_amount' => ['value' => 20, 'currency' =>'USD'],
189189
'discounts' => [
190190
0 => ['amount'=>['value'=> 2, 'currency' =>'USD'],
191-
'label' => 'Discount'
191+
'label' => 'Discount Label for 10% off'
192192
]
193193
],
194194
'taxes'=> [
@@ -201,7 +201,7 @@ private function assertTotalsWithTaxesAndDiscounts(array $customerOrderItemTotal
201201
],
202202
'discounts' => [
203203
0 => ['amount' => [ 'value' => 6, 'currency' =>'USD'],
204-
'label' => 'Discount'
204+
'label' => 'Discount Label for 10% off'
205205
]
206206
]
207207
];
@@ -233,7 +233,7 @@ public function testCustomerOrdersSimpleProductWithTaxesAndDiscountsWithTwoRules
233233
// Asserting discounts on order item level
234234
$this->assertEquals(4, $customerOrderResponse[0]['items'][0]['discounts'][0]['amount']['value']);
235235
$this->assertEquals('USD', $customerOrderResponse[0]['items'][0]['discounts'][0]['amount']['currency']);
236-
$this->assertEquals('Discount', $customerOrderResponse[0]['items'][0]['discounts'][0]['label']);
236+
$this->assertEquals('Discount Label for 10% off', $customerOrderResponse[0]['items'][0]['discounts'][0]['label']);
237237
$customerOrderItem = $customerOrderResponse[0];
238238
$this->assertTotalsWithTaxesAndDiscountsWithTwoRules($customerOrderItem['total']);
239239
$this->deleteOrder();
@@ -270,7 +270,7 @@ private function assertTotalsWithTaxesAndDiscountsWithTwoRules(array $customerOr
270270
'total_amount' => ['value' => 20, 'currency' =>'USD'],
271271
'discounts' => [
272272
0 => ['amount'=>['value'=> 2, 'currency' =>'USD'],
273-
'label' => 'Discount'
273+
'label' => 'Discount Label for 10% off'
274274
]
275275
],
276276
'taxes'=> [
@@ -288,7 +288,7 @@ private function assertTotalsWithTaxesAndDiscountsWithTwoRules(array $customerOr
288288
],
289289
'discounts' => [
290290
0 => ['amount' => [ 'value' => 6, 'currency' =>'USD'],
291-
'label' => 'Discount'
291+
'label' => 'Discount Label for 10% off'
292292
]
293293
]
294294
];

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ public function testGetCustomerOrderBundleProductWithTaxesAndDiscounts()
145145
'bundle-product-two-dropdown-options-simple1-simple2',
146146
$bundledItemInTheOrder['product_sku']
147147
);
148+
$this->assertEquals(6, $bundledItemInTheOrder['discounts'][0]['amount']['value']);
149+
$this->assertEquals(
150+
'Discount Label for 10% off',
151+
$bundledItemInTheOrder["discounts"][0]['label']
152+
);
148153
$this->assertArrayHasKey('bundle_options', $bundledItemInTheOrder);
149154
$childItemsInTheOrder = $bundledItemInTheOrder['bundle_options'];
150155
$this->assertNotEmpty($childItemsInTheOrder);
@@ -183,7 +188,7 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts(array $custome
183188
'total_amount' => ['value' => 20],
184189
'discounts' => [
185190
0 => ['amount'=>['value'=> 2],
186-
'label' => 'Discount'
191+
'label' => 'Discount Label for 10% off'
187192
]
188193
],
189194
'taxes'=> [
@@ -196,7 +201,7 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts(array $custome
196201
],
197202
'discounts' => [
198203
0 => ['amount' => [ 'value' => 8, 'currency' =>'USD'],
199-
'label' => 'Discount'
204+
'label' => 'Discount Label for 10% off'
200205
]
201206
]
202207
];

dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_10_percent_off_with_discount_on_shipping.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
'discount_step' => 0,
2828
'apply_to_shipping' => 1,
2929
'stop_rules_processing' => 1,
30-
'website_ids' => [$websiteId]
30+
'website_ids' => [$websiteId],
31+
'store_labels' => [
32+
'store_id' => 0,
33+
'store_label' => 'Discount Label for 10% off',
34+
]
3135
]
3236
);
3337

0 commit comments

Comments
 (0)