diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php index 319fa1a2..d0b0b863 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php @@ -101,6 +101,13 @@ class UpdateCompanyEInvoiceInfoLogic extends AbstractControllerLogic $companyModule = $this->fetchesCompanyModule->execute(['id' => $dto->companyModuleId]); $this->createsAddress->execute($companyModule, $object); + // create billing address if not exists + $billingAddress = $companyModule->addresses->where('type', AddressType::BILLING)->where('status', ApprovalStatus::APPROVED)->first(); + if (!$billingAddress) { + $billingAddress = new AddressObject($dto->streetOne, $dto->streetTwo, $district->country_id, $dto->stateId, $district->id, $dto->postCode, AddressType::BILLING, ApprovalStatus::APPROVED, 'Billing Address'); + $this->createsAddress->execute($companyModule, $billingAddress); + } + //Update tin, msic code $this->updatesCompanyEInvoiceInfo->execute($companyModule->company, $dto->tin, $dto->msicCode);