mirror of
https://github.com/CatalaLang/catala.git
synced 2024-09-19 16:28:12 +03:00
Fixed Js and bumped version number
This commit is contained in:
parent
896a83db4a
commit
64661f06c6
2
Makefile
2
Makefile
@ -183,7 +183,7 @@ run_french_law_library_tests: build_french_law_library
|
||||
#> build_french_law_library_js : Builds the JS version of the OCaml French law library
|
||||
build_french_law_library_js: generate_french_law_library format
|
||||
dune build --profile release $(FRENCH_LAW_LIB_DIR)/api_web.bc.js
|
||||
cd javascript && ln -sf ../_build/default/$(FRENCH_LAW_LIB_DIR)/api_web.bc.js french_law.js
|
||||
cp -f _build/default/$(FRENCH_LAW_LIB_DIR)/api_web.bc.js french_law_js/french_law.js
|
||||
|
||||
##########################################
|
||||
# Website assets
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is generated by dune, edit dune-project instead
|
||||
opam-version: "2.0"
|
||||
version: "0.2.0"
|
||||
version: "0.3.0"
|
||||
synopsis: "Low-level language for tax code specification"
|
||||
description: """
|
||||
The Catala language is designed to be a low-level target for
|
||||
|
@ -1,7 +1,7 @@
|
||||
(lang dune 2.2)
|
||||
|
||||
(name catala)
|
||||
(version 0.2.0)
|
||||
(version 0.3.0)
|
||||
(generate_opam_files true)
|
||||
(formatting)
|
||||
|
||||
@ -40,4 +40,4 @@
|
||||
)
|
||||
|
||||
(using menhir 2.1)
|
||||
(allow_approximate_merlin)
|
||||
(allow_approximate_merlin)
|
52
french_law_js/README.md
Normal file
52
french_law_js/README.md
Normal file
@ -0,0 +1,52 @@
|
||||
# The French Law Javascript Library
|
||||
|
||||
This Javascript library contains some computations defined by French
|
||||
legislative texts. The JS code is extracted from OCaml, which is itself
|
||||
extracted from Catala code (https://catala-lang.org).
|
||||
|
||||
## 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:
|
||||
|
||||
```javascript
|
||||
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"`
|
@ -11,26 +11,24 @@ suite
|
||||
id: 0,
|
||||
remunerationMensuelle: 0,
|
||||
dateNaissance: new Date("2003-03-02"),
|
||||
gardeAlternee: false,
|
||||
priseEnChargeServiceSociaux: false,
|
||||
priseEnCharge: "Effective et permanente",
|
||||
aDejaOuvertDroitAuxAllocationsFamiliales: true,
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
remunerationMensuelle: 300,
|
||||
dateNaissance: new Date("2013-10-30"),
|
||||
gardeAlternee: true,
|
||||
gardeAlterneePartageAllocation: true,
|
||||
priseEnChargeServiceSociaux: false,
|
||||
priseEnCharge: "Garde alternée, partage des allocations",
|
||||
aDejaOuvertDroitAuxAllocationsFamiliales: true,
|
||||
},
|
||||
],
|
||||
income: 30000,
|
||||
residence: "Métropole",
|
||||
personneQuiAssumeLaChargeEffectivePermanenteEstParent: true,
|
||||
personneQuiAssumeLaChargeEffectivePermanenteRemplitConditionsTitreISecuriteSociale: true,
|
||||
});
|
||||
})
|
||||
.on("cycle", function (event) {
|
||||
console.log(String(event.target));
|
||||
})
|
||||
.on("complete", function () {
|
||||
console.log("Fastest is " + this.filter("fastest").map("name"));
|
||||
})
|
||||
.run({ async: true });
|
4000
french_law_js/french_law.js
Normal file
4000
french_law_js/french_law.js
Normal file
File diff suppressed because one or more lines are too long
59
french_law_js/package-lock.json
generated
Normal file
59
french_law_js/package-lock.json
generated
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "french_law",
|
||||
"version": "0.3.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "french_law",
|
||||
"version": "0.3.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"lodash": "^4.17.20",
|
||||
"platform": "^1.3.6"
|
||||
},
|
||||
"devDependencies": {}
|
||||
},
|
||||
"node_modules/benchmark": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
|
||||
"integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.4",
|
||||
"platform": "^1.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.20",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
|
||||
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
|
||||
},
|
||||
"node_modules/platform": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
||||
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"benchmark": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
|
||||
"integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=",
|
||||
"requires": {
|
||||
"lodash": "^4.17.4",
|
||||
"platform": "^1.3.3"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.20",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
|
||||
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
|
||||
},
|
||||
"platform": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
||||
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
|
||||
}
|
||||
}
|
||||
}
|
28
french_law_js/package.json
Normal file
28
french_law_js/package.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "french_law",
|
||||
"version": "0.3.0",
|
||||
"description": "Library of computations defined by French legislative texts, extract from Catala programs (https://catala-lang.org)",
|
||||
"main": "french_law.js",
|
||||
"dependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"lodash": "^4.17.20",
|
||||
"platform": "^1.3.6"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "node allocations_familiales.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/CatalaLang/catala.git"
|
||||
},
|
||||
"keywords": [
|
||||
"law"
|
||||
],
|
||||
"author": "Denis Merigoux",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/CatalaLang/catala/issues"
|
||||
},
|
||||
"homepage": "https://github.com/CatalaLang/catala#readme"
|
||||
}
|
@ -24,10 +24,10 @@ cat examples/allocations_familiales/securite_sociale_R.catala_fr >> allocations_
|
||||
cat examples/allocations_familiales/securite_sociale_D.catala_fr >> allocations_familiales.catala_fr
|
||||
cat examples/allocations_familiales/epilogue.catala_fr >> allocations_familiales.catala_fr
|
||||
cat examples/allocations_familiales/tests/tests_allocations_familiales.catala_fr >> allocations_familiales.catala_fr
|
||||
sed -r '/^@@Inclusion.+$/d' allocations_familiales.catala_fr > allocations_familiales_fixed.catala_fr
|
||||
sed -r '/^## Inclusion.+$/d' allocations_familiales.catala_fr > allocations_familiales_fixed.catala_fr
|
||||
mv -f allocations_familiales_fixed.catala_fr allocations_familiales.catala_fr
|
||||
scp allocations_familiales.catala_fr $1/playground/
|
||||
rm allocations_familiales.catala_fr
|
||||
scp syntax_highlighting/en/ace/mode-catala_en.js $1/playground/
|
||||
scp syntax_highlighting/fr/ace/mode-catala_fr.js $1/playground/
|
||||
scp javascript/french_law.js $1/french_law.js
|
||||
scp french_law_js/french_law.js $1/french_law.js
|
||||
|
@ -1 +0,0 @@
|
||||
../_build/default/src/french_law/api_web.bc.js
|
25
javascript/package-lock.json
generated
25
javascript/package-lock.json
generated
@ -1,25 +0,0 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"benchmark": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
|
||||
"integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=",
|
||||
"requires": {
|
||||
"lodash": "^4.17.4",
|
||||
"platform": "^1.3.3"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.20",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
|
||||
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
|
||||
},
|
||||
"platform": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
||||
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
|
||||
}
|
||||
}
|
||||
}
|
@ -29,9 +29,14 @@ class type enfant_entree =
|
||||
|
||||
method gardeAlterneePartageAllocation : bool Js.t Js.readonly_prop
|
||||
|
||||
method priseEnChargeServiceSociaux : bool Js.t Js.readonly_prop
|
||||
method priseEnCharge : Js.js_string Js.t Js.readonly_prop
|
||||
(** Expects one of the five:
|
||||
|
||||
method allocationVerseeServiceSociaux : bool Js.t Js.readonly_prop
|
||||
- "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" *)
|
||||
|
||||
method aDejaOuvertDroitAuxAllocationsFamiliales : bool Js.t Js.readonly_prop
|
||||
end
|
||||
@ -85,15 +90,18 @@ let _ =
|
||||
child##.dateNaissance##getMonth
|
||||
child##.dateNaissance##getDay;
|
||||
AF.d_prise_en_charge =
|
||||
( if Js.to_bool child##.gardeAlternee then
|
||||
if Js.to_bool child##.gardeAlterneePartageAllocation then
|
||||
( match Js.to_string child##.priseEnCharge with
|
||||
| "Effective et permanente" -> EffectiveEtPermanente ()
|
||||
| "Garde alternée, allocataire unique" ->
|
||||
GardeAlterneeAllocataireUnique ()
|
||||
| "Garde alternée, partage des allocations" ->
|
||||
GardeAlterneePartageAllocations ()
|
||||
else GardeAlterneeAllocataireUnique ()
|
||||
else if Js.to_bool child##.priseEnChargeServiceSociaux then
|
||||
if Js.to_bool child##.allocationVerseeServiceSociaux then
|
||||
| "Confié aux service sociaux, allocation versée à la famille" ->
|
||||
ServicesSociauxAllocationVerseeALaFamille ()
|
||||
| "Confié aux service sociaux, allocation versée aux services sociaux"
|
||||
->
|
||||
ServicesSociauxAllocationVerseeAuxServicesSociaux ()
|
||||
else ServicesSociauxAllocationVerseeALaFamille ()
|
||||
else EffectiveEtPermanente () );
|
||||
| _ -> failwith "Unknown prise en charge" );
|
||||
AF.d_remuneration_mensuelle =
|
||||
money_of_units_int child##.remunerationMensuelle;
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user