diff --git a/packages/app/src/api/core-domain/infra/pdf/templates/DeclarationReceipt.tsx b/packages/app/src/api/core-domain/infra/pdf/templates/DeclarationReceipt.tsx index c9683a034..754e4d6a2 100644 --- a/packages/app/src/api/core-domain/infra/pdf/templates/DeclarationReceipt.tsx +++ b/packages/app/src/api/core-domain/infra/pdf/templates/DeclarationReceipt.tsx @@ -37,6 +37,16 @@ export const DeclarationReceipt = (input: DeclarationOpmc) => { const nafCode = declaration.company.nafCode.getValue(); + const { address, postalCode, city } = declaration.company; + let addressValue = "Information non diffusible"; + if ( + !(address?.includes("[ND]") || address === undefined) && + !(postalCode?.getValue()?.includes("[ND]") || postalCode?.getValue() === undefined) && + !(city?.includes("[ND]") || city === undefined) + ) { + addressValue = `${address} ${postalCode?.getValue()} ${city}`; + } + const table: BaseReceiptTemplateProps["table"] = [ { title: "Informations déclarant", @@ -76,9 +86,7 @@ export const DeclarationReceipt = (input: DeclarationOpmc) => { }, { key: "Adresse", - value: `${declaration.company.address} ${declaration.company.postalCode?.getValue()} ${ - declaration.company.city - }`, + value: addressValue, }, ...(declaration.company.ues?.name === undefined ? [] diff --git a/packages/app/src/api/core-domain/infra/pdf/templates/RepresentationEquilibreeReceipt.tsx b/packages/app/src/api/core-domain/infra/pdf/templates/RepresentationEquilibreeReceipt.tsx index 934e0b19d..b9678605b 100644 --- a/packages/app/src/api/core-domain/infra/pdf/templates/RepresentationEquilibreeReceipt.tsx +++ b/packages/app/src/api/core-domain/infra/pdf/templates/RepresentationEquilibreeReceipt.tsx @@ -21,6 +21,16 @@ export interface RepresentationEquilibreeReceiptProps { export const RepresentationEquilibreeReceipt = ({ repEq }: RepresentationEquilibreeReceiptProps) => { const nafCode = repEq.company.nafCode.getValue(); + const { address, postalCode, city } = repEq.company; + let addressValue = "Information non diffusible"; + if ( + !(address?.includes("[ND]") || address === undefined) && + !(postalCode?.getValue()?.includes("[ND]") || postalCode?.getValue() === undefined) && + !(city?.includes("[ND]") || city === undefined) + ) { + addressValue = `${address} ${postalCode?.getValue()} ${city}`; + } + const table: BaseReceiptTemplateProps["table"] = [ { title: "Informations déclarant", @@ -52,7 +62,7 @@ export const RepresentationEquilibreeReceipt = ({ repEq }: RepresentationEquilib }, { key: "Adresse", - value: `${repEq.company.address} ${repEq.company.postalCode?.getValue()} ${repEq.company.city}`, + value: addressValue, }, ], }, diff --git a/packages/app/src/app/(default)/index-egapro/declaration/commencer/CommencerForm.tsx b/packages/app/src/app/(default)/index-egapro/declaration/commencer/CommencerForm.tsx index 3d9a932a5..ff1679882 100644 --- a/packages/app/src/app/(default)/index-egapro/declaration/commencer/CommencerForm.tsx +++ b/packages/app/src/app/(default)/index-egapro/declaration/commencer/CommencerForm.tsx @@ -106,15 +106,21 @@ export const prepareDataWithExistingDeclaration = async ( entreprise: { ...baseFormData.entreprise, entrepriseDéclarante: { - adresse: company?.firstMatchingEtablissement.address, + adresse: company?.firstMatchingEtablissement.address.includes("[ND]") + ? "Information non diffusible" + : company?.firstMatchingEtablissement.address, codeNaf: company.activitePrincipaleUniteLegale, - codePostal: company.firstMatchingEtablissement?.codePostalEtablissement, + codePostal: company.firstMatchingEtablissement?.codePostalEtablissement.includes("[ND]") + ? undefined + : company.firstMatchingEtablissement?.codePostalEtablissement, codePays: company.firstMatchingEtablissement?.codePaysEtrangerEtablissement ? COUNTRIES_COG_TO_ISO[company.firstMatchingEtablissement?.codePaysEtrangerEtablissement] : undefined, raisonSociale: company.simpleLabel, siren, - commune: company.firstMatchingEtablissement?.libelleCommuneEtablissement, + commune: company.firstMatchingEtablissement?.libelleCommuneEtablissement.includes("[ND]") + ? undefined + : company.firstMatchingEtablissement?.libelleCommuneEtablissement, département: countyCode, région: countyCode ? COUNTY_TO_REGION[countyCode] : undefined, }, diff --git a/packages/app/src/app/(default)/representation-equilibree/(funnel)/entreprise/Form.tsx b/packages/app/src/app/(default)/representation-equilibree/(funnel)/entreprise/Form.tsx index 8f85bae1f..413f9cbf7 100644 --- a/packages/app/src/app/(default)/representation-equilibree/(funnel)/entreprise/Form.tsx +++ b/packages/app/src/app/(default)/representation-equilibree/(funnel)/entreprise/Form.tsx @@ -45,12 +45,14 @@ export const EntrepriseForm = () => { const { address, countryCodeCOG, postalCode } = getAdditionalMeta(company); const companyDto: CompanyDTO = { - address, - city: company.firstMatchingEtablissement.libelleCommuneEtablissement, + address: address.includes("[ND]") ? "Information non diffusible" : address, + city: company.firstMatchingEtablissement.libelleCommuneEtablissement.includes("[ND]") + ? "" + : company.firstMatchingEtablissement.libelleCommuneEtablissement, countryIsoCode: COUNTRIES_COG_TO_ISO[countryCodeCOG], nafCode: company.activitePrincipaleUniteLegale, name: company.simpleLabel, - postalCode, + postalCode: postalCode?.includes("[ND]") ? "" : postalCode, siren: company.siren, }; diff --git a/packages/app/src/app/(default)/representation-equilibree/(funnel)/validation/RecapRepEq.tsx b/packages/app/src/app/(default)/representation-equilibree/(funnel)/validation/RecapRepEq.tsx index 88ebc4638..a47db1e6c 100644 --- a/packages/app/src/app/(default)/representation-equilibree/(funnel)/validation/RecapRepEq.tsx +++ b/packages/app/src/app/(default)/representation-equilibree/(funnel)/validation/RecapRepEq.tsx @@ -91,13 +91,15 @@ export const ValidationRecapRepEq = () => { declaredAt: "", modifiedAt: "", company: { - address, - city: company.firstMatchingEtablissement.libelleCommuneEtablissement, + address: address.includes("[ND]") ? "Information non diffusible" : address, + city: company.firstMatchingEtablissement.libelleCommuneEtablissement.includes("[ND]") + ? "" + : company.firstMatchingEtablissement.libelleCommuneEtablissement, countryCode: COUNTRIES_COG_TO_ISO[countryCodeCOG], county: countyCode ?? void 0, nafCode: company.activitePrincipaleUniteLegale, name: company.simpleLabel, - postalCode: postalCode ?? "", + postalCode: postalCode?.includes("[ND]") ? "" : postalCode ?? "", region: regionCode ?? void 0, }, }; diff --git a/packages/app/src/common/core-domain/helpers/entreprise.ts b/packages/app/src/common/core-domain/helpers/entreprise.ts index 65548ff57..dd00bff6b 100644 --- a/packages/app/src/common/core-domain/helpers/entreprise.ts +++ b/packages/app/src/common/core-domain/helpers/entreprise.ts @@ -7,9 +7,11 @@ export const getAdditionalMeta = (company: Entreprise) => { ? inseeCodeToCounty(company.firstMatchingEtablissement.codeCommuneEtablissement) : undefined; const regionCode = countyCode ? COUNTY_TO_REGION[countyCode] : null; - const postalCode = company.firstMatchingEtablissement.codePostalEtablissement - ? company.firstMatchingEtablissement.codePostalEtablissement - : undefined; + const postalCode = + company.firstMatchingEtablissement.codePostalEtablissement && + !company.firstMatchingEtablissement.codePostalEtablissement.includes("[ND]") + ? company.firstMatchingEtablissement.codePostalEtablissement + : undefined; const address = postalCode ? company.firstMatchingEtablissement.address.split(postalCode)[0].trim() : company.firstMatchingEtablissement.address;