Closed
Description
A manual capture of an invoice is not stored in the database.
In /vendor/magento/module-sales/Controller/Adminhtml/Order/Invoice/Capture.php
in the execute()
method the capturing of the invoice is delegated to the InvoiceManagement
class. The invoice to capture is given to the manager via entity id.
$invoiceManagement = $this->_objectManager->get('Magento\Sales\Api\InvoiceManagementInterface');
$invoiceManagement->setCapture($invoice->getEntityId());
After that call, the invoice is saved.
The problem is, that the invoice being saved is not the same object being captured. Therefore, the invoice stays open.
$invoiceManagement = $this->_objectManager->get('Magento\Sales\Api\InvoiceManagementInterface');
$invoiceManagement->setCapture($invoice->getEntityId());
$invoice->getOrder()->setIsInProcess(true);
$this->_objectManager->create(
'Magento\Framework\DB\Transaction'
)->addObject(
$invoice
)->addObject(
$invoice->getOrder()
)->save();
Metadata
Metadata
Assignees
Labels
No labels