E-Invoice - special handling of cases for those booking done before 1st July 2025 that need to generate E-Invoice

This commit is contained in:
Dillon Ngo
2025-08-22 21:15:16 +08:00
parent 40e3ffe3cb
commit fc410a24aa
4 changed files with 22 additions and 6 deletions
@@ -82,7 +82,13 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic
$endDate = $endDate ? Carbon::parse($endDate)->endOfDay() : Carbon::now();
$bookings = Booking::where('status', ApprovalStatus::COMPLETED)
->whereBetween('created_at', [$startDate, $endDate])
// ->whereBetween('created_at', [$startDate, $endDate])
->whereHas('transactions', function ($query) use ($startDate, $endDate) {
$query->payments()
->complete()
->whereBetween('created_at', [$startDate, $endDate])
->latest('created_at');
})
->whereHas('attributesKVP', function (Builder $query) {
$query->where('key', KVPKey::AUTOCOUNT_DOCNO);
})
@@ -92,7 +98,7 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic
->get();
foreach ($bookings as $booking) {
// $autocountValue = optional($booking->attributesKVP->first())->value;
//$autocountValue = optional($booking->attributesKVP->first())->value;
//Log::info('Booking ID: ' . $booking->marking . ' | AUTOCOUNT_DOCNO: ' . $autocountValue);
// $this->regenerateInvoiceBookingProcessor->execute($booking);
ProcessBookingForEInvoiceV2CommandJob::dispatch($booking);
@@ -18,6 +18,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\SegmentConstants;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\KVPKey;
use App\Models\Booking;
use App\Models\SegmentConstant;
use Carbon\Carbon;
@@ -136,7 +137,10 @@ class CreateInvoiceTransactionProcessor
if ($bookingCreatedDate->isAfter($eInvoiceStartDate) && $supplier->e_invoice === 1) {
$eInvoice = true;
}
// $eInvoice = true; //cief todo: 90 - for testing
$kvp = $booking->attributesKVP()->where('key', KVPKey::BOOKING_EINVOICE_ELIGIBLE)->first();
if($kvp){
$eInvoice = true;
}
if($isAllowNormalInvoice){
$invoiceNo = ""; //July 2025 workaround generate normal invoice instead of E-Invoice
@@ -16,4 +16,6 @@ class KVPKey
public const TRANSACTION_MODEL_CLASS = 'App\Models\Transaction';
public const BOOKING_EINVOICE_ELIGIBLE = 'BOOKING_EINVOICE_ELIGIBLE';
}
+7 -3
View File
@@ -10,6 +10,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\BookingAttributeNames;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Classes\ValueObjects\Constants\KVPKey;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -32,9 +33,12 @@ class BookingResource extends JsonResource
if ($bookingCreatedDate->isAfter($eInvoiceStartDate) && $this->company->e_invoice === 1) { //&& $bookingCreatedDate->diffInMinutes($eInvoiceRequestedDate) <= 480 cief todo: 90
$eInvoice = true;
}
// if ($this->company->e_invoice === 1) {
// $eInvoice = true;
// }
$kvp = $this->attributesKVP()->where('key', KVPKey::BOOKING_EINVOICE_ELIGIBLE)->first();
if($kvp){
$eInvoice = true;
}
return [
'id' => $this->id,
'company' => new CompanyResource($this->company),