E-Invoice - Automapping Issues, Sales Invoice Report (Import)

This commit is contained in:
Dillon Ngo
2025-07-25 14:44:43 +08:00
parent 6f842ac257
commit 710e55d282
@@ -54,6 +54,7 @@ class CreateInvoiceDocumentProcessor
$brn = $supplier->documents->where('document_type', DocumentType::SSM_REGISTRATION)->first();
$documentDate = $supplier->segments->whereIn('id', [23])->first() ? \Carbon\Carbon::now() : $booking->created_at;
$eInvoiceStartDate = Carbon::parse(env('E_INVOICE_START_DATE', '2025-07-01 00:00:00'));
$autoCountInvoiceId = '';
if ($booking) {
$bookingCreatedDate = Carbon::parse($booking->created_at);
@@ -66,6 +67,10 @@ class CreateInvoiceDocumentProcessor
}
if($document_type === DocumentType::EINVOICE){
$metadata = $booking->attributesKVP()->where('key', 'AUTOCOUNT_DOCNO')->first();
if($metadata){
$autoCountInvoiceId = $metadata->value;
}
$lastDayOfMonth = $documentDate->copy()->endOfMonth();
$documentDate = $lastDayOfMonth;
}
@@ -77,7 +82,7 @@ class CreateInvoiceDocumentProcessor
$lowercaseDocumentType = strtolower($document_type);
$order_pdf = LaravelMpdf::loadView('pages.pdfs.' . $lowercaseDocumentType, ['transaction' => $transaction, 'po_order_transaction' => $purchaseOrder, 'supplier' => $supplier, 'voucher_redemption' => $voucherRedemption, 'current_paid_amount' => $currentPaidAmount, 'document_date' => $documentDate, 'brn' => $brn, 'autocountId' => null, 'booking' => $booking]); //cief todo: 90 - autocount id to be updated
$order_pdf = LaravelMpdf::loadView('pages.pdfs.' . $lowercaseDocumentType, ['transaction' => $transaction, 'po_order_transaction' => $purchaseOrder, 'supplier' => $supplier, 'voucher_redemption' => $voucherRedemption, 'current_paid_amount' => $currentPaidAmount, 'document_date' => $documentDate, 'brn' => $brn, 'autocountId' => $autoCountInvoiceId, 'booking' => $booking]); //cief todo: 90 - autocount id to be updated
if($purchaseOrder && $purchaseOrder->booking->service_id === 4) {
$purchaseOrderDocuments = $purchaseOrder->booking->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->get();