Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
Hanmac opened this issue Apr 28, 2025 · 0 comments
Open
1 task done

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

Hanmac opened this issue Apr 28, 2025 · 0 comments
Labels
bug review needed Problem should be verified

Comments

@Hanmac
Copy link
Contributor

Hanmac commented Apr 28, 2025

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

@Hanmac Hanmac added bug review needed Problem should be verified labels Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug review needed Problem should be verified
Projects
None yet
Development

No branches or pull requests

1 participant