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:33:20 +08:00
parent fc410a24aa
commit e159d0d769
7 changed files with 12 additions and 12 deletions
@@ -90,16 +90,16 @@ class BatchBookingsGenerateEInvoiceLogic extends AbstractControllerLogic
->latest('created_at');
})
->whereHas('attributesKVP', function (Builder $query) {
$query->where('key', KVPKey::AUTOCOUNT_DOCNO);
$query->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE);
})
->with(['attributesKVP' => function ($query) {
$query->where('key', KVPKey::AUTOCOUNT_DOCNO);
$query->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE);
}])
->get();
foreach ($bookings as $booking) {
//$autocountValue = optional($booking->attributesKVP->first())->value;
//Log::info('Booking ID: ' . $booking->marking . ' | AUTOCOUNT_DOCNO: ' . $autocountValue);
//Log::info('Booking ID: ' . $booking->marking . ' | AUTOCOUNT_DOCNO_INVOICE: ' . $autocountValue);
// $this->regenerateInvoiceBookingProcessor->execute($booking);
ProcessBookingForEInvoiceV2CommandJob::dispatch($booking);
}
@@ -88,7 +88,7 @@ class ExportsARCreditNoteReport implements FromQuery, WithHeadings, WithHeadingR
$refundRemark = $refundTransaction->remarks && $refundTransaction->remarks->first() ? $refundTransaction->remarks->first()->content : null;
$booking = $refundTransaction->owner->booking;
if($booking){
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO)->first();
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
if($metadata){
$autoCountSalesInvoiceId = $metadata->value;
}
@@ -80,7 +80,7 @@ class ExportsReceivePaymentForBookingReport implements FromQuery, WithHeadings,
}
if($booking){
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO)->first();
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
if($metadata){
$autoCountSalesInvoiceId = $metadata->value;
}
@@ -185,7 +185,7 @@ class ImportExcelLogic extends AbstractControllerLogic
$booking = Booking::where('marking', $ref)->first();
if($booking){
if($docNo != "" && $docNo != "<<New>>"){
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO, $docNo);
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo);
}
if($eInvoiceValidationLink){
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
@@ -219,12 +219,12 @@ class ImportExcelLogic extends AbstractControllerLogic
if($knockOffDocNo)
{
$kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO)->where('value', $knockOffDocNo)->first();
$kvp = KeyValuePair::where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->where('value', $knockOffDocNo)->first();
if($kvp){
$booking = $kvp->owner;
if($booking){
if($docNo != "" && $docNo != "<<New>>"){
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_OFFICIAL_RECEIPT_DOCNO, $docNo);
$this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT, $docNo);
}
// if($eInvoiceValidationLink){
// $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink);
@@ -94,7 +94,7 @@ class GenerateCreditNotePdfV2Logic
$autoCountInvoiceId = '';
$autoCountEInvoiceValidationLink = '';
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO)->first();
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
if($metadata){
$autoCountInvoiceId = $metadata->value;
}
@@ -69,7 +69,7 @@ class CreateInvoiceDocumentProcessor
}
if($document_type === DocumentType::EINVOICE){
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO)->first();
$metadata = $booking->attributesKVP()->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE)->first();
if($metadata){
$autoCountInvoiceId = $metadata->value;
}
@@ -6,9 +6,9 @@ namespace App\Classes\ValueObjects\Constants;
class KVPKey
{
public const AUTOCOUNT_DOCNO = 'AUTOCOUNT_DOCNO';
public const AUTOCOUNT_DOCNO_INVOICE = 'AUTOCOUNT_DOCNO_I';
public const AUTOCOUNT_OFFICIAL_RECEIPT_DOCNO = 'AUTOCOUNT_OR_DOCNO';
public const AUTOCOUNT_DOCNO_OFFICIAL_RECEIPT = 'AUTOCOUNT_DOCNO_OR';
public const AUTOCOUNT_EINVOICE_VALIDATION_LINK = 'AUTOCOUNT_EINVOICE_VALIDATION_LINK';