From e9c3af51c483654c4879a5522c6b8d03e5c05b5a Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 12 Jun 2025 22:35:10 +0800 Subject: [PATCH 01/27] fix /export/all-customers-info-for-lark-system for php 7.4 issue --- .../Services/ExportsAllCustomersInfoForLarkSystem.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php index c76f36f5..484f8dcb 100644 --- a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php +++ b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php @@ -41,15 +41,17 @@ class ExportsAllCustomersInfoForLarkSystem implements WithHeadings, WithHeadingR $company_module = $company->companyModules()->first(); $marking = $company_module->getMarking(); $employees = $company_module->employees()->first(); + $connection = $company_module->connections()->first(); + $segments = $connection ? $connection->segments()->pluck('name')->implode(', ') : ''; $data = [ $marking, $company->name, - $company->contacts()->first()->phone ?? '', - $employees?->email ?? '', + optional($company->contacts()->first())->phone ?? '', + optional($employees)->email ?? '', $company->created_at, $company->updated_at, - $company_module->connections()->first()->segments()->pluck('name')->implode(', ') + $segments ]; return $data; From 78ac0dbd8fec228e9faff001b1ec9810f8c16a2e Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 12 Jun 2025 22:48:58 +0800 Subject: [PATCH 02/27] test fix - {"message": "Endpoint request timed out"} --- .../ExportsAllCustomersInfoForLarkSystem.php | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php index 484f8dcb..304b145a 100644 --- a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php +++ b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php @@ -2,18 +2,18 @@ namespace App\Classes\Modules\Exports\Services; +use App\Models\Company; use Maatwebsite\Excel\Concerns\FromQuery; use Maatwebsite\Excel\Concerns\Exportable; use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; -use Maatwebsite\Excel\Concerns\WithHeadingRow; use App\Classes\General\Eloquent\ApplyFiltersToQuery; -use App\Models\Company; -class ExportsAllCustomersInfoForLarkSystem implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery +class ExportsAllCustomersInfoForLarkSystem implements FromQuery, WithMapping, WithHeadings, ShouldAutoSize { use Exportable; + public function __construct() {} public function headings(): array @@ -31,29 +31,36 @@ class ExportsAllCustomersInfoForLarkSystem implements WithHeadings, WithHeadingR public function query() { - return (new ApplyFiltersToQuery())->execute(Company::query(), [ - 'has_business_module_type' => 1, - ]); + return (new ApplyFiltersToQuery())->execute( + Company::query()->with([ + 'companyModules.employees', + 'companyModules.connections.segments', + 'contacts' + ]), + ['has_business_module_type' => 1] + ); } public function map($company): array { - $company_module = $company->companyModules()->first(); - $marking = $company_module->getMarking(); - $employees = $company_module->employees()->first(); - $connection = $company_module->connections()->first(); - $segments = $connection ? $connection->segments()->pluck('name')->implode(', ') : ''; + $companyModule = $company->companyModules->first(); + $marking = $companyModule?->getMarking() ?? ''; - $data = [ + $employeeEmail = $companyModule?->employees->first()?->email ?? ''; + $contactPhone = $company->contacts->first()?->phone ?? ''; + + $segments = $companyModule?->connections->first()?->segments + ->pluck('name') + ->implode(', ') ?? ''; + + return [ $marking, $company->name, - optional($company->contacts()->first())->phone ?? '', - optional($employees)->email ?? '', - $company->created_at, - $company->updated_at, - $segments + $contactPhone, + $employeeEmail, + optional($company->created_at)?->toDateString() ?? '', + optional($company->updated_at)?->toDateString() ?? '', + $segments, ]; - - return $data; } } From 8ab9a0ba2d4f42f18159eb3097a5dc30192c2b01 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 12 Jun 2025 23:03:38 +0800 Subject: [PATCH 03/27] fix /export/all-customers-info-for-lark-system for php 7.4 issue --- .../ExportsAllCustomersInfoForLarkSystem.php | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php index 304b145a..6aae057d 100644 --- a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php +++ b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php @@ -44,22 +44,30 @@ class ExportsAllCustomersInfoForLarkSystem implements FromQuery, WithMapping, Wi public function map($company): array { $companyModule = $company->companyModules->first(); - $marking = $companyModule?->getMarking() ?? ''; + $marking = $companyModule ? $companyModule->getMarking() : ''; - $employeeEmail = $companyModule?->employees->first()?->email ?? ''; - $contactPhone = $company->contacts->first()?->phone ?? ''; + $employeeEmail = ''; + if ($companyModule && $companyModule->employees->first()) { + $employeeEmail = $companyModule->employees->first()->email; + } - $segments = $companyModule?->connections->first()?->segments - ->pluck('name') - ->implode(', ') ?? ''; + $contactPhone = ''; + if ($company->contacts->first()) { + $contactPhone = $company->contacts->first()->phone; + } + + $segments = ''; + if ($companyModule && $companyModule->connections->first()) { + $segments = $companyModule->connections->first()->segments->pluck('name')->implode(', '); + } return [ $marking, $company->name, $contactPhone, $employeeEmail, - optional($company->created_at)?->toDateString() ?? '', - optional($company->updated_at)?->toDateString() ?? '', + $company->created_at ? $company->created_at->toDateString() : '', + $company->updated_at ? $company->updated_at->toDateString() : '', $segments, ]; } From fb2ca65168bc1a248bddff5dbc8b7678fcf3bbce Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 12 Jun 2025 23:31:09 +0800 Subject: [PATCH 04/27] add frontend for download /export/all-customers-info-for-lark-system --- .../PasswordProtectedDownloadComponent.vue | 143 ++++++++++++++++++ .../views/pages/downloads/index.blade.php | 16 ++ 2 files changed, 159 insertions(+) create mode 100644 resources/assets/vue/components/general/elements/PasswordProtectedDownloadComponent.vue diff --git a/resources/assets/vue/components/general/elements/PasswordProtectedDownloadComponent.vue b/resources/assets/vue/components/general/elements/PasswordProtectedDownloadComponent.vue new file mode 100644 index 00000000..bef4cf08 --- /dev/null +++ b/resources/assets/vue/components/general/elements/PasswordProtectedDownloadComponent.vue @@ -0,0 +1,143 @@ + + + + + \ No newline at end of file diff --git a/resources/views/pages/downloads/index.blade.php b/resources/views/pages/downloads/index.blade.php index bee9a3b1..5fb881e4 100644 --- a/resources/views/pages/downloads/index.blade.php +++ b/resources/views/pages/downloads/index.blade.php @@ -158,5 +158,21 @@ +
+

Customer Downloads

+
+
+
+
+ all-customers-info-for-lark-system.xls + + Download + +
+
+
+
+
+ @endsection From e6028701dbc4f645675b8670d0f2aa60cec47a8e Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 12 Jun 2025 23:53:47 +0800 Subject: [PATCH 05/27] fix /export/all-customers-info-for-lark-system - handle json response --- .../elements/PasswordProtectedDownloadComponent.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/resources/assets/vue/components/general/elements/PasswordProtectedDownloadComponent.vue b/resources/assets/vue/components/general/elements/PasswordProtectedDownloadComponent.vue index bef4cf08..22b68ce6 100644 --- a/resources/assets/vue/components/general/elements/PasswordProtectedDownloadComponent.vue +++ b/resources/assets/vue/components/general/elements/PasswordProtectedDownloadComponent.vue @@ -84,6 +84,19 @@ export default { } if (response.status === 200) { + // Check if response is JSON + const contentType = response.headers.get('content-type'); + if (contentType && contentType.includes('application/json')) { + const data = await response.json(); + if (data.src) { + // If JSON contains a file URL, trigger download + window.location.href = data.src; + this.closeModal(); + return; + } + } + + // Handle direct file download const contentDisposition = response.headers.get('Content-Disposition'); const filename = contentDisposition ? contentDisposition.split('filename=')[1] : 'downloaded_file'; From ba5fd5f92dff5a7bea5ef54588871f541b651689 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Fri, 13 Jun 2025 00:36:23 +0800 Subject: [PATCH 06/27] update /export/all-customers-info-for-lark-system --- .../Exports/ExportCompanyModuleSummaryController.php | 2 +- resources/views/pages/downloads/index.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Exports/ExportCompanyModuleSummaryController.php b/app/Http/Controllers/Exports/ExportCompanyModuleSummaryController.php index 42bcc084..547698f8 100644 --- a/app/Http/Controllers/Exports/ExportCompanyModuleSummaryController.php +++ b/app/Http/Controllers/Exports/ExportCompanyModuleSummaryController.php @@ -87,7 +87,7 @@ class ExportCompanyModuleSummaryController } $exportsAllCustomersInfoForLarkSystem = new ExportsAllCustomersInfoForLarkSystem($request); - $exportFileName = 'all_customers_info_for_lark_system.xls'; + $exportFileName = 'shipping_all_customers_info_for_lark_system.xls'; $filesystemDriver = Storage::getDefaultDriver(); if ($filesystemDriver === 's3') { diff --git a/resources/views/pages/downloads/index.blade.php b/resources/views/pages/downloads/index.blade.php index 5fb881e4..2b6139d5 100644 --- a/resources/views/pages/downloads/index.blade.php +++ b/resources/views/pages/downloads/index.blade.php @@ -164,7 +164,7 @@
- all-customers-info-for-lark-system.xls + shipping-all-customers-info-for-lark-system.xls Download From ed4ec29d63432c698c08c17a4cd7515b0c08e2b6 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Fri, 13 Jun 2025 00:44:03 +0800 Subject: [PATCH 07/27] update /export/all-customers-info-for-lark-system --- resources/views/pages/downloads/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/pages/downloads/index.blade.php b/resources/views/pages/downloads/index.blade.php index 2b6139d5..e2f42ada 100644 --- a/resources/views/pages/downloads/index.blade.php +++ b/resources/views/pages/downloads/index.blade.php @@ -164,7 +164,7 @@
- shipping-all-customers-info-for-lark-system.xls + shipping_all_customers_info_for_lark_system.xls Download From b3e8e5ea542c697df14cc752dedd707f502aea80 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 20 Jun 2025 09:41:17 +0800 Subject: [PATCH 08/27] E-Invoice - Initial commit main feature integration --- .../CriteriaNotFulfilledException.php | 14 + .../Addresses/Services/UpsertsAddress.php | 40 +++ .../FetchCompanyEInvoiceInfoLogic.php | 69 +++++ .../UpdateCompanyDetailsLogic.php | 133 ++++++++++ .../UpdateCompanyEInvoiceInfoLogic.php | 109 ++++++++ .../UpdateCompanyEInvoiceRequestLogic.php | 59 +++++ .../DataTransferObjects/EInvoiceInfoDTO.php | 43 +++ .../EInvoiceRequestDTO.php | 25 ++ .../UpdateCompanyDetailsDTO.php | 64 +++++ .../Services/UpdatesCompanyEInvoiceInfo.php | 25 ++ .../UpdatesCompanyEInvoiceRequest.php | 29 +++ .../CheckEInvoiceRuleLogic.php | 70 +++++ .../CheckEInvoiceRuleDTO.php | 22 ++ .../Modules/Rules/Services/RuleEvaluator.php | 44 ++++ .../Rules/CanPassEInvoicePromptedRule.php | 57 ++++ .../Rules/Standards/Rules/CanPassTINRule.php | 55 ++++ .../ValueObjects/Constants/AddressType.php | 2 + .../Response/RuleEvaluationResult.php | 30 +++ .../FetchCompanyEInvoiceInfoController.php | 20 ++ .../UpdateCompanyDetailsController.php | 21 ++ .../UpdateCompanyEInvoiceInfoController.php | 29 +++ .../Controllers/Rules/CheckRuleController.php | 19 ++ app/Http/Resources/CompanyModuleResource.php | 5 + app/Http/Resources/EInvoiceInfoResource.php | 31 +++ app/Http/Resources/RuleResource.php | 22 ++ ...6_15_192423_add_tin_to_companies_table.php | 38 +++ .../elements/CustomerProfileComponent.vue | 11 +- .../elements/EInvoiceInfoComponent.vue | 68 +++++ .../forms/EInvoiceInfoFormComponent.vue | 246 ++++++++++++++++++ .../forms/EInvoiceRequestFormComponent.vue | 65 +++++ .../CustomerProfileSectionComponent.vue | 67 ++++- .../general/elements/ModalComponent.vue | 9 +- .../forms/ValidationErrorComponent.vue | 14 +- .../orders/elements/OrderComponent.vue | 22 +- ...ngeCustomerCompanyDetailsFormComponent.vue | 209 +++++++++++++++ .../assets/vue/general/mixins/request.js | 4 +- routes/api.php | 4 +- routes/company.php | 8 + routes/rule.php | 10 + routes/web.php | 7 + 40 files changed, 1798 insertions(+), 21 deletions(-) create mode 100644 app/Classes/Exceptions/CriteriaNotFulfilledException.php create mode 100644 app/Classes/Modules/Addresses/Services/UpsertsAddress.php create mode 100644 app/Classes/Modules/Companies/ControllersLogic/FetchCompanyEInvoiceInfoLogic.php create mode 100644 app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php create mode 100644 app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php create mode 100644 app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceRequestLogic.php create mode 100644 app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php create mode 100644 app/Classes/Modules/Companies/DataTransferObjects/EInvoiceRequestDTO.php create mode 100644 app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php create mode 100644 app/Classes/Modules/Companies/Services/UpdatesCompanyEInvoiceInfo.php create mode 100644 app/Classes/Modules/Companies/Services/UpdatesCompanyEInvoiceRequest.php create mode 100644 app/Classes/Modules/Rules/ControllersLogic/CheckEInvoiceRuleLogic.php create mode 100644 app/Classes/Modules/Rules/DataTransferObjects/CheckEInvoiceRuleDTO.php create mode 100644 app/Classes/Modules/Rules/Services/RuleEvaluator.php create mode 100644 app/Classes/Modules/Rules/Standards/Rules/CanPassEInvoicePromptedRule.php create mode 100644 app/Classes/Modules/Rules/Standards/Rules/CanPassTINRule.php create mode 100644 app/Classes/ValueObjects/Response/RuleEvaluationResult.php create mode 100644 app/Http/Controllers/Companies/FetchCompanyEInvoiceInfoController.php create mode 100644 app/Http/Controllers/Companies/UpdateCompanyDetailsController.php create mode 100644 app/Http/Controllers/Companies/UpdateCompanyEInvoiceInfoController.php create mode 100644 app/Http/Controllers/Rules/CheckRuleController.php create mode 100644 app/Http/Resources/EInvoiceInfoResource.php create mode 100644 app/Http/Resources/RuleResource.php create mode 100644 database/migrations/2025_06_15_192423_add_tin_to_companies_table.php create mode 100644 resources/assets/vue/components/companies/elements/EInvoiceInfoComponent.vue create mode 100644 resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue create mode 100644 resources/assets/vue/components/companies/forms/EInvoiceRequestFormComponent.vue create mode 100644 resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue create mode 100644 routes/rule.php diff --git a/app/Classes/Exceptions/CriteriaNotFulfilledException.php b/app/Classes/Exceptions/CriteriaNotFulfilledException.php new file mode 100644 index 00000000..da105690 --- /dev/null +++ b/app/Classes/Exceptions/CriteriaNotFulfilledException.php @@ -0,0 +1,14 @@ +addresses()->where('id', $id)->first() ?? new Address(); + + $model->reference = $object->getReference(); + $model->street_one = $object->getStreetOne(); + $model->street_two = $object->getStreetTwo(); + $model->country_id = $object->getCountryId(); + $model->state_id = $object->getStateId(); + $model->district_id = $object->getDistrictId(); + $model->postcode = $object->getPostCode(); + $model->status = $object->getStatus(); + $model->type = $object->getType(); + + return $this->handler($addressable->addresses(), $model); + } +} diff --git a/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyEInvoiceInfoLogic.php b/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyEInvoiceInfoLogic.php new file mode 100644 index 00000000..30f7642c --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyEInvoiceInfoLogic.php @@ -0,0 +1,69 @@ + 'Retrieved Company E-Invoice Info', + 'message' => 'You have successfully retrieved a Company E-Invoice Info' + ]; + } + + /** @var CanFetchCompany */ + private $canFetchCompany; + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** + * FetchCompanyEInvoiceInfoLogic constructor. + * @param CanFetchCompany $canFetchCompany + * @param FetchesCompany $fetchesCompany + */ + public function __construct(CanFetchCompany $canFetchCompany, FetchesCompany $fetchesCompany) + { + $this->canFetchCompany = $canFetchCompany; + $this->fetchesCompany = $fetchesCompany; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $this->canFetchCompany->passes(); + + $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); + $eInvoiceInfo = $company->companyModules()->first()->addresses()->where('type', '=', AddressType::E_INVOICE)->latest()->first(); + + if($eInvoiceInfo){ + $eInvoiceInfo->tin = $company->tin; + $eInvoiceInfo->msic_code = $company->msic_code; + $eInvoiceInfo->e_invoice = $company->e_invoice; + } + else{ + return $this->response([]); + } + + return $this->resourceResponse(new EInvoiceInfoResource($eInvoiceInfo)); + } +} diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php new file mode 100644 index 00000000..fe1c2c23 --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php @@ -0,0 +1,133 @@ + 'Update Company Details', + 'message' => 'You have successfully updated the Company Details' + ]; + } + /** @var CanUpdateCompany */ + private $canUpdateCompany; + + /** @var UpdatesCompany */ + private $updatesCompany; + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** @var UpdatesCompanyDebtor */ + private $updatesCompanyDebtor; + + /** @var CanCreateAddress */ + private $canCreateAddress; + + /** @var FetchesDistrict */ + private $fetchesDistrict; + + /** @var UpsertsAddress */ + private $upsertsAddress; + + /** @var UpdatesCompanyEInvoiceInfo */ + private $updatesCompanyEInvoiceInfo; + + /** @var UpdatesCompanyModuleName */ + private $updatesCompanyModuleName; + + /** + * UpdateCompanyDetailsLogic constructor. + * @param CanUpdateCompany $canUpdateCompany + * @param UpdatesCompany $updatesCompany + * @param FetchesCompany $fetchesCompany + * @param UpdatesCompanyDebtor $updatesCompanyDebtor + * @param CanCreateAddress $canCreateAddress + * @param FetchesDistrict $fetchesDistrict + * @param UpsertsAddress $upsertsAddress + * @param UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo; + * @param UpdatesCompanyModuleName $updatesCompanyModuleName + */ + public function __construct( + CanUpdateCompany $canUpdateCompany, + UpdatesCompany $updatesCompany, + FetchesCompany $fetchesCompany, + UpdatesCompanyDebtor $updatesCompanyDebtor, + CanCreateAddress $canCreateAddress, + FetchesDistrict $fetchesDistrict, + UpsertsAddress $upsertsAddress, + UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo, + UpdatesCompanyModuleName $updatesCompanyModuleName + ) + { + $this->canUpdateCompany = $canUpdateCompany; + $this->updatesCompany = $updatesCompany; + $this->fetchesCompany = $fetchesCompany; + $this->updatesCompanyDebtor = $updatesCompanyDebtor; + $this->canCreateAddress = $canCreateAddress; + $this->fetchesDistrict = $fetchesDistrict; + $this->upsertsAddress = $upsertsAddress; + $this->updatesCompanyEInvoiceInfo = $updatesCompanyEInvoiceInfo; + $this->updatesCompanyModuleName = $updatesCompanyModuleName; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $dto = new UpdateCompanyDetailsDTO($request->all()); + $object = new CompanyObject($dto->name, $dto->reference, $dto->type); + + $this->canUpdateCompany->passes($object); + $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); + + $this->updatesCompanyModuleName->execute($company->companyModules()->first(), $object->getName()); + + //Update Name and Debtor, Type + $company = $this->updatesCompany->execute($company, $object); + + if ($request->input('debtor') || $company->first()->debtor !== null) { + $this->updatesCompanyDebtor->execute($company, $request->input('debtor')); + } + + //Update EInvoice Related Info + if($company->e_invoice){ + $district = $this->fetchesDistrict->execute(['id' => $dto->districtId]); + $addObj = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $dto->stateId, $district->id, $dto->postCode, AddressType::E_INVOICE, ApprovalStatus::APPROVED, 'E-Invoice'); + + $this->canCreateAddress->passes($addObj); + + $this->upsertsAddress->execute($company->companyModules()->first(), $addObj, $dto->addressId); + $this->updatesCompanyEInvoiceInfo->execute($company, $dto->tin, $dto->msicCode); + } + + return $this->resourceResponse(new CompanyResource($company)); + } +} + diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php new file mode 100644 index 00000000..319fa1a2 --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php @@ -0,0 +1,109 @@ + 'EInvoice Info Update', + 'message' => 'You have successfully updated company E-Invoice information' + ]; + } + + /** @var CanCreateAddress */ + private $canCreateAddress; + + /** @var FetchesDistrict */ + private $fetchesDistrict; + + /** @var FetchesCompanyModule */ + private $fetchesCompanyModule; + + /** @var CreatesAddress */ + private $createsAddress; + + /** @var RuleEvaluator */ + private $ruleEvaluator; + + /** @var UpdatesCompanyEInvoiceInfo */ + private $updatesCompanyEInvoiceInfo; + + /** @var CanPassEInvoicePromptedRule */ + private $canPassEInvoicePromptedRule; + + /** + * UpdateCompanyEInvoiceInfoLogic constructor. + * @param CanCreateAddress $canCreateAddress + * @param FetchesDistrict $fetchesDistrict + * @param FetchesCompanyModule $fetchesCompanyModule + * @param CreatesAddress $createsAddress + * @param RuleEvaluator $ruleEvaluator; + * @param UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo; + * @param CanPassEInvoicePromptedRule $canPassEInvoicePromptedRule + */ + public function __construct(CanCreateAddress $canCreateAddress, FetchesDistrict $fetchesDistrict, FetchesCompanyModule $fetchesCompanyModule, CreatesAddress $createsAddress, RuleEvaluator $ruleEvaluator, UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo, CanPassEInvoicePromptedRule $canPassEInvoicePromptedRule) + { + $this->canCreateAddress = $canCreateAddress; + $this->fetchesDistrict = $fetchesDistrict; + $this->fetchesCompanyModule = $fetchesCompanyModule; + $this->createsAddress = $createsAddress; + $this->ruleEvaluator = $ruleEvaluator; + $this->updatesCompanyEInvoiceInfo = $updatesCompanyEInvoiceInfo; + $this->canPassEInvoicePromptedRule = $canPassEInvoicePromptedRule; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + * @throws \App\Classes\Exceptions\CriteriaNotFulfilledException + */ + public function logic(Request $request) : JsonResponse + { + $dto = new EInvoiceInfoDTO($request->all()); + $result = $this->ruleEvaluator->evaluate([ + $this->canPassEInvoicePromptedRule, + ], $dto); + + if ($result->failed()) { + throw new CriteriaNotFulfilledException("- " . implode("
- ", $result->messages())); + } + + $district = $this->fetchesDistrict->execute(['id' => $dto->districtId]); + $object = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $dto->stateId, $district->id, $dto->postCode, AddressType::E_INVOICE, ApprovalStatus::APPROVED, 'E-Invoice'); + + //Update Address + $this->canCreateAddress->passes($object); + $companyModule = $this->fetchesCompanyModule->execute(['id' => $dto->companyModuleId]); + $this->createsAddress->execute($companyModule, $object); + + //Update tin, msic code + $this->updatesCompanyEInvoiceInfo->execute($companyModule->company, $dto->tin, $dto->msicCode); + + return $this->response([]); + } +} diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceRequestLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceRequestLogic.php new file mode 100644 index 00000000..a065802d --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceRequestLogic.php @@ -0,0 +1,59 @@ + 'Updated EInvoice Request', + 'message' => 'You have successfully updated company E-Invoice request' + ]; + } + + /** @var FetchesCompanyModule */ + private $fetchesCompanyModule; + + /** @var UpdatesCompanyEInvoiceRequest */ + private $updatesCompanyEInvoiceRequest; + + + /** + * UpdateCompanyEInvoiceRequestLogic constructor. + * @param FetchesCompanyModule $fetchesCompanyModule + * @param UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest + */ + public function __construct(FetchesCompanyModule $fetchesCompanyModule, UpdatesCompanyEInvoiceRequest $updatesCompanyEInvoiceRequest) + { + $this->fetchesCompanyModule = $fetchesCompanyModule; + $this->updatesCompanyEInvoiceRequest = $updatesCompanyEInvoiceRequest; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $dto = new EInvoiceRequestDTO($request->all()); + $companyModule = $this->fetchesCompanyModule->execute(['id' => $dto->companyModuleId]); + $this->updatesCompanyEInvoiceRequest->execute($companyModule->company, $dto->eInvoiceRequest); + + return $this->response([]); + } +} diff --git a/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php new file mode 100644 index 00000000..a9cf02f1 --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php @@ -0,0 +1,43 @@ +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->companyModuleId = (int) ($data['company_module_id'] ?? 0); + $this->streetOne = (string) ($data['street_one'] ?? ''); + $this->streetTwo = (string) ($data['street_two'] ?? ''); + $this->postCode = (int) ($data['post_code'] ?? 0); + } + + public function toArray(): array + { + return [ + 'tin' => $this->tin, + 'msic_code' => $this->msicCode, + 'district_id' => $this->districtId, + 'state_id' => $this->stateId, + 'company_module_id' => $this->companyModuleId, + 'street_one' => $this->streetOne, + 'street_two' => $this->streetTwo, + 'post_code' => $this->postCode, + ]; + } +} diff --git a/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceRequestDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceRequestDTO.php new file mode 100644 index 00000000..1c46f2df --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceRequestDTO.php @@ -0,0 +1,25 @@ +eInvoiceRequest = $data['e_invoice_request']; + $this->companyModuleId = $data['company_module_id']; + } + + public function toArray(): array + { + return [ + 'e_invoice_request' => $this->eInvoiceRequest, + 'company_module_id' => $this->companyModuleId, + ]; + } +} diff --git a/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php new file mode 100644 index 00000000..e9a76434 --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php @@ -0,0 +1,64 @@ +id = (int) ($data['id'] ?? 0); + $this->name = (string) ($data['name'] ?? ''); + $this->debtor = (string) ($data['debtor'] ?? ''); + $this->reference = (string) ($data['reference'] ?? ''); + $this->type = (int) ($data['type'] ?? 0); + + $this->tin = (string) ($data['tin'] ?? 0); + $this->msicCode = (int) ($data['msic_code'] ?? 0); + $this->addressId = (int) ($data['address_id'] ?? 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'] ?? 0); + } + + public function toArray(): array + { + return [ + 'id' => $this->id, + 'name' => $this->name, + 'debtor' => $this->debtor, + 'reference' => $this->reference, + 'type' => $this->type, + + 'tin' => $this->tin, + 'msic_code' => $this->msicCode, + 'address_id' => $this->addressId, + 'district_id' => $this->districtId, + 'state_id' => $this->stateId, + 'company_id' => $this->companyId, + 'street_one' => $this->streetOne, + 'street_two' => $this->streetTwo, + 'post_code' => $this->postCode, + ]; + } +} diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompanyEInvoiceInfo.php b/app/Classes/Modules/Companies/Services/UpdatesCompanyEInvoiceInfo.php new file mode 100644 index 00000000..0a2c5cc5 --- /dev/null +++ b/app/Classes/Modules/Companies/Services/UpdatesCompanyEInvoiceInfo.php @@ -0,0 +1,25 @@ +tin = $tin; + $model->msic_code = $msicCode; + + return $this->handler($model); + } +} diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompanyEInvoiceRequest.php b/app/Classes/Modules/Companies/Services/UpdatesCompanyEInvoiceRequest.php new file mode 100644 index 00000000..bdef7fc8 --- /dev/null +++ b/app/Classes/Modules/Companies/Services/UpdatesCompanyEInvoiceRequest.php @@ -0,0 +1,29 @@ +e_invoice_requested_at)) { + if($eInvoice){ + $model->e_invoice_requested_at = now(); + } + } + $model->e_invoice = $eInvoice; + + return $this->handler($model); + } +} diff --git a/app/Classes/Modules/Rules/ControllersLogic/CheckEInvoiceRuleLogic.php b/app/Classes/Modules/Rules/ControllersLogic/CheckEInvoiceRuleLogic.php new file mode 100644 index 00000000..9c690686 --- /dev/null +++ b/app/Classes/Modules/Rules/ControllersLogic/CheckEInvoiceRuleLogic.php @@ -0,0 +1,70 @@ + 'Rule Check E-Invoice', + 'message' => 'You have successfully passed all rules evaluated' + ]; + } + + /** @var RuleEvaluator */ + private $ruleEvaluator; + + /** @var CanPassEInvoicePromptedRule */ + private $canPassEInvoicePromptedRule; + + /** @var CanPassTINRule */ + private $canPassTINRule; + + /** + * CheckEInvoiceRuleLogic constructor. + */ + public function __construct(RuleEvaluator $ruleEvaluator, CanPassEInvoicePromptedRule $canPassEInvoicePromptedRule, CanPassTINRule $canPassTINRule) + { + $this->ruleEvaluator = $ruleEvaluator; + $this->canPassEInvoicePromptedRule = $canPassEInvoicePromptedRule; + $this->canPassTINRule = $canPassTINRule; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + * @throws \App\Classes\Exceptions\CriteriaNotFulfilledException + */ + public function logic(Request $request) : JsonResponse + { + $dto = new CheckEInvoiceRuleDTO($request->all()); + + $result = $this->ruleEvaluator->evaluate([ + $this->canPassEInvoicePromptedRule, + $this->canPassTINRule, + ], $dto); + + if ($result->failed()) { + throw new CriteriaNotFulfilledException("- " . implode("
- ", $result->messages())); + } + + return $this->resourceResponse(new RuleResource((object)$result)); + } +} diff --git a/app/Classes/Modules/Rules/DataTransferObjects/CheckEInvoiceRuleDTO.php b/app/Classes/Modules/Rules/DataTransferObjects/CheckEInvoiceRuleDTO.php new file mode 100644 index 00000000..c982aeb0 --- /dev/null +++ b/app/Classes/Modules/Rules/DataTransferObjects/CheckEInvoiceRuleDTO.php @@ -0,0 +1,22 @@ +companyModuleId = $data['company_module_id']; + } + + public function toArray(): array + { + return [ + 'company_module_id' => $this->companyModuleId, + ]; + } +} diff --git a/app/Classes/Modules/Rules/Services/RuleEvaluator.php b/app/Classes/Modules/Rules/Services/RuleEvaluator.php new file mode 100644 index 00000000..ac248a25 --- /dev/null +++ b/app/Classes/Modules/Rules/Services/RuleEvaluator.php @@ -0,0 +1,44 @@ +passes($object)) { + $success = false; + $messages[] = get_class($rule) . ' failed without exception'; + } + } catch (AccessForbiddenException | RequestValidationException | CriteriaNotFulfilledException $e) { + $success = false; + $messages[] = $e->getMessage(); + } catch (\Exception $e) { + $success = false; + $messages[] = 'Unexpected error in ' . get_class($rule) . ': ' . $e->getMessage(); + } + } + + return new RuleEvaluationResult($success, $messages); + } + +} diff --git a/app/Classes/Modules/Rules/Standards/Rules/CanPassEInvoicePromptedRule.php b/app/Classes/Modules/Rules/Standards/Rules/CanPassEInvoicePromptedRule.php new file mode 100644 index 00000000..61d1dfcb --- /dev/null +++ b/app/Classes/Modules/Rules/Standards/Rules/CanPassEInvoicePromptedRule.php @@ -0,0 +1,57 @@ +fetchesCompanyModule = $fetchesCompanyModule; + } + + /** + * @return bool + */ + protected function authorized($object): bool + { + return true; + + } + + /** + * @return bool + */ + protected function validators($object): bool + { + return true; + + } + + + /** + * @return bool + */ + protected function criteria($object): bool + { + //Check if account requires E-Invoice + $companyModule = $this->fetchesCompanyModule->execute(['id' => $object->companyModuleId]); + if($companyModule->company->e_invoice === null){ + throw new CriteriaNotFulfilledException("Please refresh page to answer question related to E-Invoice."); + } + return true; + } + +} diff --git a/app/Classes/Modules/Rules/Standards/Rules/CanPassTINRule.php b/app/Classes/Modules/Rules/Standards/Rules/CanPassTINRule.php new file mode 100644 index 00000000..5ec859cb --- /dev/null +++ b/app/Classes/Modules/Rules/Standards/Rules/CanPassTINRule.php @@ -0,0 +1,55 @@ +fetchesCompanyModule = $fetchesCompanyModule; + } + + /** + * @return bool + */ + protected function authorized($object): bool + { + return true; + } + + /** + * @return bool + */ + protected function validators($object): bool + { + return true; + } + + + /** + * @return bool + */ + protected function criteria($object): bool + { + //Check if TIN already provided if account requires E-Invoice + $companyModule = $this->fetchesCompanyModule->execute(['id' => $object->companyModuleId]); + if($companyModule->company->e_invoice === 1 && !$companyModule->company->tin){ + throw new CriteriaNotFulfilledException("Please provide all requested E-Invoice Info."); + } + return true; + } + +} diff --git a/app/Classes/ValueObjects/Constants/AddressType.php b/app/Classes/ValueObjects/Constants/AddressType.php index 614b9774..b9952a3e 100644 --- a/app/Classes/ValueObjects/Constants/AddressType.php +++ b/app/Classes/ValueObjects/Constants/AddressType.php @@ -10,4 +10,6 @@ final class AddressType { public const PICK_UP = 3; + public const E_INVOICE = 4; + } diff --git a/app/Classes/ValueObjects/Response/RuleEvaluationResult.php b/app/Classes/ValueObjects/Response/RuleEvaluationResult.php new file mode 100644 index 00000000..264eaf26 --- /dev/null +++ b/app/Classes/ValueObjects/Response/RuleEvaluationResult.php @@ -0,0 +1,30 @@ +success = $success; + $this->messages = $messages; + } + + public function failed(): bool + { + return ! $this->success; + } + + public function passed(): bool + { + return $this->success; + } + + public function messages(): array + { + return $this->messages; + } +} diff --git a/app/Http/Controllers/Companies/FetchCompanyEInvoiceInfoController.php b/app/Http/Controllers/Companies/FetchCompanyEInvoiceInfoController.php new file mode 100644 index 00000000..d506e24e --- /dev/null +++ b/app/Http/Controllers/Companies/FetchCompanyEInvoiceInfoController.php @@ -0,0 +1,20 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Companies/UpdateCompanyDetailsController.php b/app/Http/Controllers/Companies/UpdateCompanyDetailsController.php new file mode 100644 index 00000000..e8cbfd1c --- /dev/null +++ b/app/Http/Controllers/Companies/UpdateCompanyDetailsController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Controllers/Companies/UpdateCompanyEInvoiceInfoController.php b/app/Http/Controllers/Companies/UpdateCompanyEInvoiceInfoController.php new file mode 100644 index 00000000..9157e9de --- /dev/null +++ b/app/Http/Controllers/Companies/UpdateCompanyEInvoiceInfoController.php @@ -0,0 +1,29 @@ +execute($request); + } + + /** + * @param Request $request + * @param UpdateCompanyEInvoiceRequestLogic $logic + * @return JsonResponse + */ + public function updateRequest(Request $request, UpdateCompanyEInvoiceRequestLogic $logic): JsonResponse { + return $logic->execute($request); + } +} diff --git a/app/Http/Controllers/Rules/CheckRuleController.php b/app/Http/Controllers/Rules/CheckRuleController.php new file mode 100644 index 00000000..af95e185 --- /dev/null +++ b/app/Http/Controllers/Rules/CheckRuleController.php @@ -0,0 +1,19 @@ +execute($request); + } +} diff --git a/app/Http/Resources/CompanyModuleResource.php b/app/Http/Resources/CompanyModuleResource.php index 5ffc40f8..1e54674e 100644 --- a/app/Http/Resources/CompanyModuleResource.php +++ b/app/Http/Resources/CompanyModuleResource.php @@ -51,6 +51,11 @@ class CompanyModuleResource extends JsonResource 'connections' => $this->connections, 'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())), 'debtor' => $this->company->debtor, + '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, + ]; } diff --git a/app/Http/Resources/EInvoiceInfoResource.php b/app/Http/Resources/EInvoiceInfoResource.php new file mode 100644 index 00000000..565e86a7 --- /dev/null +++ b/app/Http/Resources/EInvoiceInfoResource.php @@ -0,0 +1,31 @@ + $this->id, + 'street_one' => $this->street_one, + 'street_two' => $this->street_two, + 'district' => $this->district, + 'state' => $this->state, + 'post_code' => $this->postcode, + 'country' => $this->country, + 'billing' => (int) $this->billing, + 'msic_code' => (int) $this->msic_code, + 'tin' => (string) $this->tin, + 'e_invoice' => (int) $this->e_invoice, + ]; + } +} diff --git a/app/Http/Resources/RuleResource.php b/app/Http/Resources/RuleResource.php new file mode 100644 index 00000000..1fb42181 --- /dev/null +++ b/app/Http/Resources/RuleResource.php @@ -0,0 +1,22 @@ + $this->success, + 'messages' => $this->messages, + ]; + } +} diff --git a/database/migrations/2025_06_15_192423_add_tin_to_companies_table.php b/database/migrations/2025_06_15_192423_add_tin_to_companies_table.php new file mode 100644 index 00000000..ed5f2c58 --- /dev/null +++ b/database/migrations/2025_06_15_192423_add_tin_to_companies_table.php @@ -0,0 +1,38 @@ +string('tin')->nullable()->after('debtor'); + $table->string('msic_code')->nullable()->after('debtor')->comment("5-digit code representing business activity"); + $table->timestamp('e_invoice_requested_at')->nullable()->after('debtor'); + $table->boolean('e_invoice')->nullable()->default(null)->after('debtor'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('companies', function (Blueprint $table) { + $table->dropColumn('tin'); + $table->dropColumn('msic_code'); + $table->dropColumn('e_invoice_requested_at'); + $table->dropColumn('e_invoice'); + }); + } +} diff --git a/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue b/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue index b71287c5..bef39049 100644 --- a/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue +++ b/resources/assets/vue/components/companies/elements/CustomerProfileComponent.vue @@ -16,7 +16,8 @@
- + +
{{item.name}} @@ -158,14 +159,14 @@
Company Type
- +
{{item.type_name}} -
+
diff --git a/resources/assets/vue/components/companies/elements/EInvoiceInfoComponent.vue b/resources/assets/vue/components/companies/elements/EInvoiceInfoComponent.vue new file mode 100644 index 00000000..ef38aa8c --- /dev/null +++ b/resources/assets/vue/components/companies/elements/EInvoiceInfoComponent.vue @@ -0,0 +1,68 @@ + + diff --git a/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue b/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue new file mode 100644 index 00000000..a4d53e4a --- /dev/null +++ b/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue @@ -0,0 +1,246 @@ + + diff --git a/resources/assets/vue/components/companies/forms/EInvoiceRequestFormComponent.vue b/resources/assets/vue/components/companies/forms/EInvoiceRequestFormComponent.vue new file mode 100644 index 00000000..f6cd76e8 --- /dev/null +++ b/resources/assets/vue/components/companies/forms/EInvoiceRequestFormComponent.vue @@ -0,0 +1,65 @@ + + + diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index 0c0e7bca..ece7adc6 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -58,12 +58,52 @@
+ +
+
+ + Submit E-Invoice Info + +
+
+
+
+ + View E-Invoice Info + +
+
Change Billing Address
+ + + + + + + + + +
@@ -90,6 +130,7 @@ required: true, } }, + data(){ return { section: 'orderListSection', @@ -100,7 +141,7 @@ computed: { pendingQueue () { return this.$store.getters.isInCompleteQueue(this.section); - } + }, }, watch: { pendingQueue(inComplete){ @@ -117,11 +158,31 @@ this.isLoading = true; this.submit(route('api.company.show', this.company_id), 'get', this.section, false, false) }, - successHandler(response){ + successHandler(response, section){ this.$store.dispatch('completeList', {'name': this.section, 'data': []}); this.isLoading = false; this.company = response.payload.data; - } + + if(this.company.company_module.e_invoice === null){ + this.$nextTick(() => { + $('#modal-einvoice-request').modal('show'); + }); + } + else if( this.company.company_module.e_invoice && (this.company.company_module.tin === null || this.company.company_module.msic_code === null) ) + { + this.$nextTick(() => { + $('#modal-einvoice-info').modal('show'); + }); + } + }, + errorHandler(error, statusCode, section) { //E-Invoice + if(section === this.section + 'CheckEInvoiceRule' && statusCode === 422){ + $('#modal-einvoice-info').modal('show'); + } + }, + updatedEInvoiceInfo(info){ + this.$store.dispatch('reloadList', {'name': this.section}); + }, } } diff --git a/resources/assets/vue/components/general/elements/ModalComponent.vue b/resources/assets/vue/components/general/elements/ModalComponent.vue index db0181fc..3424b988 100644 --- a/resources/assets/vue/components/general/elements/ModalComponent.vue +++ b/resources/assets/vue/components/general/elements/ModalComponent.vue @@ -1,5 +1,6 @@ @@ -24,7 +27,10 @@ minLength: 'this field must have at least', minValue: 'this field must at least be', sameAs: 'this field must match the', - numeric: 'this field can only contain numbers' + numeric: 'this field can only contain numbers', + maxValue: 'this value must not exceeds', + alphaNum: 'this value must be alphanumeric', + fiveDigits: 'this value must be exactly 5 digits', //custom }, } }, diff --git a/resources/assets/vue/components/orders/elements/OrderComponent.vue b/resources/assets/vue/components/orders/elements/OrderComponent.vue index ea18c931..4a67a1c1 100644 --- a/resources/assets/vue/components/orders/elements/OrderComponent.vue +++ b/resources/assets/vue/components/orders/elements/OrderComponent.vue @@ -102,7 +102,7 @@
@@ -145,10 +145,10 @@
- + - +
@@ -160,10 +160,18 @@ }, data(){ return { - expanded: false + expanded: false, + section: 'orderList' } }, methods: { + successHandler(response, section){ + if(section === this.section + 'CheckEInvoiceRule'){ + if(response.payload.data.isPassed){ + window.location.href = route('order.show', this.item.reference); + } + } + }, download(param) { let url = route('order.qr.download', param.id); if(window.LARAVEL_VAPOR_ENABLED){ @@ -185,6 +193,12 @@ window.open(url, '_blank'); } }, + checkEInvoiceRule(){ + this.parameters = { + company_module_id: this.item.company_module.id, + }; + this.submit(route('api.rule.check.einvoice'), 'post', this.section + 'CheckEInvoiceRule', false, true); + }, }, mixins: [componentHandler] } diff --git a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue new file mode 100644 index 00000000..f4dd6613 --- /dev/null +++ b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue @@ -0,0 +1,209 @@ + + diff --git a/resources/assets/vue/general/mixins/request.js b/resources/assets/vue/general/mixins/request.js index 13babef8..36e24753 100644 --- a/resources/assets/vue/general/mixins/request.js +++ b/resources/assets/vue/general/mixins/request.js @@ -18,11 +18,11 @@ export default { if(!success){ this.openModal(); errorNotification ? this.$store.dispatch('createNotification', {title: response.title, message: response.message, type: 'error'}): null; - this.errorHandler(response, statusCode); return; + this.errorHandler(response, statusCode, section); return; } successNotification ? this.$store.dispatch('createNotification', {title: response.title, message: response.message, type: 'success'}): null; - this.successHandler(response, section) + this.successHandler(response, section, this.parameters); }); diff --git a/routes/api.php b/routes/api.php index 5b419754..89749ee9 100644 --- a/routes/api.php +++ b/routes/api.php @@ -71,9 +71,11 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/help_menu.php'; require __DIR__ . '/permits_reminder.php'; - + require __DIR__ . '/job.php'; + require __DIR__ . '/rule.php'; + }); require __DIR__ . '/announcement.php'; diff --git a/routes/company.php b/routes/company.php index ad0ca9ee..2bafb203 100644 --- a/routes/company.php +++ b/routes/company.php @@ -1,6 +1,9 @@ 'company', 'as' => 'company.', 'namespace' => 'Companies'], function () { Route::get('/{id}/show', 'FetchCompanyController@fetch')->name('show'); @@ -39,4 +42,9 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani }); Route::get('/module/list', 'ListCompanyModulesController@list')->name('module.list'); + + Route::put('/details/update/{id}', [UpdateCompanyDetailsController::class, 'update'])->name('update.details'); + Route::get('/e-invoice/info/{id}', [FetchCompanyEInvoiceInfoController::class, 'fetch'])->name('einvoice.info'); + Route::post('/e-invoice/info/update', [UpdateCompanyEInvoiceInfoController::class, 'updateInfo'])->name('einvoice.info.update'); + Route::post('/e-invoice/request/update', [UpdateCompanyEInvoiceInfoController::class, 'updateRequest'])->name('einvoice.request.update'); }); diff --git a/routes/rule.php b/routes/rule.php new file mode 100644 index 00000000..6154c67b --- /dev/null +++ b/routes/rule.php @@ -0,0 +1,10 @@ +as('rule.') + ->group(function () { + Route::post('/check/eInvoice', [CheckRuleController::class, 'checkEInvoiceRule'])->name('check.einvoice'); + }); diff --git a/routes/web.php b/routes/web.php index 94909ea0..0164f7a3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -274,6 +274,13 @@ Route::get('/customer/{marking}/payment-and-billing', function ($marking) { Route::get('/customer-invoices/{company_module_id}/payment-and-billing', function ($company_module_id) { // todo-new: check company_module_id + $companyModule = CompanyModule::where('id', $company_module_id)->first(); + $isValid = $companyModule->company->e_invoice !== null; + + if (!$isValid) { + return redirect()->route('dashboard'); + } + return view('pages.customers.paymentsBilling', ['company_module_id' => $company_module_id]); })->name('customer.payment-and-billing-by-company-module-id'); From b4c239f8a9188842baf45f1017aba48dd16dfc86 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 20 Jun 2025 10:00:26 +0800 Subject: [PATCH 09/27] E-Invoice - Initial commit main feature integration --- .../CustomerProfileSectionComponent.vue | 22 ++++++++++--------- routes/web.php | 6 +++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index ece7adc6..3342adb5 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -163,16 +163,18 @@ this.isLoading = false; this.company = response.payload.data; - if(this.company.company_module.e_invoice === null){ - this.$nextTick(() => { - $('#modal-einvoice-request').modal('show'); - }); - } - else if( this.company.company_module.e_invoice && (this.company.company_module.tin === null || this.company.company_module.msic_code === null) ) - { - this.$nextTick(() => { - $('#modal-einvoice-info').modal('show'); - }); + if(!this.$store.getters.isAdmin){ + if(this.company.company_module.e_invoice === null){ + this.$nextTick(() => { + $('#modal-einvoice-request').modal('show'); + }); + } + else if( this.company.company_module.e_invoice && (this.company.company_module.tin === null || this.company.company_module.msic_code === null) ) + { + this.$nextTick(() => { + $('#modal-einvoice-info').modal('show'); + }); + } } }, errorHandler(error, statusCode, section) { //E-Invoice diff --git a/routes/web.php b/routes/web.php index 0164f7a3..fefce2ab 100644 --- a/routes/web.php +++ b/routes/web.php @@ -215,6 +215,12 @@ Route::get('/orders-table', function () { Route::get('/order/show/{order_number}', function (Illuminate\Http\Request $request, $orderNumber) { // return view('pages.orders.profile', ['id' => $orderNumber]); + $order = Order::where('reference', $orderNumber)->first(); + $isValid = $order->companyModule->company->e_invoice !== null; + if (!$isValid) { + return redirect()->route('dashboard'); + } + return view('pages.orders.profile_v2', [ 'id' => $orderNumber, 'q' => $request->query('q', null) From 8d0fba2d2191782eccc23dc8bfce4e52ec206abc Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 20 Jun 2025 10:40:46 +0800 Subject: [PATCH 10/27] E-Invoice - Initial commit main feature integration --- .../General/Eloquent/Filters/TypeNotIn.php | 20 +++++++++++++++++++ .../ControllersLogic/ListAddressesLogic.php | 8 ++++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/TypeNotIn.php diff --git a/app/Classes/General/Eloquent/Filters/TypeNotIn.php b/app/Classes/General/Eloquent/Filters/TypeNotIn.php new file mode 100644 index 00000000..87670503 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/TypeNotIn.php @@ -0,0 +1,20 @@ +whereNotIn('type', $value); + } + +} diff --git a/app/Classes/Modules/Addresses/ControllersLogic/ListAddressesLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/ListAddressesLogic.php index 71e3b80d..148f7f67 100644 --- a/app/Classes/Modules/Addresses/ControllersLogic/ListAddressesLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/ListAddressesLogic.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Addresses\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Addresses\Services\ListsAddresses; use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses; +use App\Classes\ValueObjects\Constants\AddressType; use App\Http\Resources\AddressResource; use ErrorException; use Illuminate\Http\JsonResponse; @@ -51,13 +52,12 @@ class ListAddressesLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - $this->canListAddresses->passes(); - $query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters'))); + //$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters'))); + $query = $this->listsAddresses->execute(array_merge($this->listsAddresses->deserializeFilters($request->input('filters')), ['type_not_in' => [AddressType::E_INVOICE]])); return $this->collectionResponse(AddressResource::collection($query)); - } -} \ No newline at end of file +} From 1d2eac806e84415c55571416e85a047e403e8239 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 20 Jun 2025 14:34:13 +0800 Subject: [PATCH 11/27] E-Invoice - Initial commit main feature integration --- .../Resources/AddressEInvoiceResource.php | 28 +++++++++++++++++++ app/Http/Resources/CompanyModuleResource.php | 3 +- app/Http/Resources/EInvoiceInfoResource.php | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 app/Http/Resources/AddressEInvoiceResource.php diff --git a/app/Http/Resources/AddressEInvoiceResource.php b/app/Http/Resources/AddressEInvoiceResource.php new file mode 100644 index 00000000..cbdabe17 --- /dev/null +++ b/app/Http/Resources/AddressEInvoiceResource.php @@ -0,0 +1,28 @@ + $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 + ]; + } +} diff --git a/app/Http/Resources/CompanyModuleResource.php b/app/Http/Resources/CompanyModuleResource.php index 1e54674e..f48cbc43 100644 --- a/app/Http/Resources/CompanyModuleResource.php +++ b/app/Http/Resources/CompanyModuleResource.php @@ -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, ]; } diff --git a/app/Http/Resources/EInvoiceInfoResource.php b/app/Http/Resources/EInvoiceInfoResource.php index 565e86a7..0037edff 100644 --- a/app/Http/Resources/EInvoiceInfoResource.php +++ b/app/Http/Resources/EInvoiceInfoResource.php @@ -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, From 2aabd07ec4d3ba25d9b7af1d119d3ba92a3bca81 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 26 Jun 2025 16:29:09 +0800 Subject: [PATCH 12/27] update /export/all-customers-info-for-lark-system, add Debtor Code --- .../Exports/Services/ExportsAllCustomersInfoForLarkSystem.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php index 6aae057d..19086f04 100644 --- a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php +++ b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php @@ -25,6 +25,7 @@ class ExportsAllCustomersInfoForLarkSystem implements FromQuery, WithMapping, Wi 'Email', 'Registration Date', 'Last Order Date', + 'Debtor Code', 'Custom Segments', ]; } @@ -68,6 +69,7 @@ class ExportsAllCustomersInfoForLarkSystem implements FromQuery, WithMapping, Wi $employeeEmail, $company->created_at ? $company->created_at->toDateString() : '', $company->updated_at ? $company->updated_at->toDateString() : '', + $company->debtor, $segments, ]; } From 79db1dedc9c8047166c660143e14506bdf90bc50 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 26 Jun 2025 17:45:13 +0800 Subject: [PATCH 13/27] update /export/all-customers-info-for-lark-system, add is credit term customer --- .../Services/ExportsAllCustomersInfoForLarkSystem.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php index 19086f04..40294a21 100644 --- a/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php +++ b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php @@ -26,6 +26,7 @@ class ExportsAllCustomersInfoForLarkSystem implements FromQuery, WithMapping, Wi 'Registration Date', 'Last Order Date', 'Debtor Code', + 'Credit Term Customer', 'Custom Segments', ]; } @@ -46,6 +47,10 @@ class ExportsAllCustomersInfoForLarkSystem implements FromQuery, WithMapping, Wi { $companyModule = $company->companyModules->first(); $marking = $companyModule ? $companyModule->getMarking() : ''; + $creditTermCustomer = ''; + if ($companyModule && $companyModule->connections->first()) { + $creditTermCustomer = $companyModule->connections->first()->is_credit_term ? 'YES' : 'NO'; + } $employeeEmail = ''; if ($companyModule && $companyModule->employees->first()) { @@ -70,6 +75,7 @@ class ExportsAllCustomersInfoForLarkSystem implements FromQuery, WithMapping, Wi $company->created_at ? $company->created_at->toDateString() : '', $company->updated_at ? $company->updated_at->toDateString() : '', $company->debtor, + $creditTermCustomer, $segments, ]; } From a9d4f3c83912caa3c1769c8bc49bcecb9db992fd Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 26 Jun 2025 20:04:11 +0800 Subject: [PATCH 14/27] E-Invo ice - Maintenance notice for normal user except admin --- app/Http/Kernel.php | 1 + app/Http/Middleware/EnsureUserIsAdmin.php | 28 +++++++++++ .../assets/vue/general/mixins/request.js | 5 ++ routes/api.php | 49 ++++++++++--------- routes/web.php | 5 ++ 5 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 app/Http/Middleware/EnsureUserIsAdmin.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index ea5a6e9d..ef039b85 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -75,5 +75,6 @@ class Kernel extends HttpKernel 'storage.invoice.check.bytransactions' => \App\Http\Middleware\CheckForStorageInvoiceByTransactions::class, 'storage.invoice.check.bygroup' => \App\Http\Middleware\CheckForStorageInvoiceByGroup::class, 'storage.invoice.check.bypackinglists' => \App\Http\Middleware\CheckForStorageInvoiceByPackingLists::class, + 'admin' => \App\Http\Middleware\EnsureUserIsAdmin::class, //cief todo: 90 - maintenance ]; } diff --git a/app/Http/Middleware/EnsureUserIsAdmin.php b/app/Http/Middleware/EnsureUserIsAdmin.php new file mode 100644 index 00000000..c9474b43 --- /dev/null +++ b/app/Http/Middleware/EnsureUserIsAdmin.php @@ -0,0 +1,28 @@ +authenticate(); + if(!in_array($user->type, RoleTypes::ADMIN_ROLES)){ + return response()->view('errors.503', [], 503); + } + return $next($request); + } +} diff --git a/resources/assets/vue/general/mixins/request.js b/resources/assets/vue/general/mixins/request.js index 13babef8..a1450175 100644 --- a/resources/assets/vue/general/mixins/request.js +++ b/resources/assets/vue/general/mixins/request.js @@ -13,6 +13,11 @@ export default { let statusCode = response.status, success = response.ok; + // console.log('statusCode: ' + statusCode); //cief todo: 90 - maintenance + if(statusCode == 503){ + window.location.href = '/maintenance'; + } + response.json().then(response => { if(!success){ diff --git a/routes/api.php b/routes/api.php index 5b419754..9d03d149 100644 --- a/routes/api.php +++ b/routes/api.php @@ -27,53 +27,54 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/feedback.php'; Route::group(['middleware' => 'valid.token'], function () { + Route::group(['middleware' => 'admin'], function () { //cief todo: 90 - maintenance - Route::get('/storage/{fileName}/fetch', 'Documents\RenderDocumentController@fileStorageServe')->where(['fileName' => '.*'])->name('storage.document.file'); + Route::get('/storage/{fileName}/fetch', 'Documents\RenderDocumentController@fileStorageServe')->where(['fileName' => '.*'])->name('storage.document.file'); - Route::post('online_payment/callback', 'Billplz\CallbackBillplzController@callback')->name('online_payment.callback'); + Route::post('online_payment/callback', 'Billplz\CallbackBillplzController@callback')->name('online_payment.callback'); - Route::post('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import')->name('debtor.import'); + Route::post('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import')->name('debtor.import'); - require __DIR__ . '/company.php'; + require __DIR__ . '/company.php'; - require __DIR__ . '/document.php'; + require __DIR__ . '/document.php'; - require __DIR__ . '/bank.php'; + require __DIR__ . '/bank.php'; - require __DIR__ . '/currency.php'; + require __DIR__ . '/currency.php'; - require __DIR__ . '/address.php'; + require __DIR__ . '/address.php'; - require __DIR__ . '/transaction.php'; + require __DIR__ . '/transaction.php'; - require __DIR__ . '/receipt.php'; + require __DIR__ . '/receipt.php'; - require __DIR__ . '/order.php'; + require __DIR__ . '/order.php'; - require __DIR__ . '/packing_list.php'; + require __DIR__ . '/packing_list.php'; - require __DIR__ . '/remark.php'; + require __DIR__ . '/remark.php'; - require __DIR__ . '/transport.php'; + require __DIR__ . '/transport.php'; - require __DIR__ . '/schedule.php'; + require __DIR__ . '/schedule.php'; - require __DIR__ . '/segment.php'; + require __DIR__ . '/segment.php'; - require __DIR__ . '/announcement.php'; + require __DIR__ . '/announcement.php'; - require __DIR__ . '/report.php'; + require __DIR__ . '/report.php'; - require __DIR__ . '/wallet.php'; + require __DIR__ . '/wallet.php'; - require __DIR__ . '/contact.php'; + require __DIR__ . '/contact.php'; - require __DIR__ . '/help_menu.php'; + require __DIR__ . '/help_menu.php'; - require __DIR__ . '/permits_reminder.php'; - - require __DIR__ . '/job.php'; + require __DIR__ . '/permits_reminder.php'; + require __DIR__ . '/job.php'; + }); }); require __DIR__ . '/announcement.php'; diff --git a/routes/web.php b/routes/web.php index 94909ea0..0934ba05 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1420,3 +1420,8 @@ Route::get('/group-transaction-with-completed-payments', function () { Route::get('/downloads', function () { return view('pages.downloads.index'); })->name('admin.downloads'); + + +Route::get('/maintenance', function () { + return response()->view('errors.503', [], 503); +}); From 82512bf4f6e6995f767b4026bcfd0d123c18e778 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 26 Jun 2025 23:13:17 +0800 Subject: [PATCH 15/27] E-Invoice - Sync some code fixes from Exchange to Shipping Portal --- .../Companies/DataTransferObjects/EInvoiceInfoDTO.php | 4 ++-- .../DataTransferObjects/UpdateCompanyDetailsDTO.php | 4 ++-- app/Http/Resources/EInvoiceInfoResource.php | 2 +- .../companies/elements/EInvoiceInfoComponent.vue | 2 +- .../companies/forms/EInvoiceInfoFormComponent.vue | 8 ++++---- .../forms/ChangeCustomerCompanyDetailsFormComponent.vue | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php index a9cf02f1..1a3220e7 100644 --- a/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php +++ b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php @@ -7,7 +7,7 @@ use App\Classes\General\Interfaces\DataTransferObject; class EInvoiceInfoDTO implements DataTransferObject { public string $tin; - public int $msicCode; + public string $msicCode; public int $districtId; public int $stateId; public int $companyModuleId; @@ -18,7 +18,7 @@ class EInvoiceInfoDTO implements DataTransferObject public function __construct(array $data) { $this->tin = (string) ($data['tin'] ?? ''); - $this->msicCode = (int) ($data['msic_code'] ?? 0); + $this->msicCode = (string) ($data['msic_code'] ?? ''); $this->districtId = (int) ($data['district_id'] ?? 0); $this->stateId = (int) ($data['state_id'] ?? 0); $this->companyModuleId = (int) ($data['company_module_id'] ?? 0); diff --git a/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php index e9a76434..0d8ce80e 100644 --- a/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php +++ b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php @@ -13,7 +13,7 @@ class UpdateCompanyDetailsDTO implements DataTransferObject public int $type; public string $tin; - public int $msicCode; + public string $msicCode; public int $addressId; public int $districtId; public int $stateId; @@ -31,7 +31,7 @@ class UpdateCompanyDetailsDTO implements DataTransferObject $this->type = (int) ($data['type'] ?? 0); $this->tin = (string) ($data['tin'] ?? 0); - $this->msicCode = (int) ($data['msic_code'] ?? 0); + $this->msicCode = (string) ($data['msic_code'] ?? ''); $this->addressId = (int) ($data['address_id'] ?? 0); $this->districtId = (int) ($data['district_id'] ?? 0); $this->stateId = (int) ($data['state_id'] ?? 0); diff --git a/app/Http/Resources/EInvoiceInfoResource.php b/app/Http/Resources/EInvoiceInfoResource.php index 0037edff..d183032c 100644 --- a/app/Http/Resources/EInvoiceInfoResource.php +++ b/app/Http/Resources/EInvoiceInfoResource.php @@ -23,7 +23,7 @@ class EInvoiceInfoResource extends JsonResource 'post_code' => (int) $this->postcode, 'country' => $this->country, 'billing' => (int) $this->billing, - 'msic_code' => (int) $this->msic_code, + 'msic_code' => (string) $this->msic_code, 'tin' => (string) $this->tin, 'e_invoice' => (int) $this->e_invoice, ]; diff --git a/resources/assets/vue/components/companies/elements/EInvoiceInfoComponent.vue b/resources/assets/vue/components/companies/elements/EInvoiceInfoComponent.vue index ef38aa8c..d58eb5eb 100644 --- a/resources/assets/vue/components/companies/elements/EInvoiceInfoComponent.vue +++ b/resources/assets/vue/components/companies/elements/EInvoiceInfoComponent.vue @@ -12,7 +12,7 @@

