community-features icon indicating copy to clipboard operation
community-features copied to clipboard

Order Status always 'Closed' after creating invoice and shipment

Open markjuliusuy opened this issue 6 years ago • 5 comments

We created a module to enable canCapture and canCapturePartial on bank transfer so that we can select if it's pending or paid

Preconditions (*)

  1. Magento 2.2.8 or Magento 2.3.1

Steps to reproduce (*)

I. Scenario

  1. Created an order on admin
  2. Created a pending invoice using no capture option and checked create shipment

Expected result (*)

I. Scenario

  1. The order status should be processing since it's not yet paid and complete when invoice is captured

Actual result (*)

  1. The order status is closed

markjuliusuy avatar Apr 16 '19 00:04 markjuliusuy

https://github.com/magento/magento2/issues/22337

markjuliusuy avatar Apr 16 '19 00:04 markjuliusuy

Hello! Markjuliusuy can you please confirm the issue is only with virtual or downloadable product?

BushraAsif avatar Jun 01 '19 20:06 BushraAsif

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?

arielcugenotta avatar Dec 18 '20 22:12 arielcugenotta

@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

xpoback avatar Dec 19 '20 20:12 xpoback

@magento give me 2.4.2-p1 instance

theodorhanu avatar Jun 22 '21 11:06 theodorhanu