From afd1da1bb3534ca106f5892afcdaec3fae8bf984 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 13 May 2026 12:07:01 +0800 Subject: [PATCH] Fix invoice trasaction bill_no messed up reported by Mira --- .../CreateInvoiceTransactionV2Processor.php | 22 ++++--- .../V2/TestCreateEInvoiceV2Command.php | 62 +++++++++++++++++++ 2 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 app/Console/Commands/V2/TestCreateEInvoiceV2Command.php diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php index 17f32bb8..cef5e803 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php @@ -234,14 +234,20 @@ class CreateInvoiceTransactionV2Processor } $invoice_transaction = null; - if($booking->status === ApprovalStatus::APPROVED){ - //NEW INVOICE for non-einvoice user applicable only when booking is completed - $invoice_transaction = $booking->transactions() - ->where('type', TransactionType::INVOICE) - ->complete() - ->latest() - ->first(); - } + // if($booking->status === ApprovalStatus::APPROVED){ + // //NEW INVOICE for non-einvoice user applicable only when booking is completed + // $invoice_transaction = $booking->transactions() + // ->where('type', TransactionType::INVOICE) + // ->complete() + // ->latest() + // ->first(); + // } + + $invoice_transaction = $booking->transactions() + ->whereIn('type', [TransactionType::INVOICE]) + ->complete() + ->latest() + ->first(); if(!$invoice_transaction) { $transaction_object = new TransactionObject( diff --git a/app/Console/Commands/V2/TestCreateEInvoiceV2Command.php b/app/Console/Commands/V2/TestCreateEInvoiceV2Command.php new file mode 100644 index 00000000..a774bf4d --- /dev/null +++ b/app/Console/Commands/V2/TestCreateEInvoiceV2Command.php @@ -0,0 +1,62 @@ +get(); + $bookings = Booking::whereIn('marking', ['507945'])->get(); + + $count = 0; + foreach ($bookings as $booking) { + CreateInvoiceTransactionV2CommandJob::dispatch($booking); + $count++; + Log::info('Processed: ' . $count); + Log::info('Booking ID: ' . $booking->marking . ' for E-Invoice '); + } + } +}