npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@catala-lang/french-law

v0.8.11

Published

Library of computations defined by French legislative texts, extract from Catala programs (https://catala-lang.org)

Downloads

4

Readme

@catala-lang/french-law npm

This folder contains a ready-to-use Javascript library featuring French public algorithms coded up in Catala and the corresponding ReScript wrapper.

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 generated ../ocaml/law_source/<filename>_api_web.ml modules.

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

API description

The ./src/french_law.js library exposes:

ReScript

The ReScript API is essentialy the same that the JS one within the CatalaFrenchLaw top module.

Example of project using the ReScript wrapper:

The event manager

A JavaScript object eventsManager is exposed with three callable methods:

var frenchLaw = require("french_law.js");

// Clears the raw log event array.
frenchLaw.eventsManager.resetLog(0);

// Returns the current content of the raw log event array.
let rawEvents = frenchLaw.eventsManager.retrieveRawEvents(0)

// Returns the event array parsed from the current content of the raw log event array.
let events = frenchLaw.eventsManager.retrieveEvents(0)

Important: you need to give an arbitrary value as argument.

Date and time

Date values are encoded to JS string according the ISO8601 format: 'YYYY-MM-DD'.

API functions

The french_law.js library exposes for each Catala program available in ../ocaml/law_source/ a function to call in order to run the corresponding encoded algorithm.

Available algorithms

Allocations familiales

The function 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:

var frenchLaw = require("french_law.js");

let amount = frenchLaw.computeAllocationsFamiliales({
  iDateCouranteIn: "2020-04-20",
  iEnfantsIn: [
    {
      dIdentifiant: 0,
      dRemunerationMensuelle: 0,
      dDateDeNaissance: "2003-02-02",
      dPriseEnCharge: { kind: "EffectiveEtPermanente", payload: null },
      dADejaOuvertDroitAuxAllocationsFamiliales: true,
      dBeneficieTitrePersonnelAidePersonnelleLogement: false,
    },
    {
      dIdentifiant: 1,
      dRemunerationMensuelle: 300,
      dDateDeNaissance: "2013-09-30",
      dPriseEnCharge: {
        kind: "GardeAlterneePartageAllocations",
        payload: null,
      },
      dADejaOuvertDroitAuxAllocationsFamiliales: true,
      dBeneficieTitrePersonnelAidePersonnelleLogement: false,
    },
  ],
  iRessourcesMenageIn: 30000,
  iResidenceIn: { kind: "Metropole", payload: null },
  iPersonneChargeEffectivePermanenteEstParentIn: true,
  iPersonneChargeEffectivePermanenteRemplitTitreIIn: true,
  iAvaitEnfantAChargeAvant1erJanvier2012In: false,
});

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

  • "GardeAlterneePartageAllocations"
  • "GardeAlterneeAllocataireUnique"
  • "EffectiveEtPermanente"
  • "ServicesSociauxAllocationVerseeALaFamille"
  • "ServicesSociauxAllocationVerseeAuxServicesSociaux"

See ../ocaml/law_source/allocations_familiales_api_web.ml for more information about data types.

Aides logement

TODO: add information about aides_logement_api_web.ml.

Sub libraries

All declared types and scopes of a Catala program are available in JavaScript via the following sub libs:

var frenchLaw = require("french_law.js");

// Allocations familiales
// corresponding to the file: `../ocaml/law_source/allocations_familiales_api_web.ml
var allocationsFamiliales = frenchLaw.AllocationsFamilialesLib

// APL
// corresponding to the file: `../ocaml/law_source/aides_logement_api_web.ml
var aidesLogement = frenchLaw.AidesLogementLib