E-Invoice - Fix a problem with normal invoice shown to user opted in for einvoice

This commit is contained in:
Dillon Ngo
2025-07-05 01:58:24 +08:00
parent 18434903ac
commit 3b0738219f
6 changed files with 17 additions and 25 deletions
+5 -11
View File
@@ -18,14 +18,6 @@ class OrderV2Resource extends JsonResource
*/
public function toArray($request)
{
$eInvoice = false;
$eInvoiceStartDate = Carbon::parse(env('E_INVOICE_START_DATE', '2025-07-01 00:00:00'));
$orderCreatedDate = Carbon::parse($this->created_at);
$eInvoiceRequestedDate = Carbon::parse($this->companyModule->company->e_invoice_requested_at);
if ($orderCreatedDate->isAfter($eInvoiceStartDate) && $this->companyModule->company->e_invoice === 1) { //&& $bookingCreatedDate->diffInMinutes($eInvoiceRequestedDate) <= 480 cief todo: 90
$eInvoice = true;
}
return [
'id' => $this->id,
'reference' => $this->reference,
@@ -37,14 +29,16 @@ class OrderV2Resource extends JsonResource
'address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first()),
'address_change_request' => new AddressResource($this->addressesPendingVerification()->first()),
'invoices' => $this->whenLoaded('packingLists', function() {
return TransactionWithStorageResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get());
$transactions = $this->transactions()->whereNotIn('transactions.status', [0, 1])->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get();
foreach ($transactions as $transaction) {
$transaction['is_einvoice_applicable'] = $this->companyModule->company->e_invoice === 1;
}
return TransactionWithStorageResource::collection($transactions);
}),
'storages' => $this->storages ? $this->storages : null, //from middleware
'remarks' => RemarkResource::collection($this->remarks),
'supplier_tax_rebate' => SupplierTaxRebateResource::collection($this->supplierTaxRebate),
'created_at' => $this->created_at->format('d-m-Y'),
'is_einvoice_applicable' => $eInvoice,
];
}
}
@@ -142,7 +142,8 @@ class TransactionWithStorageResource extends JsonResource
'is_waived' => (int) $this->is_waived,
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'),
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y'),
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y')
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'),
'is_einvoice_applicable' => Carbon::parse($this->created_at)->isAfter(Carbon::parse(env('E_INVOICE_START_DATE', '2025-07-01 00:00:00'))) && $this->is_einvoice_applicable,
];
}
@@ -52,7 +52,7 @@
this.isLoading = false;
},
openBase64NewTab() {
console.log(this.src);
// console.log(this.src);
var blob = this.base64toBlob(this.src);
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, "pdfBase64.pdf");
@@ -159,10 +159,10 @@
</div>
<div class="row bg-master-lightest p-t-15" v-for="invoice in order.invoices" v-if="invoice.type === 1">
<div class="col" v-if="getMergedInvoices(invoice).length > 1">
<customer-payments-billing-with-storage-component :data="getMergedInvoices(invoice)" :storage="getStorageInfo(invoice)" invoice_status="Pending Payment" :is-einvoice-applicable="order.is_einvoice_applicable" :section="section"></customer-payments-billing-with-storage-component>
<customer-payments-billing-with-storage-component :data="getMergedInvoices(invoice)" :storage="getStorageInfo(invoice)" invoice_status="Pending Payment" :section="section"></customer-payments-billing-with-storage-component>
</div>
<div class="col" v-else>
<customer-payments-billing-component :data="invoice" invoice_status="Pending Payment" :is-einvoice-applicable="order.is_einvoice_applicable" :section="section"></customer-payments-billing-component>
<customer-payments-billing-component :data="invoice" invoice_status="Pending Payment" :section="section"></customer-payments-billing-component>
</div>
</div>
</div>
@@ -351,10 +351,6 @@
type: String,
required: true
},
isEinvoiceApplicable:{
type: Boolean,
default: false
}
},
data(){
return {
@@ -365,6 +361,7 @@
expanded: true,
showPaymentProceedModal: false,
showPaymentOutdatedModal: false,
isEinvoiceApplicable: this.data.is_einvoice_applicable,
}
},
computed: {
@@ -432,14 +432,13 @@
storage:{
type: Object
},
isEinvoiceApplicable:{
type: Boolean,
default: false
}
},
data(){
const data = this.data;
const match = data.find(item => item.bill_no.startsWith('SHIP'));
return {
items: this.data,
items: data,
parameters: {
packing_list_id: null,
transaction_details: [],
@@ -448,7 +447,8 @@
showPaymentProceedModal: false,
showPaymentOutdatedModal: false,
selectedShippingInvoicesOnlyIds: [],
}
isEinvoiceApplicable: match ? match.is_einvoice_applicable : false,
};
},
watch: {
data: function() {