Skip to content

Commit 8b873ad

Browse files
author
Serhii Balko
committed
MC-39864: [Magento Cloud] - Tax Miscalculation
1 parent 7f9a7fd commit 8b873ad

File tree

1 file changed

+15
-15
lines changed
  • app/code/Magento/Sales/Model/Order/Creditmemo/Total

1 file changed

+15
-15
lines changed

app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public function collect(Creditmemo $creditmemo)
4040

4141
if ($orderItemQty) {
4242
/** Check item tax amount */
43-
$tax = ($orderItemTax - $orderItem->getTaxRefunded());
44-
$baseTax = ($baseOrderItemTax - $orderItem->getBaseTaxRefunded());
45-
$discountTaxCompensation = ($orderItem->getDiscountTaxCompensationInvoiced()
46-
- $orderItem->getDiscountTaxCompensationRefunded());
47-
$baseDiscountTaxCompensation = ($orderItem->getBaseDiscountTaxCompensationInvoiced()
48-
- $orderItem->getBaseDiscountTaxCompensationRefunded());
43+
$tax = $orderItemTax - $orderItem->getTaxRefunded();
44+
$baseTax = $baseOrderItemTax - $orderItem->getBaseTaxRefunded();
45+
$discountTaxCompensation = $orderItem->getDiscountTaxCompensationInvoiced()
46+
- $orderItem->getDiscountTaxCompensationRefunded();
47+
$baseDiscountTaxCompensation = $orderItem->getBaseDiscountTaxCompensationInvoiced()
48+
- $orderItem->getBaseDiscountTaxCompensationRefunded();
4949
if (!$item->isLast()) {
50-
$availableQty = ($orderItemQty - $orderItem->getQtyRefunded());
50+
$availableQty = $orderItemQty - $orderItem->getQtyRefunded();
5151
$tax = $creditmemo->roundPrice($tax / $availableQty * $item->getQty());
5252
$baseTax = $creditmemo->roundPrice(($baseTax / $availableQty * $item->getQty()), 'base');
5353
$discountTaxCompensation = $creditmemo->roundPrice(
@@ -76,10 +76,10 @@ public function collect(Creditmemo $creditmemo)
7676
if ($invoice = $creditmemo->getInvoice()) {
7777
// recalculate tax amounts in case if refund shipping value was changed
7878
if ($baseOrderShippingAmount && $creditmemo->getBaseShippingAmount() !== null) {
79-
$taxFactor = ($creditmemo->getBaseShippingAmount() / $baseOrderShippingAmount);
80-
$shippingTaxAmount = ($invoice->getShippingTaxAmount() * $taxFactor);
81-
$baseShippingTaxAmount = ($invoice->getBaseShippingTaxAmount() * $taxFactor);
82-
$totalDiscountTaxCompensation += ($invoice->getShippingDiscountTaxCompensationAmount() * $taxFactor);
79+
$taxFactor = $creditmemo->getBaseShippingAmount() / $baseOrderShippingAmount;
80+
$shippingTaxAmount = $invoice->getShippingTaxAmount() * $taxFactor;
81+
$baseShippingTaxAmount = $invoice->getBaseShippingTaxAmount() * $taxFactor;
82+
$totalDiscountTaxCompensation += $invoice->getShippingDiscountTaxCompensationAmount() * $taxFactor;
8383
$baseTotalDiscountTaxCompensation += $invoice->getBaseShippingDiscountTaxCompensationAmnt()
8484
* $taxFactor;
8585
$shippingTaxAmount = $creditmemo->roundPrice($shippingTaxAmount);
@@ -102,10 +102,10 @@ public function collect(Creditmemo $creditmemo)
102102
$shippingDelta = ($baseOrderShippingAmount - $baseOrderShippingRefundedAmount);
103103

104104
if ($shippingDelta > $creditmemo->getBaseShippingAmount()) {
105-
$part = ($creditmemo->getShippingAmount() / $orderShippingAmount);
106-
$basePart = ($creditmemo->getBaseShippingAmount() / $baseOrderShippingAmount);
107-
$shippingTaxAmount = ($order->getShippingTaxAmount() * $part);
108-
$baseShippingTaxAmount = ($order->getBaseShippingTaxAmount() * $basePart);
105+
$part = $creditmemo->getShippingAmount() / $orderShippingAmount;
106+
$basePart = $creditmemo->getBaseShippingAmount() / $baseOrderShippingAmount;
107+
$shippingTaxAmount = $order->getShippingTaxAmount() * $part;
108+
$baseShippingTaxAmount = $order->getBaseShippingTaxAmount() * $basePart;
109109
$shippingDiscountTaxCompensationAmount = $order->getShippingDiscountTaxCompensationAmount() * $part;
110110
$baseShippingDiscountTaxCompensationAmount = $order->getBaseShippingDiscountTaxCompensationAmnt()
111111
* $basePart;

0 commit comments

Comments
 (0)