Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mise a jour de la date de fin de l'historique des indicateurs apprenants #3610

Merged
merged 11 commits into from
Mar 20, 2024
Merged
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
Loading