Skip to content

Commit 4a1d584

Browse files
author
Stanislav Idolov
committed
ENGCOM-992: [Forwardport] of PR-#11707 to 2.3-develop UPS Option to include TAX in rate #14217
1 parent 97b4208 commit 4a1d584

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ private function mapCurrencyCode($code)
795795
* @return Result
796796
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
797797
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
798-
* @SuppressWarnings(PHPMD.ElseExpression)
798+
* @SuppressWarnings(PHPMD.ElseExpression)
799799
*/
800800
protected function _parseXmlResponse($xmlResponse)
801801
{
@@ -820,37 +820,44 @@ protected function _parseXmlResponse($xmlResponse)
820820
foreach ($arr as $shipElement) {
821821
$code = (string)$shipElement->Service->Code;
822822
if (in_array($code, $allowedMethods)) {
823-
//The location of tax information is in a different place depending on whether we are using negotiated rates or not
823+
//The location of tax information is in a different place
824+
// depending on whether we are using negotiated rates or not
824825
if ($negotiatedActive) {
825-
$includeTaxesArr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment/NegotiatedRates/NetSummaryCharges/TotalChargesWithTaxes");
826-
$includeTaxesActive = $this->getConfigFlag(
827-
'include_taxes'
828-
) && !empty($includeTaxesArr);
826+
$includeTaxesArr = $xml->getXpath(
827+
"//RatingServiceSelectionResponse/RatedShipment/NegotiatedRates"
828+
. "/NetSummaryCharges/TotalChargesWithTaxes"
829+
);
830+
$includeTaxesActive = $this->getConfigFlag('include_taxes') && !empty($includeTaxesArr);
829831
if ($includeTaxesActive) {
830-
$cost = $shipElement->NegotiatedRates->NetSummaryCharges->TotalChargesWithTaxes->MonetaryValue;
832+
$cost = $shipElement->NegotiatedRates
833+
->NetSummaryCharges
834+
->TotalChargesWithTaxes
835+
->MonetaryValue;
836+
831837
$responseCurrencyCode = $this->mapCurrencyCode(
832-
(string)$shipElement->NegotiatedRates->NetSummaryCharges->TotalChargesWithTaxes->CurrencyCode
838+
(string)$shipElement->NegotiatedRates
839+
->NetSummaryCharges
840+
->TotalChargesWithTaxes
841+
->CurrencyCode
833842
);
834-
}
835-
else {
836-
$cost = $shipElement->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue;
843+
} else {
844+
$cost = $shipElement->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue;
837845
$responseCurrencyCode = $this->mapCurrencyCode(
838846
(string)$shipElement->NegotiatedRates->NetSummaryCharges->GrandTotal->CurrencyCode
839847
);
840848
}
841849
} else {
842-
$includeTaxesArr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment/TotalChargesWithTaxes");
843-
$includeTaxesActive = $this->getConfigFlag(
844-
'include_taxes'
845-
) && !empty($includeTaxesArr);
850+
$includeTaxesArr = $xml->getXpath(
851+
"//RatingServiceSelectionResponse/RatedShipment/TotalChargesWithTaxes"
852+
);
853+
$includeTaxesActive = $this->getConfigFlag('include_taxes') && !empty($includeTaxesArr);
846854
if ($includeTaxesActive) {
847855
$cost = $shipElement->TotalChargesWithTaxes->MonetaryValue;
848856
$responseCurrencyCode = $this->mapCurrencyCode(
849857
(string)$shipElement->TotalChargesWithTaxes->CurrencyCode
850858
);
851-
}
852-
else {
853-
$cost = $shipElement->TotalCharges->MonetaryValue;
859+
} else {
860+
$cost = $shipElement->TotalCharges->MonetaryValue;
854861
$responseCurrencyCode = $this->mapCurrencyCode(
855862
(string)$shipElement->TotalCharges->CurrencyCode
856863
);

0 commit comments

Comments
 (0)