mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
refactor(french_law/ocaml): refactor the api_web.ml
This commit is contained in:
parent
231f327efb
commit
d9045499c0
7
Makefile
7
Makefile
@ -196,13 +196,18 @@ $(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales.ml:
|
||||
CATALA_OPTS="$(CATALA_OPTS) -t" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.ml
|
||||
cp -f $(ALLOCATIONS_FAMILIALES_DIR)/allocations_familiales.ml $@
|
||||
|
||||
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales_api_web.ml:
|
||||
CATALA_OPTS="$(CATALA_OPTS) -t" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales_api_web.ml
|
||||
cp -f $(ALLOCATIONS_FAMILIALES_DIR)/allocations_familiales_api_web.ml $@
|
||||
|
||||
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/unit_tests/tests_allocations_familiales.ml:
|
||||
CATALA_OPTS="$(CATALA_OPTS) -t" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) tests/tests_allocations_familiales.ml
|
||||
cp -f $(ALLOCATIONS_FAMILIALES_DIR)/tests/tests_allocations_familiales.ml $@
|
||||
|
||||
#> generate_french_law_library_ocaml : Generates the French law library OCaml sources from Catala
|
||||
generate_french_law_library_ocaml:\
|
||||
generate_french_law_library_ocaml: plugins \
|
||||
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales.ml \
|
||||
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales_api_web.ml \
|
||||
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/unit_tests/tests_allocations_familiales.ml
|
||||
$(MAKE) format
|
||||
|
||||
|
@ -338,8 +338,7 @@ let driver source_file (options : Cli.options) : int =
|
||||
Cli.debug_print "Compiling program into OCaml...";
|
||||
Cli.debug_print "Writing to %s..."
|
||||
(Option.value ~default:"stdout" output_file);
|
||||
Lcalc.To_ocaml.format_program fmt prgm type_ordering;
|
||||
File.ocamlformat_file_opt output_file
|
||||
Lcalc.To_ocaml.format_program fmt prgm type_ordering
|
||||
| `Plugin (Plugin.Lcalc p) ->
|
||||
let output_file, _ = get_output ~ext:p.Plugin.extension () in
|
||||
Cli.debug_print "Compiling program through backend \"%s\"..."
|
||||
|
@ -8,7 +8,7 @@
|
||||
(name jsoo)
|
||||
(modes plugin)
|
||||
(modules jsoo)
|
||||
(libraries catala.driver catala.runtime))
|
||||
(libraries catala.driver))
|
||||
|
||||
(documentation
|
||||
(package catala)
|
||||
|
@ -27,7 +27,7 @@ open Lcalc.To_ocaml
|
||||
module D = Dcalc.Ast
|
||||
|
||||
let name = "jsoo"
|
||||
let extension = ".js"
|
||||
let extension = ".ml"
|
||||
|
||||
module To_jsoo = struct
|
||||
let format_tlit (fmt : Format.formatter) (l : Dcalc.Ast.typ_lit) : unit =
|
||||
|
@ -9,6 +9,8 @@ CURR_DIR=examples/$(shell basename $(shell pwd))/
|
||||
CATALA=cd ../../; _build/default/compiler/catala.exe \
|
||||
$(CATALA_OPTS) --language=$(CATALA_LANG)
|
||||
|
||||
PLUGIN_DIR=_build/default/compiler/plugins
|
||||
|
||||
help : ../Makefile.common.mk
|
||||
@sed -n 's/^#> //p' $<
|
||||
|
||||
@ -31,6 +33,14 @@ help : ../Makefile.common.mk
|
||||
OCaml \
|
||||
$(CURR_DIR)$<
|
||||
|
||||
#> <target_file>_api_web.ml : Compiles the file to OCaml + genereates the API web
|
||||
%_api_web.ml: %.catala_$(CATALA_LANG)
|
||||
@$(CATALA) Makefile $(CURR_DIR)$<
|
||||
$(CATALA) \
|
||||
jsoo \
|
||||
--plugin-dir=$(PLUGIN_DIR) \
|
||||
$(CURR_DIR)$<
|
||||
|
||||
#> <target_file>.py : Compiles the file to Python
|
||||
%.py: %.catala_$(CATALA_LANG)
|
||||
@$(CATALA) Makefile $(CURR_DIR)$<
|
||||
|
@ -8,8 +8,10 @@ algorithms coded up in Catala.
|
||||
The JS code is extracted from OCaml using
|
||||
[`js_of_ocaml`](https://ocsigen.org/js_of_ocaml/). See the
|
||||
[dedicated README](../ocaml/README.md) 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.
|
||||
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:
|
||||
@ -20,74 +22,42 @@ make build_french_law_library_js
|
||||
|
||||
## API description
|
||||
|
||||
<details>
|
||||
The `french_law.js` library exposes:
|
||||
|
||||
<summary>API content</summary>
|
||||
- an [event manager](#the-event-manager)
|
||||
- a list of [API functions](#api-functions)
|
||||
- a list of fully exposed [sub-libraries](#sub-libraries)
|
||||
|
||||
### Data types
|
||||
### The event manager
|
||||
|
||||
#### `source_position`
|
||||
|
||||
Stores information about the log position.
|
||||
A JavaScript object `eventsManager` is exposed with three callable methods:
|
||||
|
||||
```javascript
|
||||
{
|
||||
fileName : string
|
||||
startLine : int
|
||||
endLine : int
|
||||
startColumn : int
|
||||
endColumn : int
|
||||
lawHeadings : [string]
|
||||
}
|
||||
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)
|
||||
```
|
||||
|
||||
#### `log_event`
|
||||
> **Important**: you need to give an arbitrary value as argument.
|
||||
|
||||
Stores information about one log event.
|
||||
### API functions
|
||||
|
||||
```javascript
|
||||
{
|
||||
eventType : string
|
||||
information : [string]
|
||||
sourcePosition : source_position?
|
||||
loggedValueJson : string
|
||||
}
|
||||
```
|
||||
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.
|
||||
|
||||
`loggedValueJson` is the resulting string representation of the
|
||||
`Runtime.runtime_value` serialization via `yojson` -- see
|
||||
`./src/compiler/runtime.mli`.
|
||||
#### Available algorithms
|
||||
|
||||
### Functions
|
||||
##### Allocations familiales
|
||||
|
||||
#### `french_law.resetLog()`
|
||||
|
||||
Clears the log array.
|
||||
|
||||
Example of use:
|
||||
|
||||
```javascript
|
||||
french_law.resetLog(0) // Note that you have to pass an arbitrary argument.
|
||||
```
|
||||
|
||||
#### `french_law.retrieveLog()`
|
||||
|
||||
Returns the array of [`log_event`](#log_event) resulting of the computation of the
|
||||
[algorithms](#available-algorithms).
|
||||
|
||||
Example of use:
|
||||
|
||||
```javascript
|
||||
let logs = french_law.retrieveLog(0) // Note that you have to pass an arbitrary argument.
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Available algorithms
|
||||
|
||||
### Allocations familiales
|
||||
|
||||
The function of the library is `computeAllocationsFamiliales`. This computation
|
||||
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:
|
||||
|
||||
@ -99,35 +69,56 @@ by the input. More precisely, the result returned is the sum of:
|
||||
An example of use:
|
||||
|
||||
```javascript
|
||||
Law.computeAllocationsFamiliales({
|
||||
currentDate: new Date("2020-05-20"),
|
||||
children: [
|
||||
var frenchLaw = require("french_law.js");
|
||||
|
||||
let amount = frenchLaw.computeAllocationsFamiliales({
|
||||
iDateCouranteIn: new Date("2020-05-20"),
|
||||
iEnfantIn: [
|
||||
{
|
||||
id: 0,
|
||||
remunerationMensuelle: 0,
|
||||
dateNaissance: new Date("2003-03-02"),
|
||||
priseEnCharge: "Effective et permanente",
|
||||
aDejaOuvertDroitAuxAllocationsFamiliales: true,
|
||||
dIdentifiant: 0,
|
||||
dRemunerationMensuelle: 0.0,
|
||||
dDateDeNaissance: new Date("2003-03-02"),
|
||||
dPriseEnCharge: "EffectiveEtPermanente",
|
||||
dADejaOuvertDroitAuxAllocationsFamiliales: true,
|
||||
dBeneficieTitrePersonnelAidePersonnelleLogement: false,
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
remunerationMensuelle: 300,
|
||||
dateNaissance: new Date("2013-10-30"),
|
||||
priseEnCharge: "Garde alternée, partage des allocations",
|
||||
aDejaOuvertDroitAuxAllocationsFamiliales: true,
|
||||
|
||||
dIdentifiant: 1,
|
||||
dRemunerationMensuelle: 330.0,
|
||||
dDateDeNaissance: new Date("2013-10-30"),
|
||||
dPriseEnCharge: "GardeAlterneePartageAllocations",
|
||||
dADejaOuvertDroitAuxAllocationsFamiliales: true,
|
||||
dBeneficieTitrePersonnelAidePersonnelleLogement: false,
|
||||
},
|
||||
],
|
||||
income: 30000,
|
||||
residence: "Métropole",
|
||||
personneQuiAssumeLaChargeEffectivePermanenteEstParent: true,
|
||||
personneQuiAssumeLaChargeEffectivePermanenteRemplitConditionsTitreISecuriteSociale: true,
|
||||
iRessourcesMenageIn: 30000.0,
|
||||
iResidenceIn: "Metropole",
|
||||
iPersonneChargeEffectivePermanenteEstParentIn: true,
|
||||
iPersonneChargeEffectivePermanenteRemplitTitreIIn: true,
|
||||
iAvaitEnfantAChargeAvant1erJanvier2012In: true,
|
||||
});
|
||||
```
|
||||
|
||||
Notably, the `priseEnCharge` variable for each child expects a value among:
|
||||
Notably, the `dPriseEnCharge` variable for each child expects a value among:
|
||||
- "GardeAlterneePartageAllocations"
|
||||
- "GardeAlterneeAllocataireUnique"
|
||||
- "EffectiveEtPermanente"
|
||||
- "ServicesSociauxAllocationVerseeALaFamille"
|
||||
- "ServicesSociauxAllocationVerseeAuxServicesSociaux"
|
||||
|
||||
- `"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"`
|
||||
> See `../ocaml/law_source/allocations_familiales_api_web.ml` for more
|
||||
> information about data types.
|
||||
|
||||
### Sub libraries
|
||||
|
||||
All declared types and scopes of a Catala program are available in JavaScript
|
||||
via the following sub libs:
|
||||
|
||||
```javascript
|
||||
var frenchLaw = require("french_law.js");
|
||||
|
||||
// Allocations familiales
|
||||
// corresponding to the file: `../ocaml/law_source/allocations_familiales_api_web.ml
|
||||
var allocationsFamiliales = frenchLaw.AllocationsFamilialesLib
|
||||
```
|
||||
|
6323
french_law/js/french_law.js
generated
6323
french_law/js/french_law.js
generated
File diff suppressed because one or more lines are too long
@ -39,7 +39,7 @@ Then, the `api.{ml, mli}` module provides a wrapper around the functions
|
||||
exported in `law_source`. These wrappers mostly convert back and forth between
|
||||
idiomatic OCaml types and the types expected by the Catala programs in OCaml.
|
||||
|
||||
`api.web.ml` is used for the JS library (see the [dedicated README](../js/README.md)).
|
||||
`api_web.ml` is used for the JS library (see the [dedicated README](../js/README.md)).
|
||||
|
||||
Finally, `bench.ml` provides a simple benchmarking executable that runs the
|
||||
computations of each algorithm a bunch of times with random inputs. You can run it
|
||||
|
@ -1,6 +1,7 @@
|
||||
(* This file is part of the French law library, a collection of functions for
|
||||
computing French taxes and benefits derived from Catala programs. Copyright
|
||||
(C) 2021 Inria, contributor: Denis Merigoux <denis.merigoux@inria.fr>
|
||||
(C) 2021 Inria, contributor: Denis Merigoux <denis.merigoux@inria.fr>, Emile
|
||||
Rolley <emile.rolley@tuta.io>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
use this file except in compliance with the License. You may obtain a copy of
|
||||
@ -14,15 +15,15 @@
|
||||
License for the specific language governing permissions and limitations under
|
||||
the License. *)
|
||||
|
||||
open Runtime_ocaml.Runtime
|
||||
module Allocations_familiales = Law_source.Allocations_familiales
|
||||
module AF = Allocations_familiales
|
||||
open Runtime
|
||||
|
||||
let compute_allocations_familiales
|
||||
~(current_date : Runtime.date)
|
||||
~(current_date : date)
|
||||
~(children : AF.EnfantEntree.t array)
|
||||
~(income : int)
|
||||
~(residence : AF.collectivite)
|
||||
~(residence : AF.Collectivite.t)
|
||||
~(is_parent : bool)
|
||||
~(fills_title_I : bool)
|
||||
~(had_rights_open_before_2012 : bool) : float =
|
||||
|
@ -14,13 +14,14 @@
|
||||
License for the specific language governing permissions and limitations under
|
||||
the License. *)
|
||||
|
||||
open Runtime_ocaml.Runtime
|
||||
module Allocations_familiales = Law_source.Allocations_familiales
|
||||
|
||||
val compute_allocations_familiales :
|
||||
current_date:Runtime.date ->
|
||||
current_date:date ->
|
||||
children:Allocations_familiales.EnfantEntree.t array ->
|
||||
income:int ->
|
||||
residence:Allocations_familiales.collectivite ->
|
||||
residence:Allocations_familiales.Collectivite.t ->
|
||||
is_parent:bool ->
|
||||
fills_title_I:bool ->
|
||||
had_rights_open_before_2012:bool ->
|
||||
|
@ -1,6 +1,7 @@
|
||||
(* This file is part of the French law library, a collection of functions for
|
||||
computing French taxes and benefits derived from Catala programs. Copyright
|
||||
(C) 2021 Inria, contributor: Denis Merigoux <denis.merigoux@inria.fr>
|
||||
(C) 2021 Inria, contributor: Denis Merigoux <denis.merigoux@inria.fr>, Emile
|
||||
Rolley <emile.rolley@tuta.io>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
use this file except in compliance with the License. You may obtain a copy of
|
||||
@ -14,151 +15,23 @@
|
||||
License for the specific language governing permissions and limitations under
|
||||
the License. *)
|
||||
|
||||
module Allocations_familiales = Law_source.Allocations_familiales
|
||||
module AF = Allocations_familiales
|
||||
open Runtime
|
||||
open Js_of_ocaml
|
||||
|
||||
class type enfant_entree =
|
||||
object
|
||||
method id : int Js.readonly_prop
|
||||
method remunerationMensuelle : int Js.readonly_prop
|
||||
method dateNaissance : Js.date Js.t Js.readonly_prop
|
||||
method gardeAlternee : bool Js.t Js.readonly_prop
|
||||
method gardeAlterneePartageAllocation : bool Js.t Js.readonly_prop
|
||||
|
||||
method priseEnCharge : Js.js_string Js.t Js.readonly_prop
|
||||
(** Expects one of the five:
|
||||
|
||||
- "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
|
||||
|
||||
method beneficieTitrePersonnelAidePersonnelleAuLogement :
|
||||
bool Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
class type allocations_familiales_input =
|
||||
object
|
||||
method currentDate : Js.date Js.t Js.readonly_prop
|
||||
method children : enfant_entree Js.t Js.js_array Js.t Js.readonly_prop
|
||||
method income : int Js.readonly_prop
|
||||
method residence : Js.js_string Js.t Js.readonly_prop
|
||||
|
||||
method personneQuiAssumeLaChargeEffectivePermanenteEstParent :
|
||||
bool Js.t Js.readonly_prop
|
||||
|
||||
method
|
||||
personneQuiAssumeLaChargeEffectivePermanenteRemplitConditionsTitreISecuriteSociale :
|
||||
bool Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
class type source_position =
|
||||
object
|
||||
method fileName : Js.js_string Js.t Js.prop
|
||||
method startLine : int Js.prop
|
||||
method endLine : int Js.prop
|
||||
method startColumn : int Js.prop
|
||||
method endColumn : int Js.prop
|
||||
method lawHeadings : Js.js_string Js.t Js.js_array Js.t Js.prop
|
||||
end
|
||||
|
||||
class type raw_event =
|
||||
object
|
||||
method eventType : Js.js_string Js.t Js.prop
|
||||
method information : Js.js_string Js.t Js.js_array Js.t Js.prop
|
||||
method sourcePosition : source_position Js.t Js.optdef Js.prop
|
||||
method loggedValueJson : Js.js_string Js.t Js.prop
|
||||
end
|
||||
|
||||
class type event =
|
||||
object
|
||||
method data : Js.js_string Js.t Js.prop
|
||||
end
|
||||
open Law_source
|
||||
module AF = Allocations_familiales
|
||||
module AF_web = Allocations_familiales_api_web
|
||||
|
||||
let _ =
|
||||
Js.export_all
|
||||
(object%js
|
||||
method resetLog : (unit -> unit) Js.callback = Js.wrap_callback reset_log
|
||||
|
||||
method retrieveEvents : (unit -> event Js.t Js.js_array Js.t) Js.callback
|
||||
=
|
||||
Js.wrap_callback (fun () ->
|
||||
Js.array
|
||||
(Array.of_list
|
||||
(retrieve_log () |> EventParser.parse_raw_events
|
||||
|> List.map (fun event ->
|
||||
object%js
|
||||
val mutable data =
|
||||
event |> Runtime.yojson_of_event
|
||||
|> Yojson.Safe.to_string |> Js.string
|
||||
end))))
|
||||
|
||||
method retrieveRawEvents
|
||||
: (unit -> raw_event Js.t Js.js_array Js.t) Js.callback =
|
||||
Js.wrap_callback (fun () ->
|
||||
Js.array
|
||||
(Array.of_list
|
||||
(List.map
|
||||
(fun evt ->
|
||||
object%js
|
||||
val mutable eventType =
|
||||
Js.string
|
||||
(match evt with
|
||||
| BeginCall _ -> "Begin call"
|
||||
| EndCall _ -> "End call"
|
||||
| VariableDefinition _ -> "Variable definition"
|
||||
| DecisionTaken _ -> "Decision taken")
|
||||
|
||||
val mutable information =
|
||||
Js.array
|
||||
(Array.of_list
|
||||
(match evt with
|
||||
| BeginCall info
|
||||
| EndCall info
|
||||
| VariableDefinition (info, _) ->
|
||||
List.map Js.string info
|
||||
| DecisionTaken _ -> []))
|
||||
|
||||
val mutable loggedValueJson =
|
||||
(match evt with
|
||||
| VariableDefinition (_, v) -> v
|
||||
| EndCall _ | BeginCall _ | DecisionTaken _ ->
|
||||
Runtime.unembeddable ())
|
||||
|> Runtime.yojson_of_runtime_value
|
||||
|> Yojson.Safe.to_string |> Js.string
|
||||
|
||||
val mutable sourcePosition =
|
||||
match evt with
|
||||
| DecisionTaken pos ->
|
||||
Js.def
|
||||
(object%js
|
||||
val mutable fileName = Js.string pos.filename
|
||||
val mutable startLine = pos.start_line
|
||||
val mutable endLine = pos.end_line
|
||||
val mutable startColumn = pos.start_column
|
||||
val mutable endColumn = pos.end_column
|
||||
|
||||
val mutable lawHeadings =
|
||||
Js.array
|
||||
(Array.of_list
|
||||
(List.map Js.string pos.law_headings))
|
||||
end)
|
||||
| _ -> Js.undefined
|
||||
end)
|
||||
(retrieve_log ()))))
|
||||
val eventsManager = Runtime_jsoo.Runtime.event_manager
|
||||
|
||||
method computeAllocationsFamiliales
|
||||
: (allocations_familiales_input Js.t -> float) Js.callback =
|
||||
Js.wrap_callback (fun input ->
|
||||
: (AF_web.interface_allocations_familiales_in -> float) Js.callback =
|
||||
Js.wrap_callback (fun interface_allocations_familiales_in ->
|
||||
let result =
|
||||
AF_web.#interfaceAllocationsFamiliales
|
||||
input
|
||||
interface_allocations_familiales_in
|
||||
|> AF_web.interface_allocations_familiales
|
||||
|> AF_web.interface_allocations_familiales_out_of_jsoo
|
||||
in
|
||||
money_to_float
|
||||
result.AF.InterfaceAllocationsFamilialesOut.i_montant_verse_out)
|
||||
Runtime_ocaml.Runtime.money_to_float result.i_montant_verse_out)
|
||||
end)
|
||||
|
@ -15,54 +15,58 @@
|
||||
the License. *)
|
||||
|
||||
module AF = Api.Allocations_familiales
|
||||
module Runtime = Runtime_ocaml
|
||||
open Runtime
|
||||
|
||||
let random_children (id : int) =
|
||||
{
|
||||
AF.EnfantEntree.d_identifiant = integer_of_int id;
|
||||
d_remuneration_mensuelle = money_of_units_int (Random.int 2000);
|
||||
d_date_de_naissance =
|
||||
date_of_numbers
|
||||
(2020 - Random.int 22)
|
||||
(1 + Random.int 12)
|
||||
(1 + Random.int 28);
|
||||
d_prise_en_charge =
|
||||
(match Random.int 5 with
|
||||
| 0 -> AF.EffectiveEtPermanente ()
|
||||
| 1 -> AF.GardeAlterneePartageAllocations ()
|
||||
| 2 -> AF.GardeAlterneeAllocataireUnique ()
|
||||
| 3 -> AF.ServicesSociauxAllocationVerseeALaFamille ()
|
||||
| _ -> AF.ServicesSociauxAllocationVerseeAuxServicesSociaux ());
|
||||
d_a_deja_ouvert_droit_aux_allocations_familiales = Random.bool ();
|
||||
d_beneficie_titre_personnel_aide_personnelle_logement = Random.bool ();
|
||||
}
|
||||
Runtime.
|
||||
{
|
||||
AF.EnfantEntree.d_identifiant = integer_of_int id;
|
||||
d_remuneration_mensuelle = money_of_units_int (Random.int 2000);
|
||||
d_date_de_naissance =
|
||||
date_of_numbers
|
||||
(2020 - Random.int 22)
|
||||
(1 + Random.int 12)
|
||||
(1 + Random.int 28);
|
||||
d_prise_en_charge =
|
||||
AF.PriseEnCharge.(
|
||||
match Random.int 5 with
|
||||
| 0 -> EffectiveEtPermanente ()
|
||||
| 1 -> GardeAlterneePartageAllocations ()
|
||||
| 2 -> GardeAlterneeAllocataireUnique ()
|
||||
| 3 -> ServicesSociauxAllocationVerseeALaFamille ()
|
||||
| _ -> ServicesSociauxAllocationVerseeAuxServicesSociaux ());
|
||||
d_a_deja_ouvert_droit_aux_allocations_familiales = Random.bool ();
|
||||
d_beneficie_titre_personnel_aide_personnelle_logement = Random.bool ();
|
||||
}
|
||||
|
||||
let format_residence (fmt : Format.formatter) (r : AF.collectivite) : unit =
|
||||
let format_residence (fmt : Format.formatter) (r : AF.Collectivite.t) : unit =
|
||||
Format.fprintf fmt "%s"
|
||||
(match r with
|
||||
| AF.Metropole _ -> "Métropole"
|
||||
| AF.Guyane _ -> "Guyane"
|
||||
| AF.Guadeloupe _ -> "Guadeloupe"
|
||||
| AF.Martinique _ -> "Martinique"
|
||||
| AF.LaReunion _ -> "La Réunion"
|
||||
| AF.SaintBarthelemy _ -> "Saint Barthélemy"
|
||||
| AF.SaintPierreEtMiquelon _ -> "Saint Pierre et Miquelon"
|
||||
| AF.SaintMartin _ -> "Saint Martin"
|
||||
| AF.Mayotte _ -> "Mayotte")
|
||||
AF.Collectivite.(
|
||||
match r with
|
||||
| Metropole _ -> "Métropole"
|
||||
| Guyane _ -> "Guyane"
|
||||
| Guadeloupe _ -> "Guadeloupe"
|
||||
| Martinique _ -> "Martinique"
|
||||
| LaReunion _ -> "La Réunion"
|
||||
| SaintBarthelemy _ -> "Saint Barthélemy"
|
||||
| SaintPierreEtMiquelon _ -> "Saint Pierre et Miquelon"
|
||||
| SaintMartin _ -> "Saint Martin"
|
||||
| Mayotte _ -> "Mayotte")
|
||||
|
||||
let format_prise_en_charge (fmt : Format.formatter) (g : AF.prise_en_charge) :
|
||||
let format_prise_en_charge (fmt : Format.formatter) (g : AF.PriseEnCharge.t) :
|
||||
unit =
|
||||
Format.fprintf fmt "%s"
|
||||
(match g with
|
||||
| AF.EffectiveEtPermanente _ -> "Effective et permanente"
|
||||
| AF.GardeAlterneePartageAllocations _ ->
|
||||
"Garde alternée, allocations partagée"
|
||||
| AF.GardeAlterneeAllocataireUnique _ ->
|
||||
"Garde alternée, allocataire unique"
|
||||
| AF.ServicesSociauxAllocationVerseeALaFamille _ ->
|
||||
"Oui, allocations versée à la famille"
|
||||
| AF.ServicesSociauxAllocationVerseeAuxServicesSociaux _ ->
|
||||
"Oui, allocations versée aux services sociaux")
|
||||
AF.PriseEnCharge.(
|
||||
match g with
|
||||
| EffectiveEtPermanente _ -> "Effective et permanente"
|
||||
| GardeAlterneePartageAllocations _ ->
|
||||
"Garde alternée, allocations partagée"
|
||||
| GardeAlterneeAllocataireUnique _ -> "Garde alternée, allocataire unique"
|
||||
| ServicesSociauxAllocationVerseeALaFamille _ ->
|
||||
"Oui, allocations versée à la famille"
|
||||
| ServicesSociauxAllocationVerseeAuxServicesSociaux _ ->
|
||||
"Oui, allocations versée aux services sociaux")
|
||||
|
||||
let num_successful = ref 0
|
||||
let total_amount = ref 0.
|
||||
@ -75,9 +79,9 @@ let run_test () =
|
||||
let residence =
|
||||
let x = Random.int 2 in
|
||||
match x with
|
||||
| 0 -> AF.Metropole ()
|
||||
| 1 -> AF.Guadeloupe ()
|
||||
| _ -> AF.Mayotte ()
|
||||
| 0 -> AF.Collectivite.Metropole ()
|
||||
| 1 -> AF.Collectivite.Guadeloupe ()
|
||||
| _ -> AF.Collectivite.Mayotte ()
|
||||
in
|
||||
try
|
||||
let amount =
|
||||
@ -88,11 +92,11 @@ let run_test () =
|
||||
incr num_successful;
|
||||
total_amount := Float.add !total_amount amount
|
||||
with
|
||||
| (NoValueProvided _ | ConflictError) as err ->
|
||||
| (Runtime.NoValueProvided _ | Runtime.ConflictError) as err ->
|
||||
Format.printf "%s\n%a\nincome: %d\ncurrent_date: %s\nresidence: %a\n"
|
||||
(match err with
|
||||
| NoValueProvided _ -> "No value provided somewhere!"
|
||||
| ConflictError -> "Conflict error!"
|
||||
| Runtime.NoValueProvided _ -> "No value provided somewhere!"
|
||||
| Runtime.ConflictError -> "Conflict error!"
|
||||
| _ -> failwith "impossible")
|
||||
(Format.pp_print_list (fun fmt child ->
|
||||
Format.fprintf fmt
|
||||
@ -100,15 +104,16 @@ let run_test () =
|
||||
\ income: %.2f\n\
|
||||
\ birth date: %s\n\
|
||||
\ prise en charge: %a"
|
||||
(integer_to_int child.AF.EnfantEntree.d_identifiant)
|
||||
(money_to_float child.AF.EnfantEntree.d_remuneration_mensuelle)
|
||||
(Runtime.integer_to_int child.AF.EnfantEntree.d_identifiant)
|
||||
(Runtime.money_to_float
|
||||
child.AF.EnfantEntree.d_remuneration_mensuelle)
|
||||
(Runtime.date_to_string child.AF.EnfantEntree.d_date_de_naissance)
|
||||
format_prise_en_charge child.AF.EnfantEntree.d_prise_en_charge))
|
||||
(Array.to_list children) income
|
||||
(Runtime.date_to_string current_date)
|
||||
format_residence residence;
|
||||
exit (-1)
|
||||
| AssertionFailed -> ()
|
||||
| Runtime.AssertionFailed -> ()
|
||||
|
||||
let bench =
|
||||
Random.init (int_of_float (Unix.time ()));
|
||||
|
@ -2,20 +2,26 @@
|
||||
(name bench)
|
||||
(modes native)
|
||||
(modules bench)
|
||||
(libraries catala.runtime french_law benchmark))
|
||||
(libraries catala.runtime_ocaml french_law benchmark))
|
||||
|
||||
(executable
|
||||
(name api_web)
|
||||
(modes byte js)
|
||||
(modules api_web)
|
||||
(modules
|
||||
(:standard \ bench api))
|
||||
(preprocess
|
||||
(pps js_of_ocaml-ppx))
|
||||
(libraries catala.runtime law_source js_of_ocaml yojson))
|
||||
(libraries
|
||||
catala.runtime_ocaml
|
||||
catala.runtime_jsoo
|
||||
js_of_ocaml
|
||||
yojson
|
||||
law_source))
|
||||
|
||||
(library
|
||||
(name api)
|
||||
(public_name french_law)
|
||||
(synopsis
|
||||
"A collection of functions for computing French taxes and benefits derived from Catala programs")
|
||||
(libraries catala.runtime law_source)
|
||||
(libraries catala.runtime_ocaml law_source)
|
||||
(modules api))
|
||||
|
541
french_law/ocaml/law_source/allocations_familiales.ml
generated
541
french_law/ocaml/law_source/allocations_familiales.ml
generated
File diff suppressed because it is too large
Load Diff
@ -1,80 +0,0 @@
|
||||
(* This file is part of the French law library, a collection of functions for
|
||||
computing French taxes and benefits derived from Catala programs. Copyright
|
||||
(C) 2021 Inria, contributor: Denis Merigoux <denis.merigoux@inria.fr>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
use this file except in compliance with the License. You may obtain a copy of
|
||||
the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations under
|
||||
the License. *)
|
||||
|
||||
open Runtime
|
||||
|
||||
type prise_en_charge =
|
||||
| GardeAlterneePartageAllocations of unit
|
||||
| GardeAlterneeAllocataireUnique of unit
|
||||
| EffectiveEtPermanente of unit
|
||||
| ServicesSociauxAllocationVerseeALaFamille of unit
|
||||
| ServicesSociauxAllocationVerseeAuxServicesSociaux of unit
|
||||
|
||||
type situation_obligation_scolaire =
|
||||
| Avant of unit
|
||||
| Pendant of unit
|
||||
| Apres of unit
|
||||
|
||||
type collectivite =
|
||||
| Guadeloupe of unit
|
||||
| Guyane of unit
|
||||
| Martinique of unit
|
||||
| LaReunion of unit
|
||||
| SaintBarthelemy of unit
|
||||
| SaintMartin of unit
|
||||
| Metropole of unit
|
||||
| SaintPierreEtMiquelon of unit
|
||||
| Mayotte of unit
|
||||
|
||||
type element_prestations_familiales =
|
||||
| PrestationAccueilJeuneEnfant of unit
|
||||
| AllocationsFamiliales of unit
|
||||
| ComplementFamilial of unit
|
||||
| AllocationLogement of unit
|
||||
| AllocationEducationEnfantHandicape of unit
|
||||
| AllocationSoutienFamilial of unit
|
||||
| AllocationRentreeScolaire of unit
|
||||
| AllocationJournalierePresenceParentale of unit
|
||||
|
||||
module EnfantEntree : sig
|
||||
type t = {
|
||||
d_identifiant : integer;
|
||||
d_remuneration_mensuelle : money;
|
||||
d_date_de_naissance : date;
|
||||
d_prise_en_charge : prise_en_charge;
|
||||
d_a_deja_ouvert_droit_aux_allocations_familiales : bool;
|
||||
d_beneficie_titre_personnel_aide_personnelle_logement : bool;
|
||||
}
|
||||
end
|
||||
|
||||
module InterfaceAllocationsFamilialesOut : sig
|
||||
type t = { i_montant_verse_out : money }
|
||||
end
|
||||
|
||||
module InterfaceAllocationsFamilialesIn : sig
|
||||
type t = {
|
||||
i_date_courante_in : date;
|
||||
i_enfants_in : EnfantEntree.t array;
|
||||
i_ressources_menage_in : money;
|
||||
i_residence_in : collectivite;
|
||||
i_personne_charge_effective_permanente_est_parent_in : bool;
|
||||
i_personne_charge_effective_permanente_remplit_titre_I_in : bool;
|
||||
i_avait_enfant_a_charge_avant_1er_janvier_2012_in : bool;
|
||||
}
|
||||
end
|
||||
|
||||
val interface_allocations_familiales :
|
||||
InterfaceAllocationsFamilialesIn.t -> InterfaceAllocationsFamilialesOut.t
|
974
french_law/ocaml/law_source/allocations_familiales_api_web.ml
Normal file
974
french_law/ocaml/law_source/allocations_familiales_api_web.ml
Normal file
@ -0,0 +1,974 @@
|
||||
(** This file has been generated by the Catala compiler, do not edit! *)
|
||||
|
||||
open Runtime_ocaml.Runtime
|
||||
open Runtime_jsoo.Runtime
|
||||
open Js_of_ocaml
|
||||
open Allocations_familiales
|
||||
|
||||
[@@@ocaml.warning "-4-26-27-32-41-42"]
|
||||
|
||||
(* Generated API *)
|
||||
|
||||
class type prise_en_charge =
|
||||
object
|
||||
method kind : Js.js_string Js.t Js.readonly_prop
|
||||
(** Expects one of:
|
||||
|
||||
- "GardeAlterneePartageAllocations"
|
||||
- "GardeAlterneeAllocataireUnique"
|
||||
- "EffectiveEtPermanente"
|
||||
- "ServicesSociauxAllocationVerseeALaFamille"
|
||||
- "ServicesSociauxAllocationVerseeAuxServicesSociaux" *)
|
||||
|
||||
method payload : Js.Unsafe.any Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let prise_en_charge_to_jsoo : PriseEnCharge.t -> prise_en_charge Js.t = function
|
||||
| GardeAlterneePartageAllocations arg ->
|
||||
object%js
|
||||
val kind = Js.string "GardeAlterneePartageAllocations"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| GardeAlterneeAllocataireUnique arg ->
|
||||
object%js
|
||||
val kind = Js.string "GardeAlterneeAllocataireUnique"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| EffectiveEtPermanente arg ->
|
||||
object%js
|
||||
val kind = Js.string "EffectiveEtPermanente"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| ServicesSociauxAllocationVerseeALaFamille arg ->
|
||||
object%js
|
||||
val kind = Js.string "ServicesSociauxAllocationVerseeALaFamille"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| ServicesSociauxAllocationVerseeAuxServicesSociaux arg ->
|
||||
object%js
|
||||
val kind = Js.string "ServicesSociauxAllocationVerseeAuxServicesSociaux"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
|
||||
let prise_en_charge_of_jsoo (prise_en_charge : prise_en_charge Js.t) :
|
||||
PriseEnCharge.t =
|
||||
match prise_en_charge##.kind |> Js.to_string with
|
||||
| "GardeAlterneePartageAllocations" ->
|
||||
PriseEnCharge.GardeAlterneePartageAllocations ()
|
||||
| "GardeAlterneeAllocataireUnique" ->
|
||||
PriseEnCharge.GardeAlterneeAllocataireUnique ()
|
||||
| "EffectiveEtPermanente" -> PriseEnCharge.EffectiveEtPermanente ()
|
||||
| "ServicesSociauxAllocationVerseeALaFamille" ->
|
||||
PriseEnCharge.ServicesSociauxAllocationVerseeALaFamille ()
|
||||
| "ServicesSociauxAllocationVerseeAuxServicesSociaux" ->
|
||||
PriseEnCharge.ServicesSociauxAllocationVerseeAuxServicesSociaux ()
|
||||
| cons ->
|
||||
failwith
|
||||
(Printf.sprintf
|
||||
"Unexpected '%s' kind for the enumeration 'PriseEnCharge.t'" cons)
|
||||
|
||||
class type situation_obligation_scolaire =
|
||||
object
|
||||
method kind : Js.js_string Js.t Js.readonly_prop
|
||||
(** Expects one of:
|
||||
|
||||
- "Avant"
|
||||
- "Pendant"
|
||||
- "Apres" *)
|
||||
|
||||
method payload : Js.Unsafe.any Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let situation_obligation_scolaire_to_jsoo :
|
||||
SituationObligationScolaire.t -> situation_obligation_scolaire Js.t =
|
||||
function
|
||||
| Avant arg ->
|
||||
object%js
|
||||
val kind = Js.string "Avant"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| Pendant arg ->
|
||||
object%js
|
||||
val kind = Js.string "Pendant"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| Apres arg ->
|
||||
object%js
|
||||
val kind = Js.string "Apres"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
|
||||
let situation_obligation_scolaire_of_jsoo
|
||||
(situation_obligation_scolaire : situation_obligation_scolaire Js.t) :
|
||||
SituationObligationScolaire.t =
|
||||
match situation_obligation_scolaire##.kind |> Js.to_string with
|
||||
| "Avant" -> SituationObligationScolaire.Avant ()
|
||||
| "Pendant" -> SituationObligationScolaire.Pendant ()
|
||||
| "Apres" -> SituationObligationScolaire.Apres ()
|
||||
| cons ->
|
||||
failwith
|
||||
(Printf.sprintf
|
||||
"Unexpected '%s' kind for the enumeration \
|
||||
'SituationObligationScolaire.t'"
|
||||
cons)
|
||||
|
||||
class type prise_en_compte =
|
||||
object
|
||||
method kind : Js.js_string Js.t Js.readonly_prop
|
||||
(** Expects one of:
|
||||
|
||||
- "Complete"
|
||||
- "Partagee"
|
||||
- "Zero" *)
|
||||
|
||||
method payload : Js.Unsafe.any Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let prise_en_compte_to_jsoo : PriseEnCompte.t -> prise_en_compte Js.t = function
|
||||
| Complete arg ->
|
||||
object%js
|
||||
val kind = Js.string "Complete"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| Partagee arg ->
|
||||
object%js
|
||||
val kind = Js.string "Partagee"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| Zero arg ->
|
||||
object%js
|
||||
val kind = Js.string "Zero"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
|
||||
let prise_en_compte_of_jsoo (prise_en_compte : prise_en_compte Js.t) :
|
||||
PriseEnCompte.t =
|
||||
match prise_en_compte##.kind |> Js.to_string with
|
||||
| "Complete" -> PriseEnCompte.Complete ()
|
||||
| "Partagee" -> PriseEnCompte.Partagee ()
|
||||
| "Zero" -> PriseEnCompte.Zero ()
|
||||
| cons ->
|
||||
failwith
|
||||
(Printf.sprintf
|
||||
"Unexpected '%s' kind for the enumeration 'PriseEnCompte.t'" cons)
|
||||
|
||||
class type versement_allocations =
|
||||
object
|
||||
method kind : Js.js_string Js.t Js.readonly_prop
|
||||
(** Expects one of:
|
||||
|
||||
- "Normal"
|
||||
- "AllocationVerseeAuxServicesSociaux" *)
|
||||
|
||||
method payload : Js.Unsafe.any Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let versement_allocations_to_jsoo :
|
||||
VersementAllocations.t -> versement_allocations Js.t = function
|
||||
| Normal arg ->
|
||||
object%js
|
||||
val kind = Js.string "Normal"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| AllocationVerseeAuxServicesSociaux arg ->
|
||||
object%js
|
||||
val kind = Js.string "AllocationVerseeAuxServicesSociaux"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
|
||||
let versement_allocations_of_jsoo
|
||||
(versement_allocations : versement_allocations Js.t) :
|
||||
VersementAllocations.t =
|
||||
match versement_allocations##.kind |> Js.to_string with
|
||||
| "Normal" -> VersementAllocations.Normal ()
|
||||
| "AllocationVerseeAuxServicesSociaux" ->
|
||||
VersementAllocations.AllocationVerseeAuxServicesSociaux ()
|
||||
| cons ->
|
||||
failwith
|
||||
(Printf.sprintf
|
||||
"Unexpected '%s' kind for the enumeration 'VersementAllocations.t'"
|
||||
cons)
|
||||
|
||||
class type element_prestations_familiales =
|
||||
object
|
||||
method kind : Js.js_string Js.t Js.readonly_prop
|
||||
(** Expects one of:
|
||||
|
||||
- "PrestationAccueilJeuneEnfant"
|
||||
- "AllocationsFamiliales"
|
||||
- "ComplementFamilial"
|
||||
- "AllocationLogement"
|
||||
- "AllocationEducationEnfantHandicape"
|
||||
- "AllocationSoutienFamilial"
|
||||
- "AllocationRentreeScolaire"
|
||||
- "AllocationJournalierePresenceParentale" *)
|
||||
|
||||
method payload : Js.Unsafe.any Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let element_prestations_familiales_to_jsoo :
|
||||
ElementPrestationsFamiliales.t -> element_prestations_familiales Js.t =
|
||||
function
|
||||
| PrestationAccueilJeuneEnfant arg ->
|
||||
object%js
|
||||
val kind = Js.string "PrestationAccueilJeuneEnfant"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| AllocationsFamiliales arg ->
|
||||
object%js
|
||||
val kind = Js.string "AllocationsFamiliales"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| ComplementFamilial arg ->
|
||||
object%js
|
||||
val kind = Js.string "ComplementFamilial"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| AllocationLogement arg ->
|
||||
object%js
|
||||
val kind = Js.string "AllocationLogement"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| AllocationEducationEnfantHandicape arg ->
|
||||
object%js
|
||||
val kind = Js.string "AllocationEducationEnfantHandicape"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| AllocationSoutienFamilial arg ->
|
||||
object%js
|
||||
val kind = Js.string "AllocationSoutienFamilial"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| AllocationRentreeScolaire arg ->
|
||||
object%js
|
||||
val kind = Js.string "AllocationRentreeScolaire"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| AllocationJournalierePresenceParentale arg ->
|
||||
object%js
|
||||
val kind = Js.string "AllocationJournalierePresenceParentale"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
|
||||
let element_prestations_familiales_of_jsoo
|
||||
(element_prestations_familiales : element_prestations_familiales Js.t) :
|
||||
ElementPrestationsFamiliales.t =
|
||||
match element_prestations_familiales##.kind |> Js.to_string with
|
||||
| "PrestationAccueilJeuneEnfant" ->
|
||||
ElementPrestationsFamiliales.PrestationAccueilJeuneEnfant ()
|
||||
| "AllocationsFamiliales" ->
|
||||
ElementPrestationsFamiliales.AllocationsFamiliales ()
|
||||
| "ComplementFamilial" -> ElementPrestationsFamiliales.ComplementFamilial ()
|
||||
| "AllocationLogement" -> ElementPrestationsFamiliales.AllocationLogement ()
|
||||
| "AllocationEducationEnfantHandicape" ->
|
||||
ElementPrestationsFamiliales.AllocationEducationEnfantHandicape ()
|
||||
| "AllocationSoutienFamilial" ->
|
||||
ElementPrestationsFamiliales.AllocationSoutienFamilial ()
|
||||
| "AllocationRentreeScolaire" ->
|
||||
ElementPrestationsFamiliales.AllocationRentreeScolaire ()
|
||||
| "AllocationJournalierePresenceParentale" ->
|
||||
ElementPrestationsFamiliales.AllocationJournalierePresenceParentale ()
|
||||
| cons ->
|
||||
failwith
|
||||
(Printf.sprintf
|
||||
"Unexpected '%s' kind for the enumeration \
|
||||
'ElementPrestationsFamiliales.t'"
|
||||
cons)
|
||||
|
||||
class type collectivite =
|
||||
object
|
||||
method kind : Js.js_string Js.t Js.readonly_prop
|
||||
(** Expects one of:
|
||||
|
||||
- "Guadeloupe"
|
||||
- "Guyane"
|
||||
- "Martinique"
|
||||
- "LaReunion"
|
||||
- "SaintBarthelemy"
|
||||
- "SaintMartin"
|
||||
- "Metropole"
|
||||
- "SaintPierreEtMiquelon"
|
||||
- "Mayotte" *)
|
||||
|
||||
method payload : Js.Unsafe.any Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let collectivite_to_jsoo : Collectivite.t -> collectivite Js.t = function
|
||||
| Guadeloupe arg ->
|
||||
object%js
|
||||
val kind = Js.string "Guadeloupe"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| Guyane arg ->
|
||||
object%js
|
||||
val kind = Js.string "Guyane"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| Martinique arg ->
|
||||
object%js
|
||||
val kind = Js.string "Martinique"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| LaReunion arg ->
|
||||
object%js
|
||||
val kind = Js.string "LaReunion"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| SaintBarthelemy arg ->
|
||||
object%js
|
||||
val kind = Js.string "SaintBarthelemy"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| SaintMartin arg ->
|
||||
object%js
|
||||
val kind = Js.string "SaintMartin"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| Metropole arg ->
|
||||
object%js
|
||||
val kind = Js.string "Metropole"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| SaintPierreEtMiquelon arg ->
|
||||
object%js
|
||||
val kind = Js.string "SaintPierreEtMiquelon"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
| Mayotte arg ->
|
||||
object%js
|
||||
val kind = Js.string "Mayotte"
|
||||
val payload = Js.Unsafe.coerce (Js.Unsafe.inject arg)
|
||||
end
|
||||
|
||||
let collectivite_of_jsoo (collectivite : collectivite Js.t) : Collectivite.t =
|
||||
match collectivite##.kind |> Js.to_string with
|
||||
| "Guadeloupe" -> Collectivite.Guadeloupe ()
|
||||
| "Guyane" -> Collectivite.Guyane ()
|
||||
| "Martinique" -> Collectivite.Martinique ()
|
||||
| "LaReunion" -> Collectivite.LaReunion ()
|
||||
| "SaintBarthelemy" -> Collectivite.SaintBarthelemy ()
|
||||
| "SaintMartin" -> Collectivite.SaintMartin ()
|
||||
| "Metropole" -> Collectivite.Metropole ()
|
||||
| "SaintPierreEtMiquelon" -> Collectivite.SaintPierreEtMiquelon ()
|
||||
| "Mayotte" -> Collectivite.Mayotte ()
|
||||
| cons ->
|
||||
failwith
|
||||
(Printf.sprintf
|
||||
"Unexpected '%s' kind for the enumeration 'Collectivite.t'" cons)
|
||||
|
||||
class type enfant_entree =
|
||||
object
|
||||
method dIdentifiant : int Js.readonly_prop
|
||||
method dRemunerationMensuelle : float Js.readonly_prop
|
||||
method dDateDeNaissance : Js.date Js.t Js.readonly_prop
|
||||
method dPriseEnCharge : prise_en_charge Js.t Js.readonly_prop
|
||||
|
||||
method dADejaOuvertDroitAuxAllocationsFamiliales :
|
||||
bool Js.t Js.readonly_prop
|
||||
|
||||
method dBeneficieTitrePersonnelAidePersonnelleLogement :
|
||||
bool Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let enfant_entree_to_jsoo (enfant_entree : EnfantEntree.t) : enfant_entree Js.t
|
||||
=
|
||||
object%js
|
||||
val dIdentifiant = integer_to_int enfant_entree.d_identifiant
|
||||
|
||||
val dRemunerationMensuelle =
|
||||
money_to_float enfant_entree.d_remuneration_mensuelle
|
||||
|
||||
val dDateDeNaissance = date_to_jsoo enfant_entree.d_date_de_naissance
|
||||
val dPriseEnCharge = prise_en_charge_to_jsoo enfant_entree.d_prise_en_charge
|
||||
|
||||
val dADejaOuvertDroitAuxAllocationsFamiliales =
|
||||
Js.bool enfant_entree.d_a_deja_ouvert_droit_aux_allocations_familiales
|
||||
|
||||
val dBeneficieTitrePersonnelAidePersonnelleLogement =
|
||||
Js.bool
|
||||
enfant_entree.d_beneficie_titre_personnel_aide_personnelle_logement
|
||||
end
|
||||
|
||||
let enfant_entree_of_jsoo (enfant_entree : enfant_entree Js.t) : EnfantEntree.t
|
||||
=
|
||||
{
|
||||
d_identifiant = integer_of_int enfant_entree##.dIdentifiant;
|
||||
d_remuneration_mensuelle =
|
||||
money_of_decimal
|
||||
@@ decimal_of_float enfant_entree##.dRemunerationMensuelle;
|
||||
d_date_de_naissance = date_of_jsoo enfant_entree##.dDateDeNaissance;
|
||||
d_prise_en_charge = prise_en_charge_of_jsoo enfant_entree##.dPriseEnCharge;
|
||||
d_a_deja_ouvert_droit_aux_allocations_familiales =
|
||||
Js.to_bool enfant_entree##.dADejaOuvertDroitAuxAllocationsFamiliales;
|
||||
d_beneficie_titre_personnel_aide_personnelle_logement =
|
||||
Js.to_bool enfant_entree##.dBeneficieTitrePersonnelAidePersonnelleLogement;
|
||||
}
|
||||
|
||||
class type enfant =
|
||||
object
|
||||
method identifiant : int Js.readonly_prop
|
||||
|
||||
method obligationScolaire :
|
||||
situation_obligation_scolaire Js.t Js.readonly_prop
|
||||
|
||||
method remunerationMensuelle : float Js.readonly_prop
|
||||
method dateDeNaissance : Js.date Js.t Js.readonly_prop
|
||||
method age : int Js.readonly_prop
|
||||
method priseEnCharge : prise_en_charge Js.t Js.readonly_prop
|
||||
method aDejaOuvertDroitAuxAllocationsFamiliales : bool Js.t Js.readonly_prop
|
||||
|
||||
method beneficieTitrePersonnelAidePersonnelleLogement :
|
||||
bool Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let enfant_to_jsoo (enfant : Enfant.t) : enfant Js.t =
|
||||
object%js
|
||||
val identifiant = integer_to_int enfant.identifiant
|
||||
|
||||
val obligationScolaire =
|
||||
situation_obligation_scolaire_to_jsoo enfant.obligation_scolaire
|
||||
|
||||
val remunerationMensuelle = money_to_float enfant.remuneration_mensuelle
|
||||
val dateDeNaissance = date_to_jsoo enfant.date_de_naissance
|
||||
val age = integer_to_int enfant.age
|
||||
val priseEnCharge = prise_en_charge_to_jsoo enfant.prise_en_charge
|
||||
|
||||
val aDejaOuvertDroitAuxAllocationsFamiliales =
|
||||
Js.bool enfant.a_deja_ouvert_droit_aux_allocations_familiales
|
||||
|
||||
val beneficieTitrePersonnelAidePersonnelleLogement =
|
||||
Js.bool enfant.beneficie_titre_personnel_aide_personnelle_logement
|
||||
end
|
||||
|
||||
let enfant_of_jsoo (enfant : enfant Js.t) : Enfant.t =
|
||||
{
|
||||
identifiant = integer_of_int enfant##.identifiant;
|
||||
obligation_scolaire =
|
||||
situation_obligation_scolaire_of_jsoo enfant##.obligationScolaire;
|
||||
remuneration_mensuelle =
|
||||
money_of_decimal @@ decimal_of_float enfant##.remunerationMensuelle;
|
||||
date_de_naissance = date_of_jsoo enfant##.dateDeNaissance;
|
||||
age = integer_of_int enfant##.age;
|
||||
prise_en_charge = prise_en_charge_of_jsoo enfant##.priseEnCharge;
|
||||
a_deja_ouvert_droit_aux_allocations_familiales =
|
||||
Js.to_bool enfant##.aDejaOuvertDroitAuxAllocationsFamiliales;
|
||||
beneficie_titre_personnel_aide_personnelle_logement =
|
||||
Js.to_bool enfant##.beneficieTitrePersonnelAidePersonnelleLogement;
|
||||
}
|
||||
|
||||
class type prestations_familiales_out =
|
||||
object
|
||||
method droitOuvertOut : (enfant Js.t, bool Js.t) Js.meth_callback Js.meth
|
||||
|
||||
method conditionsHorsAgeOut :
|
||||
(enfant Js.t, bool Js.t) Js.meth_callback Js.meth
|
||||
|
||||
method ageL51232Out : int Js.readonly_prop
|
||||
method regimeOutreMerL7511Out : bool Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let prestations_familiales_out_to_jsoo
|
||||
(prestations_familiales_out : PrestationsFamilialesOut.t) :
|
||||
prestations_familiales_out Js.t =
|
||||
object%js
|
||||
method droitOuvertOut =
|
||||
Js.wrap_meth_callback (fun input ->
|
||||
Js.bool
|
||||
(prestations_familiales_out.droit_ouvert_out (enfant_of_jsoo input)))
|
||||
|
||||
method conditionsHorsAgeOut =
|
||||
Js.wrap_meth_callback (fun input ->
|
||||
Js.bool
|
||||
(prestations_familiales_out.conditions_hors_age_out
|
||||
(enfant_of_jsoo input)))
|
||||
|
||||
val ageL51232Out =
|
||||
integer_to_int prestations_familiales_out.age_l512_3_2_out
|
||||
|
||||
val regimeOutreMerL7511Out =
|
||||
Js.bool prestations_familiales_out.regime_outre_mer_l751_1_out
|
||||
end
|
||||
|
||||
let prestations_familiales_out_of_jsoo
|
||||
(prestations_familiales_out : prestations_familiales_out Js.t) :
|
||||
PrestationsFamilialesOut.t =
|
||||
{
|
||||
droit_ouvert_out =
|
||||
failwith
|
||||
"The function 'droit_ouvert_out' translation isn't yet supported...";
|
||||
conditions_hors_age_out =
|
||||
failwith
|
||||
"The function 'conditions_hors_age_out' translation isn't yet \
|
||||
supported...";
|
||||
age_l512_3_2_out = integer_of_int prestations_familiales_out##.ageL51232Out;
|
||||
regime_outre_mer_l751_1_out =
|
||||
Js.to_bool prestations_familiales_out##.regimeOutreMerL7511Out;
|
||||
}
|
||||
|
||||
class type prestations_familiales_in =
|
||||
object
|
||||
method dateCouranteIn : Js.date Js.t Js.readonly_prop
|
||||
|
||||
method prestationCouranteIn :
|
||||
element_prestations_familiales Js.t Js.readonly_prop
|
||||
|
||||
method residenceIn : collectivite Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let prestations_familiales_in_to_jsoo
|
||||
(prestations_familiales_in : PrestationsFamilialesIn.t) :
|
||||
prestations_familiales_in Js.t =
|
||||
object%js
|
||||
val dateCouranteIn = date_to_jsoo prestations_familiales_in.date_courante_in
|
||||
|
||||
val prestationCouranteIn =
|
||||
element_prestations_familiales_to_jsoo
|
||||
prestations_familiales_in.prestation_courante_in
|
||||
|
||||
val residenceIn =
|
||||
collectivite_to_jsoo prestations_familiales_in.residence_in
|
||||
end
|
||||
|
||||
let prestations_familiales_in_of_jsoo
|
||||
(prestations_familiales_in : prestations_familiales_in Js.t) :
|
||||
PrestationsFamilialesIn.t =
|
||||
{
|
||||
date_courante_in = date_of_jsoo prestations_familiales_in##.dateCouranteIn;
|
||||
prestation_courante_in =
|
||||
element_prestations_familiales_of_jsoo
|
||||
prestations_familiales_in##.prestationCouranteIn;
|
||||
residence_in = collectivite_of_jsoo prestations_familiales_in##.residenceIn;
|
||||
}
|
||||
|
||||
class type allocation_familiales_avril2008_out =
|
||||
object
|
||||
method ageMinimumAlinea1L5213Out : int Js.readonly_prop
|
||||
end
|
||||
|
||||
let allocation_familiales_avril2008_out_to_jsoo
|
||||
(allocation_familiales_avril2008_out : AllocationFamilialesAvril2008Out.t) :
|
||||
allocation_familiales_avril2008_out Js.t =
|
||||
object%js
|
||||
val ageMinimumAlinea1L5213Out =
|
||||
integer_to_int
|
||||
allocation_familiales_avril2008_out.age_minimum_alinea_1_l521_3_out
|
||||
end
|
||||
|
||||
let allocation_familiales_avril2008_out_of_jsoo
|
||||
(allocation_familiales_avril2008_out :
|
||||
allocation_familiales_avril2008_out Js.t) :
|
||||
AllocationFamilialesAvril2008Out.t =
|
||||
{
|
||||
age_minimum_alinea_1_l521_3_out =
|
||||
integer_of_int
|
||||
allocation_familiales_avril2008_out##.ageMinimumAlinea1L5213Out;
|
||||
}
|
||||
|
||||
class type allocation_familiales_avril2008_in = object end
|
||||
|
||||
let allocation_familiales_avril2008_in_to_jsoo
|
||||
(_ : AllocationFamilialesAvril2008In.t) :
|
||||
allocation_familiales_avril2008_in Js.t =
|
||||
object%js end
|
||||
|
||||
let allocation_familiales_avril2008_in_of_jsoo
|
||||
(_ : allocation_familiales_avril2008_in Js.t) :
|
||||
AllocationFamilialesAvril2008In.t =
|
||||
()
|
||||
|
||||
class type enfant_le_plus_age_out =
|
||||
object
|
||||
method lePlusAgeOut : enfant Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let enfant_le_plus_age_out_to_jsoo
|
||||
(enfant_le_plus_age_out : EnfantLePlusAgeOut.t) :
|
||||
enfant_le_plus_age_out Js.t =
|
||||
object%js
|
||||
val lePlusAgeOut = enfant_to_jsoo enfant_le_plus_age_out.le_plus_age_out
|
||||
end
|
||||
|
||||
let enfant_le_plus_age_out_of_jsoo
|
||||
(enfant_le_plus_age_out : enfant_le_plus_age_out Js.t) :
|
||||
EnfantLePlusAgeOut.t =
|
||||
{ le_plus_age_out = enfant_of_jsoo enfant_le_plus_age_out##.lePlusAgeOut }
|
||||
|
||||
class type enfant_le_plus_age_in =
|
||||
object
|
||||
method enfantsIn : enfant Js.t Js.js_array Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let enfant_le_plus_age_in_to_jsoo (enfant_le_plus_age_in : EnfantLePlusAgeIn.t)
|
||||
: enfant_le_plus_age_in Js.t =
|
||||
object%js
|
||||
val enfantsIn =
|
||||
Js.array @@ Array.map enfant_to_jsoo enfant_le_plus_age_in.enfants_in
|
||||
end
|
||||
|
||||
let enfant_le_plus_age_in_of_jsoo
|
||||
(enfant_le_plus_age_in : enfant_le_plus_age_in Js.t) : EnfantLePlusAgeIn.t =
|
||||
{
|
||||
enfants_in =
|
||||
Array.map enfant_of_jsoo @@ Js.to_array enfant_le_plus_age_in##.enfantsIn;
|
||||
}
|
||||
|
||||
class type allocations_familiales_out =
|
||||
object
|
||||
method montantVerseOut : float Js.readonly_prop
|
||||
end
|
||||
|
||||
let allocations_familiales_out_to_jsoo
|
||||
(allocations_familiales_out : AllocationsFamilialesOut.t) :
|
||||
allocations_familiales_out Js.t =
|
||||
object%js
|
||||
val montantVerseOut =
|
||||
money_to_float allocations_familiales_out.montant_verse_out
|
||||
end
|
||||
|
||||
let allocations_familiales_out_of_jsoo
|
||||
(allocations_familiales_out : allocations_familiales_out Js.t) :
|
||||
AllocationsFamilialesOut.t =
|
||||
{
|
||||
montant_verse_out =
|
||||
money_of_decimal
|
||||
@@ decimal_of_float allocations_familiales_out##.montantVerseOut;
|
||||
}
|
||||
|
||||
class type allocations_familiales_in =
|
||||
object
|
||||
method personneChargeEffectivePermanenteEstParentIn :
|
||||
bool Js.t Js.readonly_prop
|
||||
|
||||
method personneChargeEffectivePermanenteRemplitTitreIIn :
|
||||
bool Js.t Js.readonly_prop
|
||||
|
||||
method ressourcesMenageIn : float Js.readonly_prop
|
||||
method residenceIn : collectivite Js.t Js.readonly_prop
|
||||
method dateCouranteIn : Js.date Js.t Js.readonly_prop
|
||||
method enfantsAChargeIn : enfant Js.t Js.js_array Js.t Js.readonly_prop
|
||||
method avaitEnfantAChargeAvant1erJanvier2012In : bool Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let allocations_familiales_in_to_jsoo
|
||||
(allocations_familiales_in : AllocationsFamilialesIn.t) :
|
||||
allocations_familiales_in Js.t =
|
||||
object%js
|
||||
val personneChargeEffectivePermanenteEstParentIn =
|
||||
Js.bool
|
||||
allocations_familiales_in
|
||||
.personne_charge_effective_permanente_est_parent_in
|
||||
|
||||
val personneChargeEffectivePermanenteRemplitTitreIIn =
|
||||
Js.bool
|
||||
allocations_familiales_in
|
||||
.personne_charge_effective_permanente_remplit_titre_I_in
|
||||
|
||||
val ressourcesMenageIn =
|
||||
money_to_float allocations_familiales_in.ressources_menage_in
|
||||
|
||||
val residenceIn =
|
||||
collectivite_to_jsoo allocations_familiales_in.residence_in
|
||||
|
||||
val dateCouranteIn = date_to_jsoo allocations_familiales_in.date_courante_in
|
||||
|
||||
val enfantsAChargeIn =
|
||||
Js.array
|
||||
@@ Array.map enfant_to_jsoo allocations_familiales_in.enfants_a_charge_in
|
||||
|
||||
val avaitEnfantAChargeAvant1erJanvier2012In =
|
||||
Js.bool
|
||||
allocations_familiales_in
|
||||
.avait_enfant_a_charge_avant_1er_janvier_2012_in
|
||||
end
|
||||
|
||||
let allocations_familiales_in_of_jsoo
|
||||
(allocations_familiales_in : allocations_familiales_in Js.t) :
|
||||
AllocationsFamilialesIn.t =
|
||||
{
|
||||
personne_charge_effective_permanente_est_parent_in =
|
||||
Js.to_bool
|
||||
allocations_familiales_in##.personneChargeEffectivePermanenteEstParentIn;
|
||||
personne_charge_effective_permanente_remplit_titre_I_in =
|
||||
Js.to_bool
|
||||
allocations_familiales_in##.personneChargeEffectivePermanenteRemplitTitreIIn;
|
||||
ressources_menage_in =
|
||||
money_of_decimal
|
||||
@@ decimal_of_float allocations_familiales_in##.ressourcesMenageIn;
|
||||
residence_in = collectivite_of_jsoo allocations_familiales_in##.residenceIn;
|
||||
date_courante_in = date_of_jsoo allocations_familiales_in##.dateCouranteIn;
|
||||
enfants_a_charge_in =
|
||||
Array.map enfant_of_jsoo
|
||||
@@ Js.to_array allocations_familiales_in##.enfantsAChargeIn;
|
||||
avait_enfant_a_charge_avant_1er_janvier_2012_in =
|
||||
Js.to_bool
|
||||
allocations_familiales_in##.avaitEnfantAChargeAvant1erJanvier2012In;
|
||||
}
|
||||
|
||||
class type smic_out =
|
||||
object
|
||||
method brutHoraireOut : float Js.readonly_prop
|
||||
end
|
||||
|
||||
let smic_out_to_jsoo (smic_out : SmicOut.t) : smic_out Js.t =
|
||||
object%js
|
||||
val brutHoraireOut = money_to_float smic_out.brut_horaire_out
|
||||
end
|
||||
|
||||
let smic_out_of_jsoo (smic_out : smic_out Js.t) : SmicOut.t =
|
||||
{
|
||||
brut_horaire_out =
|
||||
money_of_decimal @@ decimal_of_float smic_out##.brutHoraireOut;
|
||||
}
|
||||
|
||||
class type smic_in =
|
||||
object
|
||||
method dateCouranteIn : Js.date Js.t Js.readonly_prop
|
||||
method residenceIn : collectivite Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let smic_in_to_jsoo (smic_in : SmicIn.t) : smic_in Js.t =
|
||||
object%js
|
||||
val dateCouranteIn = date_to_jsoo smic_in.date_courante_in
|
||||
val residenceIn = collectivite_to_jsoo smic_in.residence_in
|
||||
end
|
||||
|
||||
let smic_in_of_jsoo (smic_in : smic_in Js.t) : SmicIn.t =
|
||||
{
|
||||
date_courante_in = date_of_jsoo smic_in##.dateCouranteIn;
|
||||
residence_in = collectivite_of_jsoo smic_in##.residenceIn;
|
||||
}
|
||||
|
||||
class type base_mensuelle_allocations_familiales_out =
|
||||
object
|
||||
method montantOut : float Js.readonly_prop
|
||||
end
|
||||
|
||||
let base_mensuelle_allocations_familiales_out_to_jsoo
|
||||
(base_mensuelle_allocations_familiales_out :
|
||||
BaseMensuelleAllocationsFamilialesOut.t) :
|
||||
base_mensuelle_allocations_familiales_out Js.t =
|
||||
object%js
|
||||
val montantOut =
|
||||
money_to_float base_mensuelle_allocations_familiales_out.montant_out
|
||||
end
|
||||
|
||||
let base_mensuelle_allocations_familiales_out_of_jsoo
|
||||
(base_mensuelle_allocations_familiales_out :
|
||||
base_mensuelle_allocations_familiales_out Js.t) :
|
||||
BaseMensuelleAllocationsFamilialesOut.t =
|
||||
{
|
||||
montant_out =
|
||||
money_of_decimal
|
||||
@@ decimal_of_float base_mensuelle_allocations_familiales_out##.montantOut;
|
||||
}
|
||||
|
||||
class type base_mensuelle_allocations_familiales_in =
|
||||
object
|
||||
method dateCouranteIn : Js.date Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let base_mensuelle_allocations_familiales_in_to_jsoo
|
||||
(base_mensuelle_allocations_familiales_in :
|
||||
BaseMensuelleAllocationsFamilialesIn.t) :
|
||||
base_mensuelle_allocations_familiales_in Js.t =
|
||||
object%js
|
||||
val dateCouranteIn =
|
||||
date_to_jsoo base_mensuelle_allocations_familiales_in.date_courante_in
|
||||
end
|
||||
|
||||
let base_mensuelle_allocations_familiales_in_of_jsoo
|
||||
(base_mensuelle_allocations_familiales_in :
|
||||
base_mensuelle_allocations_familiales_in Js.t) :
|
||||
BaseMensuelleAllocationsFamilialesIn.t =
|
||||
{
|
||||
date_courante_in =
|
||||
date_of_jsoo base_mensuelle_allocations_familiales_in##.dateCouranteIn;
|
||||
}
|
||||
|
||||
class type interface_allocations_familiales_out =
|
||||
object
|
||||
method iMontantVerseOut : float Js.readonly_prop
|
||||
end
|
||||
|
||||
let interface_allocations_familiales_out_to_jsoo
|
||||
(interface_allocations_familiales_out : InterfaceAllocationsFamilialesOut.t)
|
||||
: interface_allocations_familiales_out Js.t =
|
||||
object%js
|
||||
val iMontantVerseOut =
|
||||
money_to_float interface_allocations_familiales_out.i_montant_verse_out
|
||||
end
|
||||
|
||||
let interface_allocations_familiales_out_of_jsoo
|
||||
(interface_allocations_familiales_out :
|
||||
interface_allocations_familiales_out Js.t) :
|
||||
InterfaceAllocationsFamilialesOut.t =
|
||||
{
|
||||
i_montant_verse_out =
|
||||
money_of_decimal
|
||||
@@ decimal_of_float
|
||||
interface_allocations_familiales_out##.iMontantVerseOut;
|
||||
}
|
||||
|
||||
class type interface_allocations_familiales_in =
|
||||
object
|
||||
method iDateCouranteIn : Js.date Js.t Js.readonly_prop
|
||||
method iEnfantsIn : enfant_entree Js.t Js.js_array Js.t Js.readonly_prop
|
||||
method iRessourcesMenageIn : float Js.readonly_prop
|
||||
method iResidenceIn : collectivite Js.t Js.readonly_prop
|
||||
|
||||
method iPersonneChargeEffectivePermanenteEstParentIn :
|
||||
bool Js.t Js.readonly_prop
|
||||
|
||||
method iPersonneChargeEffectivePermanenteRemplitTitreIIn :
|
||||
bool Js.t Js.readonly_prop
|
||||
|
||||
method iAvaitEnfantAChargeAvant1erJanvier2012In : bool Js.t Js.readonly_prop
|
||||
end
|
||||
|
||||
let interface_allocations_familiales_in_to_jsoo
|
||||
(interface_allocations_familiales_in : InterfaceAllocationsFamilialesIn.t) :
|
||||
interface_allocations_familiales_in Js.t =
|
||||
object%js
|
||||
val iDateCouranteIn =
|
||||
date_to_jsoo interface_allocations_familiales_in.i_date_courante_in
|
||||
|
||||
val iEnfantsIn =
|
||||
Js.array
|
||||
@@ Array.map enfant_entree_to_jsoo
|
||||
interface_allocations_familiales_in.i_enfants_in
|
||||
|
||||
val iRessourcesMenageIn =
|
||||
money_to_float interface_allocations_familiales_in.i_ressources_menage_in
|
||||
|
||||
val iResidenceIn =
|
||||
collectivite_to_jsoo interface_allocations_familiales_in.i_residence_in
|
||||
|
||||
val iPersonneChargeEffectivePermanenteEstParentIn =
|
||||
Js.bool
|
||||
interface_allocations_familiales_in
|
||||
.i_personne_charge_effective_permanente_est_parent_in
|
||||
|
||||
val iPersonneChargeEffectivePermanenteRemplitTitreIIn =
|
||||
Js.bool
|
||||
interface_allocations_familiales_in
|
||||
.i_personne_charge_effective_permanente_remplit_titre_I_in
|
||||
|
||||
val iAvaitEnfantAChargeAvant1erJanvier2012In =
|
||||
Js.bool
|
||||
interface_allocations_familiales_in
|
||||
.i_avait_enfant_a_charge_avant_1er_janvier_2012_in
|
||||
end
|
||||
|
||||
let interface_allocations_familiales_in_of_jsoo
|
||||
(interface_allocations_familiales_in :
|
||||
interface_allocations_familiales_in Js.t) :
|
||||
InterfaceAllocationsFamilialesIn.t =
|
||||
{
|
||||
i_date_courante_in =
|
||||
date_of_jsoo interface_allocations_familiales_in##.iDateCouranteIn;
|
||||
i_enfants_in =
|
||||
Array.map enfant_entree_of_jsoo
|
||||
@@ Js.to_array interface_allocations_familiales_in##.iEnfantsIn;
|
||||
i_ressources_menage_in =
|
||||
money_of_decimal
|
||||
@@ decimal_of_float
|
||||
interface_allocations_familiales_in##.iRessourcesMenageIn;
|
||||
i_residence_in =
|
||||
collectivite_of_jsoo interface_allocations_familiales_in##.iResidenceIn;
|
||||
i_personne_charge_effective_permanente_est_parent_in =
|
||||
Js.to_bool
|
||||
interface_allocations_familiales_in##.iPersonneChargeEffectivePermanenteEstParentIn;
|
||||
i_personne_charge_effective_permanente_remplit_titre_I_in =
|
||||
Js.to_bool
|
||||
interface_allocations_familiales_in##.iPersonneChargeEffectivePermanenteRemplitTitreIIn;
|
||||
i_avait_enfant_a_charge_avant_1er_janvier_2012_in =
|
||||
Js.to_bool
|
||||
interface_allocations_familiales_in##.iAvaitEnfantAChargeAvant1erJanvier2012In;
|
||||
}
|
||||
|
||||
let allocation_familiales_avril2008
|
||||
(allocation_familiales_avril2008_in :
|
||||
allocation_familiales_avril2008_in Js.t) :
|
||||
allocation_familiales_avril2008_out Js.t =
|
||||
allocation_familiales_avril2008_in
|
||||
|> allocation_familiales_avril2008_in_of_jsoo
|
||||
|> allocation_familiales_avril2008
|
||||
|> allocation_familiales_avril2008_out_to_jsoo
|
||||
|
||||
let enfant_le_plus_age (enfant_le_plus_age_in : enfant_le_plus_age_in Js.t) :
|
||||
enfant_le_plus_age_out Js.t =
|
||||
enfant_le_plus_age_in |> enfant_le_plus_age_in_of_jsoo |> enfant_le_plus_age
|
||||
|> enfant_le_plus_age_out_to_jsoo
|
||||
|
||||
let smic (smic_in : smic_in Js.t) : smic_out Js.t =
|
||||
smic_in |> smic_in_of_jsoo |> smic |> smic_out_to_jsoo
|
||||
|
||||
let base_mensuelle_allocations_familiales
|
||||
(base_mensuelle_allocations_familiales_in :
|
||||
base_mensuelle_allocations_familiales_in Js.t) :
|
||||
base_mensuelle_allocations_familiales_out Js.t =
|
||||
base_mensuelle_allocations_familiales_in
|
||||
|> base_mensuelle_allocations_familiales_in_of_jsoo
|
||||
|> base_mensuelle_allocations_familiales
|
||||
|> base_mensuelle_allocations_familiales_out_to_jsoo
|
||||
|
||||
let prestations_familiales
|
||||
(prestations_familiales_in : prestations_familiales_in Js.t) :
|
||||
prestations_familiales_out Js.t =
|
||||
prestations_familiales_in |> prestations_familiales_in_of_jsoo
|
||||
|> prestations_familiales |> prestations_familiales_out_to_jsoo
|
||||
|
||||
let allocations_familiales
|
||||
(allocations_familiales_in : allocations_familiales_in Js.t) :
|
||||
allocations_familiales_out Js.t =
|
||||
allocations_familiales_in |> allocations_familiales_in_of_jsoo
|
||||
|> allocations_familiales |> allocations_familiales_out_to_jsoo
|
||||
|
||||
let interface_allocations_familiales
|
||||
(interface_allocations_familiales_in :
|
||||
interface_allocations_familiales_in Js.t) :
|
||||
interface_allocations_familiales_out Js.t =
|
||||
interface_allocations_familiales_in
|
||||
|> interface_allocations_familiales_in_of_jsoo
|
||||
|> interface_allocations_familiales
|
||||
|> interface_allocations_familiales_out_to_jsoo
|
||||
|
||||
let _ =
|
||||
Js.export "AllocationsFamilialesLib"
|
||||
(object%js
|
||||
method allocationFamilialesAvril2008
|
||||
: (allocation_familiales_avril2008_in Js.t ->
|
||||
allocation_familiales_avril2008_out Js.t)
|
||||
Js.callback =
|
||||
Js.wrap_callback allocation_familiales_avril2008
|
||||
|
||||
method enfantLePlusAge
|
||||
: (enfant_le_plus_age_in Js.t -> enfant_le_plus_age_out Js.t)
|
||||
Js.callback =
|
||||
Js.wrap_callback enfant_le_plus_age
|
||||
|
||||
method smic : (smic_in Js.t -> smic_out Js.t) Js.callback =
|
||||
Js.wrap_callback smic
|
||||
|
||||
method baseMensuelleAllocationsFamiliales
|
||||
: (base_mensuelle_allocations_familiales_in Js.t ->
|
||||
base_mensuelle_allocations_familiales_out Js.t)
|
||||
Js.callback =
|
||||
Js.wrap_callback base_mensuelle_allocations_familiales
|
||||
|
||||
method prestationsFamiliales
|
||||
: (prestations_familiales_in Js.t -> prestations_familiales_out Js.t)
|
||||
Js.callback =
|
||||
Js.wrap_callback prestations_familiales
|
||||
|
||||
method allocationsFamiliales
|
||||
: (allocations_familiales_in Js.t -> allocations_familiales_out Js.t)
|
||||
Js.callback =
|
||||
Js.wrap_callback allocations_familiales
|
||||
|
||||
method interfaceAllocationsFamiliales
|
||||
: (interface_allocations_familiales_in Js.t ->
|
||||
interface_allocations_familiales_out Js.t)
|
||||
Js.callback =
|
||||
Js.wrap_callback interface_allocations_familiales
|
||||
end)
|
@ -1,4 +1,6 @@
|
||||
(library
|
||||
(name law_source)
|
||||
(public_name french_law.law_source)
|
||||
(libraries catala.runtime))
|
||||
(preprocess
|
||||
(pps js_of_ocaml-ppx))
|
||||
(libraries catala.runtime_ocaml catala.runtime_jsoo js_of_ocaml))
|
||||
|
@ -1,4 +1,4 @@
|
||||
(executable
|
||||
(name run_tests)
|
||||
(modes native)
|
||||
(libraries catala.runtime ANSITerminal))
|
||||
(libraries catala.runtime_ocaml ANSITerminal))
|
||||
|
@ -6,7 +6,7 @@ let try_test msg test =
|
||||
Format.printf "%s %s\n"
|
||||
(ANSITerminal.sprintf [ANSITerminal.green] "PASS")
|
||||
(ANSITerminal.sprintf [ANSITerminal.magenta] msg)
|
||||
with Runtime.AssertionFailed ->
|
||||
with Runtime_ocaml.Runtime.AssertionFailed ->
|
||||
failure := true;
|
||||
Format.printf "%s %s\n"
|
||||
(ANSITerminal.sprintf [ANSITerminal.red] "FAIL")
|
||||
|
@ -14,13 +14,14 @@
|
||||
License for the specific language governing permissions and limitations under
|
||||
the License. *)
|
||||
|
||||
(** Runtime used by generated web API via
|
||||
{{:http://ocsigen.org/js_of_ocaml/latest/manual/overview} [js_of_ocaml]}. *)
|
||||
(** A {{:http://ocsigen.org/js_of_ocaml/latest/manual/overview} js_of_ocaml}
|
||||
wrapper around the {!module: Runtime_ocaml.Runtime}. *)
|
||||
|
||||
open Js_of_ocaml
|
||||
|
||||
(** {1 Log events} *)
|
||||
|
||||
(** Information about the position of the log inside the Catala source file. *)
|
||||
class type source_position =
|
||||
object
|
||||
method fileName : Js.js_string Js.t Js.prop
|
||||
@ -31,17 +32,48 @@ class type source_position =
|
||||
method lawHeadings : Js.js_string Js.t Js.js_array Js.t Js.prop
|
||||
end
|
||||
|
||||
(** Wrapper for the {!type: Runtime_ocaml.Runtime.raw_event} -- directly
|
||||
collected during the program execution.*)
|
||||
class type raw_event =
|
||||
object
|
||||
method eventType : Js.js_string Js.t Js.prop
|
||||
(** There is four type of raw log events:
|
||||
|
||||
- 'BeginCall' is emitted when a function or a subscope is called.
|
||||
- 'EndCall' is emitted when a function or a subscope is exited.
|
||||
- 'VariableDefinition' is emitted when a variable or a function is
|
||||
defined.
|
||||
- 'DecisionTaken' stores the information about the source position of
|
||||
the event. *)
|
||||
|
||||
method information : Js.js_string Js.t Js.js_array Js.t Js.prop
|
||||
(** Represents information about a name in the code -- i.e. variable name,
|
||||
subscope name, etc...
|
||||
|
||||
It's a list of strings with a length varying from 2 to 3, where:
|
||||
|
||||
- the first string is the name of the current scope -- starting with a
|
||||
capitalized letter [Scope_name],
|
||||
- the second string is either: the name of a scope variable or, the name
|
||||
of a subscope input variable -- [a_subscope_var.input_var]
|
||||
- the third string is either: a subscope name (starting with a
|
||||
capitalized letter [Subscope_name] or, the [input] (resp. [output])
|
||||
string -- which corresponds to the input (resp. the output) of a
|
||||
function. *)
|
||||
|
||||
method sourcePosition : source_position Js.t Js.optdef Js.prop
|
||||
|
||||
method loggedValueJson : Js.js_string Js.t Js.prop
|
||||
(** Serialized [Runtime_ocaml.Runtime.runtime_value] corresponding to a
|
||||
'VariableDefinition' raw event.*)
|
||||
end
|
||||
|
||||
(** Wrapper for the {!type: Runtime_ocaml.Runtime.event} -- structured log event
|
||||
parsed from the {!raw_event} ones.*)
|
||||
class type event =
|
||||
object
|
||||
method data : Js.js_string Js.t Js.prop
|
||||
(** Serialized [Runtime_ocaml.Runtime.event]. *)
|
||||
end
|
||||
|
||||
class type event_manager =
|
||||
@ -56,10 +88,11 @@ class type event_manager =
|
||||
end
|
||||
|
||||
val event_manager : event_manager Js.t
|
||||
(** Composable object to retrieve and reset log events. *)
|
||||
(** Composable JS object to retrieve and reset log events. *)
|
||||
|
||||
(** {1 Duration} *)
|
||||
|
||||
(** Simple JSOO wrapper around {!type: Runtime_ocaml.Runtime.duration}.*)
|
||||
class type duration =
|
||||
object
|
||||
method years : int Js.readonly_prop
|
||||
|
@ -15,6 +15,8 @@
|
||||
License for the specific language governing permissions and limitations under
|
||||
the License. *)
|
||||
|
||||
(** The OCaml runtime. *)
|
||||
|
||||
(** {1 Types} *)
|
||||
|
||||
type money
|
||||
|
@ -1,6 +1,6 @@
|
||||
(** This file has been generated by the Catala compiler, do not edit! *)
|
||||
|
||||
open Runtime
|
||||
open Runtime_ocaml.Runtime
|
||||
|
||||
[@@@ocaml.warning "-4-26-27-32-41-42"]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user