Skip to content

Commit

Permalink
fix: mise a jour de la date de fin de l'historique des indicateurs ap…
Browse files Browse the repository at this point in the history
…prenants (#3610)
  • Loading branch information
nkrmr authored Mar 20, 2024
1 parent b3312d7 commit 399bed5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { addJob } from "job-processor";

export const up = async () => {
await addJob({ name: "tmp:effectifs:update_computed_statut", queued: true });
};
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,20 @@ export function determineNewStatutFromHistorique(
function genererHistoriqueStatutFromApprenant(
historiqueStatut: IEffectifApprenant["historique_statut"],
formationPeriode: number[] | null | undefined,
endDate: Date
evaluationEndDate: Date
): IEffectifComputedStatut["historique"] {
if (!formationPeriode) {
console.error("Formation period is undefined or null");
return [];
}
const periodeEndDate = new Date(formationPeriode[1], 11, 31);
const sortedStatut = historiqueStatut.sort(
(a, b) => new Date(a.date_statut).getTime() - new Date(b.date_statut).getTime()
);

const startDate =
sortedStatut.length > 0 ? new Date(sortedStatut[0].date_statut) : new Date(formationPeriode[0], 0, 1);
const endDate = periodeEndDate < evaluationEndDate ? periodeEndDate : evaluationEndDate;

let currentDate = new Date(startDate.getFullYear(), startDate.getMonth(), 1);
const historique: IEffectifComputedStatut["historique"] = [];
Expand Down

0 comments on commit 399bed5

Please sign in to comment.