Skip to content

Commit 34e4847

Browse files
author
Prabhu Ram
committed
MC-20637: MyAccount :: Order Details :: Invoice Details by Order Number
- fixed review comments
1 parent 785b41d commit 34e4847

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

app/code/Magento/SalesGraphQl/Model/SalesItem/ShippingTaxCalculator.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\SalesGraphQl\Model\SalesItem;
89

910
use Magento\Sales\Api\Data\OrderInterface;
1011
use Magento\Sales\Model\EntityInterface;
1112
use Magento\Tax\Api\Data\OrderTaxDetailsItemInterface;
1213
use Magento\Tax\Api\OrderTaxManagementInterface;
13-
use \Magento\Quote\Model\Quote\Address;
14+
use Magento\Quote\Model\Quote\Address;
15+
use Magento\Framework\Exception\NoSuchEntityException;
1416

17+
/**
18+
* Calculates shipping taxes for sales items (Invoices, Credit memo)
19+
*/
1520
class ShippingTaxCalculator
1621
{
1722
/**
@@ -34,12 +39,12 @@ public function __construct(
3439
* @param OrderInterface $order
3540
* @param EntityInterface $salesItem
3641
* @return array
37-
* @throws \Magento\Framework\Exception\NoSuchEntityException
42+
* @throws NoSuchEntityException
3843
*/
3944
public function calculateShippingTaxes(
4045
OrderInterface $order,
4146
EntityInterface $salesItem
42-
) {
47+
): array {
4348
$orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($order->getId());
4449
$taxClassBreakdown = [];
4550
// Apply any taxes for shipping
@@ -64,7 +69,7 @@ public function calculateShippingTaxes(
6469
/**
6570
* Accumulates the pre-calculated taxes for each tax class
6671
*
67-
* This method accepts and returns the 'taxClassAmount' array with format:
72+
* This method accepts and returns the '$taxClassBreakdown' array with format:
6873
* array(
6974
* $index => array(
7075
* 'tax_amount' => $taxAmount,
@@ -74,13 +79,16 @@ public function calculateShippingTaxes(
7479
* )
7580
* )
7681
*
77-
* @param array $taxClassBreakdown
82+
* @param array $taxClassBreakdown
7883
* @param OrderTaxDetailsItemInterface $itemTaxDetail
79-
* @param float $taxRatio
84+
* @param float $taxRatio
8085
* @return array
8186
*/
82-
private function aggregateTaxes($taxClassBreakdown, OrderTaxDetailsItemInterface $itemTaxDetail, $taxRatio)
83-
{
87+
private function aggregateTaxes(
88+
array $taxClassBreakdown,
89+
OrderTaxDetailsItemInterface $itemTaxDetail,
90+
float $taxRatio
91+
): array {
8492
$itemAppliedTaxes = $itemTaxDetail->getAppliedTaxes();
8593
foreach ($itemAppliedTaxes as $itemAppliedTax) {
8694
$taxAmount = $itemAppliedTax->getAmount() * $taxRatio;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ private function placeOrder(string $cartId): string
794794
* @param string $orderNumber
795795
* @return array
796796
*/
797-
private function getCustomerInvoicesBasedOnOrderNumber($orderNumber = null): array
797+
private function getCustomerInvoicesBasedOnOrderNumber($orderNumber): array
798798
{
799799
$query =
800800
<<<QUERY

0 commit comments

Comments
 (0)