E-Invoice - Initial commit main feature integration

This commit is contained in:
Dillon Ngo
2025-06-20 14:34:13 +08:00
parent 8d0fba2d21
commit 1d2eac806e
3 changed files with 30 additions and 3 deletions
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class AddressEInvoiceResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'street_one' => $this->street_one,
'street_two' => $this->street_two,
'district' => $this->district,
'state' => $this->state,
'post_code' => (int) $this->postcode,
'country' => $this->country,
'billing' => (int) $this->billing
];
}
}
+1 -2
View File
@@ -54,8 +54,7 @@ class CompanyModuleResource extends JsonResource
'e_invoice' => $this->company->e_invoice,
'tin' => $this->company->tin,
'msic_code' => $this->company->msic_code,
'address_einvoice' => $this->company->e_invoice ? new AddressResource($this->when($this->has('addresses'), $this->addresses->where('type', AddressType::E_INVOICE)->sortByDesc('created_at')->first())) : null,
'address_einvoice' => $this->company->e_invoice ? new AddressEInvoiceResource($this->when($this->has('addresses'), $this->addresses->where('type', AddressType::E_INVOICE)->sortByDesc('created_at')->first())) : null,
];
}
+1 -1
View File
@@ -20,7 +20,7 @@ class EInvoiceInfoResource extends JsonResource
'street_two' => $this->street_two,
'district' => $this->district,
'state' => $this->state,
'post_code' => $this->postcode,
'post_code' => (int) $this->postcode,
'country' => $this->country,
'billing' => (int) $this->billing,
'msic_code' => (int) $this->msic_code,