booking = $booking; } public function handle() { Log::info(Carbon::now() . ': Start job - Processing single booking for E-Invoice.'); $start = new Carbon(); $isAutocountDataExist = $this->booking->transactions() ->whereIn('transactions.type', [TransactionType::INVOICE]) ->whereHas('attributesKVP', function ($q) { $q->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); }) ->whereHas('attributesKVP', function ($q) { $q->where('key', KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK); }) ->first(); // $documents = $this->booking->documents()->whereIn('document_type', [DocumentType::INVOICE, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->get(); $documents = $this->booking->documents()->whereIn('document_type', [DocumentType::EINVOICE, DocumentType::INVOICE])->get(); if ($documents->isEmpty() && $isAutocountDataExist) { Log::info("Processing for E-Invoice, booking id : " . $this->booking->marking); (App()->make(RegenerateInvoiceBookingV2Processor::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'); Log::info(Carbon::now() . ': End job - Processing single booking for E-Invoice. ElapsedTime: ' . $elapsedTime . '.'); } }