-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: ajout du code dispositif pour les offres en apprentissage #513
Draft
FaXaq
wants to merge
1
commit into
develop
Choose a base branch
from
feat/ajout-dispositif-apprentissage
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import { inject } from "injecti"; | ||
import { MILLESIMES_IJ, RENTREES_SCOLAIRES } from "shared"; | ||
|
||
import { rawDataRepository } from "@/modules/import/repositories/rawData.repository"; | ||
import { getCfdDispositifs } from "@/modules/import/usecases/getCfdRentrees/getCfdDispositifs.dep"; | ||
import { getCfdRentrees } from "@/modules/import/usecases/getCfdRentrees/getCfdRentrees.usecase"; | ||
import { findDiplomesProfessionnels } from "@/modules/import/usecases/importIJData/findDiplomesProfessionnels.dep"; | ||
|
@@ -26,6 +27,56 @@ import { | |
|
||
const processedUais = new Set<string>(); | ||
|
||
const parseCfd = (mef: string, duree: number): number => { | ||
const threeFirstChars = parseInt(mef.substring(0, 3)); | ||
|
||
switch (threeFirstChars) { | ||
case 320: | ||
if (duree === 1) return 310; | ||
if (duree === 2) return 311; | ||
if (duree === 3) return 312; | ||
return -1; | ||
|
||
case 323: | ||
if (duree === 1) return 370; | ||
return -1; | ||
|
||
case 400: | ||
if (duree === 1 || duree === 2 || duree === 3) return 247; | ||
return -1; | ||
|
||
case 401: | ||
if (duree === 3) return 252; | ||
return -1; | ||
|
||
case 403: | ||
if (duree === 2) return 273; | ||
return -1; | ||
|
||
case 450: | ||
if (duree === 1 || duree === 2 || duree === 3) return 890; | ||
return -1; | ||
|
||
case 500: | ||
if (duree === 1) return 240; | ||
if (duree === 2) return 241; | ||
if (duree === 3) return 242; | ||
return -1; | ||
|
||
case 503: | ||
if (duree === 1) return 270; | ||
return -1; | ||
|
||
case 561: | ||
return 257; | ||
|
||
case 461: | ||
return 258; | ||
} | ||
|
||
return -1; | ||
}; | ||
|
||
export const [importFormations] = inject( | ||
{ | ||
importFormation, | ||
|
@@ -87,10 +138,13 @@ export const [importFormationEtablissements] = inject( | |
importIndicateurSortieApprentissage, | ||
importIndicateursRegionSortieApprentissage, | ||
findUAIsApprentissage, | ||
findRawData: rawDataRepository.findRawData, | ||
findRawDatas: rawDataRepository.findRawDatas, | ||
}, | ||
(deps) => { | ||
return async ({ cfd, voie = "scolaire" }: { cfd: string; voie?: string }) => { | ||
if (voie === "apprentissage") { | ||
//console.log("codesDispo", 3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm |
||
await deps.importIndicateursRegionSortieApprentissage({ cfd }); | ||
const uais = await deps.findUAIsApprentissage({ cfd }); | ||
if (!uais) return; | ||
|
@@ -102,20 +156,63 @@ export const [importFormationEtablissements] = inject( | |
} | ||
processedUais.add(uai); | ||
} | ||
const formationEtablissement = await deps.createFormationEtablissement({ | ||
uai, | ||
cfd, | ||
codeDispositif: null, | ||
voie: "apprentissage", | ||
|
||
// Récupération du codeDispositif pour les formations en apprentissage | ||
// à partir du contenu du fichier offres_apprentissage | ||
const offreApprentissage = await deps.findRawData({ | ||
type: "offres_apprentissage", | ||
filter: { "Formation: code CFD": cfd }, | ||
}); | ||
|
||
for (const millesime of MILLESIMES_IJ) { | ||
await deps.importIndicateurSortieApprentissage({ | ||
if (!offreApprentissage) continue; | ||
|
||
const codesDispositifs: Array<string> = []; | ||
const mefs = offreApprentissage["Formation: codes MEF"]?.split(",").map((mef) => mef.trim()) ?? []; | ||
const dureeCollectee = offreApprentissage?.["Formation: durée collectée"] | ||
? parseInt(offreApprentissage?.["Formation: durée collectée"]) | ||
: -1; | ||
|
||
if (mefs.length > 0) { | ||
/** | ||
* Chercher ce MEF dans le fichier nMef le couple (FORMATION_DIPLOME, DISPOSITIF_FORMATION) qui correspond au (cfd, codeDispositif) | ||
*/ | ||
for (const mef of mefs) { | ||
const nMefs = await deps.findRawDatas({ | ||
type: "nMef", | ||
filter: { | ||
MEF: mef, | ||
FORMATION_DIPLOME: cfd, | ||
}, | ||
}); | ||
|
||
nMefs.forEach((nMef) => { | ||
codesDispositifs.push(nMef.DISPOSITIF_FORMATION); | ||
}); | ||
} | ||
} else { | ||
// déduire le code dispositif du cfd | ||
const codeDispositif = parseCfd(offreApprentissage?.["Formation: code CFD"], dureeCollectee); | ||
if (codeDispositif > -1) { | ||
codesDispositifs.push(codeDispositif.toString()); | ||
} | ||
} | ||
|
||
for (const codeDispositif of codesDispositifs) { | ||
const formationEtablissement = await deps.createFormationEtablissement({ | ||
uai, | ||
formationEtablissementId: formationEtablissement.id, | ||
millesime, | ||
cfd, | ||
codeDispositif, | ||
voie: "apprentissage", | ||
}); | ||
|
||
for (const millesime of MILLESIMES_IJ) { | ||
await deps.importIndicateurSortieApprentissage({ | ||
uai, | ||
formationEtablissementId: formationEtablissement.id, | ||
millesime, | ||
cfd, | ||
}); | ||
} | ||
} | ||
} | ||
} else { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ca mériterait d'avoir surement des tests pour être sur que le jour où on modifie ça ne casse rien, est ce qu'il y a un intérêt a remplacer les valeurs par des constantes ?