E-Invoice - Fix some issues reported by Mira on E-Invoice

This commit is contained in:
Dillon Ngo
2026-03-05 19:26:01 +08:00
parent 5f1a5da363
commit 656517390a
2 changed files with 72 additions and 1 deletions
@@ -92,7 +92,10 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic
foreach ($bookings as $booking) {
// Log::info('Booking ID: ' . $booking->marking);
ProcessBookingForEInvoiceV2CommandJob::dispatch($booking);
// if($booking->marking === '833065'){ //798334, 833065
ProcessBookingForEInvoiceV2CommandJob::dispatch($booking);
// }
}
$this->processedCount = count($bookings);
@@ -0,0 +1,68 @@
<?php
namespace App\Console\Commands\V2;
use App\Classes\Jobs\Commands\V2\OneTimeBatchProcessEInvoicesV2CommandJob;
use App\Classes\Jobs\Commands\V2\ProcessBookingForEInvoiceV2CommandJob;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\TransactionType;
use Illuminate\Console\Command;
use App\Models\Booking;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Log;
class RegenerateInvoiceEInvoiceV2Comman extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'regenerate-invoice-einvoice-command';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Regenerate Invoice E-Invoices';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$bookings = Booking::whereIn('invoice_status', [ApprovalStatus::APPROVED])->whereIn('status', [ApprovalStatus::APPROVED])->get();
$count = 0;
foreach ($bookings as $booking) {
$count++;
$start = Carbon::parse('2026-03-05 04:00:00');
$end = Carbon::parse('2026-03-05 05:00:00');
if ($booking->updated_at->between($start, $end)) {
Log::info('Processed: ' . $count . ', Booking ID: ' . $booking->marking . ', Booking updated: ' . $booking->updated_at);
$booking->status = 3;
$booking->save();
}
Log::info('Processed: ' . $count . ', Booking ID: ' . $booking->marking . ', Booking ID: ' . $booking->marking);
}
}
}