Skip to content

Commit

Permalink
fix: Declaration data to DTO when default data missing (#2148)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturlg authored Feb 22, 2024
1 parent b00e89f commit 15a86e0
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/app/src/common/core-domain/mappers/declarationMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ export const declarationMap: Required<Mapper<Declaration, DeclarationDTO, Declar
estCalculable: "oui",
note: salaryRaises.score?.getValue() ?? 0,
résultat: salaryRaises.result?.getValue() ?? 0,
populationFavorable: toBinaryFavorablePopulation(salaryRaises.favorablePopulation!.getValue()),
populationFavorable: toBinaryFavorablePopulation(
salaryRaises.favorablePopulation?.getValue() || FavorablePopulation.Enum.EQUALITY,
),
catégories: {
[CSP.Enum.OUVRIERS]: salaryRaises.categories[0]?.getValue() || "",
[CSP.Enum.EMPLOYES]: salaryRaises.categories[1]?.getValue() || "",
Expand All @@ -284,7 +286,9 @@ export const declarationMap: Required<Mapper<Declaration, DeclarationDTO, Declar
estCalculable: "oui",
note: promotions.score?.getValue() ?? 0,
résultat: promotions.result?.getValue() ?? 0,
populationFavorable: toBinaryFavorablePopulation(promotions.favorablePopulation!.getValue()),
populationFavorable: toBinaryFavorablePopulation(
promotions.favorablePopulation?.getValue() || FavorablePopulation.Enum.EQUALITY,
),
catégories: {
[CSP.Enum.OUVRIERS]: promotions.categories[0]?.getValue() || "",
[CSP.Enum.EMPLOYES]: promotions.categories[1]?.getValue() || "",
Expand All @@ -309,7 +313,9 @@ export const declarationMap: Required<Mapper<Declaration, DeclarationDTO, Declar
noteNombreSalaries: salaryRaisesAndPromotions.employeesCountScore?.getValue() ?? 0,
notePourcentage: salaryRaisesAndPromotions.percentScore?.getValue() ?? 0,
populationFavorable: salaryRaisesAndPromotions.favorablePopulation
? toBinaryFavorablePopulation(salaryRaisesAndPromotions.favorablePopulation!.getValue())
? toBinaryFavorablePopulation(
salaryRaisesAndPromotions.favorablePopulation?.getValue() || FavorablePopulation.Enum.EQUALITY,
)
: undefined,
résultat: salaryRaisesAndPromotions.result?.getValue() ?? 0,
résultatEquivalentSalarié: salaryRaisesAndPromotions.employeesCountResult?.getValue() ?? 0,
Expand All @@ -323,7 +329,9 @@ export const declarationMap: Required<Mapper<Declaration, DeclarationDTO, Declar
dto["remunerations-resultat"] = {
note: remunerations.score ? remunerations.score?.getValue() : 0,
populationFavorable: remunerations.favorablePopulation
? toBinaryFavorablePopulation(remunerations.favorablePopulation!.getValue())
? toBinaryFavorablePopulation(
remunerations.favorablePopulation?.getValue() || FavorablePopulation.Enum.EQUALITY,
)
: undefined,
résultat: remunerations.result ? remunerations.result?.getValue() : 0,
};
Expand Down Expand Up @@ -442,7 +450,9 @@ export const declarationMap: Required<Mapper<Declaration, DeclarationDTO, Declar
if (highRemunerations) {
dto["hautes-remunerations"] = {
note: obj.highRemunerations!.score.getValue(),
populationFavorable: toBinaryFavorablePopulation(obj.highRemunerations!.favorablePopulation.getValue()),
populationFavorable: toBinaryFavorablePopulation(
obj.highRemunerations?.favorablePopulation?.getValue() || FavorablePopulation.Enum.EQUALITY,
),
résultat: obj.highRemunerations!.result.getValue(),
};
}
Expand Down

0 comments on commit 15a86e0

Please sign in to comment.