if billing address is null, when update e invoice details, add billing address

This commit is contained in:
Edmond Lang
2025-07-24 21:49:24 +08:00
parent 549bf98725
commit 42e6e82df8
@@ -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);