community-features
community-features copied to clipboard
Order Status always 'Closed' after creating invoice and shipment
We created a module to enable canCapture and canCapturePartial on bank transfer so that we can select if it's pending or paid
Preconditions (*)
- Magento 2.2.8 or Magento 2.3.1
Steps to reproduce (*)
I. Scenario
- Created an order on admin
- Created a pending invoice using no capture option and checked create shipment
Expected result (*)
I. Scenario
- The order status should be processing since it's not yet paid and complete when invoice is captured
Actual result (*)
- The order status is closed
https://github.com/magento/magento2/issues/22337
Hello! Markjuliusuy can you please confirm the issue is only with virtual or downloadable product?
Hi @markjuliusuy
I have the same problem (Magento 2.4.1). If I create the invoice using this:
$invoice = $this->_invoiceService->prepareInvoice($order); $invoice->register(); $invoice->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID); $invoice->save(); $transactionSave =$this->_transaction->addObject( $invoice->getOrder() ); $transactionSave->save(); $this->invoiceSender->send($invoice); $order->addStatusHistoryComment( __('Notified customer about invoice #%1.', $invoice->getId()) ) ->setIsCustomerNotified(true) ->save();
The invoice is to create perfectly, but when the delivery is created (on the panel), the order has a closed status. If I leave to generate the invoice by clicking on the panel, this problem does not happen.
Is there any parameter missing when creating the invoice?
@BushraAsif yes, it's only with the unshippable products.
@arielcugenotta it's bug, the code is correct. You can use the fix below with a plugin or a preference (like I did).
This has been fixed in 2.4-develop https://github.com/magento/magento2/commit/4f90cf54c303bdcb3de6d010a63fb8af87d46eec
@magento give me 2.4.2-p1 instance