Skip to content

Commit d13ee6a

Browse files
committed
AC-15401: order entity type change durring invoice
1 parent ee918f0 commit d13ee6a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app/code/Magento/Sales/Model/Service/InvoiceService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function prepareInvoice(
153153
$totalQty = 0;
154154
$invoice = $this->orderConverter->toInvoice($order);
155155
$preparedItemsQty = $this->prepareItemsQty($order, $orderItemsQtyToInvoice);
156+
$originalEntityType = $order->getEntityType() ?? null;
156157

157158
foreach ($order->getAllItems() as $orderItem) {
158159
if (!$this->canInvoiceItem($orderItem, $preparedItemsQty)) {
@@ -177,6 +178,9 @@ public function prepareInvoice(
177178

178179
$invoice->setTotalQty($totalQty);
179180
$invoice->collectTotals();
181+
if ($originalEntityType) {
182+
$order->setHistoryEntityName($originalEntityType);
183+
}
180184
$order->getInvoiceCollection()->addItem($invoice);
181185

182186
return $invoice;

0 commit comments

Comments
 (0)