diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php index 6b08aad5..dea2b21c 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDetailsLogic.php @@ -9,6 +9,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\Addresses\Services\UpdatesAddressMetadata; +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; @@ -57,6 +59,12 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic /** @var UpdatesAddressMetadata */ private $updatesAddressMetadata; + /** @var FetchesDocument */ + private $fetchesDocument; + + /** @var UpdatesDocumentReference */ + private $updatesDocumentReference; + /** * UpdateCompanyDetailsLogic constructor. @@ -70,6 +78,9 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic * @param UpsertsAddress $upsertsAddress * @param UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo; * @param UpdatesAddressMetadata $updatesAddressMetadata + * @param FetchesDocument $fetchesDocument + * @param UpdatesDocumentReference $updatesDocumentReference + * */ public function __construct( CanUpdateCompany $canUpdateCompany, @@ -80,7 +91,9 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic FetchesDistrict $fetchesDistrict, UpsertsAddress $upsertsAddress, UpdatesCompanyEInvoiceInfo $updatesCompanyEInvoiceInfo, - UpdatesAddressMetadata $updatesAddressMetadata + UpdatesAddressMetadata $updatesAddressMetadata, + FetchesDocument $fetchesDocument, + UpdatesDocumentReference $updatesDocumentReference ) { $this->canUpdateCompany = $canUpdateCompany; @@ -93,6 +106,8 @@ class UpdateCompanyDetailsLogic extends AbstractControllerLogic $this->upsertsAddress = $upsertsAddress; $this->updatesCompanyEInvoiceInfo = $updatesCompanyEInvoiceInfo; $this->updatesAddressMetadata = $updatesAddressMetadata; + $this->fetchesDocument = $fetchesDocument; + $this->updatesDocumentReference = $updatesDocumentReference; } /** @@ -126,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/EInvoiceInfoDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/EInvoiceInfoDTO.php index 02779898..0fa91ba7 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 $companyId; 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->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/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php index 0d8ce80e..35cfb61d 100644 --- a/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php +++ b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php @@ -20,7 +20,10 @@ class UpdateCompanyDetailsDTO implements DataTransferObject public int $companyId; public string $streetOne; public string $streetTwo; - public int $postCode; + public string $postCode; + + public string $identificationReference; + public int $identificationId; public function __construct(array $data) { @@ -30,7 +33,7 @@ class UpdateCompanyDetailsDTO implements DataTransferObject $this->reference = (string) ($data['reference'] ?? ''); $this->type = (int) ($data['type'] ?? 0); - $this->tin = (string) ($data['tin'] ?? 0); + $this->tin = (string) ($data['tin'] ?? ''); $this->msicCode = (string) ($data['msic_code'] ?? ''); $this->addressId = (int) ($data['address_id'] ?? 0); $this->districtId = (int) ($data['district_id'] ?? 0); @@ -38,7 +41,10 @@ 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'] ?? ''); + + $this->identificationReference = (string) ($data['identification_reference'] ?? ''); + $this->identificationId = (int) ($data['identification_id'] ?? 0); } public function toArray(): array @@ -59,6 +65,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/app/Http/Middleware/EnsureUserIsAdmin.php b/app/Http/Middleware/EnsureUserIsAdmin.php index a3450eac..18949d20 100644 --- a/app/Http/Middleware/EnsureUserIsAdmin.php +++ b/app/Http/Middleware/EnsureUserIsAdmin.php @@ -18,10 +18,13 @@ 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); } } 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/address/forms/EInvoiceInfoFormComponent.vue b/resources/assets/vue/components/address/forms/EInvoiceInfoFormComponent.vue index 7722e33e..d10f1818 100644 --- a/resources/assets/vue/components/address/forms/EInvoiceInfoFormComponent.vue +++ b/resources/assets/vue/components/address/forms/EInvoiceInfoFormComponent.vue @@ -53,7 +53,7 @@