From eb3eac3d6d375df33c8c67165338bc50425d2a8f Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 2 Sep 2025 05:40:37 +0800 Subject: [PATCH] E-Invoice - BatchBookingsGenerateEInvoiceLogic will not process those booking with invoice already generated --- .../V2/ProcessBookingForEInvoiceV2CommandJob.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Classes/Jobs/Commands/V2/ProcessBookingForEInvoiceV2CommandJob.php b/app/Classes/Jobs/Commands/V2/ProcessBookingForEInvoiceV2CommandJob.php index e5e0a552..1410776a 100644 --- a/app/Classes/Jobs/Commands/V2/ProcessBookingForEInvoiceV2CommandJob.php +++ b/app/Classes/Jobs/Commands/V2/ProcessBookingForEInvoiceV2CommandJob.php @@ -3,6 +3,7 @@ namespace App\Classes\Jobs\Commands\V2; use App\Classes\Modules\Bookings\Processors\RegenerateInvoiceBookingProcessor; +use App\Classes\ValueObjects\Constants\DocumentType; use Carbon\Carbon; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -34,7 +35,15 @@ class ProcessBookingForEInvoiceV2CommandJob implements ShouldQueue Log::info(Carbon::now() . ': Start job - Processing single booking for E-Invoice.'); $start = new Carbon(); - (App()->make(RegenerateInvoiceBookingProcessor::class))->execute($this->booking); + $documents = $this->booking->documents()->whereIn('document_type', [DocumentType::PURCHASE_ORDER, DocumentType::INVOICE, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->get(); + + if ($documents->isEmpty()) { + Log::info("Processing for E-Invoice, booking id : " . $this->booking->marking); + (App()->make(RegenerateInvoiceBookingProcessor::class))->execute($this->booking); + } + else{ + Log::info("NO Processing for E-Invoice, booking id : " . $this->booking->marking); + } $end = new Carbon(); $elapsedTime = $start->diff($end)->format('%H:%I:%S');