-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Fixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passednon-issue
Description
vendor/magento/module-sales/Model/Order/Invoice.php
public function cancel()
{
if (!$this->canCancel()) {
return $this;
}
..
if ($this->getState() == self::STATE_PAID) {
$order->setTotalPaid($order->getTotalPaid() - $this->getGrandTotal());
$order->setBaseTotalPaid($order->getBaseTotalPaid() - $this->getBaseGrandTotal());
}
...
return $this;
}
I suppose that this code will never be used :
if ($this->getState() == self::STATE_PAID) {
$order->setTotalPaid($order->getTotalPaid() - $this->getGrandTotal());
$order->setBaseTotalPaid($order->getBaseTotalPaid() - $this->getBaseGrandTotal());
}
if we have:
if (!$this->canCancel()) {
return $this;
}
Problem:
public function cancel()
{
if (!$this->canCancel()) {
return $this;
}
Possible solution:
public function cancel()
{
if ($this->getState() == self::STATE_CANCELED) {
return $this;
}
Preconditions
- Tested on Magento 2.2.6
Steps to reproduce
- Load a invoice programmatically where state == STATE_PAID
- Call $invoice->cancel()
Expected result
- The invoice should be canceled.
Actual result
- Can't cancel invoice if invoice state == STATE_PAID
Metadata
Metadata
Assignees
Labels
Fixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passednon-issue