Skip to content

Commit c154689

Browse files
committed
Merge branch 'ACP2E-2535' of https://github.com/magento-l3/magento2ce into PR-12-19-2023
2 parents d156df6 + 836c925 commit c154689

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public function canInvoice()
721721
*/
722722
public function canCreditmemo()
723723
{
724-
if ($this->hasForcedCanCreditmemo()) {
724+
if ($this->hasForcedCanCreditmemo() && $this->getData('forced_can_creditmemo') === true) {
725725
return $this->getForcedCanCreditmemo();
726726
}
727727

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,19 @@ public function testCanNotCreditMemoWithForced()
570570
$this->assertTrue($this->order->canCreditmemo());
571571
}
572572

573+
/**
574+
* Test canCreditMemo when the forced_can_creditmemo flag set to false.
575+
*
576+
* @return void
577+
*/
578+
public function testCanNotCreditMemoWithForcedWhenFlagSetToFalse()
579+
{
580+
$this->prepareOrderItem();
581+
$this->order->setData('forced_can_creditmemo', false);
582+
$this->order->setState(Order::STATE_PROCESSING);
583+
$this->assertFalse($this->order->canCreditmemo());
584+
}
585+
573586
public function testCanEditIfHasInvoices()
574587
{
575588
$invoiceCollection = $this->getMockBuilder(OrderInvoiceCollection::class)

0 commit comments

Comments
 (0)