mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 13:33:57 +00:00
53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
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;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use App\Models\Booking;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
class ProcessBookingForEInvoiceV2CommandJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
/** @var Booking */
|
|
private $booking;
|
|
|
|
/**
|
|
* ProcessBookingForEInvoiceV2CommandJob constructor.
|
|
* @param Booking $booking
|
|
*/
|
|
public function __construct(Booking $booking)
|
|
{
|
|
$this->booking = $booking;
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
Log::info(Carbon::now() . ': Start job - Processing single booking for E-Invoice.');
|
|
$start = new Carbon();
|
|
|
|
$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');
|
|
Log::info(Carbon::now() . ': End job - Processing single booking for E-Invoice. ElapsedTime: ' . $elapsedTime . '.');
|
|
}
|
|
}
|