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

Ajoute les types de scolarités "maternelle" et "primaire" #4487

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/lib/teleservices/demarches-simplifiees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ const fsl_var_sources = {
"scolarite",
`enfant_${id}`
)
const scolariteLabel = Scolarite.types.find(
(t) => t.value === scolarite
)?.label
const scolariteLabel =
Scolarite.scolariteTypes.find((s) => s.value === scolarite)?.label ||
Scolarite.scolariteEnfantTypes.find((s) => s.value === scolarite)?.label
return {
champ_Q2hhbXAtMjU1NDk1MQ: date_naissance.slice(0, 10),
champ_Q2hhbXAtMjU1NDk0OQ: prenom,
Expand Down
5 changes: 5 additions & 0 deletions lib/enums/scolarite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export enum Scolarite {
Lycee = "lycee",
}

export enum ScolariteEnfant {
Maternelle = "maternelle",
Primaire = "primaire",
}

export enum Etudiant {
Cap1 = "cap_1",
Cap2 = "cap_2",
Expand Down
8 changes: 7 additions & 1 deletion lib/properties/individu-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,13 @@ export default {
? "Où êtes-vous scolarisé ou scolarisée ?"
: `Où sera scolarisé ou scolarisée ${individu._firstName} à la rentrée prochaine ?`
},
items: ScolariteCategories.types,
items: ({ individu }) =>
individu._role == "demandeur"
? ScolariteCategories.scolariteTypes
: [
...ScolariteCategories.scolariteEnfantTypes,
...ScolariteCategories.scolariteTypes,
],
moreInfo:
"Pour les étudiants en classes préparatoires aux grandes écoles, il faut sélectionner « Dans un établissement de l'enseignement supérieur ».",
}),
Expand Down
13 changes: 12 additions & 1 deletion lib/scolarite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import {
GroupeSpecialite,
MentionBaccalaureat,
Scolarite,
ScolariteEnfant,
} from "./enums/scolarite.js"
export default {
types: [
scolariteTypes: [
{
value: Scolarite.College,
label: "Au collège",
Expand All @@ -26,6 +27,16 @@ export default {
label: "Autre",
},
],
scolariteEnfantTypes: [
{
value: ScolariteEnfant.Maternelle,
label: "À la maternelle",
},
{
value: ScolariteEnfant.Primaire,
label: "À l'école primaire",
},
],
mentionsBaccalaureat: [
{
label: "Mention assez bien",
Expand Down
2 changes: 1 addition & 1 deletion lib/state/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function individuBlockFactory(id, chapter?: ChapterName) {
subject,
datesGenerator(situation.dateDeValeur).today.value
)
return 8 < age && age <= 25
return 2 <= age && age <= 25
},
steps: [r("scolarite")],
},
Expand Down
8 changes: 6 additions & 2 deletions src/views/simulation/enfants.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ export default {
},
nationality: Nationality.getNationalityFromCountryCode,
scolarite(value) {
return (
ScolariteCategories.types.find((s) => s.value === value)?.label || "-"
const scolariteType = ScolariteCategories.scolariteTypes.find(
(s) => s.value === value
)
const scolariteEnfantType = ScolariteCategories.scolariteEnfantTypes.find(
(s) => s.value === value
)
return scolariteType?.label || scolariteEnfantType?.label || "-"
},
},
}
Expand Down
18 changes: 14 additions & 4 deletions tests/unit/openfisca/mapping/dispatch-individuals.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from "@jest/globals"
import { ScolariteEnfant } from "@lib/enums/scolarite.js"
import subject from "@root/backend/lib/openfisca/mapping/index.js"

describe("openfisca dispatchIndividuals", function () {
Expand Down Expand Up @@ -52,7 +53,7 @@ describe("openfisca dispatchIndividuals", function () {
it("sets a fake declarant", function () {
expect(result.foyers_fiscaux._.declarants).toEqual(["parent1"])
})
it("sets one personne a charge", function () {
it("sets one person a charge", function () {
expect(result.foyers_fiscaux._.personnes_a_charge).toEqual([
situation.demandeur.id,
])
Expand All @@ -63,7 +64,11 @@ describe("openfisca dispatchIndividuals", function () {
const situation = buildSituation({
demandeur: {
id: "demandeur",
enfant_a_charge: { 2013: true },
enfant_a_charge: {
2013: true,
scolarite: ScolariteEnfant.Maternelle,
test: "toto",
},
},
conjoint: {
id: "conjoint",
Expand All @@ -74,15 +79,20 @@ describe("openfisca dispatchIndividuals", function () {
it("sets a fake declarant", function () {
expect(result.foyers_fiscaux._.declarants).toEqual(["parent1"])
})
it("sets one persone a charge", function () {
it("sets one person a charge", function () {
expect(result.foyers_fiscaux._.personnes_a_charge).toEqual([
situation.demandeur.id,
])
})
it("creates a separate foyer_fiscal for the conjoint one persone a charge", function () {
it("creates a separate foyer_fiscal for the conjoint one person a charge", function () {
expect(result.foyers_fiscaux.conjoint.declarants).toEqual([
situation.conjoint.id,
])
})
it("checks scolarite enfant_a_charge", function () {
expect(result.individus.demandeur.enfant_a_charge.scolarite).toEqual(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quelle est la différence entre enfants: [{ id: "e1" }],
et situation.demandeur.enfant_a_charge.scolarite
J'ai l'impression que la première option est la plus probable non ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est corrigé

situation.demandeur.enfant_a_charge.scolarite
)
})
})
})
Loading