diff --git a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/CSPModeTable.tsx b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/CSPModeTable.tsx index 29fc58eea..18068d92b 100644 --- a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/CSPModeTable.tsx +++ b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/CSPModeTable.tsx @@ -120,8 +120,6 @@ export const CSPModeTable = ({ computer, staff }: CSPModeTableProps) => { withTooltip header={getCommonHeader({ firstColumnLabel: "Catégorie socio-professionnelle" })} body={categories.map((categoryName, categoryIndex) => { - const categoryId = categoryName; - register(`remunerations.${categoryIndex}.categoryId`, { value: categoryId }); register(`remunerations.${categoryIndex}.name`, { value: categoryName }); return { @@ -153,7 +151,6 @@ export const CSPModeTable = ({ computer, staff }: CSPModeTableProps) => { return getCommonBodyColumns({ ageRange, - categoryId, categoryIndex, categoryName, computer, diff --git a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/Form.tsx b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/Form.tsx index 214f87da1..099d815c1 100644 --- a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/Form.tsx +++ b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/Form.tsx @@ -96,7 +96,6 @@ export const Indic1Form = () => { const { formState: { isValid }, handleSubmit, - getValues, watch, resetField, control, @@ -115,12 +114,12 @@ export const Indic1Form = () => { } const currentMode = watch("mode"); + const currentRemunerations = watch("remunerations"); // default values for CSP mode, set category to empty if no data only if count is >= 3 const defaultCspModeRemunerations = Object.keys(funnel.effectifs.csp).map( categoryName => ({ name: categoryName, - categoryId: categoryName, category: ageRanges.reduce( (newAgeGroups, ageRange) => ({ ...newAgeGroups, @@ -195,8 +194,6 @@ export const Indic1Form = () => { ? lastCspRemunerations ?? defaultCspModeRemunerations : lastOtherRemunerations ?? defaultOtherModesRemunerations; - const currentRemunerations = getValues("remunerations"); - if (lastMode && currentRemunerations?.length) { if (lastMode === RemunerationsMode.Enum.CSP) { setLastCspRemunerations(currentRemunerations as ExternalRemunerations); diff --git a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/OtherModesTable.tsx b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/OtherModesTable.tsx index 877d1a839..9dff687f4 100644 --- a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/OtherModesTable.tsx +++ b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/OtherModesTable.tsx @@ -72,12 +72,6 @@ export const OtherModesTable = ({ computer, staff, defaultRemunerations }: Other header={getCommonHeader({ firstColumnLabel: "Niveau ou coefficient hiérarchique" })} body={remunerationsFields.map( (remunerationsField, remunerationsFieldIndex) => { - const categoryId = remunerationsField.categoryId || remunerationsField.id; - register(`remunerations.${remunerationsFieldIndex}.categoryId`, { - value: categoryId, - deps: `remunerations.${remunerationsFieldIndex}.name`, - }); - return { key: remunerationsField.id, isDeletable: remunerationsFieldIndex > 0, @@ -155,7 +149,6 @@ export const OtherModesTable = ({ computer, staff, defaultRemunerations }: Other return getCommonBodyColumns({ ageRange, - categoryId, categoryIndex: remunerationsFieldIndex, categoryName: remunerationsField.name, computer, diff --git a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/tableUtil.tsx b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/tableUtil.tsx index 77c6bea4e..05ee55ab0 100644 --- a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/tableUtil.tsx +++ b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/indicateur1/tableUtil.tsx @@ -58,7 +58,6 @@ export type Indic1FormType = z.infer; interface CommonBodyColumnsProps { ageRange: AgeRange.Enum; - categoryId: string; categoryIndex: number; categoryName: string; computer: IndicateurUnComputer; @@ -77,7 +76,6 @@ export const getCommonBodyColumns = ({ menCount = 0, categoryName, categoryIndex, - categoryId, ageRange, errors, computer, @@ -132,7 +130,7 @@ export const getCommonBodyColumns = ({ }, }, (() => { - const { resultRaw: groupResult } = computer.computeGroup(buildRemunerationKey(categoryId, ageRange)); + const { resultRaw: groupResult } = computer.computeGroup(buildRemunerationKey(categoryName, ageRange)); return !Number.isNaN(groupResult) && Number.isFinite(groupResult) ? precisePercentFormat.format(groupResult / 100) : "-"; diff --git a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/recapitulatif/RecapSimu.tsx b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/recapitulatif/RecapSimu.tsx index cdf00c02e..f93017c04 100644 --- a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/recapitulatif/RecapSimu.tsx +++ b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/recapitulatif/RecapSimu.tsx @@ -164,11 +164,11 @@ export const RecapSimu = () => { body={remuWithCount.map(category => ({ categoryLabel: funnel.indicateur1.mode === RemunerationsMode.Enum.CSP - ? CSP.Label[category.categoryId as CSP.Enum] + ? CSP.Label[category.name as CSP.Enum] : category.name, alignCols: "center", cols: ageRanges.map(ageRange => { - const groupKey = buildRemunerationKey(category.categoryId, ageRange); + const groupKey = buildRemunerationKey(category.name, ageRange); const canComputeGroup = computerIndicateurUn.canComputeGroup(groupKey); const groupResult = computerIndicateurUn.computeGroup(groupKey); return canComputeGroup ? precisePercentFormat.format(groupResult.resultRaw / 100) : "NC"; diff --git a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/recapitulatif/simuToDecla.ts b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/recapitulatif/simuToDecla.ts index 5421f3c33..b87b24f9b 100644 --- a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/recapitulatif/simuToDecla.ts +++ b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/recapitulatif/simuToDecla.ts @@ -156,13 +156,13 @@ export const simuFunnelToDeclarationDTO = (simulation: CreateSimulationDTO): Dec ? "remunerations-coefficient-autre" : "remunerations-coefficient-branche" ] = { - catégories: indicateur1.remunerations.map(({ name: nom, categoryId }) => ({ + catégories: indicateur1.remunerations.map(({ name: nom }) => ({ nom, tranches: { - [AgeRange.Enum.LESS_THAN_30]: computeGroupIndicateurUn(computerIndicateurUn)(`${categoryId}::29`) || "", - [AgeRange.Enum.FROM_30_TO_39]: computeGroupIndicateurUn(computerIndicateurUn)(`${categoryId}:30:39`) || "", - [AgeRange.Enum.FROM_40_TO_49]: computeGroupIndicateurUn(computerIndicateurUn)(`${categoryId}:40:49`) || "", - [AgeRange.Enum.FROM_50_TO_MORE]: computeGroupIndicateurUn(computerIndicateurUn)(`${categoryId}:50:`) || "", + [AgeRange.Enum.LESS_THAN_30]: computeGroupIndicateurUn(computerIndicateurUn)(`${nom}::29`) || "", + [AgeRange.Enum.FROM_30_TO_39]: computeGroupIndicateurUn(computerIndicateurUn)(`${nom}:30:39`) || "", + [AgeRange.Enum.FROM_40_TO_49]: computeGroupIndicateurUn(computerIndicateurUn)(`${nom}:40:49`) || "", + [AgeRange.Enum.FROM_50_TO_MORE]: computeGroupIndicateurUn(computerIndicateurUn)(`${nom}:50:`) || "", }, })), }; diff --git a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/utils.ts b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/utils.ts index 4e459375f..683003ba7 100644 --- a/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/utils.ts +++ b/packages/app/src/app/(default)/index-egapro/simulateur/(funnel)/utils.ts @@ -30,7 +30,6 @@ export const getCspRemuWithCount = ( ) => Object.keys(funnelCsp).map(categoryName => ({ name: categoryName, - categoryId: categoryName, category: ageRanges.reduce( (newAgeGroups, ageRange) => { const currentAgeRange = remunerations?.find(rem => rem?.name === categoryName)?.category?.[ageRange]; diff --git a/packages/app/src/common/core-domain/computers/AbstractGroupComputer.ts b/packages/app/src/common/core-domain/computers/AbstractGroupComputer.ts index 866665ec0..8bb3b4d97 100644 --- a/packages/app/src/common/core-domain/computers/AbstractGroupComputer.ts +++ b/packages/app/src/common/core-domain/computers/AbstractGroupComputer.ts @@ -59,7 +59,7 @@ export abstract class AbstractGroupComputer< const validGroups: ExtendedTotalMetadata["validGroups"] = []; const additionalMetadata = {} as AdditionalMetadata; - for (const [categoryId, category] of Object.entries(this.input) as Array<[GroupKey, Group]>) { + for (const [categoryName, category] of Object.entries(this.input) as Array<[GroupKey, Group]>) { const womenCount = category.womenCount || 0; const menCount = category.menCount || 0; totalEmployeeCount += menCount + womenCount; @@ -77,7 +77,7 @@ export abstract class AbstractGroupComputer< // Exclure les groupes qui n'ont pas au moins (this.GROUP_COUNT_THRESHOLD) hommes et (this.GROUP_COUNT_THRESHOLD) femmes. (e.g. 3 pour l'indicateur 1, 10 pour les indicateurs 2 ou 3) if (category.menCount >= this.GROUP_COUNT_THRESHOLD && category.womenCount >= this.GROUP_COUNT_THRESHOLD) { - validGroups.push(categoryId as GroupKey); + validGroups.push(categoryName as GroupKey); totalGroupCount += menCount + womenCount; } } diff --git a/packages/app/src/common/core-domain/computers/IndicateurDeuxComputer.ts b/packages/app/src/common/core-domain/computers/IndicateurDeuxComputer.ts index 556339a24..58789d390 100644 --- a/packages/app/src/common/core-domain/computers/IndicateurDeuxComputer.ts +++ b/packages/app/src/common/core-domain/computers/IndicateurDeuxComputer.ts @@ -27,11 +27,11 @@ export class IndicateurDeuxComputer extends AbstractGroupComputer= 10 && category.womenCount >= 10 && category.men && category.women)) { return false; diff --git a/packages/app/src/common/core-domain/computers/utils.ts b/packages/app/src/common/core-domain/computers/utils.ts index 168b8cb2a..e863c711e 100644 --- a/packages/app/src/common/core-domain/computers/utils.ts +++ b/packages/app/src/common/core-domain/computers/utils.ts @@ -18,22 +18,21 @@ export const ageRanges = [ export type ExternalRemunerations = Array<{ category: Record; - categoryId: string; name: string; }>; export function flattenRemunerations(remunerations: ExternalRemunerations): InputRemunerations { const flattened: InputRemunerations = {}; - for (const { categoryId, category } of remunerations) { + for (const { name, category } of remunerations) { if (category) { for (const [ageRange, ageGroup] of Object.entries(category)) { - flattened[buildRemunerationKey(categoryId, ageRange as AgeRange.Enum)] = ageGroup; + flattened[buildRemunerationKey(name, ageRange as AgeRange.Enum)] = ageGroup; } } } return flattened; } -export function buildRemunerationKey(categoryId: string, ageRange: AgeRange.Enum): string { - return `${categoryId}:${ageRange}`; +export function buildRemunerationKey(categoryName: string, ageRange: AgeRange.Enum): string { + return `${categoryName}:${ageRange}`; } diff --git a/packages/app/src/common/core-domain/dtos/CreateSimulationDTO.ts b/packages/app/src/common/core-domain/dtos/CreateSimulationDTO.ts index 2bf6c82f6..f42d668b3 100644 --- a/packages/app/src/common/core-domain/dtos/CreateSimulationDTO.ts +++ b/packages/app/src/common/core-domain/dtos/CreateSimulationDTO.ts @@ -94,7 +94,6 @@ const otherAgeRangesSchema = zodFr const otherAgeRangeNumbers = zodFr.array( zodFr.object({ name: zodFr.string().min(1, "Le champ est requis"), - categoryId: zodFr.string().min(1), category: zodFr.record(zodFr.nativeEnum(AgeRange.Enum), otherAgeRangesSchema), }), ); @@ -129,7 +128,6 @@ export const createSteps = { remunerations: zodFr.array( zodFr.object({ name: zodFr.nativeEnum(CSP.Enum), - categoryId: zodFr.string().min(1), category: zodFr .record( zodFr.nativeEnum(AgeRange.Enum),