TIN

{{ eInvoiceData.tin }}

-
+

MSIC Code

{{ eInvoiceData.msic_code }}

diff --git a/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue b/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue index a4d53e4a..7813db1d 100644 --- a/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue @@ -18,7 +18,7 @@
- +
-
+

MSIC Code

{{parameters.msic_code}}

@@ -220,9 +220,9 @@ } : {}) }, - msic_code: { + msic_code: companyType === 1 ? { notZero, fiveDigits - } + }: {}, } } }, diff --git a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue index f4dd6613..daafd246 100644 --- a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue +++ b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue @@ -178,7 +178,7 @@ : {}) } : {}, - msic_code: isEInvoiceEnabled ? { + msic_code: isEInvoiceEnabled && companyType === 1 ? { notZero, fiveDigits }: {}, From 3913d3c738a47a871dae58a9f7dbfc50490b44d4 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 27 Jun 2025 00:26:14 +0800 Subject: [PATCH 16/27] E-Invoice - Remove outdated code --- routes/web.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/routes/web.php b/routes/web.php index fefce2ab..9e635e4b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -215,11 +215,11 @@ Route::get('/orders-table', function () { Route::get('/order/show/{order_number}', function (Illuminate\Http\Request $request, $orderNumber) { // return view('pages.orders.profile', ['id' => $orderNumber]); - $order = Order::where('reference', $orderNumber)->first(); - $isValid = $order->companyModule->company->e_invoice !== null; - if (!$isValid) { - return redirect()->route('dashboard'); - } + // $order = Order::where('reference', $orderNumber)->first(); + // $isValid = $order->companyModule->company->e_invoice !== null; + // if (!$isValid) { + // return redirect()->route('dashboard'); + // } return view('pages.orders.profile_v2', [ 'id' => $orderNumber, @@ -280,12 +280,12 @@ Route::get('/customer/{marking}/payment-and-billing', function ($marking) { Route::get('/customer-invoices/{company_module_id}/payment-and-billing', function ($company_module_id) { // todo-new: check company_module_id - $companyModule = CompanyModule::where('id', $company_module_id)->first(); - $isValid = $companyModule->company->e_invoice !== null; + // $companyModule = CompanyModule::where('id', $company_module_id)->first(); + // $isValid = $companyModule->company->e_invoice !== null; - if (!$isValid) { - return redirect()->route('dashboard'); - } + // if (!$isValid) { + // return redirect()->route('dashboard'); + // } return view('pages.customers.paymentsBilling', ['company_module_id' => $company_module_id]); })->name('customer.payment-and-billing-by-company-module-id'); From 6d12f2d2393226c455fe5f285aa96d8c0b21241b Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 27 Jun 2025 00:34:14 +0800 Subject: [PATCH 17/27] E-Invoice - Allow admin to view order without triggering rule checking --- .../components/orders/elements/OrderComponent.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/assets/vue/components/orders/elements/OrderComponent.vue b/resources/assets/vue/components/orders/elements/OrderComponent.vue index 4a67a1c1..11ed9f17 100644 --- a/resources/assets/vue/components/orders/elements/OrderComponent.vue +++ b/resources/assets/vue/components/orders/elements/OrderComponent.vue @@ -194,10 +194,15 @@ } }, checkEInvoiceRule(){ - this.parameters = { - company_module_id: this.item.company_module.id, - }; - this.submit(route('api.rule.check.einvoice'), 'post', this.section + 'CheckEInvoiceRule', false, true); + if(!this.$store.getters.isAdmin){ + this.parameters = { + company_module_id: this.item.company_module.id, + }; + this.submit(route('api.rule.check.einvoice'), 'post', this.section + 'CheckEInvoiceRule', false, true); + } + else{ + window.location.href = route('order.show', this.item.reference); + } }, }, mixins: [componentHandler] From 273f81f9a817617d9ae868036afdb76a92e5ad3e Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 27 Jun 2025 12:25:09 +0800 Subject: [PATCH 18/27] E-Invoice - Updated maintenance message --- .env.example | 4 ++++ config/maintenance.php | 6 ++++++ resources/views/errors/503.blade.php | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 config/maintenance.php diff --git a/.env.example b/.env.example index ae852c04..47f16055 100644 --- a/.env.example +++ b/.env.example @@ -66,3 +66,7 @@ COMMANDS_V2_ENABLED=false STORAGE_FEE_LAUNCH_DATE="2023-12-11 00:00:00" SST_START_DATE="2024-04-01 00:00:00" + +E_INVOICE_START_DATE="2025-07-01 00:00:00" +MAINTENANCE_MESSAGE_TITLE="We'll be back online on 00:00 1/7/2025" +MAINTENANCE_MESSAGE="Sorry for the inconvenience but we're performing some maintenance at the moment." diff --git a/config/maintenance.php b/config/maintenance.php new file mode 100644 index 00000000..7ac7d65a --- /dev/null +++ b/config/maintenance.php @@ -0,0 +1,6 @@ + env('MAINTENANCE_MESSAGE_TITLE', "We'll be back soon!"), + 'message' => env('MAINTENANCE_MESSAGE', "Sorry for the inconvenience but we're performing some maintenance at the moment. We'll be back online shortly!"), +]; diff --git a/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php index f184d0c1..d8043a61 100644 --- a/resources/views/errors/503.blade.php +++ b/resources/views/errors/503.blade.php @@ -22,8 +22,8 @@
-

We'll be back soon!

-

Sorry for the inconvenience but we're performing some maintenance at the moment. We'll be back online shortly!

+

{{ config('maintenance.title') }}

+

{{ config('maintenance.message') }}

— CIEF IZYIM

From c564a8ed7066cb5746a41016a39ec928e2dbf018 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 27 Jun 2025 12:46:18 +0800 Subject: [PATCH 19/27] E-Invoice - Updated maintenance message --- config/maintenance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/maintenance.php b/config/maintenance.php index 7ac7d65a..66376756 100644 --- a/config/maintenance.php +++ b/config/maintenance.php @@ -2,5 +2,5 @@ return [ 'title' => env('MAINTENANCE_MESSAGE_TITLE', "We'll be back soon!"), - 'message' => env('MAINTENANCE_MESSAGE', "Sorry for the inconvenience but we're performing some maintenance at the moment. We'll be back online shortly!"), + 'message' => env('MAINTENANCE_MESSAGE', "Sorry for the inconvenience but we're performing some maintenance at the moment."), ]; From 6911eba11927ba4216d1875f35a4630a8568bfd3 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 27 Jun 2025 12:52:05 +0800 Subject: [PATCH 20/27] E-Invoice - Updated maintenance message --- resources/views/errors/503.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php index d8043a61..54e11d89 100644 --- a/resources/views/errors/503.blade.php +++ b/resources/views/errors/503.blade.php @@ -23,6 +23,7 @@

{{ config('maintenance.title') }}

+ Maintenance

{{ config('maintenance.message') }}

— CIEF IZYIM

From 63902e9266c6bf54e4358dd4511164890b29fa7b Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 28 Jun 2025 13:45:24 +0800 Subject: [PATCH 21/27] E-Invoice - Allow admin to update E-Invoice info on behalf of customer --- .../sections/CustomerProfileSectionComponent.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index 3342adb5..3d1b988c 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -176,6 +176,14 @@ }); } } + else{ + if( this.company.company_module.e_invoice && (this.company.company_module.tin === null || this.company.company_module.msic_code === null) ) + { + this.$nextTick(() => { + $('#modal-einvoice-info').modal('show'); + }); + } + } }, errorHandler(error, statusCode, section) { //E-Invoice if(section === this.section + 'CheckEInvoiceRule' && statusCode === 422){ From f56548efa72103ba4ae78ca500c8492d8435bc47 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 28 Jun 2025 15:30:16 +0800 Subject: [PATCH 22/27] E-Invoice - Minor amendment requested by Harry on TIN length validation --- .../components/companies/forms/EInvoiceInfoFormComponent.vue | 4 ++-- .../vue/components/general/forms/ValidationErrorComponent.vue | 2 ++ .../forms/ChangeCustomerCompanyDetailsFormComponent.vue | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue b/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue index 7813db1d..c7cd3fec 100644 --- a/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue @@ -207,7 +207,7 @@ ? { required, alphaNum, - minLength: minLength(11), + minLength: minLength(10), //was 11 maxLength: maxLength(13) } : {}), @@ -216,7 +216,7 @@ required, alphaNum, minLength: minLength(10), - maxLength: maxLength(12) + maxLength: maxLength(13) ///was 12 } : {}) }, diff --git a/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue b/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue index bfa04a92..83690ed8 100644 --- a/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue +++ b/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue @@ -3,6 +3,7 @@ {{errorMessages[param]}} {{object.min}} characters + {{object.max}} characters {{object.eq}} field {{object.min}} {{errorMessages[param]}} {{object.max}} @@ -25,6 +26,7 @@ required: 'this field is required', email: 'enter a valid email address', minLength: 'this field must have at least', + maxLength: 'this field must not exceed', minValue: 'this field must at least be', sameAs: 'this field must match the', numeric: 'this field can only contain numbers', diff --git a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue index daafd246..90c4511e 100644 --- a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue +++ b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue @@ -164,7 +164,7 @@ ? { required, alphaNum, - minLength: minLength(11), + minLength: minLength(10), //was 11 maxLength: maxLength(13) } : {}), @@ -173,7 +173,7 @@ required, alphaNum, minLength: minLength(10), - maxLength: maxLength(12) + maxLength: maxLength(13) //was 12 } : {}) } From c37ed89a7339f9846500d49af39066ea79e8b8fe Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 28 Jun 2025 15:57:09 +0800 Subject: [PATCH 23/27] E-Invoice - Minor amendment requested by Harry on TIN length validation --- .../vue/components/general/forms/ValidationErrorComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue b/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue index 83690ed8..231668c1 100644 --- a/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue +++ b/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue @@ -26,7 +26,7 @@ required: 'this field is required', email: 'enter a valid email address', minLength: 'this field must have at least', - maxLength: 'this field must not exceed', + maxLength: 'this field must have at most', minValue: 'this field must at least be', sameAs: 'this field must match the', numeric: 'this field can only contain numbers', From b417ba074e67dd93bc66f7dd7c8c4150f1043660 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 29 Jun 2025 16:22:15 +0800 Subject: [PATCH 24/27] E-Invoice - Sin Yee request for einvoice postcode need to able to input starting with 0, e.g. 02600 --- .../Addresses/DataTransferObjects/AddressObject.php | 12 ++++++------ .../DataTransferObjects/EInvoiceInfoDTO.php | 4 ++-- .../DataTransferObjects/UpdateCompanyDetailsDTO.php | 4 ++-- app/Http/Resources/AddressEInvoiceResource.php | 2 +- app/Http/Resources/EInvoiceInfoResource.php | 2 +- .../companies/forms/EInvoiceInfoFormComponent.vue | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php b/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php index f1d79e53..7c6ae8b0 100644 --- a/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php +++ b/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php @@ -23,7 +23,7 @@ class AddressObject implements DataTransferObject /** @var int */ private $districtId; - /** @var int */ + /** @var string */ private $postCode; /** @var int */ @@ -42,12 +42,12 @@ class AddressObject implements DataTransferObject * @param int $countryId * @param int $stateId * @param int $districtId - * @param int $postCode + * @param string $postCode * @param int $type * @param int $status * @param null|string $reference */ - public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, int $type, int $status, ?string $reference = null) + public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, string $postCode, int $type, int $status, ?string $reference = null) { $this->streetOne = $streetOne; $this->streetTwo = $streetTwo; @@ -101,9 +101,9 @@ class AddressObject implements DataTransferObject } /** - * @return int + * @return string */ - public function getPostCode(): int + public function getPostCode(): string { return $this->postCode; } @@ -133,4 +133,4 @@ class AddressObject implements DataTransferObject } -} \ No newline at end of file +} diff --git a/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php index 1a3220e7..15c105aa 100644 --- a/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php +++ b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php @@ -13,7 +13,7 @@ class EInvoiceInfoDTO implements DataTransferObject public int $companyModuleId; public string $streetOne; public string $streetTwo; - public int $postCode; + public string $postCode; public function __construct(array $data) { @@ -24,7 +24,7 @@ class EInvoiceInfoDTO implements DataTransferObject $this->companyModuleId = (int) ($data['company_module_id'] ?? 0); $this->streetOne = (string) ($data['street_one'] ?? ''); $this->streetTwo = (string) ($data['street_two'] ?? ''); - $this->postCode = (int) ($data['post_code'] ?? 0); + $this->postCode = (string) ($data['post_code'] ?? ''); } public function toArray(): array diff --git a/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php index 0d8ce80e..d77019ef 100644 --- a/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php +++ b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php @@ -20,7 +20,7 @@ class UpdateCompanyDetailsDTO implements DataTransferObject public int $companyId; public string $streetOne; public string $streetTwo; - public int $postCode; + public string $postCode; public function __construct(array $data) { @@ -38,7 +38,7 @@ class UpdateCompanyDetailsDTO implements DataTransferObject $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'] ?? 0); + $this->postCode = (string) ($data['post_code'] ?? 0); } public function toArray(): array diff --git a/app/Http/Resources/AddressEInvoiceResource.php b/app/Http/Resources/AddressEInvoiceResource.php index cbdabe17..d6e49801 100644 --- a/app/Http/Resources/AddressEInvoiceResource.php +++ b/app/Http/Resources/AddressEInvoiceResource.php @@ -20,7 +20,7 @@ class AddressEInvoiceResource extends JsonResource 'street_two' => $this->street_two, 'district' => $this->district, 'state' => $this->state, - 'post_code' => (int) $this->postcode, + 'post_code' => (string) $this->postcode, 'country' => $this->country, 'billing' => (int) $this->billing ]; diff --git a/app/Http/Resources/EInvoiceInfoResource.php b/app/Http/Resources/EInvoiceInfoResource.php index d183032c..97483dd3 100644 --- a/app/Http/Resources/EInvoiceInfoResource.php +++ b/app/Http/Resources/EInvoiceInfoResource.php @@ -20,7 +20,7 @@ class EInvoiceInfoResource extends JsonResource 'street_two' => $this->street_two, 'district' => $this->district, 'state' => $this->state, - 'post_code' => (int) $this->postcode, + 'post_code' => (string) $this->postcode, 'country' => $this->country, 'billing' => (int) $this->billing, 'msic_code' => (string) $this->msic_code, diff --git a/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue b/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue index c7cd3fec..b5289ac8 100644 --- a/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/EInvoiceInfoFormComponent.vue @@ -54,7 +54,7 @@
- + From da7843c5df0829bb08d749e98d6b38ab6fd89d02 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 30 Jun 2025 00:45:41 +0800 Subject: [PATCH 25/27] E-Invoice - Sin Yee requestion for ability for admin to edit SSM Registration and Identification Card --- .../UpdateCompanyDetailsLogic.php | 24 +++++++++++++++++-- .../UpdateCompanyDetailsDTO.php | 10 +++++++- ...ngeCustomerCompanyDetailsFormComponent.vue | 15 +++++++++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php index fe1c2c23..599d770f 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php @@ -8,6 +8,8 @@ use App\Classes\Modules\Companies\Services\UpdatesCompanyDebtor; use App\Classes\Modules\Addresses\Services\UpsertsAddress; use App\Classes\Modules\Addresses\Services\FetchesDistrict; use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleName; +use App\Classes\Modules\Documents\Services\FetchesDocument; +use App\Classes\Modules\Documents\Services\UpdatesDocumentReference; use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress; use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject; use App\Classes\Modules\Companies\Services\UpdatesCompanyEInvoiceInfo; @@ -59,6 +61,12 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic /** @var UpdatesCompanyModuleName */ private $updatesCompanyModuleName; + /** @var FetchesDocument */ + private $fetchesDocument; + + /** @var UpdatesDocumentReference */ + private $updatesDocumentReference; + /** * UpdateCompanyDetailsLogic constructor. * @param CanUpdateCompany $canUpdateCompany @@ -69,7 +77,9 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic * @param FetchesDistrict $fetchesDistrict * @param UpsertsAddress $upsertsAddress * @param UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo; - * @param UpdatesCompanyModuleName $updatesCompanyModuleName + * @param FetchesDocument $fetchesDocument + * @param UpdatesDocumentReference $updatesDocumentReference + * */ public function __construct( CanUpdateCompany $canUpdateCompany, @@ -80,7 +90,9 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic FetchesDistrict $fetchesDistrict, UpsertsAddress $upsertsAddress, UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo, - UpdatesCompanyModuleName $updatesCompanyModuleName + UpdatesCompanyModuleName $updatesCompanyModuleName, + FetchesDocument $fetchesDocument, + UpdatesDocumentReference $updatesDocumentReference ) { $this->canUpdateCompany = $canUpdateCompany; @@ -92,6 +104,8 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic $this->upsertsAddress = $upsertsAddress; $this->updatesCompanyEInvoiceInfo = $updatesCompanyEInvoiceInfo; $this->updatesCompanyModuleName = $updatesCompanyModuleName; + $this->fetchesDocument = $fetchesDocument; + $this->updatesDocumentReference = $updatesDocumentReference; } /** @@ -127,6 +141,12 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic $this->updatesCompanyEInvoiceInfo->execute($company, $dto->tin, $dto->msicCode); } + //Update Identification Card / SSM Registration + if($dto->identificationId){ + $document = $this->fetchesDocument->execute(['id' => $dto->identificationId]); + $this->updatesDocumentReference->execute($document, $dto->identificationReference); + } + return $this->resourceResponse(new CompanyResource($company)); } } diff --git a/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php index d77019ef..beae10bd 100644 --- a/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php +++ b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php @@ -22,6 +22,9 @@ class UpdateCompanyDetailsDTO implements DataTransferObject public string $streetTwo; public string $postCode; + public string $identificationReference; + public int $identificationId; + public function __construct(array $data) { $this->id = (int) ($data['id'] ?? 0); @@ -38,7 +41,9 @@ class UpdateCompanyDetailsDTO implements DataTransferObject $this->companyId = (int) ($data['company_id'] ?? 0); $this->streetOne = (string) ($data['street_one'] ?? ''); $this->streetTwo = (string) ($data['street_two'] ?? ''); - $this->postCode = (string) ($data['post_code'] ?? 0); + $this->postCode = (string) ($data['post_code'] ?? ''); + $this->identificationReference = (string) ($data['identification_reference'] ?? ''); + $this->identificationId = (int) ($data['identification_id'] ?? 0); } public function toArray(): array @@ -59,6 +64,9 @@ class UpdateCompanyDetailsDTO implements DataTransferObject 'street_one' => $this->streetOne, 'street_two' => $this->streetTwo, 'post_code' => $this->postCode, + + 'identification_reference' => $this->identificationReference, + 'identification_id' => $this->identificationId, ]; } } diff --git a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue index 90c4511e..17df6bbe 100644 --- a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue +++ b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue @@ -30,6 +30,16 @@
Company
Business
+ +
+
+ + + + +
+
+
E-Invoice Info @@ -142,6 +152,8 @@ district_id: this.data.company_module.address_einvoice ? this.data.company_module.address_einvoice.district.id : null, state_id: this.data.company_module.address_einvoice ? this.data.company_module.address_einvoice.state.id : null, post_code: this.data.company_module.address_einvoice ? this.data.company_module.address_einvoice.post_code : null, + identification_id: this.data.identification ? this.data.identification.id : null, + identification_reference: this.data.identification ? this.data.identification.reference : null, } }; }, @@ -188,12 +200,13 @@ district_id: isEInvoiceEnabled ? { required } : {}, state_id: isEInvoiceEnabled ? { required } : {}, post_code: isEInvoiceEnabled ? { required, notZero } : {}, - + identification_reference: this.data.identification ? { required } : {}, } } }, methods: { successHandler(response) { + this.$store.dispatch('reloadList', {'name': 'orderListSection'}); this.closeModal(); }, submitForm() { From c64f6f5da501fce4ee89fe160f3db5d53140802d Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 30 Jun 2025 15:46:09 +0800 Subject: [PATCH 26/27] E-Invoice - Sin Yee requestion for ability for admin to edit SSM Registration and Identification Card --- .../orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue index 17df6bbe..3dae5b1c 100644 --- a/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue +++ b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue @@ -95,7 +95,7 @@
- +
From d97796d885a0b0d5fffff6249fa4776ed72bba85 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 30 Jun 2025 23:33:05 +0800 Subject: [PATCH 27/27] E-Invoice - Disable maintenance page for normal user --- app/Http/Middleware/EnsureUserIsAdmin.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Http/Middleware/EnsureUserIsAdmin.php b/app/Http/Middleware/EnsureUserIsAdmin.php index c9474b43..4dcd5225 100644 --- a/app/Http/Middleware/EnsureUserIsAdmin.php +++ b/app/Http/Middleware/EnsureUserIsAdmin.php @@ -19,10 +19,14 @@ class EnsureUserIsAdmin */ public function handle(Request $request, Closure $next) { - $user = JWTAuth::parseToken()->authenticate(); - if(!in_array($user->type, RoleTypes::ADMIN_ROLES)){ - return response()->view('errors.503', [], 503); + $maintenanceTitle = env('MAINTENANCE_MESSAGE_TITLE', null); + if (!empty($maintenanceTitle)) { + $user = JWTAuth::parseToken()->authenticate(); + if(!in_array($user->type, RoleTypes::ADMIN_ROLES)){ + return response()->view('errors.503', [], 503); + } } + return $next($request); } }