Skip to content

Commit 53e9cef

Browse files
committed
fix: declaration pdf receipt formatting and wording
1 parent 07c4ce2 commit 53e9cef

File tree

1 file changed

+72
-64
lines changed

1 file changed

+72
-64
lines changed

packages/app/src/api/core-domain/infra/pdf/templates/DeclarationReceipt.tsx

+72-64
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type DeclarationOpmc } from "@common/core-domain/domain/DeclarationOpmc
33
import { CompanyWorkforceRange } from "@common/core-domain/domain/valueObjects/declaration/CompanyWorkforceRange";
44
import { RemunerationsMode } from "@common/core-domain/domain/valueObjects/declaration/indicators/RemunerationsMode";
55
import { NAF } from "@common/dict";
6+
import { type NonEmptyString } from "@common/shared-domain/domain/valueObjects/NonEmptyString";
67
import { formatDateToFr } from "@common/utils/date";
78
import { isEqual } from "date-fns";
89

@@ -16,6 +17,21 @@ const insertSoftHyphens = (url: string, everyNChars: number) => {
1617
return parts.join(" ");
1718
};
1819

20+
const pushRow = (
21+
rows: BaseReceiptTemplateProps.Row[],
22+
key: string,
23+
value: NonEmptyString | string | { getValue: () => string | undefined } | undefined,
24+
showAsBlock: boolean = true,
25+
) => {
26+
const valueStr = typeof value === "string" ? value : value?.getValue ? value.getValue() : undefined;
27+
28+
rows.push({
29+
key: key,
30+
value: valueStr ?? "À définir",
31+
showAsBlock: showAsBlock,
32+
});
33+
};
34+
1935
export const DeclarationReceipt = (input: DeclarationOpmc) => {
2036
const declaration = input.declaration;
2137

@@ -350,84 +366,80 @@ export const DeclarationReceipt = (input: DeclarationOpmc) => {
350366
},
351367
];
352368

