Merge branch 'dillon/90-e-invoice-shipping-portal-f' into dillon/90-e-invoice-shipping-portal-e-1 (Lost Tracked Task)

This commit is contained in:
Dillon Ngo
2025-10-14 12:40:40 +08:00
4 changed files with 39 additions and 43 deletions
@@ -14,6 +14,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\Order;
use App\Models\Transaction;
use Illuminate\Support\Facades\Log;
@@ -39,8 +40,6 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
$start = new Carbon();
$docNo = $this->details['docno'] ?? null;
$remark1 = $this->details['remark1'] ?? null;
$remark2 = $this->details['remark2'] ?? null;
$docDate = $this->details['docdate'] ?? null;
$debtorCode = $this->details['debtorcode'] ?? null;
$ref = $this->details['ref'] ?? null;
@@ -63,8 +62,6 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
// Log for debugging
Log::info("Processing Sales Invoice Report:", [
'DocNo' => $docNo,
'Remark1' => $remark1,
'Remark2' => $remark2,
'DocDate' => $docDate,
'DebtorCode' => $debtorCode,
'Ref' => $ref,
@@ -86,24 +83,25 @@ class ProcessSalesInvoiceReportV2CommandJob implements ShouldQueue
]);
$order = Order::where('reference', $ref)->first();
$transactions = $order->transactions()->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
$matchedTransaction = null;
foreach ($transactions as $transaction) {
$transactionDetails = $transaction->transactionDetails;
foreach ($transactionDetails as $detail) {
$detailName = str_replace('<br>', ' ', $detail->name);
if (
$detailName === $furtherDescription &&
$detail->quantity == $qty &&
$detail->price == $unitPrice
) {
$matchedTransaction = $transaction;
break 2;
}
}
}
// $order = Order::where('reference', $ref)->first();
// $transactions = $order->transactions()->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
// $matchedTransaction = null;
// foreach ($transactions as $transaction) {
// $transactionDetails = $transaction->transactionDetails;
// foreach ($transactionDetails as $detail) {
// $detailName = str_replace('<br>', ' ', $detail->name);
// if (
// $detailName === $furtherDescription &&
// $detail->quantity == $qty &&
// $detail->price == $unitPrice
// ) {
// $matchedTransaction = $transaction;
// break 2;
// }
// }
// }
$matchedTransaction = Transaction::where('bill_no', $ref)->first();
if($matchedTransaction){
if($docNo != "" && $docNo != "<<New>>"){
$this->updateOrCreateKeyValuePair($matchedTransaction, KVPKey::AUTOCOUNT_DOCNO_INVOICE, $docNo);
@@ -32,8 +32,6 @@ class ExportsSalesInvoicesReport implements FromQuery, WithHeadings, WithHeading
return [
'DocNo',
'DocDate',
'Remark1',
'Remark2',
'DebtorCode',
'Ref',
'ShipInfo',
@@ -155,10 +153,8 @@ class ExportsSalesInvoicesReport implements FromQuery, WithHeadings, WithHeading
$rows[] = [
$firstItem ? '<<New>>' : '', //DocNo
$formattedDocumentDate, //DocDate
$transaction->id, //Remark1
$transaction->bill_no, //Remark2
$company->debtor, //DebtorCode
$order->reference, //Ref
$transaction->bill_no, //Ref
$order->reference, //ShipInfo
'500-0000', //AccNo
'SERVICE OR ITEM :', //DetailDescription
@@ -59,7 +59,7 @@ class AutoCountDataImport implements ToCollection, WithHeadingRow, WithChunkRead
{
$optionalColumn = 'einvoicevalidationlink';
$salesInvoiceHeader =
['docno', 'docdate', 'remark1', 'remark2', 'debtorcode', 'ref',
['docno', 'docdate', 'debtorcode', 'ref',
'shipinfo', 'accno', 'detaildescription', 'furtherdescription', 'classification', 'projno', 'deptno',
'qty', 'unitprice', 'taxcode', 'taxableamt', 'taxrate', 'submiteinvoice', 'consolidatedeinvoice'];
@@ -157,7 +157,7 @@
<table style="border-spacing:10px 10px;">
<tbody>
<tr>
<td style="border-bottom: solid 2p·x #000000;">
<td style="font-size: 20px;">
<div class="bank-info">
Please transfer the payment to:<br>
Bank: Maybank Berhad<br>
@@ -169,22 +169,24 @@
</tbody>
</table>
</td>
<td align="center" width="20%" style="float: right;">
<table width="100%">
<tbody>
<tr align="center">
<td>
<img src="{{ url(config('qr.qr_code_img_url') . $autocountEInvoiceValidationLink ) }}" style="width: 230px; height: 230px;" />
</td>
</tr>
<tr align="center">
<td>
<h2 style="margin: 0 !important;"><strong>{{ $autocountEInvoiceValidationLink }}</strong></h2>
</td>
</tr>
</tbody>
</table>
<td width="20%" align="center">
<div style="display: inline-block; text-align: center; max-width: 230px; width: 100%;">
<img src="{{ url(config('qr.qr_code_img_url') . $autocountEInvoiceValidationLink ) }}"
style="width: 40%; height: auto; display: block;" />
<div style="margin-top: 5px;
word-break: break-word;
overflow-wrap: break-word;
white-space: normal;
font-size: 12px;
line-height: 1.2;
text-align: center;">
<strong>{{ $autocountEInvoiceValidationLink }}</strong>
</div>
</div>
</td>
</tr>
</tbody>
</table>