catala/french_law/js
2022-04-26 16:22:47 +02:00
..
.gitignore Big renaming and dir reorg 2021-06-21 11:39:06 +02:00
allocations_familiales.js Update all APIs in various languages 2021-11-07 00:53:14 +01:00
french_law.js Fix last bugs 2022-04-26 16:22:47 +02:00
Makefile Install JS dependencies correctly 2021-06-21 11:54:56 +02:00
package-lock.json Revert "Merge pull request #196 from CatalaLang/fixup-cmdliner" 2022-02-21 14:53:48 +01:00
package.json Bump Catala version number 2021-11-07 01:38:17 +01:00
README.md Added more doc 2021-06-25 10:50:49 +02:00

Javascript French Law Library

This folder contains a ready-to-use Javascript library featuring French public algorithms coded up in Catala.

Generating the source files

The JS code is extracted from OCaml using js_of_ocaml. See the dedicated README of the OCaml library for more precisions about the OCaml code. The wrapping between OCaml and JS is done by the api_web.ml module.

You can generate the french_law.js source JS module by invoking this command from the root of the repository:

make build_french_law_library_js

Available algorithms

Allocations familiales

The function of the library is computeAllocationsFamiliales. This computation returns the amount of allocations familiales for one household described by the input. More precisely, the result returned is the sum of:

  • la base des allocations familiales
  • l'allocation forfaitaire relai pour dépassement de l'âge limite
  • la majoration pour âge
  • le complément dégressif en cas de dépassement du plafond de revenus

An example of use:

Law.computeAllocationsFamiliales({
  currentDate: new Date("2020-05-20"),
  children: [
    {
      id: 0,
      remunerationMensuelle: 0,
      dateNaissance: new Date("2003-03-02"),
      priseEnCharge: "Effective et permanente",
      aDejaOuvertDroitAuxAllocationsFamiliales: true,
    },
    {
      id: 1,
      remunerationMensuelle: 300,
      dateNaissance: new Date("2013-10-30"),
      priseEnCharge: "Garde alternée, partage des allocations",
      aDejaOuvertDroitAuxAllocationsFamiliales: true,
    },
  ],
  income: 30000,
  residence: "Métropole",
  personneQuiAssumeLaChargeEffectivePermanenteEstParent: true,
  personneQuiAssumeLaChargeEffectivePermanenteRemplitConditionsTitreISecuriteSociale: true,
});

Notably, the priseEnCharge variable for each child expects a value among:

  • "Effective et permanente"
  • "Garde alternée, allocataire unique"
  • "Garde alternée, partage des allocations"
  • "Confié aux service sociaux, allocation versée à la famille"
  • "Confié aux service sociaux, allocation versée aux services sociaux"