Skip to content

Commit 6cc5151

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-1769' into JUN062023_PR_sarmistha
2 parents d4a9791 + 23afef3 commit 6cc5151

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Magento\Sales\Api\Data\OrderItemInterface;
1515
use Magento\Sales\Api\OrderItemRepositoryInterface;
1616
use Magento\Sales\Api\OrderRepositoryInterface;
17+
use Magento\Framework\App\ObjectManager;
18+
use Magento\Tax\Helper\Data as TaxHelper;
1719

1820
/**
1921
* Data provider for order items
@@ -45,6 +47,11 @@ class DataProvider
4547
*/
4648
private $optionsProcessor;
4749

50+
/**
51+
* @var TaxHelper
52+
*/
53+
private $taxHelper;
54+
4855
/**
4956
* @var int[]
5057
*/
@@ -61,19 +68,22 @@ class DataProvider
6168
* @param OrderRepositoryInterface $orderRepository
6269
* @param SearchCriteriaBuilder $searchCriteriaBuilder
6370
* @param OptionsProcessor $optionsProcessor
71+
* @param TaxHelper|null $taxHelper
6472
*/
6573
public function __construct(
6674
OrderItemRepositoryInterface $orderItemRepository,
6775
ProductRepositoryInterface $productRepository,
6876
OrderRepositoryInterface $orderRepository,
6977
SearchCriteriaBuilder $searchCriteriaBuilder,
70-
OptionsProcessor $optionsProcessor
78+
OptionsProcessor $optionsProcessor,
79+
?TaxHelper $taxHelper = null
7180
) {
7281
$this->orderItemRepository = $orderItemRepository;
7382
$this->productRepository = $productRepository;
7483
$this->orderRepository = $orderRepository;
7584
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
7685
$this->optionsProcessor = $optionsProcessor;
86+
$this->taxHelper = $taxHelper ?? ObjectManager::getInstance()->get(TaxHelper::class);
7787
}
7888

7989
/**
@@ -140,7 +150,9 @@ private function fetch()
140150
'status' => $orderItem->getStatus(),
141151
'discounts' => $this->getDiscountDetails($associatedOrder, $orderItem),
142152
'product_sale_price' => [
143-
'value' => $orderItem->getPrice(),
153+
'value' => $this->taxHelper->displaySalesPriceInclTax($associatedOrder->getStoreId())
154+
? $orderItem->getPriceInclTax()
155+
: $orderItem->getPrice(),
144156
'currency' => $associatedOrder->getOrderCurrencyCode()
145157
],
146158
'selected_options' => $itemOptions['selected_options'],

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
use Magento\Quote\Test\Fixture\CustomerCart;
2929
use Magento\TestFramework\Fixture\DataFixtureStorage;
3030
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
31+
use Magento\Tax\Model\Config as TaxConfig;
32+
use Magento\TestFramework\Fixture\Config;
3133

3234
/**
3335
* Class RetrieveOrdersTest
@@ -107,6 +109,9 @@ public function testGetCustomerOrdersSimpleProductQuery()
107109
$this->assertEquals($expectedOrderTotal, $actualOrderTotalFromResponse, 'Totals do not match');
108110
}
109111

112+
#[
113+
Config(TaxConfig::XML_PATH_DISPLAY_SALES_PRICE, TaxConfig::DISPLAY_TYPE_INCLUDING_TAX),
114+
]
110115
/**
111116
* Verify the customer order with tax, discount with shipping tax class set for calculation setting
112117
*
@@ -168,6 +173,8 @@ public function testCustomerOrdersSimpleProductWithTaxesAndDiscounts()
168173
]
169174
];
170175
$this->assertResponseFields($customerOrderResponse[0]["payment_methods"], $paymentMethodAssertionMap);
176+
$this->assertEquals(10.75, $customerOrderResponse[0]['items'][0]['product_sale_price']['value']);
177+
$this->assertEquals(7.5, $customerOrderResponse[0]['total']['taxes'][0]['rate']);
171178
// Asserting discounts on order item level
172179
$this->assertEquals(4, $customerOrderResponse[0]['items'][0]['discounts'][0]['amount']['value']);
173180
$this->assertEquals('USD', $customerOrderResponse[0]['items'][0]['discounts'][0]['amount']['currency']);
@@ -1393,7 +1400,13 @@ private function getCustomerOrderQuery($orderNumber): array
13931400
billing_address {
13941401
... address
13951402
}
1396-
items{product_name product_sku quantity_ordered discounts {amount{value currency} label}}
1403+
items{
1404+
product_name
1405+
product_sku
1406+
quantity_ordered
1407+
product_sale_price {value}
1408+
discounts {amount{value currency} label}
1409+
}
13971410
total {
13981411
base_grand_total{value currency}
13991412
grand_total{value currency}

0 commit comments

Comments
 (0)