Update aides_logement and fix bugs to produce an updated working simulator (#377)

This commit is contained in:
Denis Merigoux 2023-01-13 12:05:32 +01:00 committed by GitHub
commit f4c92530c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 12467 additions and 10405 deletions

View File

@ -307,9 +307,132 @@ let rec translate_expr (ctx : 'm ctx) (e : 'm Scopelang.Ast.expr) :
let arg_struct =
Expr.estruct sc_sig.scope_sig_input_struct field_map (mark_tany m pos)
in
Expr.eapp
(Expr.evar sc_sig.scope_sig_scope_var (mark_tany m pos))
[arg_struct] m
let called_func =
tag_with_log_entry
(Expr.evar sc_sig.scope_sig_scope_var (mark_tany m pos))
BeginCall
[ScopeName.get_info scope; Marked.mark (Expr.pos e) "direct"]
in
let single_arg =
tag_with_log_entry arg_struct
(VarDef (TStruct sc_sig.scope_sig_input_struct))
[
ScopeName.get_info scope;
Marked.mark (Expr.pos e) "direct";
Marked.mark (Expr.pos e) "input";
]
in
let direct_output_info =
[
ScopeName.get_info scope;
Marked.mark (Expr.pos e) "direct";
Marked.mark (Expr.pos e) "output";
]
in
(* calling_expr = scope_function scope_input_struct *)
let calling_expr = Expr.eapp called_func [single_arg] m in
(* For the purposes of log parsing explained in Runtime.EventParser, we need
to wrap this function call in a flurry of log tags. Specifically, we are
mascarading this scope call as a function call. In a normal function
call, the log parser expects the output of the function to be defined as
a default, hence the production of the output should yield a
PosRecordIfTrueBool (which is not the case here). To remedy this absence
we fabricate a fake PosRecordIfTrueBool attached to a silent let binding
to "true" before returning the output value.
But this is not sufficient. Indeed for the tricky case of
[tests/test_scope/scope_call3.catala_en], when a scope returns a
function, because we insert loggins calls at the call site of the
function and not during its definition, then we're missing the call log
instructions of the function returned. To avoid this trap, we need to
rebind the resulting scope output struct by eta-expanding the functions
to insert logging instructions*)
let result_var = Var.make "result" in
let result_eta_expanded_var = Var.make "result" in
(* result_eta_expanded = { struct_output_function_field = lambda x -> log
(struct_output.struct_output_function_field x) ... } *)
let result_eta_expanded =
Expr.estruct sc_sig.scope_sig_output_struct
(StructField.Map.mapi
(fun field typ ->
let original_field_expr =
Expr.estructaccess
(Expr.make_var result_var
(Expr.with_ty m
(TStruct sc_sig.scope_sig_output_struct, Expr.pos e)))
field sc_sig.scope_sig_output_struct (Expr.with_ty m typ)
in
match Marked.unmark typ with
| TArrow (t_in, t_out) ->
(* Here the output scope struct field is a function so we
eta-expand it and insert logging instructions. Invariant:
works because user-defined functions in scope have only one
argument. *)
let param_var = Var.make "param" in
let f_markings =
[ScopeName.get_info scope; StructField.get_info field]
in
Expr.make_abs
(Array.of_list [param_var])
(tag_with_log_entry
(tag_with_log_entry
(Expr.eapp
(tag_with_log_entry original_field_expr BeginCall
f_markings)
[
tag_with_log_entry
(Expr.make_var param_var (Expr.with_ty m t_in))
(VarDef (Marked.unmark t_in))
(f_markings @ [Marked.mark (Expr.pos e) "input"]);
]
(Expr.with_ty m t_out))
(VarDef (Marked.unmark t_out))
(f_markings @ [Marked.mark (Expr.pos e) "output"]))
EndCall f_markings)
[t_in] (Expr.pos e)
| _ -> original_field_expr)
(StructName.Map.find sc_sig.scope_sig_output_struct ctx.structs))
(Expr.with_ty m (TStruct sc_sig.scope_sig_output_struct, Expr.pos e))
in
(* Here we have to go through an if statement that records a decision being
taken with a log. We can't just do a let-in with the true boolean value
enclosed in the log because it might get optimized by a compiler later
down the chain. *)
(* if_then_else_returned = if log true then result_eta_expanded else
emptyError *)
let if_then_else_returned =
Expr.eifthenelse
(tag_with_log_entry
(Expr.box
(Marked.mark
(Expr.with_ty m (TLit TBool, Expr.pos e))
(ELit (LBool true))))
PosRecordIfTrueBool direct_output_info)
(Expr.make_var result_eta_expanded_var
(Expr.with_ty m (TStruct sc_sig.scope_sig_output_struct, Expr.pos e)))
(Expr.box
(Marked.mark
(Expr.with_ty m
(TStruct sc_sig.scope_sig_output_struct, Expr.pos e))
(ELit LEmptyError)))
(Expr.with_ty m (TStruct sc_sig.scope_sig_output_struct, Expr.pos e))
in
(* let result_var = calling_expr in let result_eta_expanded_var =
result_eta_expaneded in log (if_then_else_returned ) *)
Expr.make_let_in result_var
(TStruct sc_sig.scope_sig_output_struct, Expr.pos e)
calling_expr
(Expr.make_let_in result_eta_expanded_var
(TStruct sc_sig.scope_sig_output_struct, Expr.pos e)
result_eta_expanded
(tag_with_log_entry
(tag_with_log_entry if_then_else_returned
(VarDef (TStruct sc_sig.scope_sig_output_struct))
direct_output_info)
EndCall
[ScopeName.get_info scope; Marked.mark (Expr.pos e) "direct"])
(Expr.pos e))
(Expr.pos e)
| EApp { f; args } ->
(* We insert various log calls to record arguments and outputs of
user-defined functions belonging to scopes *)

View File

@ -202,8 +202,21 @@ let driver source_file (options : Cli.options) : int =
end
else prgm
in
(* Cli.debug_print (Format.asprintf "Typechecking results :@\n%a"
(Print.typ prgm.decl_ctx) typ); *)
match backend with
| `Typecheck ->
Cli.debug_print "Typechecking again...";
let _ =
try Shared_ast.Typing.program prgm
with Errors.StructuredError (msg, details) ->
let msg =
"Typing error occured during re-typing on the 'default \
calculus'. This is a bug in the Catala compiler.\n"
^ msg
in
raise (Errors.StructuredError (msg, details))
in
(* That's it! *)
Cli.result_print "Typechecking successful!"
| `Dcalc ->
@ -229,7 +242,7 @@ let driver source_file (options : Cli.options) : int =
Shared_ast.Expr.unbox (Shared_ast.Program.to_expr prgm scope_uid)
in
Format.fprintf fmt "%a\n"
(Shared_ast.Expr.format prgm.decl_ctx)
(Shared_ast.Expr.format ~debug:options.debug prgm.decl_ctx)
prgrm_dcalc_expr
| (`Interpret | `OCaml | `Python | `Scalc | `Lcalc | `Proof | `Plugin _)
as backend -> (
@ -244,8 +257,6 @@ let driver source_file (options : Cli.options) : int =
in
raise (Errors.StructuredError (msg, details))
in
(* Cli.debug_print (Format.asprintf "Typechecking results :@\n%a"
(Print.typ prgm.decl_ctx) typ); *)
match backend with
| `Proof ->
let vcs =
@ -315,7 +326,7 @@ let driver source_file (options : Cli.options) : int =
(Shared_ast.Program.to_expr prgm scope_uid)
in
Format.fprintf fmt "%a\n"
(Shared_ast.Expr.format prgm.decl_ctx)
(Shared_ast.Expr.format ~debug:options.debug prgm.decl_ctx)
prgrm_lcalc_expr
| (`OCaml | `Python | `Scalc | `Plugin _) as backend -> (
match backend with

View File

@ -151,7 +151,8 @@ codes={\catcode`\$=3\catcode`\^=7}
\tableofcontents
\[\star\star\star\]
\clearpage|latex}
\clearpage
|latex}
(match language with Fr -> "french" | En -> "english" | Pl -> "polish")
(match language with Fr -> "\\setmainfont{Marianne}" | _ -> "")
(* for France, we use the official font of the French state design system

View File

@ -662,7 +662,7 @@ let source_file_item :=
END_DIRECTIVE ; {
let filename = String.trim (String.concat "" args) in
let pos = Pos.from_lpos $sloc in
let jorftext = Re.Pcre.regexp "JORFTEXT\\d{12}" in
let jorftext = Re.Pcre.regexp "(JORFARTI\\d{12}|LEGIARTI\\d{12}|CETATEXT\\d{12})" in
if Re.Pcre.pmatch ~rex:jorftext filename && page = None then
LawInclude (Ast.LegislativeText (filename, pos))
else if Filename.extension filename = ".pdf" || page <> None then

Binary file not shown.

View File

@ -202,6 +202,8 @@
\\
Référence au journal officiel & \begin{catala}
# Article 1 | JORFARTI000012345678
# Article 2 | LEGIARTI000012345678
# Décision 3 | CETATEXT000012345678
\end{catala}
\\
Bloc de code &

View File

@ -1,6 +1,59 @@
# Archives législatives et réglementaires
# Archives de l'arrêté du 27 septembre 2019 relatif au calcul des aides personnelles au logement et de la prime de déménagement
## Articles valables du 1er octobre 2021 au 1er juillet 2022
## Articles valables du 1er juillet 2022 au 31 décembre 2022
### Article 15 | LEGIARTI000046126962 [archive]
Pour l'application du 5° de l'article D. 823-17 du même code, le forfait " R0 " est fixé selon
le tableau suivant (en euros) :
Composition du foyer MONTANT (en euros)
----------------------------------------- -------------------
Personne seule sans personne à charge 4 870
Couple sans personne à charge 6 977
Personne seule ou couple ayant :
-une personne à charge 8 322
-deux personnes à charge 8 509
-trois personnes à charge 8 834
-quatre personnes à charge 9 163
-cinq personnes à charge 9 488
-six personnes à charge 9 816
-par personne à charge supplémentaire 323
```catala
champ d'application CalculAidePersonnaliséeLogementLocatif
sous condition date_courante >= |2022-07-01| et
date_courante <= |2022-12-31|:
définition abattement_forfaitaire_d823_17 égal à
si nombre_personnes_à_charge = 0 alors
selon situation_familiale_calcul_apl sous forme
-- PersonneSeule: 4 870 €
-- Couple: 6 977 €
sinon (si nombre_personnes_à_charge = 1 alors
8 322 €
sinon (si nombre_personnes_à_charge = 2 alors
8 509 €
sinon (si nombre_personnes_à_charge = 3 alors
8 834 €
sinon (si nombre_personnes_à_charge = 4 alors
9 163 €
sinon (si nombre_personnes_à_charge = 5 alors
9 488 €
sinon (si nombre_personnes_à_charge = 6 alors
9 816 €
sinon
(9 816€ + (323 € * (décimal de
(nombre_personnes_à_charge - 6))))
))))))
```
NOTA :
Conformément à larticle 3 de larrêté du 29 juillet 2022 (NOR : TREL2220748A),
ces dispositions sont applicables pour les prestations dues à compter du 1 er juillet 2022.
## Articles valables du 1er octobre 2021 au 30 juin 2022
### Article 7 | LEGIARTI000044137432 [archive]
@ -722,7 +775,79 @@ Conformément au I de larticle 3 de larrêté du 23 septembre 2021, ces di
applicables pour les prestations dues à compter du 1er octobre 2021.
## Articles valables du 1er octobre 2020 au 1er octobre 2021
## Articles valables du 1er janvier 2022 au 30 juin 2022
### Article 6 | LEGIARTI000045011471 [archive]
Pour l'application de l'article D. 822-21 du même code, le montant forfaitaire auquel sont réputées
égales les ressources du bénéficiaire et, le cas échéant, de son conjoint, est fixé à 7 800 euros
pour la location et à 6 000 euros pour la résidence en logement-foyer.
Toutefois, lorsque le demandeur est titulaire d'une bourse de l'enseignement supérieur qui n'est
pas assujettie à l'impôt sur le revenu, le montant forfaitaire de ressources est fixé à 6 300 euros
pour la location et à 4 900 euros pour la résidence en logement-foyer.
```catala
# TODO informatique et juridique: traduire cet article qui vient définir
# ressources_forfaitaires_r822_20
```
NOTA :
Conformément à larticle 2 de larrêté du 20 décembre 2021 (NOR : LOGL2134477A),
ces dispositions sont applicables pour les prestations dues à compter du 1 er janvier 2022.
### Article 15 | LEGIARTI000045011468 [archive]
Pour l'application du 5° de l'article D. 823-17 du même code, le forfait " R0 " est fixé selon
le tableau suivant (en euros) :
Composition du foyer MONTANT (en euros)
----------------------------------------- -------------------
Personne seule sans personne à charge 4 683
Couple sans personne à charge 6 709
Personne seule ou couple ayant :
-une personne à charge 8 002
-deux personnes à charge 8 182
-trois personnes à charge 8 495
-quatre personnes à charge 8 811
-cinq personnes à charge 9 124
-six personnes à charge 9 439
-par personne à charge supplémentaire 311
```catala
champ d'application CalculAidePersonnaliséeLogementLocatif
sous condition date_courante >= |2022-01-01| et
date_courante < |2022-07-01|:
définition abattement_forfaitaire_d823_17 égal à
si nombre_personnes_à_charge = 0 alors
selon situation_familiale_calcul_apl sous forme
-- PersonneSeule: 4 683 €
-- Couple: 6709 €
sinon (si nombre_personnes_à_charge = 1 alors
8 002 €
sinon (si nombre_personnes_à_charge = 2 alors
8 192 €
sinon (si nombre_personnes_à_charge = 3 alors
8 495 €
sinon (si nombre_personnes_à_charge = 4 alors
8 811 €
sinon (si nombre_personnes_à_charge = 5 alors
9 124 €
sinon (si nombre_personnes_à_charge = 6 alors
9 439 €
sinon
(9 439€ + (311 € * (décimal de
(nombre_personnes_à_charge - 6))))
))))))
```
NOTA :
Conformément à larticle 2 de larrêté du 20 décembre 2021 (NOR : LOGL2134477A),
ces dispositions sont applicables pour les prestations dues à compter du 1 er janvier 2022.
## Articles valables du 1er octobre 2020 au 31 septembre 2021
### Arrêté du 27 septembre 2019 relatif au calcul des aides personnelles au logement et de la prime de déménagement
@ -1266,81 +1391,7 @@ champ d'application CalculAidePersonnaliséeLogementFoyer sous condition
)
```
## Articles valables du 1er janvier 2022 au 1er juillet 2022
### Article 6 | LEGIARTI000045011471 [archive]
Pour l'application de l'article D. 822-21 du même code, le montant forfaitaire auquel sont réputées
égales les ressources du bénéficiaire et, le cas échéant, de son conjoint, est fixé à 7 800 euros
pour la location et à 6 000 euros pour la résidence en logement-foyer.
Toutefois, lorsque le demandeur est titulaire d'une bourse de l'enseignement supérieur qui n'est
pas assujettie à l'impôt sur le revenu, le montant forfaitaire de ressources est fixé à 6 300 euros
pour la location et à 4 900 euros pour la résidence en logement-foyer.
```catala
# TODO informatique et juridique: traduire cet article qui vient définir
# ressources_forfaitaires_r822_20
```
NOTA :
Conformément à larticle 2 de larrêté du 20 décembre 2021 (NOR : LOGL2134477A),
ces dispositions sont applicables pour les prestations dues à compter du 1 er janvier 2022.
### Article 15 | LEGIARTI000045011468 [archive]
Pour l'application du 5° de l'article D. 823-17 du même code, le forfait " R0 " est fixé selon
le tableau suivant (en euros) :
Composition du foyer MONTANT (en euros)
----------------------------------------- -------------------
Personne seule sans personne à charge 4 683
Couple sans personne à charge 6 709
Personne seule ou couple ayant :
-une personne à charge 8 002
-deux personnes à charge 8 182
-trois personnes à charge 8 495
-quatre personnes à charge 8 811
-cinq personnes à charge 9 124
-six personnes à charge 9 439
-par personne à charge supplémentaire 311
```catala
champ d'application CalculAidePersonnaliséeLogementLocatif
sous condition date_courante >= |2022-01-01| et
date_courante < |2022-07-01|:
définition abattement_forfaitaire_d823_17 égal à
si nombre_personnes_à_charge = 0 alors
selon situation_familiale_calcul_apl sous forme
-- PersonneSeule: 4 683 €
-- Couple: 6709 €
sinon (si nombre_personnes_à_charge = 1 alors
8 002 €
sinon (si nombre_personnes_à_charge = 2 alors
8 192 €
sinon (si nombre_personnes_à_charge = 3 alors
8 495 €
sinon (si nombre_personnes_à_charge = 4 alors
8 811 €
sinon (si nombre_personnes_à_charge = 5 alors
9 124 €
sinon (si nombre_personnes_à_charge = 6 alors
9 439 €
sinon
(9 439€ + (311 € * (décimal de
(nombre_personnes_à_charge - 6))))
))))))
```
NOTA :
Conformément à larticle 2 de larrêté du 20 décembre 2021 (NOR : LOGL2134477A),
ces dispositions sont applicables pour les prestations dues à compter du 1 er janvier 2022.
## Articles valables du 1er janvier 2020 au 1er janvier 2022
### Arrêté du 27 septembre 2019 relatif au calcul des aides personnelles au logement et de la prime de déménagement
## Articles valables du 1er janvier 2020 au 31 décembre 2021
#### Article 15 | LEGIARTI000041489192 [archive]

File diff suppressed because it is too large Load Diff

View File

@ -28,9 +28,39 @@ le bureau BRS de la 6° sous-direction de la direction du budget le 31/08/2022.
Pour éviter de refaire les calculs de revalorisation en Catala, nous prendrons
comme référence les valeurs de la CNAV rappelées dans des circulaires internes.
## Circulaire de la CNAV 2022-3 du 11/01/2022 "Revalorisation à compter du 1er janvier 2022"
## Circulaire de la CNAV 2023-3 du 09/01/2022 "Revalorisation à compter du 1er janvier 2023"
Circulaire de la CNAV 2022-3 du 11/01/2022 "Revalorisation à compter du 1er janvier 2022"
[Lien vers le texte](https://www.legislation.cnav.fr/Documents/circulaire_cnav_2023_03_09012023.pdf)
Le montant de lAspa sélève, à compter du 1er janvier 2023, à :
Bénéficiaire Montant annuel Montant mensuel
-------------- -------------- ---------------
Personne seule 11 533,02 € 961,08 €
Couple marié 17 905,06 € 1 492,08 €
```catala
# Pas important pour nous
```
Pour prétendre à cette allocation non contributive, les plafonds de ressources sont fixés à:
Bénéficiaire Montant annuel Montant mensuel
-------------- -------------- -----------------
Personne seule 11 533,02 € 961,08 €
Couple marié 17 905,06 € 1 492,08 €
```catala
# Uniquement la valeur du plafond individuel est important pour l'éligibilité
# aux APL
champ d'application ÉligibilitéAidesPersonnelleLogement:
définition plafond_individuel_l815_9_sécu sous condition
date_courante >= |2023-01-01| et
date_courante < |2024-01-01|
conséquence égal à 11 533,02 €
```
## Circulaire de la CNAV 2022-3 du 11/01/2022 "Revalorisation à compter du 1er janvier 2022"
[Lien vers le texte](https://www.legislation.cnav.fr/Documents/circulaire_cnav_2022_03_11012022.pdf)
@ -266,7 +296,8 @@ champ d'application CalculetteAidesAuLogementGardeAlternée:
# à domicile.
(calculette.aide_finale_formule -
calculette_sans_garde_alternée.aide_finale_formule) *
((somme décimal de coefficents_enfants_garde_alternée_pris_en_compte) /
((somme décimal de
coefficents_enfants_garde_alternée_pris_en_compte) /
(décimal de
nombre de coefficents_enfants_garde_alternée_pris_en_compte))))
```

View File

@ -127,7 +127,8 @@ champ d'application RessourcesAidesPersonnelleLogement:
ressources_personnes_vivant_habituellement_foyer
définition ressources_personnes_vivant_habituellement_foyer égal à
somme argent de personne.ressources pour personne parmi personnes_vivant_habituellement_foyer
somme argent de personne.ressources pour
personne parmi personnes_vivant_habituellement_foyer
```
Sont considérées comme vivant habituellement au foyer les personnes y ayant
@ -1079,26 +1080,37 @@ sociale agricole compétente.
# Pas pertinent pour le calcul du montant.
```
####### Article R823-2 | LEGIARTI000038878937
####### Article R823-2 | LEGIARTI000044636869
Les aides personnelles au logement sont attribuées sur la demande de l'intéressé
déposée auprès de l'organisme payeur mentionné à l'article R. 823-1 dont il
relève. Cette demande est conforme à un modèle type.
déposée auprès de l'organisme payeur mentionné à l'article R. 823-1 dont il relève.
Cette demande est conforme à un modèle type.
Elle est assortie de pièces justificatives définies par arrêté des ministres
chargés du logement, du budget, de la sécurité sociale et de l'agriculture.
Le même arrêté définit le modèle-type de la demande et précise celles de ces
pièces justificatives qui doivent être produites chaque année et, parmi
celles-ci, celles dont le défaut de présentation avant la date qu'il fixe
entraîne la suspension du paiement de l'aide.
pièces justificatives qui doivent être produites chaque année et, parmi celles-ci,
celles dont le défaut de présentation avant la date qu'il fixe entraîne la
suspension du paiement de l'aide.
Le fait que le logement réponde aux conditions de décence mentionnées à l'article
R. 822-24 est justifié par une attestation du bailleur.
Le fait que le logement réponde aux conditions de décence mentionnées à
l'article R. 822-24 est justifié par une attestation du bailleur. En outre,
celui-ci est en mesure de présenter, à la demande des organismes payeurs,
le diagnostic de performance énergétique du logement faisant état du respect
du critère de performance énergétique minimale mentionné à l'article 3 bis du
décret n° 2002-120 du 30 janvier 2002 relatif aux caractéristiques du logement
décent pris pour l'application de l'article 187 de la loi n° 2000-1208 du 13
décembre 2000 relative à la solidarité et au renouvellement urbain.
La personne de nationalité étrangère qui demande à bénéficier des aides
personnelles au logement justifie, en outre, de la régularité de son séjour
par la production d'un des titres de séjour ou documents prévus à l' article
D. 512-1 du code de la sécurité sociale .
par la production d'un des titres de séjour ou documents prévus à l'article
D. 512-1 du code de la sécurité sociale.
NOTA:
Conformément à l'article 6 du décret n° 2021-1750 du 21 décembre 2021, ces
dispositions entrent en vigueur le 1er janvier 2023.
```catala
# Pas pertinent pour le calcul du montant.

View File

@ -10,7 +10,8 @@ la fonction du bloc de code ci-dessous.
```catala-metadata
champ d'application EnfantLePlusÂgé:
définition le_plus_âgé égal à
potentiel_plus_âgé parmi enfants tel que potentiel_plus_âgé.date_de_naissance est minimum
potentiel_plus_âgé parmi enfants tel que
potentiel_plus_âgé.date_de_naissance est minimum
ou si collection vide alors Enfant {
-- identifiant: -1
-- obligation_scolaire: Pendant

View File

@ -183,7 +183,7 @@ est porté à 10,85 € l'heure ;
```catala
champ d'application Smic :
définition brut_horaire sous condition
date_courante >= |2022-05-01| et date_courante <= |2022-12-31| et (
date_courante >= |2022-05-01| et date_courante <= |2022-07-31| et (
(résidence = Métropole) ou
(résidence = Guadeloupe) ou
(résidence = Guyane) ou
@ -201,8 +201,87 @@ champ d'application Smic :
```catala
champ d'application Smic :
définition brut_horaire sous condition
date_courante >= |2022-05-01| et date_courante <= |2022-12-31| et (
date_courante >= |2022-05-01| et date_courante <= |2022-07-31| et (
(résidence = Mayotte)
)
conséquence égal à 8,19 €
```
## Arrêté du 29 juillet 2022 relatif au relèvement du salaire minimum de croissance
### Article 2 | JORFARTI000046113526
En conséquence, à compter du 1er août 2022, pour les catégories de travailleurs
mentionnés à l'article L. 2211-1 du code du travail, le montant du salaire
minimum de croissance est relevé dans les conditions ci-après :
1° En métropole, en Guadeloupe, en Guyane, en Martinique, à La Réunion,
à Saint-Barthélemy, à Saint-Martin et à Saint-Pierre-et-Miquelon,
son montant est porté à 11,07 € l'heure ;
```catala
champ d'application Smic :
définition brut_horaire sous condition
date_courante >= |2022-08-01| et date_courante <= |2022-12-31| et (
(résidence = Métropole) ou
(résidence = Guadeloupe) ou
(résidence = Guyane) ou
(résidence = Martinique) ou
(résidence = LaRéunion) ou
(résidence = SaintBarthélemy) ou
(résidence = SaintMartin) ou
(résidence = SaintPierreEtMiquelon)
)
conséquence égal à 11,07 €
```
2° A Mayotte, son montant est fixé à 8,35 € l'heure.
```catala
champ d'application Smic :
définition brut_horaire sous condition
date_courante >= |2022-08-01| et date_courante <= |2022-12-31| et (
(résidence = Mayotte)
)
conséquence égal à 8,35 €
```
## Décret n° 2022-1608 du 22 décembre 2022 portant relèvement du salaire minimum de croissance
### Article 1 | JORFARTI000046780051
A compter du 1er janvier 2023, pour les catégories de travailleurs mentionnés à
l'article L. 2211-1 du code du travail, le montant du salaire minimum de
croissance est relevé dans les conditions ci-après :
1° En métropole, en Guadeloupe, en Guyane, en Martinique, à La Réunion,
à Saint-Barthélemy, à Saint-Martin et à Saint-Pierre-et-Miquelon,
son montant est porté à 11,27 euros l'heure ;
```catala
champ d'application Smic :
définition brut_horaire sous condition
date_courante >= |2023-01-01| et date_courante <= |2023-12-31| et (
(résidence = Métropole) ou
(résidence = Guadeloupe) ou
(résidence = Guyane) ou
(résidence = Martinique) ou
(résidence = LaRéunion) ou
(résidence = SaintBarthélemy) ou
(résidence = SaintMartin) ou
(résidence = SaintPierreEtMiquelon)
)
conséquence égal à 11,27 €
```
2° A Mayotte, son montant est fixé à 8,51 euros l'heure.
```catala
champ d'application Smic :
définition brut_horaire sous condition
date_courante >= |2023-01-01| et date_courante <= |2023-12-31| et (
(résidence = Mayotte)
)
conséquence égal à 8,51 €
```

View File

@ -587,8 +587,8 @@ scope Test5:
}
definition income_tax equals
if normal_income_tax_computation_applies then
(output of NewIncomeTaxComputationFixed with { -- individual: individual })
.income_tax
(output of NewIncomeTaxComputationFixed with
{ -- individual: individual }).income_tax
else $0 # Insert some other modes of computation here
```

View File

@ -191,13 +191,6 @@ let raise_article_parsing_error
(Yojson.Basic.to_string json);
exit 1
type law_excerpt = Yojson.Basic.t
let retrieve_law_excerpt (access_token : string) (text_id : string) :
law_excerpt =
run_request
(make_request access_token "consult/jorfPart" ["textCid", text_id])
let get_article_id (article : article) : string =
try
article.content
@ -237,6 +230,18 @@ let get_article_text (article : article) : string =
with Yojson.Basic.Util.Type_error (msg, obj) ->
raise_article_parsing_error article.content msg obj
let get_article_title (article : article) : string =
try
article.content
|> Yojson.Basic.Util.member
(match article.typ with
| CETATEXT -> "text"
| LEGIARTI | JORFARTI -> "article")
|> Yojson.Basic.Util.member "titre"
|> Yojson.Basic.Util.to_string
with Yojson.Basic.Util.Type_error (msg, obj) ->
raise_article_parsing_error article.content msg obj
let get_article_expiration_date (article : article) : Unix.tm =
try
let article_id = get_article_id article in
@ -284,50 +289,3 @@ let get_article_new_version (article : article) : string =
|> Yojson.Basic.Util.to_string
with Yojson.Basic.Util.Type_error (msg, obj) ->
raise_article_parsing_error article.content msg obj)
let get_law_excerpt_title (json : law_excerpt) : string =
json |> Yojson.Basic.Util.member "title" |> Yojson.Basic.Util.to_string
type law_excerpt_article = { id : string; num : string; content : string }
let clean_html (s : string) : string =
let new_line = Re.Pcre.regexp "\\s*\\<br\\s*\\/\\>\\s*" in
let s = Re.Pcre.substitute ~rex:new_line ~subst:(fun _ -> "\n") s in
let tag = Re.Pcre.regexp "\\<[^\\>]+\\>" in
let s = Re.Pcre.substitute ~rex:tag ~subst:(fun _ -> "") s in
String.trim s
let get_law_excerpt_articles (json : law_excerpt) : law_excerpt_article list =
let articles =
json |> Yojson.Basic.Util.member "articles" |> Yojson.Basic.Util.to_list
in
let articles =
List.sort
(fun a1 a2 ->
let a1_num =
int_of_string
(a1 |> Yojson.Basic.Util.member "num" |> Yojson.Basic.Util.to_string)
in
let a2_num =
int_of_string
(a2 |> Yojson.Basic.Util.member "num" |> Yojson.Basic.Util.to_string)
in
compare a1_num a2_num)
articles
in
List.map
(fun article ->
let article_id =
article |> Yojson.Basic.Util.member "id" |> Yojson.Basic.Util.to_string
in
let article_num =
article |> Yojson.Basic.Util.member "num" |> Yojson.Basic.Util.to_string
in
let article_content =
article
|> Yojson.Basic.Util.member "content"
|> Yojson.Basic.Util.to_string
|> clean_html
in
{ id = article_id; num = article_num; content = article_content })
articles

View File

@ -42,26 +42,12 @@ val retrieve_article : access_token -> article_id -> article
(** [retrieve_article token article_id] returns the article from the LegiFrance
API.*)
type law_excerpt
val retrieve_law_excerpt : access_token -> string -> law_excerpt
(**[retrieve_law_excerpt token excerpt_id] returns a whole excerpt of a
legislative statute from the LegiFrance API. [excerpt_id] should be of the
form ["JORFTEXT000033736934"] *)
(**{2 Manipulating API objects}*)
(**{3 Articles}*)
val get_article_id : article -> string
val get_article_text : article -> string
val get_article_title : article -> string
val get_article_expiration_date : article -> Unix.tm
val get_article_new_version : article -> string
(**{3 Law excerpts}*)
val get_law_excerpt_title : law_excerpt -> string
type law_excerpt_article = { id : string; num : string; content : string }
val get_law_excerpt_articles : law_excerpt -> law_excerpt_article list

View File

@ -165,25 +165,14 @@ let compare_to_versions
let include_legislative_text
(id : string * Pos.t)
(access_token : Api.access_token) : string =
let excerpt = Api.retrieve_law_excerpt access_token (fst id) in
let title = "#" ^ Api.get_law_excerpt_title excerpt in
let excerpts = Api.get_law_excerpt_articles excerpt in
let text_to_return =
String.concat "\n\n"
(List.map (fun article -> article.Api.content) excerpts)
in
let articles =
List.map
(fun article ->
Printf.sprintf "## Article %s|%s@\n%s" article.Api.num article.Api.id
article.Api.content)
excerpts
in
let to_insert = title ^ "\n\n" ^ String.concat "\n\n" articles in
let pos = snd id in
let id = Api.parse_id (fst id) in
let article = Api.retrieve_article access_token id in
let text_to_return = Api.get_article_text article in
let to_insert = text_to_return in
Cli.debug_format "Position: %s" (Pos.to_string_short pos);
let file = Pos.get_file pos in
let include_line = Pos.get_end_line pos in
let include_line = Pos.get_start_line pos in
let ic = open_in file in
let new_file = file ^ ".new" in
Cli.warning_print "LégiFrance inclusion detected, writing new contents to %s"

View File

@ -65,7 +65,6 @@ function run_computation_AL(log) {
"logementEstChambre": false,
"colocation": false,
"ageesOuHandicapAdultesHebergeesOnereuxParticuliers": false,
"reductionLoyerSolidarite": 0,
"logementMeubleD8422": false,
"changementLogementD8424": {
"kind": "PasDeChangement",
@ -131,7 +130,7 @@ function run_computation_AL(log) {
"payload": null
},
"conditionRattacheFoyerFiscalParentIfi": false,
"nombreEnfantsANaitreApresTroisiemeMoisGrossesse": 0,
"enfantANaitreApresQuatriemeMoisGrossesse": false,
},
"demandeurIn": {
"nationalite": {

File diff suppressed because one or more lines are too long

View File

@ -71,7 +71,7 @@ let format_prise_en_charge (fmt : Format.formatter) (g : AF.PriseEnCharge.t) :
let num_successful = ref 0
let total_amount = ref 0.
let run_test () =
let run_test_allocations_familiales () =
let num_children = Random.int 7 in
let children = Array.init num_children random_children in
let income = Random.int 100000 in
@ -115,19 +115,134 @@ let run_test () =
exit (-1)
| Runtime.AssertionFailed _ -> ()
let aides_logement_input :
Law_source.Aides_logement.CalculetteAidesAuLogementGardeAlterneeIn.t =
{
menage_in =
{
prestations_recues = Array.of_list [];
logement =
{
residence_principale = true;
est_ehpad_ou_maison_autonomie_l313_12_asf = false;
mode_occupation =
Law_source.Aides_logement.ModeOccupation.Locataire
{
bailleur =
Law_source.Aides_logement.TypeBailleur.BailleurPrive ();
beneficiaire_aide_adulte_ou_enfant_handicapes = false;
logement_est_chambre = false;
colocation = false;
agees_ou_handicap_adultes_hebergees_onereux_particuliers =
false;
logement_meuble_d842_2 = false;
changement_logement_d842_4 =
Law_source.Aides_logement.ChangementLogementD8424
.PasDeChangement
();
loyer_principal = Runtime.money_of_units_int 450;
};
proprietaire = Law_source.Aides_logement.ParentOuAutre.Autre ();
loue_ou_sous_loue_a_des_tiers =
Law_source.Aides_logement.LoueOuSousLoueADesTiers.Non ();
usufruit = Law_source.Aides_logement.ParentOuAutre.Autre ();
logement_decent_l89_462 = true;
surface_m_carres = Runtime.integer_of_int 65;
zone = Law_source.Aides_logement.ZoneDHabitation.Zone2 ();
};
personnes_a_charge =
Array.of_list
[
Law_source.Aides_logement.PersonneACharge.EnfantACharge
{
beneficie_titre_personnel_aide_personnelle_logement = false;
a_deja_ouvert_droit_aux_allocations_familiales = true;
remuneration_mensuelle = Runtime.money_of_units_int 0;
obligation_scolaire =
Law_source.Aides_logement.SituationObligationScolaire
.Pendant
();
situation_garde_alternee =
Law_source.Aides_logement.SituationGardeAlternee
.PasDeGardeAlternee
();
date_de_naissance = Runtime.date_of_numbers 2015 1 1;
identifiant = Runtime.integer_of_int 0;
};
Law_source.Aides_logement.PersonneACharge.EnfantACharge
{
beneficie_titre_personnel_aide_personnelle_logement = false;
a_deja_ouvert_droit_aux_allocations_familiales = true;
remuneration_mensuelle = Runtime.money_of_units_int 0;
obligation_scolaire =
Law_source.Aides_logement.SituationObligationScolaire
.Pendant
();
situation_garde_alternee =
Law_source.Aides_logement.SituationGardeAlternee
.PasDeGardeAlternee
();
date_de_naissance = Runtime.date_of_numbers 2016 1 1;
identifiant = Runtime.integer_of_int 1;
};
];
nombre_autres_occupants_logement = Runtime.integer_of_int 0;
situation_familiale =
Law_source.Aides_logement.SituationFamiliale.Concubins ();
condition_rattache_foyer_fiscal_parent_ifi = false;
enfant_a_naitre_apres_quatrieme_mois_grossesse = false;
};
demandeur_in =
{
nationalite = Law_source.Aides_logement.Nationalite.Francaise ();
patrimoine =
{
produisant_revenu_periode_r822_3_3_r822_4 =
Runtime.money_of_units_int 0;
ne_produisant_pas_revenu_periode_r822_3_3_r822_4 =
Runtime.money_of_units_int 0;
};
personne_hebergee_centre_soin_l_L162_22_3_securite_sociale = false;
date_naissance = Runtime.date_of_numbers 1992 1 1;
};
date_courante_in = Runtime.date_of_numbers 2022 5 1;
ressources_menage_prises_en_compte_in = Runtime.money_of_units_int 11500;
}
let run_test_aides_logement () =
try
ignore
(Law_source.Aides_logement.calculette_aides_au_logement_garde_alternee
aides_logement_input)
with
| (Runtime.NoValueProvided _ | Runtime.ConflictError _) as err ->
Format.printf "%s"
(match err with
| Runtime.NoValueProvided _ -> "No value provided somewhere!"
| Runtime.ConflictError _ -> "Conflict error!"
| _ -> failwith "impossible");
exit (-1)
| Runtime.AssertionFailed _ -> ()
let _bench =
Random.init (int_of_float (Unix.time ()));
let num_iter = 10000 in
let _ =
Benchmark.latency1 ~style:Auto ~name:"Allocations familiales"
(Int64.of_int num_iter) run_test ()
(Int64.of_int num_iter) run_test_allocations_familiales ()
in
Printf.printf
"Successful computations: %d (%.2f%%)\n\
Total benefits awarded: %.2f (mean %.2f)\n"
"Successful\n\
\ computations: %d (%.2f%%)\n\
\ Total benefits awarded: %.2f (mean %.2f)\n"
!num_successful
(Float.mul
(Float.div (float_of_int !num_successful) (float_of_int num_iter))
100.)
!total_amount
(Float.div !total_amount (float_of_int !num_successful))
(Float.div !total_amount (float_of_int !num_successful));
let _ =
Benchmark.latency1 ~style:Auto ~name:"Aides au logement"
(Int64.of_int num_iter) run_test_aides_logement ()
in
Printf.printf "Successful\n"

File diff suppressed because it is too large Load Diff

View File

@ -736,7 +736,7 @@ let smic (smic_in: SmicIn.t) : Smic.t =
(date_of_numbers (2022) (5) (1)))
(o_and
(o_lte_dat_dat date_courante_
(date_of_numbers (2022) (12) (31)))
(date_of_numbers (2022) (7) (31)))
(o_or (o_eq residence_ (Collectivite.Metropole ()))
(o_or
(o_eq residence_ (Collectivite.Guadeloupe ()))
@ -778,11 +778,145 @@ let smic (smic_in: SmicIn.t) : Smic.t =
(o_and
(o_gte_dat_dat date_courante_
(date_of_numbers (2022) (5) (1)))
(o_and
(o_lte_dat_dat date_courante_
(date_of_numbers (2022) (7) (31)))
(o_eq residence_ (Collectivite.Mayotte ()))))))
(fun (_: unit) -> money_of_cents_string "819"));
(fun (_: unit) ->
handle_default
{filename = "examples/allocations_familiales/../smic/smic.catala_fr";
start_line=11; start_column=12;
end_line=11; end_column=24;
law_headings=["Prologue";
"Montant du salaire minimum de croissance"]}
([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/../smic/smic.catala_fr";
start_line=225; start_column=5;
end_line=234; end_column=6;
law_headings=["Article 2";
"Arrêté du 29 juillet 2022 relatif au relèvement du salaire minimum de croissance";
"Montant du salaire minimum de croissance"]}
(o_and
(o_gte_dat_dat date_courante_
(date_of_numbers (2022) (8) (1)))
(o_and
(o_lte_dat_dat date_courante_
(date_of_numbers (2022) (12) (31)))
(o_or (o_eq residence_ (Collectivite.Metropole ()))
(o_or
(o_eq residence_ (Collectivite.Guadeloupe ()))
(o_or
(o_eq residence_ (Collectivite.Guyane ()))
(o_or
(o_eq residence_
(Collectivite.Martinique ()))
(o_or
(o_eq residence_
(Collectivite.LaReunion ()))
(o_or
(o_eq residence_
(Collectivite.SaintBarthelemy
()))
(o_or
(o_eq residence_
(Collectivite.SaintMartin
()))
(o_eq residence_
(Collectivite.SaintPierreEtMiquelon
())))))))))))))
(fun (_: unit) -> money_of_cents_string "1107"));
(fun (_: unit) ->
handle_default
{filename = "examples/allocations_familiales/../smic/smic.catala_fr";
start_line=11; start_column=12;
end_line=11; end_column=24;
law_headings=["Prologue";
"Montant du salaire minimum de croissance"]}
([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/../smic/smic.catala_fr";
start_line=243; start_column=5;
end_line=245; end_column=6;
law_headings=["Article 2";
"Arrêté du 29 juillet 2022 relatif au relèvement du salaire minimum de croissance";
"Montant du salaire minimum de croissance"]}
(o_and
(o_gte_dat_dat date_courante_
(date_of_numbers (2022) (8) (1)))
(o_and
(o_lte_dat_dat date_courante_
(date_of_numbers (2022) (12) (31)))
(o_eq residence_ (Collectivite.Mayotte ()))))))
(fun (_: unit) -> money_of_cents_string "819"))|])
(fun (_: unit) -> money_of_cents_string "835"));
(fun (_: unit) ->
handle_default
{filename = "examples/allocations_familiales/../smic/smic.catala_fr";
start_line=11; start_column=12;
end_line=11; end_column=24;
law_headings=["Prologue";
"Montant du salaire minimum de croissance"]}
([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/../smic/smic.catala_fr";
start_line=265; start_column=5;
end_line=274; end_column=6;
law_headings=["Article 1";
"Décret n° 2022-1608 du 22 décembre 2022 portant relèvement du salaire minimum de croissance";
"Montant du salaire minimum de croissance"]}
(o_and
(o_gte_dat_dat date_courante_
(date_of_numbers (2023) (1) (1)))
(o_and
(o_lte_dat_dat date_courante_
(date_of_numbers (2023) (12) (31)))
(o_or (o_eq residence_ (Collectivite.Metropole ()))
(o_or
(o_eq residence_ (Collectivite.Guadeloupe ()))
(o_or
(o_eq residence_ (Collectivite.Guyane ()))
(o_or
(o_eq residence_
(Collectivite.Martinique ()))
(o_or
(o_eq residence_
(Collectivite.LaReunion ()))
(o_or
(o_eq residence_
(Collectivite.SaintBarthelemy
()))
(o_or
(o_eq residence_
(Collectivite.SaintMartin
()))
(o_eq residence_
(Collectivite.SaintPierreEtMiquelon
())))))))))))))
(fun (_: unit) -> money_of_cents_string "1127"));
(fun (_: unit) ->
handle_default
{filename = "examples/allocations_familiales/../smic/smic.catala_fr";
start_line=11; start_column=12;
end_line=11; end_column=24;
law_headings=["Prologue";
"Montant du salaire minimum de croissance"]}
([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/../smic/smic.catala_fr";
start_line=283; start_column=5;
end_line=285; end_column=6;
law_headings=["Article 1";
"Décret n° 2022-1608 du 22 décembre 2022 portant relèvement du salaire minimum de croissance";
"Montant du salaire minimum de croissance"]}
(o_and
(o_gte_dat_dat date_courante_
(date_of_numbers (2023) (1) (1)))
(o_and
(o_lte_dat_dat date_courante_
(date_of_numbers (2023) (12) (31)))
(o_eq residence_ (Collectivite.Mayotte ()))))))
(fun (_: unit) -> money_of_cents_string "851"))|])
(fun (_: unit) -> false) (fun (_: unit) -> raise EmptyError))
with
EmptyError -> (raise (NoValueProvided
@ -1825,17 +1959,17 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
(embed_array (embed_enfant))
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=32; start_column=14; end_line=32; end_column=40;
start_line=33; start_column=14; end_line=33; end_column=40;
law_headings=["Règles diverses"; "Épilogue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=32; start_column=14; end_line=32; end_column=40;
start_line=33; start_column=14; end_line=33; end_column=40;
law_headings=["Règles diverses"; "Épilogue"]} true))
(fun (_: unit) -> enfants_a_charge_))))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=32; start_column=14; end_line=32; end_column=40;
start_line=33; start_column=14; end_line=33; end_column=40;
law_headings=["Règles diverses"; "Épilogue"]})) in
let result_: EnfantLePlusAge.t = (log_end_call
["AllocationsFamiliales"; "enfant_le_plus_âgé"; "EnfantLePlusÂgé"]
@ -1952,8 +2086,8 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
[||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=33; start_column=14;
end_line=33; end_column=36;
start_line=34; start_column=14;
end_line=34; end_column=36;
law_headings=["Règles diverses"; "Épilogue"]} true))
(fun (_: unit) ->
o_eq enfant_le_plus_age_dot_le_plus_age_ param_))
@ -2295,8 +2429,8 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
(fun (_: unit) -> false))|])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=30; start_column=9;
end_line=30; end_column=32;
start_line=31; start_column=9;
end_line=31; end_column=32;
law_headings=["Règles diverses"; "Épilogue"]} true))
(fun (_: unit) -> true))|])
(fun (_: unit) -> (log_decision_taken
@ -4495,8 +4629,8 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=27; start_column=5;
end_line=27; end_column=44;
start_line=28; start_column=5;
end_line=28; end_column=44;
law_headings=["Règles diverses"; "Épilogue"]}
(o_not ((log_end_call
["AllocationsFamiliales";
@ -5005,7 +5139,7 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
"Prologue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=36; start_column=14; end_line=36; end_column=32;
start_line=37; start_column=14; end_line=37; end_column=32;
law_headings=["Règles diverses"; "Épilogue"]} true))
(fun (_: unit) ->
if droit_ouvert_base_ then montant_avec_garde_alternee_base_
@ -5026,7 +5160,7 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
"Prologue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=38; start_column=14; end_line=38; end_column=38;
start_line=39; start_column=14; end_line=39; end_column=38;
law_headings=["Règles diverses"; "Épilogue"]} true))
(fun (_: unit) ->
if droit_ouvert_base_ then
@ -5128,7 +5262,7 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
"Prologue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=44; start_column=14; end_line=44; end_column=27;
start_line=45; start_column=14; end_line=45; end_column=27;
law_headings=["Règles diverses"; "Épilogue"]} true))
(fun (_: unit) ->
if droit_ouvert_base_ then
@ -5191,11 +5325,11 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
try
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=75; start_column=11; end_line=75; end_column=27;
start_line=76; start_column=11; end_line=76; end_column=27;
law_headings=["Interface du programme"; "Épilogue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=116; start_column=14; end_line=116; end_column=30;
start_line=117; start_column=14; end_line=117; end_column=30;
law_headings=["Article L131-1"; "Interface du programme";
"Épilogue"]} true))
(fun (_: unit) ->
@ -5232,7 +5366,7 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=75; start_column=11; end_line=75; end_column=27;
start_line=76; start_column=11; end_line=76; end_column=27;
law_headings=["Interface du programme"; "Épilogue"]})))) in
let allocations_familiales_dot_personne_charge_effective_permanente_est_parent_: bool =
try ((log_variable_definition
@ -5241,30 +5375,30 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
(embed_bool)
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=91; start_column=5; end_line=91; end_column=75;
start_line=92; start_column=5; end_line=92; end_column=75;
law_headings=["Interface du programme"; "Épilogue"]}
([|(fun (_: unit) ->
handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=91; start_column=5; end_line=91; end_column=75;
start_line=92; start_column=5; end_line=92; end_column=75;
law_headings=["Interface du programme"; "Épilogue"]}
([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=92; start_column=18;
end_line=92; end_column=67;
start_line=93; start_column=18;
end_line=93; end_column=67;
law_headings=["Interface du programme"; "Épilogue"]}
i_personne_charge_effective_permanente_est_parent_))
(fun (_: unit) -> true))|])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=91; start_column=5; end_line=91; end_column=75;
start_line=92; start_column=5; end_line=92; end_column=75;
law_headings=["Interface du programme"; "Épilogue"]} true))
(fun (_: unit) -> false))))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=91; start_column=5; end_line=91; end_column=75;
start_line=92; start_column=5; end_line=92; end_column=75;
law_headings=["Interface du programme"; "Épilogue"]})) in
let allocations_familiales_dot_personne_charge_effective_permanente_remplit_titre__i_: bool =
try ((log_variable_definition
@ -5273,30 +5407,30 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
(embed_bool)
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=95; start_column=5; end_line=95; end_column=80;
start_line=96; start_column=5; end_line=96; end_column=80;
law_headings=["Interface du programme"; "Épilogue"]}
([|(fun (_: unit) ->
handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=95; start_column=5; end_line=95; end_column=80;
start_line=96; start_column=5; end_line=96; end_column=80;
law_headings=["Interface du programme"; "Épilogue"]}
([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=96; start_column=18;
end_line=96; end_column=72;
start_line=97; start_column=18;
end_line=97; end_column=72;
law_headings=["Interface du programme"; "Épilogue"]}
i_personne_charge_effective_permanente_remplit_titre__i_))
(fun (_: unit) -> true))|])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=95; start_column=5; end_line=95; end_column=80;
start_line=96; start_column=5; end_line=96; end_column=80;
law_headings=["Interface du programme"; "Épilogue"]} true))
(fun (_: unit) -> false))))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=95; start_column=5; end_line=95; end_column=80;
start_line=96; start_column=5; end_line=96; end_column=80;
law_headings=["Interface du programme"; "Épilogue"]})) in
let allocations_familiales_dot_ressources_menage_: money =
try ((log_variable_definition
@ -5304,17 +5438,17 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
"allocations_familiales.ressources_ménage"] (embed_money)
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=87; start_column=14; end_line=87; end_column=54;
start_line=88; start_column=14; end_line=88; end_column=54;
law_headings=["Interface du programme"; "Épilogue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=87; start_column=14; end_line=87; end_column=54;
start_line=88; start_column=14; end_line=88; end_column=54;
law_headings=["Interface du programme"; "Épilogue"]} true))
(fun (_: unit) -> i_ressources_menage_))))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=87; start_column=14; end_line=87; end_column=54;
start_line=88; start_column=14; end_line=88; end_column=54;
law_headings=["Interface du programme"; "Épilogue"]})) in
let allocations_familiales_dot_residence_: Collectivite.t =
try ((log_variable_definition
@ -5322,17 +5456,17 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
(embed_collectivite)
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=88; start_column=14; end_line=88; end_column=46;
start_line=89; start_column=14; end_line=89; end_column=46;
law_headings=["Interface du programme"; "Épilogue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=88; start_column=14; end_line=88; end_column=46;
start_line=89; start_column=14; end_line=89; end_column=46;
law_headings=["Interface du programme"; "Épilogue"]} true))
(fun (_: unit) -> i_residence_))))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=88; start_column=14; end_line=88; end_column=46;
start_line=89; start_column=14; end_line=89; end_column=46;
law_headings=["Interface du programme"; "Épilogue"]})) in
let allocations_familiales_dot_date_courante_: date =
try ((log_variable_definition
@ -5340,17 +5474,17 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
"allocations_familiales.date_courante"] (embed_date)
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=85; start_column=14; end_line=85; end_column=50;
start_line=86; start_column=14; end_line=86; end_column=50;
law_headings=["Interface du programme"; "Épilogue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=85; start_column=14; end_line=85; end_column=50;
start_line=86; start_column=14; end_line=86; end_column=50;
law_headings=["Interface du programme"; "Épilogue"]} true))
(fun (_: unit) -> i_date_courante_))))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=85; start_column=14; end_line=85; end_column=50;
start_line=86; start_column=14; end_line=86; end_column=50;
law_headings=["Interface du programme"; "Épilogue"]})) in
let allocations_familiales_dot_enfants_a_charge_: Enfant.t array =
try ((log_variable_definition
@ -5359,17 +5493,17 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
(embed_array (embed_enfant))
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=86; start_column=14; end_line=86; end_column=53;
start_line=87; start_column=14; end_line=87; end_column=53;
law_headings=["Interface du programme"; "Épilogue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=86; start_column=14; end_line=86; end_column=53;
start_line=87; start_column=14; end_line=87; end_column=53;
law_headings=["Interface du programme"; "Épilogue"]} true))
(fun (_: unit) -> enfants_a_charge_))))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=86; start_column=14; end_line=86; end_column=53;
start_line=87; start_column=14; end_line=87; end_column=53;
law_headings=["Interface du programme"; "Épilogue"]})) in
let allocations_familiales_dot_avait_enfant_a_charge_avant_1er_janvier_2012_: bool =
try ((log_variable_definition
@ -5378,30 +5512,31 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
(embed_bool)
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=99; start_column=5; end_line=99; end_column=72;
start_line=100; start_column=5; end_line=100; end_column=72;
law_headings=["Interface du programme"; "Épilogue"]}
([|(fun (_: unit) ->
handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=99; start_column=5; end_line=99; end_column=72;
start_line=100; start_column=5;
end_line=100; end_column=72;
law_headings=["Interface du programme"; "Épilogue"]}
([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=100; start_column=18;
end_line=100; end_column=64;
start_line=101; start_column=18;
end_line=101; end_column=64;
law_headings=["Interface du programme"; "Épilogue"]}
i_avait_enfant_a_charge_avant_1er_janvier_2012_))
(fun (_: unit) -> true))|])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=99; start_column=5; end_line=99; end_column=72;
start_line=100; start_column=5; end_line=100; end_column=72;
law_headings=["Interface du programme"; "Épilogue"]} true))
(fun (_: unit) -> false))))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=99; start_column=5; end_line=99; end_column=72;
start_line=100; start_column=5; end_line=100; end_column=72;
law_headings=["Interface du programme"; "Épilogue"]})) in
let result_: AllocationsFamiliales.t = (log_end_call
["InterfaceAllocationsFamiliales"; "allocations_familiales";
@ -5428,16 +5563,16 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
try
(handle_default
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=79; start_column=12; end_line=79; end_column=27;
start_line=80; start_column=12; end_line=80; end_column=27;
law_headings=["Interface du programme"; "Épilogue"]} ([||])
(fun (_: unit) -> (log_decision_taken
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=89; start_column=14; end_line=89; end_column=29;
start_line=90; start_column=14; end_line=90; end_column=29;
law_headings=["Interface du programme"; "Épilogue"]} true))
(fun (_: unit) -> allocations_familiales_dot_montant_verse_))
with
EmptyError -> (raise (NoValueProvided
{filename = "examples/allocations_familiales/epilogue.catala_fr";
start_line=79; start_column=12; end_line=79; end_column=27;
start_line=80; start_column=12; end_line=80; end_column=27;
law_headings=["Interface du programme"; "Épilogue"]})))) in
{InterfaceAllocationsFamiliales.i_montant_verse = i_montant_verse_}