353-
if (!declaration.remunerations?.notComputableReason) {
354-
if (declaration.remunerations?.score?.getValue() !== indicatorNoteMax["remunerations"])
355-
rows.push({
356-
key: "Objectif Indicateur écart de rémunération",
357-
value: input.objectiveRemunerations?.getValue() ?? "À définir",
358-
showAsBlock: true,
359-
});
369+
if (
370+
!declaration.remunerations?.notComputableReason &&
371+
declaration.remunerations?.score?.getValue() !== indicatorNoteMax["remunerations"]
372+
) {
373+
pushRow(rows, "Objectif Indicateur écart de rémunération", input.objectiveRemunerations);
360374
}
361375

362376
if (declaration.company.range?.getValue() === CompanyWorkforceRange.Enum.FROM_50_TO_250) {
363-
if (!declaration.salaryRaisesAndPromotions?.notComputableReason) {
364-
if (
365-
declaration.salaryRaisesAndPromotions?.score?.getValue() !== indicatorNoteMax["augmentations-et-promotions"]
366-
) {
367-
rows.push({
368-
key: "Objectif Indicateur écart de taux d'augmentations individuelles",
369-
value: input.objectiveSalaryRaiseAndPromotions?.getValue() ?? "À définir",
370-
showAsBlock: true,
371-
});
372-
}
377+
if (
378+
!declaration.salaryRaisesAndPromotions?.notComputableReason &&
379+
declaration.salaryRaisesAndPromotions?.score?.getValue() !== indicatorNoteMax["augmentations-et-promotions"]
380+
) {
381+
pushRow(
382+
rows,
383+
"Objectif Indicateur écart de taux d'augmentations individuelles",
384+
input.objectiveSalaryRaiseAndPromotions,
385+
);
373386
}
374387
} else {
375-
if (!declaration.salaryRaises?.notComputableReason) {
376-
if (declaration.salaryRaises?.score?.getValue() != indicatorNoteMax["augmentations"]) {
377-
rows.push({
378-
key: "Objectif Indicateur écart de taux d'augmentations individuelles (hors promotions)",
379-
value: input.objectiveSalaryRaise?.getValue() ?? "À définir",
380-
showAsBlock: true,
381-
});
382-
}
388+
if (
389+
!declaration.salaryRaises?.notComputableReason &&
390+
declaration.salaryRaises?.score?.getValue() != indicatorNoteMax["augmentations"]
391+
) {
392+
pushRow(
393+
rows,
394+
"Objectif Indicateur écart de taux d'augmentations individuelles (hors promotions)",
395+
input.objectiveSalaryRaise,
396+
);
383397
}
384398

385-
if (!declaration.promotions?.notComputableReason) {
386-
if (declaration.promotions?.score?.getValue() !== indicatorNoteMax["promotions"]) {
387-
rows.push({
388-
key: "Objectif Indicateur écart de taux de promotions",
389-
value: input.objectivePromotions?.getValue() ?? "À définir",
390-
showAsBlock: true,
391-
});
392-
}
399+
if (
400+
!declaration.promotions?.notComputableReason &&
401+
declaration.promotions?.score?.getValue() !== indicatorNoteMax["promotions"]
402+
) {
403+
pushRow(rows, "Objectif Indicateur écart de taux de promotions", input.objectivePromotions);
393404
}
394405
}
395406

396-
if (!declaration.maternityLeaves?.notComputableReason) {
397-
if (declaration.maternityLeaves?.score?.getValue() !== indicatorNoteMax["conges-maternite"]) {
398-
rows.push({
399-
key: "Objectif Indicateur retour de congé maternité",
400-
value: input.objectiveMaternityLeaves?.getValue() ?? "À définir",
401-
showAsBlock: true,
402-
});
403-
}
407+
if (
408+
!declaration.maternityLeaves?.notComputableReason &&
409+
declaration.maternityLeaves?.score?.getValue() !== indicatorNoteMax["conges-maternite"]
410+
) {
411+
pushRow(rows, "Objectif Indicateur retour de congé maternité", input.objectiveMaternityLeaves);
404412
}
405413

406414
if (declaration.highRemunerations?.score?.getValue() !== indicatorNoteMax["hautes-remunerations"]) {
407-
rows.push({
408-
key: "Objectif Indicateur dix plus hautes rémunérations",
409-
value: input.objectiveHighRemunerations?.getValue() ?? "À définir",
410-
showAsBlock: true,
411-
});
415+
pushRow(rows, "Objectif Indicateur dix plus hautes rémunérations", input.objectiveHighRemunerations);
412416
}
413417

414-
rows.push({
415-
key: "Date de publication des objectifs",
416-
value: input.objectivesPublishDate ? formatDateToFr(input.objectivesPublishDate) : "À définir",
417-
});
418+
pushRow(
419+
rows,
420+
"Date de publication des objectifs",
421+
input.objectivesPublishDate ? formatDateToFr(input.objectivesPublishDate) : "À définir",
422+
false,
423+
);
418424

419425
if (declaration.index.getValue() < 75) {
420-
rows.push({
421-
key: "Date de publication des mesures de correction",
422-
value: input.measuresPublishDate ? formatDateToFr(input.measuresPublishDate) : "À définir",
423-
});
426+
pushRow(
427+
rows,
428+
"Date de publication des mesures de correction",
429+
input.measuresPublishDate ? formatDateToFr(input.measuresPublishDate) : "À définir",
430+
false,
431+
);
424432

425433
if (!declaration.publication?.url && declaration.year.getValue() > 2020) {
426-
rows.push({
427-
key: "Modalités de communication auprès des salariés",
428-
value: input.objectivesMeasuresModalities?.getValue() ?? "À définir",
429-
showAsBlock: true,
430-
});
434+
pushRow(rows, "Modalités de communication auprès des salariés", input.objectivesMeasuresModalities);
435+
}
436+
437+
if (declaration.publication?.url) {
438+
pushRow(
439+
rows,
440+
"Modalités de communication des mesures de correction auprès des salariés",
441+
input.objectivesMeasuresModalities,
442+
);
431443
}
432444
}
433445

@@ -437,11 +449,7 @@ export const DeclarationReceipt = (input: DeclarationOpmc) => {
437449
declaration.index.getValue() >= 75 &&
438450
declaration.index.getValue() <= 84
439451
) {
440-
rows.push({
441-
key: "Modalités de communication auprès des salariés",
442-
value: input.objectivesMeasuresModalities?.getValue() ?? "À définir",
443-
showAsBlock: true,
444-
});
452+
pushRow(rows, "Modalités de communication auprès des salariés", input.objectivesMeasuresModalities);
445453
}
446454

447455
table.push({

0 commit comments

Comments
 (0)