@@ -3,6 +3,7 @@ import { type DeclarationOpmc } from "@common/core-domain/domain/DeclarationOpmc
3
3
import { CompanyWorkforceRange } from "@common/core-domain/domain/valueObjects/declaration/CompanyWorkforceRange" ;
4
4
import { RemunerationsMode } from "@common/core-domain/domain/valueObjects/declaration/indicators/RemunerationsMode" ;
5
5
import { NAF } from "@common/dict" ;
6
+ import { type NonEmptyString } from "@common/shared-domain/domain/valueObjects/NonEmptyString" ;
6
7
import { formatDateToFr } from "@common/utils/date" ;
7
8
import { isEqual } from "date-fns" ;
8
9
@@ -16,6 +17,21 @@ const insertSoftHyphens = (url: string, everyNChars: number) => {
16
17
return parts . join ( " " ) ;
17
18
} ;
18
19
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
+
19
35
export const DeclarationReceipt = ( input : DeclarationOpmc ) => {
20
36
const declaration = input . declaration ;
21
37
@@ -350,84 +366,80 @@ export const DeclarationReceipt = (input: DeclarationOpmc) => {
350
366
} ,
351
367
] ;
352
368
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 ) ;
360
374
}
361
375
362
376
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
+ ) ;
373
386
}
374
387
} 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
+ ) ;
383
397
}
384
398
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 ) ;
393
404
}
394
405
}
395
406
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 ) ;
404
412
}
405
413
406
414
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 ) ;
412
416
}
413
417
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
+ ) ;
418
424
419
425
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
+ ) ;
424
432
425
433
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
+ ) ;
431
443
}
432
444
}
433
445
@@ -437,11 +449,7 @@ export const DeclarationReceipt = (input: DeclarationOpmc) => {
437
449
declaration . index . getValue ( ) >= 75 &&
438
450
declaration . index . getValue ( ) <= 84
439
451
) {
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 ) ;
445
453
}
446
454
447
455
table . push ( {
0 commit comments