View File

@ -372,7 +372,9 @@ module EventParser = struct
| VariableDefinition (name, value) ->
Printf.sprintf "VariableDefinition([ %s ], %s)" (String.concat ", " name)
(yojson_of_runtime_value value |> Yojson.Safe.to_string)
| DecisionTaken _ -> Printf.sprintf "DecisionTaken(_)"
| DecisionTaken pos ->
Printf.sprintf "DecisionTaken(%s:%d.%d-%d.%d)" pos.filename pos.start_line
pos.start_column pos.end_line pos.end_column
let parse_raw_events raw_events =
let nb_raw_events = List.length raw_events
@ -386,7 +388,6 @@ module EventParser = struct
and is_subscope_input_var_def name =
2 = List.length name && String.contains (List.nth name 1) '.'
in
let rec parse_events (ctx : context) : context =
match ctx.rest with
| [] -> { ctx with events = ctx.events |> List.rev }

View File

@ -0,0 +1,89 @@
```catala
declaration scope HousingComputation:
output f content integer depends on integer
output result content integer
scope HousingComputation:
definition f of x equals (output of RentComputation).f of x
definition result equals f of 1
declaration scope RentComputation:
internal g content integer depends on integer
output f content integer depends on integer
scope RentComputation:
definition g of x equals x + 1
definition f of x equals g of (x + 1)
```
```catala-test-inline
$ catala Interpret -t -s HousingComputation
[LOG] ≔ HousingComputation.f: <function>
[LOG] ☛ Definition applied:
┌─⯈ tests/test_scope/good/scope_call3.catala_en:8.13-19:
└─┐
8 │ definition result equals f of 1
│ ‾‾‾‾‾‾
[LOG] → HousingComputation.f
[LOG] ≔ HousingComputation.f.input: 1
[LOG] ☛ Definition applied:
┌─⯈ tests/test_scope/good/scope_call3.catala_en:7.13-14:
└─┐
7 │ definition f of x equals (output of RentComputation).f of x
│ ‾
[LOG] → RentComputation.direct
[LOG] ≔ RentComputation.direct.input: RentComputation_in { }
[LOG] ≔ RentComputation.g: <function>
[LOG] ≔ RentComputation.f: <function>
[LOG] ☛ Definition applied:
┌─⯈ tests/test_scope/good/scope_call3.catala_en:7.28-53:
└─┐
7 │ definition f of x equals (output of RentComputation).f of x
│ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
[LOG] ≔ RentComputation.direct.output: RentComputation { "f"= λ (param: integer) → RentComputation { "f"= λ (param1: integer) → error_empty ⟨true ⊢ λ (param2: integer) → error_empty ⟨true ⊢ param2 +! 1⟩ param1 +! 1⟩ }."f" param }
[LOG] ← RentComputation.direct
[LOG] → RentComputation.f
[LOG] ≔ RentComputation.f.input: 1
[LOG] ☛ Definition applied:
┌─⯈ tests/test_scope/good/scope_call3.catala_en:16.13-14:
└──┐
16 │ definition f of x equals g of (x + 1)
│ ‾
[LOG] → RentComputation.g
[LOG] ≔ RentComputation.g.input: 2
[LOG] ☛ Definition applied:
┌─⯈ tests/test_scope/good/scope_call3.catala_en:15.13-14:
└──┐
15 │ definition g of x equals x + 1
│ ‾
[LOG] ≔ RentComputation.g.output: 3
[LOG] ← RentComputation.g
[LOG] ≔ RentComputation.f.output: 3
[LOG] ← RentComputation.f
[LOG] ≔ HousingComputation.f.output: 3
[LOG] ← HousingComputation.f
[LOG] ≔ HousingComputation.result: 3
[RESULT] Computation successful! Results:
[RESULT] f =
λ (param: integer) → error_empty
⟨true ⊢
let result : RentComputation {"f": integer → integer} =
λ (RentComputation_in: RentComputation_in {}) →
let g : integer → integer = error_empty
(λ (param1: integer) → error_empty
⟨true ⊢ param1 +! 1⟩) in
let f : integer → integer = error_empty
(λ (param1: integer) → error_empty
⟨true ⊢ g param1 +! 1⟩) in
RentComputation { "f"= f } RentComputation_in { } in
let result1 : RentComputation {"f": integer → integer} =
RentComputation { "f"=
λ (param1: integer) → result."f" param1 } in
if true then result1 else ∅ ."f" param⟩
[RESULT] result = 3
```

