E-Invoice - Partial completion of => Doc Delivery - E-INVOICE, E-CN, E-RN

This commit is contained in:
Dillon Ngo
2025-06-06 03:17:52 +08:00
parent 094e60e9c3
commit 893631064b
29 changed files with 1036 additions and 72 deletions
+7 -1
View File
@@ -27,9 +27,14 @@ class BookingResource extends JsonResource
$eInvoice = false;
$eInvoiceStartDate = Carbon::parse(env('E_INVOICE_START_DATE', '2025-07-01 00:00:00'));
$bookingCreatedDate = Carbon::parse($this->created_at);
if ($bookingCreatedDate->isAfter($eInvoiceStartDate) && $this->company->e_invoice === 1) {
$eInvoiceRequestedDate = Carbon::parse($this->company->e_invoice_requested_at);
//cief todo: 90 - for testing
if ($bookingCreatedDate->isAfter($eInvoiceStartDate) && $this->company->e_invoice === 1) { //&& $bookingCreatedDate->diffInMinutes($eInvoiceRequestedDate) <= 480 cief todo: 90
$eInvoice = true;
}
// if ($this->company->e_invoice === 1) {
// $eInvoice = true;
// }
return [
'id' => $this->id,
'company' => new CompanyResource($this->company),
@@ -48,6 +53,7 @@ class BookingResource extends JsonResource
'purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()),
'delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()),
'invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::INVOICE)->first()),
'e_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::EINVOICE)->latest()->first()),
'supplier_delivery_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()),
'proforma_invoice' => new DocumentResource($this->documents()->where('document_type', DocumentType::PROFORMA_INVOICE)->whereNotIn('status', [ApprovalStatus::REJECTED, ApprovalStatus::EXPIRED])->orderByDesc('id')->first()),
'ecommerce_purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->first()),