Merge branch 'dillon/90-e-invoice-f' into vapor/development

This commit is contained in:
Dillon Ngo
2025-07-27 23:01:32 +08:00
3 changed files with 62 additions and 8 deletions
@@ -0,0 +1,43 @@
<?php
namespace App\Classes\Jobs\Commands\V2;
use App\Classes\Modules\Bookings\Processors\RegenerateInvoiceBookingProcessor;
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();
(App()->make(RegenerateInvoiceBookingProcessor::class))->execute($this->booking);
$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 . '.');
}
}
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Bookings\ControllersLogic;
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\Modules\Bookings\Processors\RegenerateInvoiceBookingProcessor;
@@ -17,6 +18,7 @@ use Illuminate\Support\Facades\Log;
class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic
{
protected int $processedCount = 0;
/**
* @return array
*/
@@ -24,7 +26,11 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic
{
return [
'title' => 'Generate Bookings E-Invoices',
'message' => 'You have successfully process bookings for E-Invoices'
'message' => sprintf(
'You have successfully submitted %d booking%s for E-Invoices.',
$this->processedCount,
$this->processedCount === 1 ? '' : 's'
),
];
}
@@ -87,8 +93,10 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic
foreach ($bookings as $booking) {
// $autocountValue = optional($booking->attributesKVP->first())->value;
//Log::info('Booking ID: ' . $booking->marking . ' | AUTOCOUNT_DOCNO: ' . $autocountValue);
$this->regenerateInvoiceBookingProcessor->execute($booking);
// $this->regenerateInvoiceBookingProcessor->execute($booking);
ProcessBookingForEInvoiceV2CommandJob::dispatch($booking);
}
$this->processedCount = count($bookings);
return $this->resourceResponse(JsonResource::collection(collect([])));
}
@@ -33,9 +33,9 @@
<div class="col-12 col-md-auto pl-md-0">
<button
class="btn btn-lg fs-11 w-100 h-100 d-flex justify-content-center align-items-center"
:class="parameters.reportType !== '' ? 'btn-primary requestModal pointer' : 'btn-secondary'"
:disabled="parameters.reportType === ''"
:data-type="parameters.reportType !== '' ? 'uploadDocumentModel' : null"
:class="parameters.reportType === 'Sales Invoice Report' ? 'btn-primary requestModal pointer' : 'btn-secondary'"
:disabled="parameters.reportType !== 'Sales Invoice Report'"
:data-type="parameters.reportType === 'Sales Invoice Report' ? 'uploadDocumentModel' : null"
>
<span>Import</span>
</button>
@@ -52,11 +52,14 @@
>
<span>Process E-Invoices</span>
</button>
<modal-component class="animate__animated animate__fast animate__fadeIn" id="modal-generate-einvoice">
<modal-component
class="animate__animated animate__fast animate__fadeIn"
styleType="fill-in" size="large"
id="modal-generate-einvoice">
<general-confirmation-form-component
contentText="Are you sure you want to batch generate E-Invoices? (Only applicable for bookings with DocNo)"
contentText="Are you sure you want to batch process for E-Invoices? (Only applicable for bookings with DocNo)"
modalType="confirm"
class="text-center"
class="text-center bg-white padding-40 b-rad-lg"
:apiRoute="generateEInvoicesUrl"
apiMethod="get"
:section="section"