Skip to content

Commit 6cc067a

Browse files
committed
MAGETWO-91769: Credit Memo - Wrong tax calculation! #10982
- Added possibility to recalculate tax amounts in case of '0' shipping value refund
1 parent ac3ae89 commit 6cc067a

File tree

2 files changed

+10
-5
lines changed
  • app/code/Magento/Sales

2 files changed

+10
-5
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
*/
66
namespace Magento\Sales\Model\Order\Creditmemo\Total;
77

8+
/**
9+
* Order credit memo tax total calculation model
10+
*/
811
class Tax extends AbstractTotal
912
{
1013
/**
14+
* Collect credit memo tax total
15+
*
1116
* @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
1217
* @return $this
1318
*
@@ -72,7 +77,7 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
7277
$isPartialShippingRefunded = false;
7378
if ($invoice = $creditmemo->getInvoice()) {
7479
//recalculate tax amounts in case if refund shipping value was changed
75-
if ($order->getBaseShippingAmount() && $creditmemo->getBaseShippingAmount()) {
80+
if ($order->getBaseShippingAmount() && $creditmemo->getBaseShippingAmount() !== null) {
7681
$taxFactor = $creditmemo->getBaseShippingAmount() / $order->getBaseShippingAmount();
7782
$shippingTaxAmount = $invoice->getShippingTaxAmount() * $taxFactor;
7883
$baseShippingTaxAmount = $invoice->getBaseShippingTaxAmount() * $taxFactor;

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,10 @@ public function collectDataProvider()
447447
],
448448
],
449449
'creditmemo_data' => [
450-
'grand_total' => 64.95,
451-
'base_grand_total' => 64.95,
452-
'tax_amount' => 4.95,
453-
'base_tax_amount' => 4.95,
450+
'grand_total' => 64.94,
451+
'base_grand_total' => 64.94,
452+
'tax_amount' => 4.94,
453+
'base_tax_amount' => 4.94,
454454
],
455455
],
456456
];

0 commit comments

Comments
 (0)