Skip to content

Commit 785b41d

Browse files
author
Prabhu Ram
committed
MC-20637: MyAccount :: Order Details :: Invoice Details by Order Number
- fixed review and static failures
1 parent 80cee36 commit 785b41d

File tree

5 files changed

+130
-130
lines changed

5 files changed

+130
-130
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ public function resolve(
8888
),
8989
'shipping_handling' => [
9090
'amount_excluding_tax' => [
91-
'value' => $invoiceModel->getShippingAmount(),
91+
'value' => $invoiceModel->getShippingAmount() ?? 0,
9292
'currency' => $currency
9393
],
9494
'amount_including_tax' => [
95-
'value' => $invoiceModel->getShippingInclTax(),
95+
'value' => $invoiceModel->getShippingInclTax() ?? 0,
9696
'currency' => $currency
9797
],
9898
'total_amount' => [
99-
'value' => $invoiceModel->getShippingAmount(),
99+
'value' => $invoiceModel->getShippingAmount() ?? 0,
100100
'currency' => $currency
101101
],
102102
'discounts' => $this->getShippingDiscountDetails($invoiceModel),

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
26

37
namespace Magento\SalesGraphQl\Model\SalesItem;
48

59
use Magento\Sales\Api\Data\OrderInterface;
610
use Magento\Sales\Model\EntityInterface;
711
use Magento\Tax\Api\Data\OrderTaxDetailsItemInterface;
812
use Magento\Tax\Api\OrderTaxManagementInterface;
13+
use \Magento\Quote\Model\Quote\Address;
914

1015
class ShippingTaxCalculator
1116
{
@@ -36,7 +41,7 @@ public function calculateShippingTaxes(
3641
EntityInterface $salesItem
3742
) {
3843
$orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($order->getId());
39-
$taxClassAmount = [];
44+
$taxClassBreakdown = [];
4045
// Apply any taxes for shipping
4146
$shippingTaxAmount = $salesItem->getShippingTaxAmount();
4247
$originalShippingTaxAmount = $order->getShippingTaxAmount();
@@ -48,13 +53,12 @@ public function calculateShippingTaxes(
4853
$itemTaxDetails = $orderTaxDetails->getItems();
4954
foreach ($itemTaxDetails as $itemTaxDetail) {
5055
//Aggregate taxable items associated with shipping
51-
if ($itemTaxDetail->getType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
52-
$taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio);
56+
if ($itemTaxDetail->getType() == Address::TYPE_SHIPPING) {
57+
$taxClassBreakdown = $this->aggregateTaxes($taxClassBreakdown, $itemTaxDetail, $shippingRatio);
5358
}
5459
}
5560
}
56-
57-
return $taxClassAmount;
61+
return $taxClassBreakdown;
5862
}
5963

6064
/**
@@ -70,31 +74,31 @@ public function calculateShippingTaxes(
7074
* )
7175
* )
7276
*
73-
* @param array $taxClassAmount
77+
* @param array $taxClassBreakdown
7478
* @param OrderTaxDetailsItemInterface $itemTaxDetail
75-
* @param float $ratio
79+
* @param float $taxRatio
7680
* @return array
7781
*/
78-
private function _aggregateTaxes($taxClassAmount, OrderTaxDetailsItemInterface $itemTaxDetail, $ratio)
82+
private function aggregateTaxes($taxClassBreakdown, OrderTaxDetailsItemInterface $itemTaxDetail, $taxRatio)
7983
{
8084
$itemAppliedTaxes = $itemTaxDetail->getAppliedTaxes();
8185
foreach ($itemAppliedTaxes as $itemAppliedTax) {
82-
$taxAmount = $itemAppliedTax->getAmount() * $ratio;
83-
$baseTaxAmount = $itemAppliedTax->getBaseAmount() * $ratio;
86+
$taxAmount = $itemAppliedTax->getAmount() * $taxRatio;
87+
$baseTaxAmount = $itemAppliedTax->getBaseAmount() * $taxRatio;
8488
if (0 == $taxAmount && 0 == $baseTaxAmount) {
8589
continue;
8690
}
8791
$taxCode = $itemAppliedTax->getCode();
88-
if (!isset($taxClassAmount[$taxCode])) {
89-
$taxClassAmount[$taxCode]['title'] = $itemAppliedTax->getTitle();
90-
$taxClassAmount[$taxCode]['percent'] = $itemAppliedTax->getPercent();
91-
$taxClassAmount[$taxCode]['tax_amount'] = $taxAmount;
92-
$taxClassAmount[$taxCode]['base_tax_amount'] = $baseTaxAmount;
92+
if (!isset($taxClassBreakdown[$taxCode])) {
93+
$taxClassBreakdown[$taxCode]['title'] = $itemAppliedTax->getTitle();
94+
$taxClassBreakdown[$taxCode]['percent'] = $itemAppliedTax->getPercent();
95+
$taxClassBreakdown[$taxCode]['tax_amount'] = $taxAmount;
96+
$taxClassBreakdown[$taxCode]['base_tax_amount'] = $baseTaxAmount;
9397
} else {
94-
$taxClassAmount[$taxCode]['tax_amount'] += $taxAmount;
95-
$taxClassAmount[$taxCode]['base_tax_amount'] += $baseTaxAmount;
98+
$taxClassBreakdown[$taxCode]['tax_amount'] += $taxAmount;
99+
$taxClassBreakdown[$taxCode]['base_tax_amount'] += $baseTaxAmount;
96100
}
97101
}
98-
return $taxClassAmount;
102+
return $taxClassBreakdown;
99103
}
100104
}

app/code/Magento/SalesGraphQl/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"magento/module-store": "*",
1010
"magento/module-catalog": "*",
1111
"magento/module-tax": "*",
12+
"magento/module-quote": "*",
1213
"magento/module-graph-ql": "*"
1314
},
1415
"suggest": {

0 commit comments

Comments
 (0)