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/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 @@ +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 +} 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/Addresses/Services/UpsertsAddress.php b/app/Classes/Modules/Addresses/Services/UpsertsAddress.php new file mode 100644 index 00000000..08bc26d4 --- /dev/null +++ b/app/Classes/Modules/Addresses/Services/UpsertsAddress.php @@ -0,0 +1,40 @@ +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..599d770f --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php @@ -0,0 +1,153 @@ + '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; + + /** @var FetchesDocument */ + private $fetchesDocument; + + /** @var UpdatesDocumentReference */ + private $updatesDocumentReference; + + /** + * 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 FetchesDocument $fetchesDocument + * @param UpdatesDocumentReference $updatesDocumentReference + * + */ + public function __construct( + CanUpdateCompany $canUpdateCompany, + UpdatesCompany $updatesCompany, + FetchesCompany $fetchesCompany, + UpdatesCompanyDebtor $updatesCompanyDebtor, + CanCreateAddress $canCreateAddress, + FetchesDistrict $fetchesDistrict, + UpsertsAddress $upsertsAddress, + UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo, + UpdatesCompanyModuleName $updatesCompanyModuleName, + FetchesDocument $fetchesDocument, + UpdatesDocumentReference $updatesDocumentReference + ) + { + $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; + $this->fetchesDocument = $fetchesDocument; + $this->updatesDocumentReference = $updatesDocumentReference; + } + + /** + * @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); + } + + //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/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..15c105aa --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php @@ -0,0 +1,43 @@ +tin = (string) ($data['tin'] ?? ''); + $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); + $this->streetOne = (string) ($data['street_one'] ?? ''); + $this->streetTwo = (string) ($data['street_two'] ?? ''); + $this->postCode = (string) ($data['post_code'] ?? ''); + } + + 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..beae10bd --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php @@ -0,0 +1,72 @@ +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 = (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); + $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'] ?? ''); + $this->identificationReference = (string) ($data['identification_reference'] ?? ''); + $this->identificationId = (int) ($data['identification_id'] ?? 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, + + 'identification_reference' => $this->identificationReference, + 'identification_id' => $this->identificationId, + ]; + } +} 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/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php b/app/Classes/Modules/Exports/Services/ExportsAllCustomersInfoForLarkSystem.php index c76f36f5..40294a21 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 @@ -25,33 +25,58 @@ class ExportsAllCustomersInfoForLarkSystem implements WithHeadings, WithHeadingR 'Email', 'Registration Date', 'Last Order Date', + 'Debtor Code', + 'Credit Term Customer', 'Custom Segments', ]; } 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(); + $companyModule = $company->companyModules->first(); + $marking = $companyModule ? $companyModule->getMarking() : ''; + $creditTermCustomer = ''; + if ($companyModule && $companyModule->connections->first()) { + $creditTermCustomer = $companyModule->connections->first()->is_credit_term ? 'YES' : 'NO'; + } - $data = [ + $employeeEmail = ''; + if ($companyModule && $companyModule->employees->first()) { + $employeeEmail = $companyModule->employees->first()->email; + } + + $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, - $company->contacts()->first()->phone ?? '', - $employees?->email ?? '', - $company->created_at, - $company->updated_at, - $company_module->connections()->first()->segments()->pluck('name')->implode(', ') + $contactPhone, + $employeeEmail, + $company->created_at ? $company->created_at->toDateString() : '', + $company->updated_at ? $company->updated_at->toDateString() : '', + $company->debtor, + $creditTermCustomer, + $segments, ]; - - return $data; } } 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/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/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/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..4dcd5225 --- /dev/null +++ b/app/Http/Middleware/EnsureUserIsAdmin.php @@ -0,0 +1,32 @@ +authenticate(); + if(!in_array($user->type, RoleTypes::ADMIN_ROLES)){ + return response()->view('errors.503', [], 503); + } + } + + return $next($request); + } +} diff --git a/app/Http/Resources/AddressEInvoiceResource.php b/app/Http/Resources/AddressEInvoiceResource.php new file mode 100644 index 00000000..d6e49801 --- /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' => (string) $this->postcode, + 'country' => $this->country, + 'billing' => (int) $this->billing + ]; + } +} diff --git a/app/Http/Resources/CompanyModuleResource.php b/app/Http/Resources/CompanyModuleResource.php index 5ffc40f8..f48cbc43 100644 --- a/app/Http/Resources/CompanyModuleResource.php +++ b/app/Http/Resources/CompanyModuleResource.php @@ -51,6 +51,10 @@ 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 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 new file mode 100644 index 00000000..97483dd3 --- /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' => (string) $this->postcode, + 'country' => $this->country, + 'billing' => (int) $this->billing, + 'msic_code' => (string) $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/config/maintenance.php b/config/maintenance.php new file mode 100644 index 00000000..66376756 --- /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."), +]; 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..d58eb5eb --- /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..b5289ac8 --- /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..3d1b988c 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,41 @@ 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.$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'); + }); + } + } + 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 @@ @@ -22,9 +26,13 @@ required: 'this field is required', email: 'enter a valid email address', minLength: 'this field must have at least', + 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' + 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..11ed9f17 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,17 @@ window.open(url, '_blank'); } }, + checkEInvoiceRule(){ + 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] } 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..3dae5b1c --- /dev/null +++ b/resources/assets/vue/components/orders/forms/ChangeCustomerCompanyDetailsFormComponent.vue @@ -0,0 +1,222 @@ + + diff --git a/resources/assets/vue/general/mixins/request.js b/resources/assets/vue/general/mixins/request.js index 13babef8..9370ce3e 100644 --- a/resources/assets/vue/general/mixins/request.js +++ b/resources/assets/vue/general/mixins/request.js @@ -13,16 +13,21 @@ 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){ 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/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php index f184d0c1..54e11d89 100644 --- a/resources/views/errors/503.blade.php +++ b/resources/views/errors/503.blade.php @@ -22,8 +22,9 @@
-

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') }}

+ Maintenance +

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

— CIEF IZYIM

diff --git a/resources/views/pages/downloads/index.blade.php b/resources/views/pages/downloads/index.blade.php index bee9a3b1..e2f42ada 100644 --- a/resources/views/pages/downloads/index.blade.php +++ b/resources/views/pages/downloads/index.blade.php @@ -158,5 +158,21 @@ +
+

Customer Downloads

+
+
+
+
+ shipping_all_customers_info_for_lark_system.xls + + Download + +
+
+
+
+
+ @endsection diff --git a/routes/api.php b/routes/api.php index 5b419754..5c78a00b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -27,53 +27,56 @@ 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__ . '/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..369675d6 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) @@ -274,6 +280,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'); @@ -1420,3 +1433,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); +});