From 0643b28329669a359e774e28239b40122ecccadf Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 19 May 2025 02:54:00 +0800 Subject: [PATCH] E-Invoice - New state field when filling E-invoice info, validation of tin field and msic code field, etc... --- .../ControllersLogic/ListStatesLogic.php | 51 ++++++++ .../Addresses/Services/ListsStates.php | 33 ++++++ .../UpdateCompanyEInvoiceInfoLogic.php | 2 +- .../DataTransferObjects/EInvoiceInfoDTO.php | 15 ++- .../Addresses/ListStatesController.php | 19 +++ app/Http/Resources/StateResource.php | 22 ++++ .../forms/EInvoiceInfoFormComponent.vue | 111 ++++++++++++------ .../elements/EInvoiceInfoComponent.vue | 2 +- .../BookingPaymentQuotationV2Component.vue | 3 +- .../forms/ValidationErrorComponent.vue | 13 +- routes/crud.php | 3 + 11 files changed, 230 insertions(+), 44 deletions(-) create mode 100644 app/Classes/Modules/Addresses/ControllersLogic/ListStatesLogic.php create mode 100644 app/Classes/Modules/Addresses/Services/ListsStates.php create mode 100644 app/Http/Controllers/Addresses/ListStatesController.php create mode 100644 app/Http/Resources/StateResource.php diff --git a/app/Classes/Modules/Addresses/ControllersLogic/ListStatesLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/ListStatesLogic.php new file mode 100644 index 00000000..60ecd262 --- /dev/null +++ b/app/Classes/Modules/Addresses/ControllersLogic/ListStatesLogic.php @@ -0,0 +1,51 @@ + 'Retrieved States', + 'message' => 'You have successfully retrieved a list of States' + ]; + } + + /** @var ListsStates */ + private $listsStates; + + /** + * ListStatesLogic constructor. + * @param ListsStates $listsStates + */ + public function __construct(ListsStates $listsStates) + { + $this->listsStates = $listsStates; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $query = $this->listsStates->execute($this->listsStates->deserializeFilters($request->input('filters'))); + + return $this->collectionResponse(StateResource::collection($query)); + + } + +} diff --git a/app/Classes/Modules/Addresses/Services/ListsStates.php b/app/Classes/Modules/Addresses/Services/ListsStates.php new file mode 100644 index 00000000..c7ac955f --- /dev/null +++ b/app/Classes/Modules/Addresses/Services/ListsStates.php @@ -0,0 +1,33 @@ +repository = $repository; + } + + + /** + * @return Builder + */ + function getRepository(): Builder + { + return $this->repository->newQuery(); + } +} diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php index 1b050809..3b7006ae 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php @@ -93,7 +93,7 @@ class UpdateCompanyEInvoiceInfoLogic extends AbstractControllerLogic } $district = $this->fetchesDistrict->execute(['id' => $dto->districtId]); - $object = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $district->state_id, $district->id, $dto->postCode); + $object = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $dto->stateId, $district->id, $dto->postCode); //Update Address $this->canCreateAddress->passes($object); diff --git a/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php index 2717bf7c..893f20c7 100644 --- a/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php +++ b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php @@ -6,9 +6,10 @@ use App\Classes\General\Interfaces\DataTransferObject; class EInvoiceInfoDTO implements DataTransferObject { - public int $tin; + public string $tin; public int $msicCode; public int $districtId; + public int $stateId; public int $companyId; public string $streetOne; public string $streetTwo; @@ -16,13 +17,14 @@ class EInvoiceInfoDTO implements DataTransferObject public function __construct(array $data) { - $this->tin = (int) ($data['tin'] ?? ''); - $this->msicCode = (int) ($data['msic_code'] ?? ''); - $this->districtId = (int) ($data['district_id'] ?? ''); - $this->companyId = (int) ($data['company_id'] ?? ''); + $this->tin = (string) ($data['tin'] ?? ''); + $this->msicCode = (int) ($data['msic_code'] ?? 0); + $this->districtId = (int) ($data['district_id'] ?? 0); + $this->stateId = (int) ($data['state_id'] ?? 0); + $this->companyId = (int) ($data['company_id'] ?? 0); $this->streetOne = (string) ($data['street_one'] ?? ''); $this->streetTwo = (string) ($data['street_two'] ?? ''); - $this->postCode = (int) ($data['post_code'] ?? ''); + $this->postCode = (int) ($data['post_code'] ?? 0); } public function toArray(): array @@ -31,6 +33,7 @@ class EInvoiceInfoDTO implements DataTransferObject 'tin' => $this->tin, 'msic_code' => $this->msicCode, 'district_id' => $this->districtId, + 'state_id' => $this->stateId, 'company_id' => $this->companyId, 'street_one' => $this->streetOne, 'street_two' => $this->streetTwo, diff --git a/app/Http/Controllers/Addresses/ListStatesController.php b/app/Http/Controllers/Addresses/ListStatesController.php new file mode 100644 index 00000000..a881ad6c --- /dev/null +++ b/app/Http/Controllers/Addresses/ListStatesController.php @@ -0,0 +1,19 @@ +execute($request); + } +} diff --git a/app/Http/Resources/StateResource.php b/app/Http/Resources/StateResource.php new file mode 100644 index 00000000..d73c455c --- /dev/null +++ b/app/Http/Resources/StateResource.php @@ -0,0 +1,22 @@ + $this->id, + 'state' => $this->name, + ]; + } +} diff --git a/resources/assets/vue/components/address/forms/EInvoiceInfoFormComponent.vue b/resources/assets/vue/components/address/forms/EInvoiceInfoFormComponent.vue index 5478b2f3..aad9ba94 100644 --- a/resources/assets/vue/components/address/forms/EInvoiceInfoFormComponent.vue +++ b/resources/assets/vue/components/address/forms/EInvoiceInfoFormComponent.vue @@ -32,7 +32,7 @@
- +
@@ -40,7 +40,7 @@
- +
@@ -59,6 +59,14 @@
+
+
+ + + + +
+
@@ -103,7 +111,7 @@

Billing Address

-

{{parameters.street_one}} {{parameters.street_two}}, {{districts[parseFloat(parameters.district_id) - 1].city}} {{parameters.post_code}} {{districts[parseFloat(parameters.district_id) - 1].state.name}}, {{districts[parseFloat(parameters.district_id) - 1].country.name}}

+

{{parameters.street_one}} {{parameters.street_two}}, {{districts[parseFloat(parameters.district_id) - 1].city}} {{parameters.post_code}} {{states[parseFloat(parameters.state_id) - 1].state}}, {{districts[parseFloat(parameters.district_id) - 1].country.name}}

@@ -128,68 +136,105 @@