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/UpdateCompanyDetailsDTO.php b/app/Classes/Modules/Companies/DataTransferObjects/UpdateCompanyDetailsDTO.php index d77019ef..35cfb61d 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); @@ -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 = (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 +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/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue b/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue index f241c8af..1f625f68 100644 --- a/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue +++ b/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue @@ -36,9 +36,13 @@