From fab05569d491b15efeea9cd961160d334a319a98 Mon Sep 17 00:00:00 2001 From: ghost2023 Date: Tue, 23 Jun 2026 10:03:54 +0300 Subject: [PATCH] fix --- .../modules/companies/companies.service.ts | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/apps/edr-freight-api/src/modules/companies/companies.service.ts b/apps/edr-freight-api/src/modules/companies/companies.service.ts index 50bfe8d75..a4466efb2 100644 --- a/apps/edr-freight-api/src/modules/companies/companies.service.ts +++ b/apps/edr-freight-api/src/modules/companies/companies.service.ts @@ -116,7 +116,7 @@ export class CompaniesService { jobTitle: dto.jobTitle ?? null, isPrimaryContact: dto.isPrimaryContact ?? true, activeProfileType, - onboardingStep: 'company', + onboardingStep: "company", }); // Persist the operational role(s) chosen during onboarding. Types are @@ -158,6 +158,8 @@ export class CompaniesService { async getCompanyStats(): Promise { return this.companiesRepo.getStats(); + } + /** * Begin onboarding: create a DRAFT company + the user's external profile + the * chosen operational role(s) up front, so every subsequent wizard step can @@ -263,7 +265,10 @@ export class CompaniesService { private async generateDraftTin(): Promise { for (let i = 0; i < 10; i++) { const candidate = - "D" + Math.floor(Math.random() * 1_000_000_000).toString().padStart(9, "0"); + "D" + + Math.floor(Math.random() * 1_000_000_000) + .toString() + .padStart(9, "0"); if (!(await this.companiesRepo.existsByTin(candidate))) return candidate; } // Extremely unlikely; fall back to a timestamp-derived value. @@ -293,8 +298,9 @@ export class CompaniesService { `Company for profile ${profile.id} not found`, ); - company.companyProfiles = - await this.companyProfilesRepo.findByCompanyId(company.id); + company.companyProfiles = await this.companyProfilesRepo.findByCompanyId( + company.id, + ); return { profile, company }; } @@ -325,9 +331,9 @@ export class CompaniesService { // one resolves; otherwise aggregate across the whole company. const companyProfileId = profile?.activeProfileType ? ((await this.companyProfilesRepo.findByType( - companyId, - profile.activeProfileType, - )) ?? null) + companyId, + profile.activeProfileType, + )) ?? null) : null; const scope = companyProfileId ? { companyProfileId: companyProfileId.id } @@ -540,18 +546,12 @@ export class CompaniesService { companyUpdates.renewedFrom = dto.renewedFrom; if (dto.renewalDate !== undefined) companyUpdates.renewalDate = dto.renewalDate; - if (dto.renewedTo !== undefined) - companyUpdates.renewedTo = dto.renewedTo; - if (dto.region !== undefined) - companyUpdates.region = dto.region; - if (dto.zone !== undefined) - companyUpdates.zone = dto.zone; - if (dto.woreda !== undefined) - companyUpdates.woreda = dto.woreda; - if (dto.kebele !== undefined) - companyUpdates.kebele = dto.kebele; - if (dto.houseNo !== undefined) - companyUpdates.houseNo = dto.houseNo; + if (dto.renewedTo !== undefined) companyUpdates.renewedTo = dto.renewedTo; + if (dto.region !== undefined) companyUpdates.region = dto.region; + if (dto.zone !== undefined) companyUpdates.zone = dto.zone; + if (dto.woreda !== undefined) companyUpdates.woreda = dto.woreda; + if (dto.kebele !== undefined) companyUpdates.kebele = dto.kebele; + if (dto.houseNo !== undefined) companyUpdates.houseNo = dto.houseNo; if (dto.etradePhone !== undefined) companyUpdates.etradePhone = normalizeE164(dto.etradePhone); @@ -617,7 +617,10 @@ export class CompaniesService { profileId: string, status: ProfileStatus, ): Promise { - const updated = await this.companyProfilesRepo.updateStatus(profileId, status); + const updated = await this.companyProfilesRepo.updateStatus( + profileId, + status, + ); if (!updated) throw new NotFoundException(`Company profile ${profileId} not found`); return updated; @@ -923,9 +926,9 @@ export class CompaniesService { if (profiles.length === 0) return null; const naturalType = - tradeDirection === 'IMPORT' + tradeDirection === "IMPORT" ? ProfileType.importer - : tradeDirection === 'EXPORT' + : tradeDirection === "EXPORT" ? ProfileType.exporter : null;