mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
E-Invoice - Fix batch generate E-Invoice not working, timed out issue
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Classes\Jobs\Commands\V2;
|
||||
|
||||
use App\Classes\Modules\Bookings\Processors\RegenerateInvoiceBookingV2Processor;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -35,10 +37,20 @@ class ProcessBookingForEInvoiceV2CommandJob implements ShouldQueue
|
||||
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()) {
|
||||
if ($documents->isEmpty() && $isAutocountDataExist) {
|
||||
Log::info("Processing for E-Invoice, booking id : " . $this->booking->marking);
|
||||
(App()->make(RegenerateInvoiceBookingV2Processor::class))->execute($this->booking);
|
||||
}
|
||||
|
||||
+3
-19
@@ -7,8 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\Commands\V2\ProcessBookingForEInvoiceV2CommandJob;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Booking;
|
||||
use App\Classes\ValueObjects\Constants\KVPKey;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -92,25 +90,11 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic
|
||||
})
|
||||
->get();
|
||||
|
||||
$count = 0;
|
||||
foreach ($bookings as $booking) {
|
||||
$temp = $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();
|
||||
Log::info('Booking ID: ' . $booking->marking);
|
||||
if($temp){
|
||||
ProcessBookingForEInvoiceV2CommandJob::dispatch($booking);
|
||||
Log::info('Booking ID with AUTOCOUNT_DOCNO_INVOICE: ' . $booking->marking);
|
||||
$count = $count + 1;
|
||||
}
|
||||
// Log::info('Booking ID: ' . $booking->marking);
|
||||
ProcessBookingForEInvoiceV2CommandJob::dispatch($booking);
|
||||
}
|
||||
$this->processedCount = $count; //count($bookings);
|
||||
$this->processedCount = count($bookings);
|
||||
|
||||
return $this->resourceResponse(JsonResource::collection(collect([])));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user