From 656517390aa361b302f86df0c7f7504943374dba Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 5 Mar 2026 19:26:01 +0800 Subject: [PATCH 1/2] E-Invoice - Fix some issues reported by Mira on E-Invoice --- .../BatchBookingsGenerateEInvoiceLogic.php | 5 +- .../V2/RegenerateInvoiceEInvoiceV2Comman.php | 68 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/V2/RegenerateInvoiceEInvoiceV2Comman.php diff --git a/app/Classes/Modules/Bookings/ControllersLogic/BatchBookingsGenerateEInvoiceLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/BatchBookingsGenerateEInvoiceLogic.php index 187c9c2e..5aac50be 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/BatchBookingsGenerateEInvoiceLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/BatchBookingsGenerateEInvoiceLogic.php @@ -92,7 +92,10 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic foreach ($bookings as $booking) { // Log::info('Booking ID: ' . $booking->marking); - ProcessBookingForEInvoiceV2CommandJob::dispatch($booking); + // if($booking->marking === '833065'){ //798334, 833065 + ProcessBookingForEInvoiceV2CommandJob::dispatch($booking); + // } + } $this->processedCount = count($bookings); diff --git a/app/Console/Commands/V2/RegenerateInvoiceEInvoiceV2Comman.php b/app/Console/Commands/V2/RegenerateInvoiceEInvoiceV2Comman.php new file mode 100644 index 00000000..179dc930 --- /dev/null +++ b/app/Console/Commands/V2/RegenerateInvoiceEInvoiceV2Comman.php @@ -0,0 +1,68 @@ +whereIn('status', [ApprovalStatus::APPROVED])->get(); + + $count = 0; + foreach ($bookings as $booking) { + $count++; + $start = Carbon::parse('2026-03-05 04:00:00'); + $end = Carbon::parse('2026-03-05 05:00:00'); + + if ($booking->updated_at->between($start, $end)) { + Log::info('Processed: ' . $count . ', Booking ID: ' . $booking->marking . ', Booking updated: ' . $booking->updated_at); + $booking->status = 3; + $booking->save(); + } + Log::info('Processed: ' . $count . ', Booking ID: ' . $booking->marking . ', Booking ID: ' . $booking->marking); + } + } +} From aca38805b159bf1c037999d6fdd002f7e0e71746 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 5 Mar 2026 20:36:36 +0800 Subject: [PATCH 2/2] E-Invoice - Fix some issues reported by Mira on E-Invoice --- .../V2/ProcessBookingForEInvoiceV2CommandJob.php | 14 ++++++++++++++ .../BatchBookingsGenerateEInvoiceLogic.php | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Classes/Jobs/Commands/V2/ProcessBookingForEInvoiceV2CommandJob.php b/app/Classes/Jobs/Commands/V2/ProcessBookingForEInvoiceV2CommandJob.php index e69f6923..879a45cf 100644 --- a/app/Classes/Jobs/Commands/V2/ProcessBookingForEInvoiceV2CommandJob.php +++ b/app/Classes/Jobs/Commands/V2/ProcessBookingForEInvoiceV2CommandJob.php @@ -105,5 +105,19 @@ class ProcessBookingForEInvoiceV2CommandJob implements ShouldQueue $firstInvoiceTrx->bill_no = explode('-deleted-', $firstInvoiceTrx->bill_no)[0]; $firstInvoiceTrx->save(); } + else{ + $transaction = $this->booking->transactions()->whereIn('type', [TransactionType::INVOICE]); + Log::info('count again making sure there is an invoice: ' . $transaction->count()); + if($transaction->count() === 0){ + $firstInvoiceTrx = $this->booking->transactions() + ->whereIn('type', [TransactionType::INVOICE]) + ->withTrashed() + ->orderBy('created_at', 'asc') + ->first(); + $firstInvoiceTrx->restore(); + $firstInvoiceTrx->bill_no = explode('-deleted-', $firstInvoiceTrx->bill_no)[0]; + $firstInvoiceTrx->save(); + } + } } } diff --git a/app/Classes/Modules/Bookings/ControllersLogic/BatchBookingsGenerateEInvoiceLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/BatchBookingsGenerateEInvoiceLogic.php index 5aac50be..aece2dae 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/BatchBookingsGenerateEInvoiceLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/BatchBookingsGenerateEInvoiceLogic.php @@ -92,9 +92,9 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic foreach ($bookings as $booking) { // Log::info('Booking ID: ' . $booking->marking); - // if($booking->marking === '833065'){ //798334, 833065 + //if($booking->marking === '833065' || $booking->marking === '798334'){ //798334, 833065 ProcessBookingForEInvoiceV2CommandJob::dispatch($booking); - // } + //} } $this->processedCount = count($bookings);