Skip to content

Commit

Permalink
fix: wording and allow if company has privated data (#2181)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturlg authored Mar 6, 2024
1 parent b9c30e9 commit d3ebb40
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -52,7 +62,7 @@ export const RepresentationEquilibreeReceipt = ({ repEq }: RepresentationEquilib
},
{
key: "Adresse",
value: `${repEq.company.address} ${repEq.company.postalCode?.getValue()} ${repEq.company.city}`,
value: addressValue,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
Expand Down
8 changes: 5 additions & 3 deletions packages/app/src/common/core-domain/helpers/entreprise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d3ebb40

Please sign in to comment.