Skip to content

[BUG] Order State set to complete with multiple Invoices #4789

Open
@Hanmac

Description

@Hanmac

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The order is set to complete, even if one of the invoices isn't paid

Expected Behavior

The Order should not be complete yet

Steps To Reproduce

Have an Order with two Products:
Product A, and Product B

Then use a Payment method, that creates an Invoice, but doesn't directly pay it. (like Gateway methods?)
Create separate Invoices for A and for B.

Now mark one of the Invoices as Paid, but not the other.

Code piece from _checkState:

if (!$this->isCanceled()
&& !$this->canUnhold()
&& !$this->canInvoice()
&& !$this->canShip()
) {
if ($this->getBaseGrandTotal() == 0 || $this->canCreditmemo()) {
if ($this->getState() !== self::STATE_COMPLETE) {
$this->_setState(self::STATE_COMPLETE, true, '', $userNotification);
}

Code piece from canCreditmemo:

if (abs($this->getStore()->roundPrice($this->getTotalPaid()) - $this->getTotalRefunded()) < .0001) {
return false;
}

Because there are invoices for all Products A and B,
and getTotalPaid is greater than 0.0001,
the whole Order is complete, even if only one invoice is paid.

Environment

- OpenMage: 20.*
- php: 8.1

Anything else?

I'm not 100% sure if that is a bug or wanted behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions