Skip to content

Commit

Permalink
Ajoute les types de scolarités "maternelle" et "primaire" (#4487)
Browse files Browse the repository at this point in the history
* feat: ajoute les scolarité "maternelle" et "primaire"

* feat: ajoute un test unitaire sur la scolarite de l'enfant à charge à la maternelle

* feat: màj test unitaire sur la scolarite de l'enfant à charge à la maternelle

* refactor: type enum scolarite maternelle
  • Loading branch information
Shamzic authored Jul 31, 2024
1 parent b6f4e07 commit da71489
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 12 deletions.
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
32 changes: 28 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,9 @@ describe("openfisca dispatchIndividuals", function () {
const situation = buildSituation({
demandeur: {
id: "demandeur",
enfant_a_charge: { 2013: true },
enfant_a_charge: {
2008: true,
},
},
conjoint: {
id: "conjoint",
Expand All @@ -74,15 +77,36 @@ 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("check 'personne a charge' status", 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,
])
})
})

describe("check child", function () {
const situation = buildSituation({
demandeur: {
id: "demandeur",
},
enfants: [
{
id: "enfant_0",
enfant_a_charge: { 2018: true },
scolarite: ScolariteEnfant.Maternelle,
},
],
})
const result: any = subject.dispatchIndividuals(situation)
it("checks schooling", function () {
expect(result.individus.enfant_0.scolarite).toEqual(
situation.enfants[0].scolarite
)
})
})
})

0 comments on commit da71489

Please sign in to comment.