Skip to content

Commit 59b6cca

Browse files
author
Anna Bukatar
committed
ACP2E-2583: base_discount_canceled column is not updating properly
1 parent efbeb8f commit 59b6cca

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,8 @@ public function registerCancellation($comment = '', $graceful = true)
13791379
$this->setBaseShippingCanceled($this->getBaseShippingAmount() - $this->getBaseShippingInvoiced());
13801380

13811381
$this->setDiscountCanceled(
1382-
abs((float) $this->getDiscountAmount()) - abs((float) $this->getDiscountInvoiced()))
1383-
;
1382+
abs((float) $this->getDiscountAmount()) - abs((float) $this->getDiscountInvoiced())
1383+
);
13841384
$this->setBaseDiscountCanceled(
13851385
abs((float) $this->getBaseDiscountAmount()) - abs((float) $this->getBaseDiscountInvoiced())
13861386
);

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)