A canceled invoice can be canceled again. I think \Magento\Sales\Model\Order\Invoice::cancel should check whether the invoice can be canceled before executing all cancel operations.
$invoice->cancel()@redelschaap, thank you for your report.
We've created internal ticket(s) MAGETWO-75779 to track progress on the issue.
Maybe Adding a Guard Clause in \Magento\Sales\Model\Order\Invoice::cancel with:
public function cancel()
{
if (!$this->canCancel()) {
return $this;
}
...
}
can Solve the problem.
If you accept this solution @okorshenko @magento-engcom-team @veloraven can proceed to create PR.
We need to backport this into 2.2-develop
Working on it
Created 2.2-develop Backport @okorshenko
Hi @redelschaap the issue has been fixed in 2.2-develop branch and will be available in 2.2.2 soon
Hi @redelschaap the issue has been fixed in 2.2-develop branch and will be available in 2.2.2 soon
Most helpful comment
Working on it