magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Order Status always 'Closed' after creating invoice and shipment #160

Open markjuliusuy opened 5 years ago

markjuliusuy commented 5 years ago

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 commented 5 years ago

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

BushraAsif commented 5 years ago

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

arielcugenotta commented 3 years ago

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?

xpoback commented 3 years ago

@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

theodorhanu commented 3 years ago

@magento give me 2.4.2-p1 instance