Magento2: Canceled invoice can be canceled again

Created on 16 Jun 2017  路  7Comments  路  Source: magento/magento2



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.

Preconditions


  1. Tested on Magento 2.1.5

Steps to reproduce

  1. Load a canceled invoice programmatically
  2. Call $invoice->cancel()

Expected result

  1. Throw an exception saying the invoice has already been canceled.

Actual result

  1. The invoice gets canceled twice, so order amounts are also being adjusted twice.
Sales Fixed in 2.2.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x bug report

Most helpful comment

Working on it

All 7 comments

@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

Was this page helpful?
0 / 5 - 0 ratings