Skip to content

Commit 38fc6c6

Browse files
author
Serhii Balko
committed
MC-39864: [Magento Cloud] - Tax Miscalculation
1 parent 7d9d478 commit 38fc6c6

File tree

1 file changed

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

1 file changed

+12
-10
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ private function calculateAllowedTax(Creditmemo $creditMemo): float
182182
{
183183
$invoice = $creditMemo->getInvoice();
184184
$order = $creditMemo->getOrder();
185-
$amount = $invoice !== null ? $invoice->getTaxAmount() : $order->getTaxInvoiced();
185+
$amount = $invoice !== null ? $invoice->getTaxAmount()
186+
: $order->getTaxInvoiced() - $order->getTaxRefunded();
186187

187-
return (float) $amount - $order->getTaxRefunded() - $creditMemo->getTaxAmount();
188+
return (float) $amount - $creditMemo->getTaxAmount();
188189
}
189190

190191
/**
@@ -197,9 +198,10 @@ private function calculateAllowedBaseTax(Creditmemo $creditMemo): float
197198
{
198199
$invoice = $creditMemo->getInvoice();
199200
$order = $creditMemo->getOrder();
200-
$amount = $invoice !== null ? $invoice->getBaseTaxAmount() : $order->getBaseTaxInvoiced();
201+
$amount = $invoice !== null ? $invoice->getBaseTaxAmount()
202+
: $order->getBaseTaxInvoiced() - $order->getBaseTaxRefunded();
201203

202-
return (float) $amount - $order->getBaseTaxRefunded() - $creditMemo->getBaseTaxAmount();
204+
return (float) $amount - $creditMemo->getBaseTaxAmount();
203205
}
204206

205207
/**
@@ -218,12 +220,12 @@ private function calculateAllowedDiscountTaxCompensation(Creditmemo $creditMemo)
218220
+ $invoice->getShippingDiscountTaxCompensationAmount();
219221
} else {
220222
$amount = $order->getDiscountTaxCompensationInvoiced()
221-
+ $order->getShippingDiscountTaxCompensationAmount();
223+
+ $order->getShippingDiscountTaxCompensationAmount()
224+
- $order->getDiscountTaxCompensationRefunded()
225+
- $order->getShippingDiscountTaxCompensationRefunded();
222226
}
223227

224228
return (float) $amount
225-
- $order->getDiscountTaxCompensationRefunded()
226-
- $order->getShippingDiscountTaxCompensationRefunded()
227229
- $creditMemo->getDiscountTaxCompensationAmount()
228230
- $creditMemo->getShippingDiscountTaxCompensationAmount();
229231
}
@@ -244,12 +246,12 @@ private function calculateAllowedBaseDiscountTaxCompensation(Creditmemo $creditM
244246
+ $invoice->getBaseShippingDiscountTaxCompensationAmnt();
245247
} else {
246248
$amount = $order->getBaseDiscountTaxCompensationInvoiced()
247-
+ $order->getBaseShippingDiscountTaxCompensationAmnt();
249+
+ $order->getBaseShippingDiscountTaxCompensationAmnt()
250+
- $order->getBaseDiscountTaxCompensationRefunded()
251+
- $order->getBaseShippingDiscountTaxCompensationRefunded();
248252
}
249253

250254
return (float) $amount
251-
- $order->getBaseDiscountTaxCompensationRefunded()
252-
- $order->getBaseShippingDiscountTaxCompensationRefunded()
253255
- $creditMemo->getBaseShippingDiscountTaxCompensationAmnt()
254256
- $creditMemo->getBaseDiscountTaxCompensationAmount();
255257
}

0 commit comments

Comments
 (0)