E-Invoice - Fix batch generate E-Invoice not working

This commit is contained in:
Dillon Ngo
2025-10-06 18:26:11 +08:00
parent 6ce4af05d9
commit 417b907f1b
2 changed files with 14 additions and 3 deletions
@@ -99,7 +99,11 @@ class RegenerateInvoiceBookingV2Processor
$this->deletesDocument->execute($row);
}
$this->createInvoiceTransactionProcessor->execute($booking, $firstBillNo, [
$kvpCopies = $firstInvoice->attributesKVP->map(function ($kvp) {
return $kvp->replicate();
});
$this->createInvoiceTransactionProcessor->execute($booking, $firstBillNo, $kvpCopies, [
'generateEInvoice' => true,
'generateEInvoiceWithNormalInvoiceTemplate' => $eInvoiceWithNormalInvoiceTemplate,
'generateEInvoiceRefund' => $eInvoiceWithRefund,
@@ -107,7 +111,7 @@ class RegenerateInvoiceBookingV2Processor
]);
}
else {
$this->createInvoiceTransactionProcessor->execute($booking, "", [
$this->createInvoiceTransactionProcessor->execute($booking, "", null, [
'generateEInvoice' => false,
'generateEInvoiceWithNormalInvoiceTemplate' => $eInvoiceWithNormalInvoiceTemplate,
'generateEInvoiceRefund' => $eInvoiceWithRefund,
@@ -88,11 +88,12 @@ class CreateInvoiceTransactionV2Processor
/**
* @param Booking $booking
* @param String $invoiceNo
* @param Illuminate\Support\Collection<\App\Models\KeyValuePair> $kvpCopies
* @param array $options
* @return void
* @throws MalformedRequestException
*/
public function execute(Booking $booking, String $invoiceNo= "", array $options = [])
public function execute(Booking $booking, String $invoiceNo= "", $kvpCopies = null, array $options = [])
{
$generateEInvoice = $options['generateEInvoice'] ?? false;
$generateEInvoiceWithNormalInvoiceTemplate = $options['generateEInvoiceWithNormalInvoiceTemplate'] ?? false;
@@ -220,6 +221,12 @@ class CreateInvoiceTransactionV2Processor
);
$invoice_transaction = $this->createsTransaction->execute($purchaseOrder->booking ?? $booking, $transaction_object);
if ($kvpCopies) {
foreach ($kvpCopies as $kvp) {
$invoice_transaction->attributesKVP()->save($kvp);
}
}
$voucherRedemption = $transaction->voucherRedemption;
// purchase order