Skip to content

Commit

Permalink
Amélioration du système de vérification géographique (#4780)
Browse files Browse the repository at this point in the history
* feat: amélioration du système de vérification géographique et correction d'erreurs

* refacto: simplifier le code de vérification géographique
  • Loading branch information
jenovateurs authored Jan 6, 2025
1 parent d6f154a commit fe8d3e6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ conditions_generales:
- type: age
operator: ">="
value: 18
- type: epcis
values:
- "200067932"
- type: attached_to_institution
- type: quotient_familial
operator: <=
value: 752
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ conditions_generales:
- type: age
operator: <=
value: 25
- type: epcis
values:
- "200046977"
- type: attached_to_institution
profils:
- type: enseignement_superieur
conditions: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ description:
Terminale professionnelle.
prefix: la
conditions_generales:
- type: epcis
values:
- "243600327"
- type: attached_to_institution
- type: age
operator: ">="
value: 18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ description:
heures de conduite.
prefix: l’
conditions_generales:
- type: epcis
values:
- "248300543"
- type: attached_to_institution
profils:
- type: chomeur
conditions: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ conditions_generales:
- type: age
operator: <=
value: 25
- type: epcis
values:
- "246700488"
- type: attached_to_institution
- type: difficultes_acces_ou_frais_logement
profils: []
conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ description:
les académies de Paris, Créteil et Versailles et vivant à Paris.
prefix: l’
conditions_generales:
- type: departements
values:
- "75"
- type: attached_to_institution
profils:
- type: enseignement_superieur
conditions: []
Expand Down
11 changes: 6 additions & 5 deletions tools/test-benefits-geographical-constraint-consistency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ benefits.all
.forEach((benefit) => {
const result = testGeographicalRelevancy(benefit)
if (!result?.isValid) {
console.log(`
console.error(`
================================
Benefit : ${benefit.id}
Benefit slug : ${benefit.slug}
Insee code : ${benefit.institution.code_insee}
potentially incompatible with conditions :
${JSON.stringify(result?.conditions)}`)
Condition type : ${result?.conditions.type}
Benefit institution type : ${benefit.institution.type}`)
}
})

Expand All @@ -34,8 +35,8 @@ function testGeographicalRelevancy(benefit) {
return {
isValid:
conditionGeo.type === "attached_to_institution" ||
(conditionGeo.values.length == 1 &&
conditionGeo.values[0] === benefit.institution.code_insee &&
conditionGeo.values.length > 1 || // Non vérifiable, car une institution peut porter un dispositif applicable à des communes autour
(conditionGeo.values[0] === benefit.institution.code_insee &&
conditionGeo.type.slice(0, -1) === benefit.institution.type),
conditions: conditionGeo,
}
Expand Down

0 comments on commit fe8d3e6

Please sign in to comment.