Skip to content

Commit efc6bae

Browse files
committed
Merge remote-tracking branch 'l3/ACP2E-2583' into Tier4-PR-Delivery-12-1-23
2 parents 5b6fa62 + 59b6cca commit efc6bae

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/code/Magento/Sales/Model/Order.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,9 +1378,11 @@ public function registerCancellation($comment = '', $graceful = true)
13781378
$this->setShippingCanceled($this->getShippingAmount() - $this->getShippingInvoiced());
13791379
$this->setBaseShippingCanceled($this->getBaseShippingAmount() - $this->getBaseShippingInvoiced());
13801380

1381-
$this->setDiscountCanceled(abs((float) $this->getDiscountAmount()) - $this->getDiscountInvoiced());
1381+
$this->setDiscountCanceled(
1382+
abs((float) $this->getDiscountAmount()) - abs((float) $this->getDiscountInvoiced())
1383+
);
13821384
$this->setBaseDiscountCanceled(
1383-
abs((float) $this->getBaseDiscountAmount()) - $this->getBaseDiscountInvoiced()
1385+
abs((float) $this->getBaseDiscountAmount()) - abs((float) $this->getBaseDiscountInvoiced())
13841386
);
13851387

13861388
$this->setTotalCanceled($this->getGrandTotal() - $this->getTotalPaid());

app/code/Magento/Sales/Test/Unit/Model/OrderTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,20 @@ public function testCanCancelActionFlag($cancelActionFlag)
881881
$this->assertEquals($cancelActionFlag, $this->order->canCancel());
882882
}
883883

884+
public function testRegisterDiscountCanceled()
885+
{
886+
$this->item->expects($this->any())
887+
->method('getQtyToInvoice')
888+
->willReturn(42);
889+
$this->prepareOrderItem();
890+
$this->order->setDiscountAmount(-30);
891+
$this->order->setDiscountInvoiced(-10);
892+
$this->order->setBaseDiscountAmount(-30);
893+
$this->order->setBaseDiscountInvoiced(-10);
894+
$this->order->registerCancellation();
895+
$this->assertEquals(20, abs((float) $this->order->getDiscountCanceled()));
896+
}
897+
884898
/**
885899
* @param array $actionFlags
886900
* @param string $orderState

0 commit comments

Comments
 (0)