diff --git a/app/Classes/Jobs/Commands/V2/ProcessSalesInvoiceReportV2CommandJob.php b/app/Classes/Jobs/Commands/V2/ProcessSalesInvoiceReportV2CommandJob.php index 741095e3..a5b3871a 100644 --- a/app/Classes/Jobs/Commands/V2/ProcessSalesInvoiceReportV2CommandJob.php +++ b/app/Classes/Jobs/Commands/V2/ProcessSalesInvoiceReportV2CommandJob.php @@ -73,18 +73,7 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue 'EInvoiceValidationLink' => $eInvoiceValidationLink, ]); - // $booking = Booking::where('marking', $ref)->first(); - // if($booking){ - // if($docNo != "" && $docNo != "<>"){ - // $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo); - // } - // if($eInvoiceValidationLink){ - // $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink); - // } - // if($docDate){ - // $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCDATE_INVOICE, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate); - // } - // } + $transaction = Transaction::where('bill_no', $ref)->first(); if($transaction){ @@ -98,6 +87,20 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue $this->updateOrCreateKeyValuePair($transaction, KVPKey::AUTOCOUNT_DOCDATE_INVOICE, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate); } } + else{ + $booking = Booking::where('marking', $shipInfo)->first(); + if($booking){ + if($docNo != "" && $docNo != "<>"){ + $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo); + } + if($eInvoiceValidationLink){ + $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_EINVOICE_VALIDATION_LINK, $eInvoiceValidationLink); + } + if($docDate){ + $this->updateOrCreateKeyValuePair($booking, KVPKey::AUTOCOUNT_DOCDATE_INVOICE, is_numeric($docDate) ? $this->convertDocDateToString($docDate) : $docDate); + } + } + } $end = new Carbon(); $elapsedTime = $start->diff($end)->format('%H:%I:%S'); diff --git a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceWithRefundReport.php b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceWithRefundReport.php index 2809fad9..ad650adc 100644 --- a/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceWithRefundReport.php +++ b/app/Classes/Modules/Exports/Services/ExportsSalesInvoiceWithRefundReport.php @@ -100,6 +100,10 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi $invoiceTransaction = $booking->transactions()->where('type', TransactionType::INVOICE)->complete()->first(); // $invoiceTransaction = $booking->transactions()->where('type', TransactionType::INVOICE)->first(); + if (!$invoiceTransaction) { + Log::info('ExportsSalesInvoiceWithRefundReport booking NO invoice : ' . json_encode($booking)); + } + $currencyId = $booking->fix_currency_id; $subtotal = 0; @@ -152,7 +156,7 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi $firstItem ? '<>' : '', $formattedDocumentDate, $company->debtor, - $booking->marking, + $invoiceTransaction ? $invoiceTransaction->bill_no : '', $booking->marking, '500-0000', 'PRODUCT NAME :', @@ -189,7 +193,7 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi '', $formattedDocumentDate, $company->debtor, - $booking->marking, + $invoiceTransaction ? $invoiceTransaction->bill_no : '', $booking->marking, '500-0000', 'PRODUCT NAME :', @@ -236,7 +240,7 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi '', $formattedDocumentDate, $company->debtor, - $booking->marking, + $invoiceTransaction ? $invoiceTransaction->bill_no : '', $booking->marking, '500-0000', 'PRODUCT NAME :', @@ -257,7 +261,7 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi '<>', $formattedDocumentDate, $company->debtor, - $booking->marking, + $invoiceTransaction ? $invoiceTransaction->bill_no: '', $booking->marking, '500-0000', 'PRODUCT NAME :',