View File

@ -1,128 +0,0 @@
(** This file has been generated by the Catala compiler, do not edit! *)
open Runtime_ocaml.Runtime
[@@@ocaml.warning "-4-26-27-32-41-42"]
module Enum = struct
type t =
| Int of integer
| Dec of decimal
| Dat of date
end
module Structure = struct
type t = {i: integer; e: Enum.t}
end
module SOut = struct
type t = {y_out: Enum.t; z_out: Structure.t array; a_out: decimal}
end
module SIn = struct
type t = {x_in: integer; y_in: Enum.t}
end
module S2Out = struct
type t = {a_out: Enum.t}
end
module S2In = struct
type t = unit
end
let s (s_in: SIn.t) : SOut.t =
let x_: integer = s_in.SIn.x_in in
let y_: Enum.t = s_in.SIn.y_in in
let z_: Structure.t array = (
try
(handle_default
{filename = "./common.catala_en"; start_line=14; start_column=10;
end_line=14; end_column=11; law_headings=[]} ([||])
(fun (_: unit) -> true)
(fun (_: unit) ->
[|{Structure.i = (integer_of_string "3");
Structure.e = (Enum.Int x_)};
{Structure.i = (integer_of_string "4"); Structure.e = y_};
{Structure.i = (integer_of_string "5");
Structure.e = (Enum.Dat (date_of_numbers (1970) (1) (1)))}|]))
with
EmptyError -> (raise (NoValueProvided
{filename = "./common.catala_en"; start_line=14; start_column=10;
end_line=14; end_column=11; law_headings=[]}))) in
let a_: decimal = (
try
(handle_default
{filename = "./common.catala_en"; start_line=15; start_column=10;
end_line=15; end_column=11; law_headings=[]} ([||])
(fun (_: unit) -> true)
(fun (_: unit) ->
(decimal_of_integer (array_length (z_ @ z_))) /&
(decimal_of_string "2.")))
with
EmptyError -> (raise (NoValueProvided
{filename = "./common.catala_en"; start_line=15; start_column=10;
end_line=15; end_column=11; law_headings=[]}))) in
{SOut.y_out = y_; SOut.z_out = z_; SOut.a_out = a_}
let s2 (s2_in: S2In.t) : S2Out.t =
let sub_dot_x_: integer =
try
((handle_default
{filename = "err6.catala_en"; start_line=5; start_column=3;
end_line=5; end_column=6; law_headings=[]} ([||])
(fun (_: unit) -> true) (fun (_: unit) -> integer_of_string "44")))
with
EmptyError -> (raise (NoValueProvided
{filename = "./common.catala_en"; start_line=12; start_column=9;
end_line=12; end_column=10; law_headings=[]})) in
let sub_dot_y_: Enum.t =
try
((handle_default
{filename = "err6.catala_en"; start_line=5; start_column=3;
end_line=5; end_column=6; law_headings=[]} ([||])
(fun (_: unit) -> true)
(fun (_: unit) -> Enum.Int (integer_of_string "44"))))
with
EmptyError -> (raise (NoValueProvided
{filename = "./common.catala_en"; start_line=13; start_column=16;
end_line=13; end_column=17; law_headings=[]})) in
let result_: SOut.t = ((s) {SIn.x_in = sub_dot_x_; SIn.y_in = sub_dot_y_}) in
let sub_dot_y_: Enum.t = result_.SOut.y_out in
let sub_dot_z_: Structure.t array = result_.SOut.z_out in
let sub_dot_a_: decimal = result_.SOut.a_out in
let r_: bool = (
try
(handle_default
{filename = "err6.catala_en"; start_line=6; start_column=12;
end_line=6; end_column=13; law_headings=[]} ([||])
(fun (_: unit) ->
(Array.fold_left
(fun (acc_: bool) (x_: _) ->
acc_ ||
(match (x_.Structure.e)
with
| Enum.Int _ -> true
| Enum.Dec _ -> false
| Enum.Dat _ -> false)) false sub_dot_z_))
(fun (_: unit) -> true))
with
EmptyError -> (raise (NoValueProvided
{filename = "err6.catala_en"; start_line=6; start_column=12;
end_line=6; end_column=13; law_headings=[]}))) in
let a_: Enum.t = (
try
(handle_default
{filename = "err6.catala_en"; start_line=7; start_column=10;
end_line=7; end_column=11; law_headings=[]} ([||])
(fun (_: unit) -> true)
(fun (_: unit) ->
if r_ then (Enum.Int (array_length sub_dot_z_)) else
(Enum.Dec (decimal_of_string "0."))))
with
EmptyError -> (raise (NoValueProvided
{filename = "err6.catala_en"; start_line=7; start_column=10;
end_line=7; end_column=11; law_headings=[]}))) in
{S2Out.a_out = a_}