From 42e6e82df8beabf9cfcb2db9d27583f545124a00 Mon Sep 17 00:00:00 2001 From: Edmond Lang Date: Thu, 24 Jul 2025 21:49:24 +0800 Subject: [PATCH] if billing address is null, when update e invoice details, add billing address --- .../ControllersLogic/UpdateCompanyEInvoiceInfoLogic.php | 7 +++++++ 1 file changed, 7 insertions(+) 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);