Skip to content

Invoice cannot be captured manually #2655

Closed
@schurter-wallee

Description

@schurter-wallee

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
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions