mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Merge branch 'master' into aides_logement_outre_mer
This commit is contained in:
commit
7f705beb07
4
.github/workflows/run-make-all.yml
vendored
4
.github/workflows/run-make-all.yml
vendored
@ -22,8 +22,10 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- name: Prepare container with all dependencies
|
||||
run: git archive HEAD | docker build - --target dev-build-context
|
||||
- name: Escape slashes in IMAGE_TAG (to avoid Docker issues)
|
||||
run: echo "IMAGE_TAG=${IMAGE_TAG////--}" >> $GITHUB_ENV
|
||||
- name: Run builds, checks and tests
|
||||
run: git archive HEAD | docker build - --force-rm -t catalalang/catala-build:${IMAGE_TAG}
|
||||
run: git archive HEAD | docker build - --force-rm -t "catalalang/catala-build:${IMAGE_TAG}"
|
||||
- name: Cleanup Docker image
|
||||
if: ${{ github.ref != 'refs/heads/master' }}
|
||||
run: docker image rm catalalang/catala-build:${IMAGE_TAG}
|
||||
|
@ -58,6 +58,7 @@ type 'm ctx = {
|
||||
('m Ast.expr Var.t * naked_typ * Desugared.Ast.io) ScopeVar.Map.t
|
||||
SubScopeName.Map.t;
|
||||
local_vars : ('m Scopelang.Ast.expr, 'm Ast.expr Var.t) Var.Map.t;
|
||||
date_rounding : date_rounding;
|
||||
}
|
||||
|
||||
let mark_tany m pos = Expr.with_ty m (Marked.mark pos TAny) ~pos
|
||||
@ -554,7 +555,8 @@ let rec translate_expr (ctx : 'm ctx) (e : 'm Scopelang.Ast.expr) :
|
||||
Expr.eifthenelse (translate_expr ctx cond) (translate_expr ctx etrue)
|
||||
(translate_expr ctx efalse)
|
||||
m
|
||||
| EOp { op; tys } -> Expr.eop (Operator.translate op) tys m
|
||||
| EOp { op; tys } ->
|
||||
Expr.eop (Operator.translate (Some ctx.date_rounding) op) tys m
|
||||
| EErrorOnEmpty e' -> Expr.eerroronempty (translate_expr ctx e') m
|
||||
| EArray es -> Expr.earray (List.map (translate_expr ctx) es) m
|
||||
|
||||
@ -911,6 +913,17 @@ let translate_scope_decl
|
||||
| _ -> ctx)
|
||||
ctx scope_variables
|
||||
in
|
||||
let date_rounding : date_rounding =
|
||||
match
|
||||
List.find_opt
|
||||
(function Desugared.Ast.DateRounding _, _ -> true)
|
||||
sigma.scope_options
|
||||
with
|
||||
| Some (Desugared.Ast.DateRounding Desugared.Ast.Increasing, _) -> RoundUp
|
||||
| Some (DateRounding Decreasing, _) -> RoundDown
|
||||
| None -> AbortOnRound
|
||||
in
|
||||
let ctx = { ctx with date_rounding } in
|
||||
let scope_input_var = scope_sig.scope_sig_input_var in
|
||||
let scope_input_struct_name = scope_sig.scope_sig_input_struct in
|
||||
let scope_return_struct_name = scope_sig.scope_sig_output_struct in
|
||||
@ -1076,6 +1089,7 @@ let translate_program (prgm : 'm Scopelang.Ast.program) : 'm Ast.program =
|
||||
subscope_vars = SubScopeName.Map.empty;
|
||||
local_vars = Var.Map.empty;
|
||||
toplevel_vars;
|
||||
date_rounding = AbortOnRound;
|
||||
}
|
||||
in
|
||||
(* the resulting expression is the list of definitions of all the scopes,
|
||||
|
@ -239,7 +239,7 @@ and evaluate_operator :
|
||||
| Add_int_int, [LInt x; LInt y] -> LInt (o_add_int_int x y)
|
||||
| Add_rat_rat, [LRat x; LRat y] -> LRat (o_add_rat_rat x y)
|
||||
| Add_mon_mon, [LMoney x; LMoney y] -> LMoney (o_add_mon_mon x y)
|
||||
| Add_dat_dur, [LDate x; LDuration y] -> LDate (o_add_dat_dur x y)
|
||||
| Add_dat_dur r, [LDate x; LDuration y] -> LDate (o_add_dat_dur r x y)
|
||||
| Add_dur_dur, [LDuration x; LDuration y] ->
|
||||
LDuration (o_add_dur_dur x y)
|
||||
| Sub_int_int, [LInt x; LInt y] -> LInt (o_sub_int_int x y)
|
||||
@ -294,7 +294,7 @@ and evaluate_operator :
|
||||
LBool (protect o_eq_dur_dur x y)
|
||||
| ( ( Minus_int | Minus_rat | Minus_mon | Minus_dur | ToRat_int
|
||||
| ToRat_mon | ToMoney_rat | Round_rat | Round_mon | Add_int_int
|
||||
| Add_rat_rat | Add_mon_mon | Add_dat_dur | Add_dur_dur
|
||||
| Add_rat_rat | Add_mon_mon | Add_dat_dur _ | Add_dur_dur
|
||||
| Sub_int_int | Sub_rat_rat | Sub_mon_mon | Sub_dat_dat
|
||||
| Sub_dat_dur | Sub_dur_dur | Mult_int_int | Mult_rat_rat
|
||||
| Mult_mon_rat | Mult_dur_int | Div_int_int | Div_rat_rat
|
||||
|
@ -175,6 +175,7 @@ let always_false_rule
|
||||
type assertion = expr boxed
|
||||
type variation_typ = Increasing | Decreasing
|
||||
type reference_typ = Decree | Law
|
||||
type catala_option = DateRounding of variation_typ
|
||||
|
||||
type meta_assertion =
|
||||
| FixedBy of reference_typ Marked.pos
|
||||
@ -196,6 +197,7 @@ type scope = {
|
||||
scope_uid : ScopeName.t;
|
||||
scope_defs : scope_def ScopeDefMap.t;
|
||||
scope_assertions : assertion list;
|
||||
scope_options : catala_option Marked.pos list;
|
||||
scope_meta_assertions : meta_assertion list;
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ val always_false_rule :
|
||||
type assertion = expr boxed
|
||||
type variation_typ = Increasing | Decreasing
|
||||
type reference_typ = Decree | Law
|
||||
type catala_option = DateRounding of variation_typ
|
||||
|
||||
type meta_assertion =
|
||||
| FixedBy of reference_typ Marked.pos
|
||||
@ -119,6 +120,7 @@ type scope = {
|
||||
scope_uid : ScopeName.t;
|
||||
scope_defs : scope_def ScopeDefMap.t;
|
||||
scope_assertions : assertion list;
|
||||
scope_options : catala_option Marked.pos list;
|
||||
scope_meta_assertions : meta_assertion list;
|
||||
}
|
||||
|
||||
|
@ -1142,6 +1142,37 @@ let process_scope_use_item
|
||||
| Surface.Ast.Rule rule -> process_rule precond scope ctxt prgm rule
|
||||
| Surface.Ast.Definition def -> process_def precond scope ctxt prgm def
|
||||
| Surface.Ast.Assertion ass -> process_assert precond scope ctxt prgm ass
|
||||
| Surface.Ast.DateRounding (r, _) ->
|
||||
let scope_uid = scope in
|
||||
let scope : Ast.scope = ScopeName.Map.find scope_uid prgm.program_scopes in
|
||||
let r =
|
||||
match r with
|
||||
| Surface.Ast.Increasing -> Ast.Increasing
|
||||
| Surface.Ast.Decreasing -> Ast.Decreasing
|
||||
in
|
||||
let new_scope =
|
||||
match
|
||||
List.find_opt
|
||||
(fun (scope_opt, _) ->
|
||||
scope_opt = Ast.DateRounding Ast.Increasing
|
||||
|| scope_opt = Ast.DateRounding Ast.Decreasing)
|
||||
scope.scope_options
|
||||
with
|
||||
| Some (_, old_pos) ->
|
||||
Errors.raise_multispanned_error
|
||||
[None, old_pos; None, Marked.get_mark item]
|
||||
"You cannot set multiple date rounding modes"
|
||||
| None ->
|
||||
{
|
||||
scope with
|
||||
scope_options =
|
||||
Marked.same_mark_as (Ast.DateRounding r) item :: scope.scope_options;
|
||||
}
|
||||
in
|
||||
{
|
||||
prgm with
|
||||
program_scopes = ScopeName.Map.add scope_uid new_scope prgm.program_scopes;
|
||||
}
|
||||
| _ -> prgm
|
||||
|
||||
(** {1 Translating top-level items} *)
|
||||
@ -1381,6 +1412,7 @@ let translate_program
|
||||
scope_defs = init_scope_defs ctxt s_context.var_idmap;
|
||||
scope_assertions = [];
|
||||
scope_meta_assertions = [];
|
||||
scope_options = [];
|
||||
scope_uid = s_uid;
|
||||
})
|
||||
ctxt.Name_resolution.scopes
|
||||
|
@ -78,7 +78,7 @@ and translate_expr (ctx : 'm ctx) (e : 'm D.expr) : 'm A.expr boxed =
|
||||
l) ->
|
||||
Expr.elit l m
|
||||
| ELit LEmptyError -> Expr.eraise EmptyError m
|
||||
| EOp { op; tys } -> Expr.eop (Operator.translate op) tys m
|
||||
| EOp { op; tys } -> Expr.eop (Operator.translate None op) tys m
|
||||
| EIfThenElse { cond; etrue; efalse } ->
|
||||
Expr.eifthenelse (translate_expr ctx cond) (translate_expr ctx etrue)
|
||||
(translate_expr ctx efalse)
|
||||
|
@ -302,7 +302,8 @@ let rec translate_and_hoist (ctx : 'm ctx) (e : 'm D.expr) :
|
||||
let es', hoists = es |> List.map (translate_and_hoist ctx) |> List.split in
|
||||
|
||||
Expr.earray es' mark, disjoint_union_maps (Expr.pos e) hoists
|
||||
| EOp { op; tys } -> Expr.eop (Operator.translate op) tys mark, Var.Map.empty
|
||||
| EOp { op; tys } ->
|
||||
Expr.eop (Operator.translate None op) tys mark, Var.Map.empty
|
||||
|
||||
and translate_expr ?(append_esome = true) (ctx : 'm ctx) (e : 'm D.expr) :
|
||||
'm A.expr boxed =
|
||||
|
@ -70,8 +70,8 @@ let format_op
|
||||
| LastDayOfMonth -> Format.pp_print_string fmt "last_day_of_month"
|
||||
| Round_mon -> Format.pp_print_string fmt "money_round"
|
||||
| Round_rat -> Format.pp_print_string fmt "decimal_round"
|
||||
| Add_int_int | Add_rat_rat | Add_mon_mon | Add_dat_dur | Add_dur_dur | Concat
|
||||
->
|
||||
| Add_int_int | Add_rat_rat | Add_mon_mon | Add_dat_dur _ | Add_dur_dur
|
||||
| Concat ->
|
||||
Format.pp_print_string fmt "+"
|
||||
| Sub_int_int | Sub_rat_rat | Sub_mon_mon | Sub_dat_dat | Sub_dat_dur
|
||||
| Sub_dur_dur ->
|
||||
|
@ -49,6 +49,7 @@ type 'm scope_decl = {
|
||||
scope_sig : (typ * Desugared.Ast.io) ScopeVar.Map.t;
|
||||
scope_decl_rules : 'm rule list;
|
||||
scope_mark : 'm mark;
|
||||
scope_options : Desugared.Ast.catala_option Marked.pos list;
|
||||
}
|
||||
|
||||
type 'm program = {
|
||||
|
@ -41,6 +41,7 @@ type 'm scope_decl = {
|
||||
scope_sig : (typ * Desugared.Ast.io) ScopeVar.Map.t;
|
||||
scope_decl_rules : 'm rule list;
|
||||
scope_mark : 'm mark;
|
||||
scope_options : Desugared.Ast.catala_option Marked.pos list;
|
||||
}
|
||||
|
||||
type 'm program = {
|
||||
|
@ -662,6 +662,7 @@ let translate_scope (ctx : ctx) (scope : Desugared.Ast.scope) :
|
||||
Ast.scope_decl_rules;
|
||||
Ast.scope_sig;
|
||||
Ast.scope_mark = Untyped { pos };
|
||||
Ast.scope_options = scope.scope_options;
|
||||
}
|
||||
|
||||
(** {1 API} *)
|
||||
|
@ -81,6 +81,7 @@ and naked_typ =
|
||||
(** {2 Constants and operators} *)
|
||||
|
||||
type date = Runtime.date
|
||||
type date_rounding = Runtime.date_rounding
|
||||
type duration = Runtime.duration
|
||||
|
||||
type log_entry =
|
||||
@ -162,7 +163,9 @@ module Op = struct
|
||||
| Add_int_int : ([< scopelang | dcalc | lcalc ], resolved) t
|
||||
| Add_rat_rat : ([< scopelang | dcalc | lcalc ], resolved) t
|
||||
| Add_mon_mon : ([< scopelang | dcalc | lcalc ], resolved) t
|
||||
| Add_dat_dur : ([< scopelang | dcalc | lcalc ], resolved) t
|
||||
| Add_dat_dur :
|
||||
date_rounding
|
||||
-> ([< scopelang | dcalc | lcalc ], resolved) t
|
||||
| Add_dur_dur : ([< scopelang | dcalc | lcalc ], resolved) t
|
||||
| Sub : (desugared, overloaded) t
|
||||
| Sub_int_int : ([< scopelang | dcalc | lcalc ], resolved) t
|
||||
|
@ -52,7 +52,12 @@ let name : type a k. (a, k) t -> string = function
|
||||
| Add_int_int -> "o_add_int_int"
|
||||
| Add_rat_rat -> "o_add_rat_rat"
|
||||
| Add_mon_mon -> "o_add_mon_mon"
|
||||
| Add_dat_dur -> "o_add_dat_dur"
|
||||
| Add_dat_dur rm -> begin
|
||||
match rm with
|
||||
| RoundUp -> "o_add_dat_dur RoundUp"
|
||||
| RoundDown -> "o_add_dat_dur RoundDown"
|
||||
| AbortOnRound -> "o_add_dat_dur AbortOnRound"
|
||||
end
|
||||
| Add_dur_dur -> "o_add_dur_dur"
|
||||
| Sub -> "o_sub"
|
||||
| Sub_int_int -> "o_sub_int_int"
|
||||
@ -125,6 +130,7 @@ let compare (type a k a2 k2) (t1 : (a, k) t) (t2 : (a2, k2) t) =
|
||||
match compare_log_entries l1 l2 with
|
||||
| 0 -> List.compare Uid.MarkedString.compare info1 info2
|
||||
| n -> n)
|
||||
| Add_dat_dur l, Add_dat_dur r -> Stdlib.compare l r
|
||||
| Not, Not
|
||||
| Length, Length
|
||||
| GetDay, GetDay
|
||||
@ -157,7 +163,6 @@ let compare (type a k a2 k2) (t1 : (a, k) t) (t2 : (a2, k2) t) =
|
||||
| Add_int_int, Add_int_int
|
||||
| Add_rat_rat, Add_rat_rat
|
||||
| Add_mon_mon, Add_mon_mon
|
||||
| Add_dat_dur, Add_dat_dur
|
||||
| Add_dur_dur, Add_dur_dur
|
||||
| Sub, Sub
|
||||
| Sub_int_int, Sub_int_int
|
||||
@ -240,7 +245,7 @@ let compare (type a k a2 k2) (t1 : (a, k) t) (t2 : (a2, k2) t) =
|
||||
| Add_int_int, _ -> -1 | _, Add_int_int -> 1
|
||||
| Add_rat_rat, _ -> -1 | _, Add_rat_rat -> 1
|
||||
| Add_mon_mon, _ -> -1 | _, Add_mon_mon -> 1
|
||||
| Add_dat_dur, _ -> -1 | _, Add_dat_dur -> 1
|
||||
| Add_dat_dur _, _ -> -1 | _, Add_dat_dur _ -> 1
|
||||
| Add_dur_dur, _ -> -1 | _, Add_dur_dur -> 1
|
||||
| Sub, _ -> -1 | _, Sub -> 1
|
||||
| Sub_int_int, _ -> -1 | _, Sub_int_int -> 1
|
||||
@ -316,7 +321,7 @@ let kind_dispatch :
|
||||
overloaded op
|
||||
| ( Minus_int | Minus_rat | Minus_mon | Minus_dur | ToRat_int | ToRat_mon
|
||||
| ToMoney_rat | Round_rat | Round_mon | Add_int_int | Add_rat_rat
|
||||
| Add_mon_mon | Add_dat_dur | Add_dur_dur | Sub_int_int | Sub_rat_rat
|
||||
| Add_mon_mon | Add_dat_dur _ | Add_dur_dur | Sub_int_int | Sub_rat_rat
|
||||
| Sub_mon_mon | Sub_dat_dat | Sub_dat_dur | Sub_dur_dur | Mult_int_int
|
||||
| Mult_rat_rat | Mult_mon_rat | Mult_dur_int | Div_int_int | Div_rat_rat
|
||||
| Div_mon_mon | Div_mon_rat | Div_dur_dur | Lt_int_int | Lt_rat_rat
|
||||
@ -331,9 +336,10 @@ let kind_dispatch :
|
||||
lcalc *)
|
||||
let translate :
|
||||
type k.
|
||||
date_rounding option ->
|
||||
([< scopelang | dcalc | lcalc ], k) t ->
|
||||
([< scopelang | dcalc | lcalc ], k) t =
|
||||
fun op ->
|
||||
fun r op ->
|
||||
match op with
|
||||
| Length -> Length
|
||||
| Log (i, l) -> Log (i, l)
|
||||
@ -364,7 +370,7 @@ let translate :
|
||||
| Add_int_int -> Add_int_int
|
||||
| Add_rat_rat -> Add_rat_rat
|
||||
| Add_mon_mon -> Add_mon_mon
|
||||
| Add_dat_dur -> Add_dat_dur
|
||||
| Add_dat_dur rmode -> Add_dat_dur (Option.value r ~default:rmode)
|
||||
| Add_dur_dur -> Add_dur_dur
|
||||
| Sub_int_int -> Sub_int_int
|
||||
| Sub_rat_rat -> Sub_rat_rat
|
||||
@ -450,7 +456,7 @@ let resolved_type (op, pos) =
|
||||
| Add_int_int -> [TInt; TInt], TInt
|
||||
| Add_rat_rat -> [TRat; TRat], TRat
|
||||
| Add_mon_mon -> [TMoney; TMoney], TMoney
|
||||
| Add_dat_dur -> [TDate; TDuration], TDate
|
||||
| Add_dat_dur _ -> [TDate; TDuration], TDate
|
||||
| Add_dur_dur -> [TDuration; TDuration], TDuration
|
||||
| Sub_int_int -> [TInt; TInt], TInt
|
||||
| Sub_rat_rat -> [TRat; TRat], TRat
|
||||
@ -511,8 +517,8 @@ let resolve_overload_aux (op : ('a, overloaded) t) (operands : typ_lit list) :
|
||||
| Add, [TRat; TRat] -> Add_rat_rat, `Straight
|
||||
| Add, [TMoney; TMoney] -> Add_mon_mon, `Straight
|
||||
| Add, [TDuration; TDuration] -> Add_dur_dur, `Straight
|
||||
| Add, [TDate; TDuration] -> Add_dat_dur, `Straight
|
||||
| Add, [TDuration; TDate] -> Add_dat_dur, `Reversed
|
||||
| Add, [TDate; TDuration] -> Add_dat_dur AbortOnRound, `Straight
|
||||
| Add, [TDuration; TDate] -> Add_dat_dur AbortOnRound, `Reversed
|
||||
| Sub, [TInt; TInt] -> Sub_int_int, `Straight
|
||||
| Sub, [TRat; TRat] -> Sub_rat_rat, `Straight
|
||||
| Sub, [TMoney; TMoney] -> Sub_mon_mon, `Straight
|
||||
|
@ -51,6 +51,7 @@ val kind_dispatch :
|
||||
(** Calls one of the supplied functions depending on the kind of the operator *)
|
||||
|
||||
val translate :
|
||||
date_rounding option ->
|
||||
([< scopelang | dcalc | lcalc ], 'k) t ->
|
||||
([< scopelang | dcalc | lcalc ], 'k) t
|
||||
(** An identity function that allows translating an operator between different
|
||||
|
@ -188,7 +188,9 @@ let operator_to_string : type a k. (a, k) Op.t -> string = function
|
||||
| Add_int_int -> "+!"
|
||||
| Add_rat_rat -> "+."
|
||||
| Add_mon_mon -> "+$"
|
||||
| Add_dat_dur -> "+@"
|
||||
| Add_dat_dur AbortOnRound -> "+@"
|
||||
| Add_dat_dur RoundUp -> "+@u"
|
||||
| Add_dat_dur RoundDown -> "+@d"
|
||||
| Add_dur_dur -> "+^"
|
||||
| Sub -> "-"
|
||||
| Sub_int_int -> "-!"
|
||||
|
@ -586,6 +586,7 @@ type scope_use_item =
|
||||
| Definition of definition
|
||||
| Assertion of assertion
|
||||
| MetaAssertion of meta_assertion
|
||||
| DateRounding of variation_typ Marked.pos
|
||||
[@@deriving
|
||||
visitors
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -496,6 +496,17 @@ let scope_item :=
|
||||
Definition d, Marked.get_mark (Shared_ast.RuleName.get_info d.definition_id)
|
||||
}
|
||||
| ASSERTION ; contents = addpos(assertion) ; <>
|
||||
| DATE ; i = LIDENT ; v = addpos(variation_type) ;
|
||||
{
|
||||
(* Round is a builtin, we need to check which one it is *)
|
||||
match Localisation.lex_builtin i with
|
||||
| Some Round ->
|
||||
DateRounding(v), Marked.get_mark v
|
||||
| _ ->
|
||||
Errors.raise_spanned_error
|
||||
(Pos.from_lpos $loc(i))
|
||||
"Expected the form 'date round increasing' or 'date round decreasing'"
|
||||
}
|
||||
|
||||
let struct_scope_base :=
|
||||
| DATA ; i = lident ;
|
||||
|
@ -124,7 +124,8 @@ let date_of_year (year : int) = Runtime.date_of_numbers year 1 1
|
||||
defined here as Jan 1, 1900 **)
|
||||
let nb_days_to_date (nb : int) : string =
|
||||
Runtime.date_to_string
|
||||
(Runtime.Oper.o_add_dat_dur base_day (Runtime.duration_of_numbers 0 0 nb))
|
||||
(Runtime.Oper.o_add_dat_dur AbortOnRound base_day
|
||||
(Runtime.duration_of_numbers 0 0 nb))
|
||||
|
||||
(** [print_z3model_expr] pretty-prints the value [e] given by a Z3 model
|
||||
according to the Catala type [ty], corresponding to [e] **)
|
||||
@ -541,7 +542,8 @@ let rec translate_op :
|
||||
| And, _ -> app Boolean.mk_and
|
||||
| Or, _ -> app Boolean.mk_or
|
||||
| Xor, _ -> app2 Boolean.mk_xor
|
||||
| (Add_int_int | Add_rat_rat | Add_mon_mon | Add_dat_dur | Add_dur_dur), _ ->
|
||||
| (Add_int_int | Add_rat_rat | Add_mon_mon | Add_dat_dur _ | Add_dur_dur), _
|
||||
->
|
||||
app Arithmetic.mk_add
|
||||
| ( ( Sub_int_int | Sub_rat_rat | Sub_mon_mon | Sub_dat_dat | Sub_dat_dur
|
||||
| Sub_dur_dur ),
|
||||
|
Binary file not shown.
@ -483,6 +483,14 @@
|
||||
\end{catala}
|
||||
& State transitions declaration
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
date round increasing
|
||||
# or decreasing
|
||||
```
|
||||
\end{catala}
|
||||
& Define date rounding mode
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
declaration const content decimal
|
||||
|
@ -469,7 +469,6 @@
|
||||
entrée var4 contenu ...
|
||||
entrée résultat var5 contenu ...
|
||||
contexte var6 contenu ...
|
||||
contexte résultat var7 contenu ...
|
||||
```
|
||||
\end{catala}
|
||||
& Qualificateurs d'entrée-sortie
|
||||
@ -483,6 +482,14 @@
|
||||
\end{catala}
|
||||
& Transitions d'état
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
date arrondi croissant
|
||||
# ou décroissant
|
||||
```
|
||||
\end{catala}
|
||||
& Mode arrondi dates
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
déclaration const contenu décimal
|
||||
|
@ -221,8 +221,11 @@ exception cas_base_l822_4 règle condition_logement_location_tiers
|
||||
selon ménage.logement.loué_ou_sous_loué_à_des_tiers sous forme
|
||||
-- LouéOuSousLouéÀDesTiers.Non: vrai
|
||||
-- LouéOuSousLouéÀDesTiers.Oui de personne:
|
||||
personne.date_naissance_personne_sous_location + 30 an >
|
||||
date_courante ou
|
||||
(résultat de VérificationÂgeSupérieurÀ avec
|
||||
{ -- date_naissance: personne.date_naissance_personne_sous_location
|
||||
-- date_courante: date_courante
|
||||
-- années: 30 an }).est_supérieur
|
||||
ou
|
||||
personne.conforme_article_l442_1
|
||||
conséquence rempli
|
||||
```
|
||||
@ -983,6 +986,7 @@ champ d'application ÉligibilitéAllocationLogement:
|
||||
= 0
|
||||
et
|
||||
(selon ménage.situation_familiale sous forme
|
||||
# VERIF: opération ambiguë
|
||||
-- Mariés de date_mariage : date_courante <= date_mariage + durée_l841_1_3
|
||||
-- n'importe quel: faux)
|
||||
conséquence rempli
|
||||
|
@ -1203,12 +1203,17 @@ champ d'application ÉligibilitéAidesPersonnelleLogement:
|
||||
parent.ressources <=
|
||||
plafond_individuel_l815_9_sécu * 1,25 et
|
||||
(
|
||||
# VERIF: parent.date_naissance + âge_l351_8_1_sécu est ambiguë, à détecter
|
||||
(parent.date_naissance +
|
||||
âge_l351_8_1_sécu <= date_courante ou
|
||||
(parent.titulaire_allocation_personne_âgée et
|
||||
parent.date_naissance + 65 an <=
|
||||
date_courante)
|
||||
(résultat de VérificationÂgeInférieurOuÉgalÀ avec
|
||||
{ -- date_naissance: parent.date_naissance
|
||||
-- date_courante: date_courante
|
||||
-- années: 65 an }).est_inférieur_ou_égal
|
||||
)
|
||||
) ou
|
||||
# VERIF: parent.date_naissance + âge_l161_17_2_sécu est ambiguë, à détecter
|
||||
(parent.date_naissance +
|
||||
âge_l161_17_2_sécu <= date_courante et
|
||||
parent.bénéficiaire_l161_19_l351_8_l643_3_sécu)
|
||||
@ -2064,6 +2069,7 @@ champ d'application ÉligibilitéPrimeDeDéménagement:
|
||||
-- AvantPremierJourMoisCivilTroisièmeMoisDeGrossesse: faux
|
||||
-- AprèsPremierJourMoisCivilTroisièmeMoisDeGrossesse: vrai
|
||||
-- DateDeNaissance de date_naissance:
|
||||
# VERIF: ambigü
|
||||
date_courante <=
|
||||
((premier_jour_du_mois de (date_naissance + 2 an))) + (-1 jour))
|
||||
)
|
||||
|
@ -66,7 +66,10 @@ champ d'application ÉligibilitéPrestationsFamiliales :
|
||||
étiquette cas_base règle droit_ouvert de enfant sous condition
|
||||
enfant.obligation_scolaire sous forme Après et
|
||||
(enfant.rémuneration_mensuelle <= plafond_l512_3_2) et
|
||||
(enfant.date_de_naissance + âge_l512_3_2 > date_courante)
|
||||
(résultat de VérificationÂgeSupérieurÀ avec
|
||||
{ -- date_naissance: enfant.date_de_naissance
|
||||
-- date_courante: date_courante
|
||||
-- années: âge_l512_3_2 }).est_supérieur
|
||||
conséquence rempli
|
||||
|
||||
# On définit les conditions hors âge d'abord car elles
|
||||
|
@ -14,4 +14,24 @@ déclaration énumération Collectivité :
|
||||
-- Métropole
|
||||
-- SaintPierreEtMiquelon
|
||||
-- Mayotte
|
||||
|
||||
déclaration champ d'application VérificationÂgeInférieurOuÉgalÀ:
|
||||
entrée date_naissance contenu date
|
||||
entrée date_courante contenu date
|
||||
entrée années contenu durée
|
||||
résultat est_inférieur_ou_égal contenu booléen
|
||||
|
||||
champ d'application VérificationÂgeInférieurOuÉgalÀ:
|
||||
définition est_inférieur_ou_égal égal à date_naissance + années <= date_courante
|
||||
date arrondi croissant
|
||||
|
||||
déclaration champ d'application VérificationÂgeSupérieurÀ:
|
||||
entrée date_naissance contenu date
|
||||
entrée date_courante contenu date
|
||||
entrée années contenu durée
|
||||
résultat est_supérieur contenu booléen
|
||||
|
||||
champ d'application VérificationÂgeSupérieurÀ:
|
||||
définition est_supérieur égal à date_naissance + années > date_courante
|
||||
date arrondi croissant
|
||||
```
|
||||
|
132695
french_law/js/french_law.js
generated
132695
french_law/js/french_law.js
generated
File diff suppressed because one or more lines are too long
7493
french_law/ocaml/law_source/aides_logement.ml
generated
7493
french_law/ocaml/law_source/aides_logement.ml
generated
File diff suppressed because it is too large
Load Diff
142
french_law/ocaml/law_source/aides_logement_api_web.ml
generated
142
french_law/ocaml/law_source/aides_logement_api_web.ml
generated
@ -2189,6 +2189,40 @@ class type base_mensuelle_allocations_familiales =
|
||||
base_mensuelle_allocations_familiales##.montant
|
||||
}
|
||||
|
||||
class type verification_age_inferieur_ou_egal_a =
|
||||
object method estInferieurOuEgal: bool Js.t Js.readonly_prop
|
||||
end
|
||||
let verification_age_inferieur_ou_egal_a_to_jsoo
|
||||
(verification_age_inferieur_ou_egal_a
|
||||
: VerificationAgeInferieurOuEgalA.t)
|
||||
: verification_age_inferieur_ou_egal_a Js.t =
|
||||
object%js
|
||||
val estInferieurOuEgal =
|
||||
Js.bool verification_age_inferieur_ou_egal_a.est_inferieur_ou_egal
|
||||
end
|
||||
let verification_age_inferieur_ou_egal_a_of_jsoo
|
||||
(verification_age_inferieur_ou_egal_a
|
||||
: verification_age_inferieur_ou_egal_a Js.t) :
|
||||
VerificationAgeInferieurOuEgalA.t =
|
||||
{
|
||||
est_inferieur_ou_egal =
|
||||
Js.to_bool verification_age_inferieur_ou_egal_a##.estInferieurOuEgal
|
||||
}
|
||||
|
||||
class type verification_age_superieur_a =
|
||||
object method estSuperieur: bool Js.t Js.readonly_prop
|
||||
end
|
||||
let verification_age_superieur_a_to_jsoo (verification_age_superieur_a
|
||||
: VerificationAgeSuperieurA.t) : verification_age_superieur_a Js.t =
|
||||
object%js
|
||||
val estSuperieur = Js.bool verification_age_superieur_a.est_superieur
|
||||
end
|
||||
let verification_age_superieur_a_of_jsoo
|
||||
(verification_age_superieur_a : verification_age_superieur_a Js.t) :
|
||||
VerificationAgeSuperieurA.t =
|
||||
{est_superieur = Js.to_bool verification_age_superieur_a##.estSuperieur
|
||||
}
|
||||
|
||||
class type smic =
|
||||
object method brutHoraire: Js.number Js.t Js.readonly_prop
|
||||
end
|
||||
@ -2450,6 +2484,9 @@ class type logement_foyer =
|
||||
method redevance: Js.number Js.t Js.readonly_prop
|
||||
method categorieEquivalenceLoyerD84216:
|
||||
categorie_equivalence_loyer_allocation_logement_foyer Js.t Js.readonly_prop
|
||||
method beneficiaireAideAdulteOuEnfantHandicapes:
|
||||
bool Js.t Js.readonly_prop
|
||||
method logementMeubleD8422: bool Js.t Js.readonly_prop
|
||||
end
|
||||
let logement_foyer_to_jsoo (logement_foyer : LogementFoyer.t)
|
||||
: logement_foyer Js.t =
|
||||
@ -2469,6 +2506,9 @@ class type logement_foyer =
|
||||
Js.number_of_float @@ money_to_float logement_foyer.redevance
|
||||
val categorieEquivalenceLoyerD84216 =
|
||||
categorie_equivalence_loyer_allocation_logement_foyer_to_jsoo logement_foyer.categorie_equivalence_loyer_d842_16
|
||||
val beneficiaireAideAdulteOuEnfantHandicapes =
|
||||
Js.bool logement_foyer.beneficiaire_aide_adulte_ou_enfant_handicapes
|
||||
val logementMeubleD8422 = Js.bool logement_foyer.logement_meuble_d842_2
|
||||
end
|
||||
let logement_foyer_of_jsoo (logement_foyer : logement_foyer Js.t) :
|
||||
LogementFoyer.t =
|
||||
@ -2489,7 +2529,11 @@ class type logement_foyer =
|
||||
logement_foyer##.redevance;
|
||||
categorie_equivalence_loyer_d842_16 =
|
||||
categorie_equivalence_loyer_allocation_logement_foyer_of_jsoo
|
||||
logement_foyer##.categorieEquivalenceLoyerD84216
|
||||
logement_foyer##.categorieEquivalenceLoyerD84216;
|
||||
beneficiaire_aide_adulte_ou_enfant_handicapes =
|
||||
Js.to_bool logement_foyer##.beneficiaireAideAdulteOuEnfantHandicapes;
|
||||
logement_meuble_d842_2 =
|
||||
Js.to_bool logement_foyer##.logementMeubleD8422
|
||||
}
|
||||
|
||||
class type enfant_prestations_familiales =
|
||||
@ -3746,6 +3790,7 @@ class type calcul_nombre_part_logement_foyer_in =
|
||||
method nombrePersonnesAChargeIn: int Js.readonly_prop
|
||||
method situationFamilialeCalculAplIn:
|
||||
situation_familiale_calcul_a_p_l Js.t Js.readonly_prop
|
||||
method residenceIn: collectivite Js.t Js.readonly_prop
|
||||
method limitationMajorationPersonnesAChargeIn:
|
||||
(unit, unit -> bool Js.t) Js.meth_callback Js.meth
|
||||
end
|
||||
@ -3760,6 +3805,8 @@ class type calcul_nombre_part_logement_foyer_in =
|
||||
integer_to_int calcul_nombre_part_logement_foyer_in.nombre_personnes_a_charge_in
|
||||
val situationFamilialeCalculAplIn =
|
||||
situation_familiale_calcul_a_p_l_to_jsoo calcul_nombre_part_logement_foyer_in.situation_familiale_calcul_apl_in
|
||||
val residenceIn =
|
||||
collectivite_to_jsoo calcul_nombre_part_logement_foyer_in.residence_in
|
||||
method limitationMajorationPersonnesAChargeIn = Js.wrap_meth_callback
|
||||
(
|
||||
fun _ (function_input0: unit) ->
|
||||
@ -3781,6 +3828,9 @@ class type calcul_nombre_part_logement_foyer_in =
|
||||
situation_familiale_calcul_a_p_l_of_jsoo
|
||||
calcul_nombre_part_logement_foyer_in
|
||||
##.situationFamilialeCalculAplIn;
|
||||
residence_in =
|
||||
collectivite_of_jsoo
|
||||
calcul_nombre_part_logement_foyer_in##.residenceIn;
|
||||
limitation_majoration_personnes_a_charge_in = failwith "The function 'limitation_majoration_personnes_a_charge_in' translation isn't yet supported..."
|
||||
}
|
||||
|
||||
@ -3795,6 +3845,7 @@ class type calcul_aide_personnalisee_logement_foyer_in =
|
||||
method zoneIn: zone_d_habitation Js.t Js.readonly_prop
|
||||
method dateCouranteIn: Js.js_string Js.t Js.readonly_prop
|
||||
method redevanceIn: Js.number Js.t Js.readonly_prop
|
||||
method residenceIn: collectivite Js.t Js.readonly_prop
|
||||
method condition2Du83225In:
|
||||
(unit, unit -> bool Js.t) Js.meth_callback Js.meth
|
||||
method limitationMajorationPersonnesAChargeIn:
|
||||
@ -3823,6 +3874,8 @@ class type calcul_aide_personnalisee_logement_foyer_in =
|
||||
date_to_jsoo calcul_aide_personnalisee_logement_foyer_in.date_courante_in
|
||||
val redevanceIn =
|
||||
Js.number_of_float @@ money_to_float calcul_aide_personnalisee_logement_foyer_in.redevance_in
|
||||
val residenceIn =
|
||||
collectivite_to_jsoo calcul_aide_personnalisee_logement_foyer_in.residence_in
|
||||
method condition2Du83225In = Js.wrap_meth_callback
|
||||
(
|
||||
fun _ (function_input0: unit) ->
|
||||
@ -3875,6 +3928,9 @@ class type calcul_aide_personnalisee_logement_foyer_in =
|
||||
redevance_in =
|
||||
money_of_decimal @@ decimal_of_float @@ Js.float_of_number
|
||||
calcul_aide_personnalisee_logement_foyer_in##.redevanceIn;
|
||||
residence_in =
|
||||
collectivite_of_jsoo
|
||||
calcul_aide_personnalisee_logement_foyer_in##.residenceIn;
|
||||
condition_2_du_832_25_in = failwith "The function 'condition_2_du_832_25_in' translation isn't yet supported...";
|
||||
limitation_majoration_personnes_a_charge_in = failwith "The function 'limitation_majoration_personnes_a_charge_in' translation isn't yet supported...";
|
||||
n_nombre_parts_d832_25_in = failwith "The function 'n_nombre_parts_d832_25_in' translation isn't yet supported..."
|
||||
@ -4615,6 +4671,66 @@ class type base_mensuelle_allocations_familiales_in =
|
||||
base_mensuelle_allocations_familiales_in##.dateCouranteIn
|
||||
}
|
||||
|
||||
class type verification_age_inferieur_ou_egal_a_in =
|
||||
object
|
||||
method dateNaissanceIn: Js.js_string Js.t Js.readonly_prop
|
||||
method dateCouranteIn: Js.js_string Js.t Js.readonly_prop
|
||||
method anneesIn: Runtime_jsoo.Runtime.duration Js.t Js.readonly_prop
|
||||
end
|
||||
let verification_age_inferieur_ou_egal_a_in_to_jsoo
|
||||
(verification_age_inferieur_ou_egal_a_in
|
||||
: VerificationAgeInferieurOuEgalAIn.t)
|
||||
: verification_age_inferieur_ou_egal_a_in Js.t =
|
||||
object%js
|
||||
val dateNaissanceIn =
|
||||
date_to_jsoo verification_age_inferieur_ou_egal_a_in.date_naissance_in
|
||||
val dateCouranteIn =
|
||||
date_to_jsoo verification_age_inferieur_ou_egal_a_in.date_courante_in
|
||||
val anneesIn =
|
||||
duration_to_jsoo verification_age_inferieur_ou_egal_a_in.annees_in
|
||||
end
|
||||
let verification_age_inferieur_ou_egal_a_in_of_jsoo
|
||||
(verification_age_inferieur_ou_egal_a_in
|
||||
: verification_age_inferieur_ou_egal_a_in Js.t) :
|
||||
VerificationAgeInferieurOuEgalAIn.t =
|
||||
{
|
||||
date_naissance_in =
|
||||
date_of_jsoo
|
||||
verification_age_inferieur_ou_egal_a_in##.dateNaissanceIn;
|
||||
date_courante_in =
|
||||
date_of_jsoo verification_age_inferieur_ou_egal_a_in##.dateCouranteIn;
|
||||
annees_in =
|
||||
duration_of_jsoo verification_age_inferieur_ou_egal_a_in##.anneesIn
|
||||
}
|
||||
|
||||
class type verification_age_superieur_a_in =
|
||||
object
|
||||
method dateNaissanceIn: Js.js_string Js.t Js.readonly_prop
|
||||
method dateCouranteIn: Js.js_string Js.t Js.readonly_prop
|
||||
method anneesIn: Runtime_jsoo.Runtime.duration Js.t Js.readonly_prop
|
||||
end
|
||||
let verification_age_superieur_a_in_to_jsoo
|
||||
(verification_age_superieur_a_in : VerificationAgeSuperieurAIn.t)
|
||||
: verification_age_superieur_a_in Js.t =
|
||||
object%js
|
||||
val dateNaissanceIn =
|
||||
date_to_jsoo verification_age_superieur_a_in.date_naissance_in
|
||||
val dateCouranteIn =
|
||||
date_to_jsoo verification_age_superieur_a_in.date_courante_in
|
||||
val anneesIn =
|
||||
duration_to_jsoo verification_age_superieur_a_in.annees_in
|
||||
end
|
||||
let verification_age_superieur_a_in_of_jsoo
|
||||
(verification_age_superieur_a_in : verification_age_superieur_a_in Js.t) :
|
||||
VerificationAgeSuperieurAIn.t =
|
||||
{
|
||||
date_naissance_in =
|
||||
date_of_jsoo verification_age_superieur_a_in##.dateNaissanceIn;
|
||||
date_courante_in =
|
||||
date_of_jsoo verification_age_superieur_a_in##.dateCouranteIn;
|
||||
annees_in = duration_of_jsoo verification_age_superieur_a_in##.anneesIn
|
||||
}
|
||||
|
||||
class type smic_in =
|
||||
object
|
||||
method dateCouranteIn: Js.js_string Js.t Js.readonly_prop
|
||||
@ -4740,6 +4856,24 @@ let base_mensuelle_allocations_familiales
|
||||
|> base_mensuelle_allocations_familiales_to_jsoo
|
||||
|
||||
|
||||
let verification_age_inferieur_ou_egal_a
|
||||
(verification_age_inferieur_ou_egal_a_in : verification_age_inferieur_ou_egal_a_in Js.t)
|
||||
: verification_age_inferieur_ou_egal_a Js.t =
|
||||
verification_age_inferieur_ou_egal_a_in
|
||||
|> verification_age_inferieur_ou_egal_a_in_of_jsoo
|
||||
|> verification_age_inferieur_ou_egal_a
|
||||
|> verification_age_inferieur_ou_egal_a_to_jsoo
|
||||
|
||||
|
||||
let verification_age_superieur_a
|
||||
(verification_age_superieur_a_in : verification_age_superieur_a_in Js.t)
|
||||
: verification_age_superieur_a Js.t =
|
||||
verification_age_superieur_a_in
|
||||
|> verification_age_superieur_a_in_of_jsoo
|
||||
|> verification_age_superieur_a
|
||||
|> verification_age_superieur_a_to_jsoo
|
||||
|
||||
|
||||
let smic (smic_in : smic_in Js.t)
|
||||
: smic Js.t =
|
||||
smic_in |> smic_in_of_jsoo |> smic |> smic_to_jsoo
|
||||
@ -4914,6 +5048,12 @@ let _ =
|
||||
method baseMensuelleAllocationsFamiliales : (base_mensuelle_allocations_familiales_in Js.t -> base_mensuelle_allocations_familiales Js.t) Js.callback =
|
||||
Js.wrap_callback base_mensuelle_allocations_familiales
|
||||
|
||||
method verificationAgeInferieurOuEgalA : (verification_age_inferieur_ou_egal_a_in Js.t -> verification_age_inferieur_ou_egal_a Js.t) Js.callback =
|
||||
Js.wrap_callback verification_age_inferieur_ou_egal_a
|
||||
|
||||
method verificationAgeSuperieurA : (verification_age_superieur_a_in Js.t -> verification_age_superieur_a Js.t) Js.callback =
|
||||
Js.wrap_callback verification_age_superieur_a
|
||||
|
||||
method smic : (smic_in Js.t -> smic Js.t) Js.callback =
|
||||
Js.wrap_callback smic
|
||||
|
||||
|
131
french_law/ocaml/law_source/allocations_familiales.ml
generated
131
french_law/ocaml/law_source/allocations_familiales.ml
generated
@ -144,6 +144,23 @@ let embed_allocations_familiales (x: AllocationsFamiliales.t) : runtime_value =
|
||||
[("montant_versé", embed_money x.AllocationsFamiliales.montant_verse)])
|
||||
|
||||
|
||||
module VerificationAgeInferieurOuEgalA = struct
|
||||
type t = {est_inferieur_ou_egal: bool}
|
||||
end
|
||||
let embed_verification_age_inferieur_ou_egal_a (x: VerificationAgeInferieurOuEgalA.t) : runtime_value =
|
||||
Struct(["VérificationÂgeInférieurOuÉgalÀ"],
|
||||
[("est_inférieur_ou_égal", embed_bool
|
||||
x.VerificationAgeInferieurOuEgalA.est_inferieur_ou_egal)])
|
||||
|
||||
|
||||
module VerificationAgeSuperieurA = struct
|
||||
type t = {est_superieur: bool}
|
||||
end
|
||||
let embed_verification_age_superieur_a (x: VerificationAgeSuperieurA.t) : runtime_value =
|
||||
Struct(["VérificationÂgeSupérieurÀ"],
|
||||
[("est_supérieur", embed_bool x.VerificationAgeSuperieurA.est_superieur)])
|
||||
|
||||
|
||||
module Smic = struct
|
||||
type t = {brut_horaire: money}
|
||||
end
|
||||
@ -310,6 +327,39 @@ let embed_allocations_familiales_in (x: AllocationsFamilialesIn.t) : runtime_val
|
||||
x.AllocationsFamilialesIn.avait_enfant_a_charge_avant_1er_janvier_2012_in)])
|
||||
|
||||
|
||||
module VerificationAgeInferieurOuEgalAIn = struct
|
||||
type t = {
|
||||
date_naissance_in: date;
|
||||
date_courante_in: date;
|
||||
annees_in: duration
|
||||
}
|
||||
end
|
||||
let embed_verification_age_inferieur_ou_egal_a_in (x: VerificationAgeInferieurOuEgalAIn.t) : runtime_value =
|
||||
Struct(["VérificationÂgeInférieurOuÉgalÀ_in"],
|
||||
[("date_naissance_in", embed_date
|
||||
x.VerificationAgeInferieurOuEgalAIn.date_naissance_in);
|
||||
("date_courante_in", embed_date
|
||||
x.VerificationAgeInferieurOuEgalAIn.date_courante_in);
|
||||
("années_in", embed_duration
|
||||
x.VerificationAgeInferieurOuEgalAIn.annees_in)])
|
||||
|
||||
|
||||
module VerificationAgeSuperieurAIn = struct
|
||||
type t = {
|
||||
date_naissance_in: date;
|
||||
date_courante_in: date;
|
||||
annees_in: duration
|
||||
}
|
||||
end
|
||||
let embed_verification_age_superieur_a_in (x: VerificationAgeSuperieurAIn.t) : runtime_value =
|
||||
Struct(["VérificationÂgeSupérieurÀ_in"],
|
||||
[("date_naissance_in", embed_date
|
||||
x.VerificationAgeSuperieurAIn.date_naissance_in);
|
||||
("date_courante_in", embed_date
|
||||
x.VerificationAgeSuperieurAIn.date_courante_in);
|
||||
("années_in", embed_duration x.VerificationAgeSuperieurAIn.annees_in)])
|
||||
|
||||
|
||||
module SmicIn = struct
|
||||
type t = {date_courante_in: date; residence_in: Collectivite.t}
|
||||
end
|
||||
@ -437,6 +487,66 @@ let enfant_le_plus_age (enfant_le_plus_age_in: EnfantLePlusAgeIn.t) : EnfantLePl
|
||||
"Prologue"]})))) in
|
||||
{EnfantLePlusAge.le_plus_age = le_plus_age_}
|
||||
|
||||
let verification_age_inferieur_ou_egal_a (verification_age_inferieur_ou_egal_a_in: VerificationAgeInferieurOuEgalAIn.t) : VerificationAgeInferieurOuEgalA.t =
|
||||
let date_naissance_: date = verification_age_inferieur_ou_egal_a_in.VerificationAgeInferieurOuEgalAIn.date_naissance_in in
|
||||
let date_courante_: date = verification_age_inferieur_ou_egal_a_in.VerificationAgeInferieurOuEgalAIn.date_courante_in in
|
||||
let annees_: duration = verification_age_inferieur_ou_egal_a_in.VerificationAgeInferieurOuEgalAIn.annees_in in
|
||||
let est_inferieur_ou_egal_: bool = (log_variable_definition
|
||||
["VérificationÂgeInférieurOuÉgalÀ"; "est_inférieur_ou_égal"]
|
||||
(embed_bool) (
|
||||
try
|
||||
(handle_default
|
||||
{filename = "examples/allocations_familiales/../smic/../prologue_france/prologue.catala_fr";
|
||||
start_line=22; start_column=12; end_line=22; end_column=33;
|
||||
law_headings=["Prologue";
|
||||
"Montant du salaire minimum de croissance"]} (
|
||||
[||])
|
||||
(fun (_: unit) -> (log_decision_taken
|
||||
{filename = "examples/allocations_familiales/../smic/../prologue_france/prologue.catala_fr";
|
||||
start_line=25; start_column=14; end_line=25; end_column=35;
|
||||
law_headings=["Prologue";
|
||||
"Montant du salaire minimum de croissance"]}
|
||||
true))
|
||||
(fun (_: unit) ->
|
||||
o_lte_dat_dat (o_add_dat_dur RoundUp date_naissance_ annees_)
|
||||
date_courante_))
|
||||
with
|
||||
EmptyError -> (raise (NoValueProvided
|
||||
{filename = "examples/allocations_familiales/../smic/../prologue_france/prologue.catala_fr";
|
||||
start_line=22; start_column=12; end_line=22; end_column=33;
|
||||
law_headings=["Prologue"; "Montant du salaire minimum de croissance"]})))) in
|
||||
{VerificationAgeInferieurOuEgalA.est_inferieur_ou_egal =
|
||||
est_inferieur_ou_egal_}
|
||||
|
||||
let verification_age_superieur_a (verification_age_superieur_a_in: VerificationAgeSuperieurAIn.t) : VerificationAgeSuperieurA.t =
|
||||
let date_naissance_: date = verification_age_superieur_a_in.VerificationAgeSuperieurAIn.date_naissance_in in
|
||||
let date_courante_: date = verification_age_superieur_a_in.VerificationAgeSuperieurAIn.date_courante_in in
|
||||
let annees_: duration = verification_age_superieur_a_in.VerificationAgeSuperieurAIn.annees_in in
|
||||
let est_superieur_: bool = (log_variable_definition
|
||||
["VérificationÂgeSupérieurÀ"; "est_supérieur"] (embed_bool) (
|
||||
try
|
||||
(handle_default
|
||||
{filename = "examples/allocations_familiales/../smic/../prologue_france/prologue.catala_fr";
|
||||
start_line=32; start_column=12; end_line=32; end_column=25;
|
||||
law_headings=["Prologue";
|
||||
"Montant du salaire minimum de croissance"]} (
|
||||
[||])
|
||||
(fun (_: unit) -> (log_decision_taken
|
||||
{filename = "examples/allocations_familiales/../smic/../prologue_france/prologue.catala_fr";
|
||||
start_line=35; start_column=14; end_line=35; end_column=27;
|
||||
law_headings=["Prologue";
|
||||
"Montant du salaire minimum de croissance"]}
|
||||
true))
|
||||
(fun (_: unit) ->
|
||||
o_gt_dat_dat (o_add_dat_dur RoundUp date_naissance_ annees_)
|
||||
date_courante_))
|
||||
with
|
||||
EmptyError -> (raise (NoValueProvided
|
||||
{filename = "examples/allocations_familiales/../smic/../prologue_france/prologue.catala_fr";
|
||||
start_line=32; start_column=12; end_line=32; end_column=25;
|
||||
law_headings=["Prologue"; "Montant du salaire minimum de croissance"]})))) in
|
||||
{VerificationAgeSuperieurA.est_superieur = est_superieur_}
|
||||
|
||||
let smic (smic_in: SmicIn.t) : Smic.t =
|
||||
let date_courante_: date = smic_in.SmicIn.date_courante_in in
|
||||
let residence_: Collectivite.t = smic_in.SmicIn.residence_in in
|
||||
@ -1377,7 +1487,7 @@ let prestations_familiales (prestations_familiales_in: PrestationsFamilialesIn.t
|
||||
(enfant_.Enfant.remuneration_mensuelle)
|
||||
plafond_l512_3_2_)
|
||||
(o_gt_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.Enfant.date_de_naissance)
|
||||
age_l512_3_2_)
|
||||
date_courante_)))))
|
||||
@ -2028,7 +2138,8 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
|
||||
"Partie réglementaire - Décrets en Conseil d'Etat";
|
||||
"Code de la sécurité sociale"]}
|
||||
(o_lte_dat_dat
|
||||
(o_add_dat_dur (enfant_.Enfant.date_de_naissance)
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.Enfant.date_de_naissance)
|
||||
(duration_of_numbers (11) (0) (0)))
|
||||
(date_of_numbers (2008) (4) (30)))))
|
||||
(fun (_: unit) ->
|
||||
@ -2523,7 +2634,7 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
|
||||
(o_and
|
||||
(o_lt_dur_dur
|
||||
(o_sub_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.Enfant.date_de_naissance)
|
||||
prestations_familiales_dot_age_l512_3_2_)
|
||||
date_courante_)
|
||||
@ -3624,7 +3735,7 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
|
||||
enfants_a_charge_droit_ouvert_prestation_familiale_)
|
||||
nombre_enfants_alinea_2_l521_3_)
|
||||
(o_lte_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.Enfant.date_de_naissance)
|
||||
((log_end_call
|
||||
["AllocationsFamiliales";
|
||||
@ -3669,7 +3780,7 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
|
||||
"est_enfant_le_plus_âgé"; "input0"]
|
||||
(embed_enfant) enfant_))))))))
|
||||
(o_lte_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.Enfant.date_de_naissance)
|
||||
((log_end_call
|
||||
["AllocationsFamiliales";
|
||||
@ -4864,12 +4975,12 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
|
||||
(integer_of_string "1"))
|
||||
(o_and
|
||||
(o_lte_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.Enfant.date_de_naissance)
|
||||
(duration_of_numbers (11) (0) (0)))
|
||||
date_courante_)
|
||||
(o_gt_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.Enfant.date_de_naissance)
|
||||
(duration_of_numbers (16) (0) (0)))
|
||||
date_courante_)))))))
|
||||
@ -4916,7 +5027,7 @@ let allocations_familiales (allocations_familiales_in: AllocationsFamilialesIn.t
|
||||
enfants_a_charge_droit_ouvert_prestation_familiale_)
|
||||
(integer_of_string "1"))
|
||||
(o_lte_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.Enfant.date_de_naissance)
|
||||
(duration_of_numbers (16) (0) (0)))
|
||||
date_courante_))))))
|
||||
@ -5359,14 +5470,14 @@ let interface_allocations_familiales (interface_allocations_familiales_in: Inter
|
||||
Enfant.obligation_scolaire =
|
||||
( if
|
||||
(o_gte_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.EnfantEntree.d_date_de_naissance)
|
||||
(duration_of_numbers (3) (0) (0)))
|
||||
i_date_courante_) then
|
||||
(SituationObligationScolaire.Avant ()) else
|
||||
( if
|
||||
(o_gte_dat_dat
|
||||
(o_add_dat_dur
|
||||
(o_add_dat_dur AbortOnRound
|
||||
(enfant_.EnfantEntree.d_date_de_naissance)
|
||||
(duration_of_numbers (16) (0) (0)))
|
||||
i_date_courante_) then
|
||||
|
@ -376,6 +376,40 @@ class type allocations_familiales =
|
||||
allocations_familiales##.montantVerse
|
||||
}
|
||||
|
||||
class type verification_age_inferieur_ou_egal_a =
|
||||
object method estInferieurOuEgal: bool Js.t Js.readonly_prop
|
||||
end
|
||||
let verification_age_inferieur_ou_egal_a_to_jsoo
|
||||
(verification_age_inferieur_ou_egal_a
|
||||
: VerificationAgeInferieurOuEgalA.t)
|
||||
: verification_age_inferieur_ou_egal_a Js.t =
|
||||
object%js
|
||||
val estInferieurOuEgal =
|
||||
Js.bool verification_age_inferieur_ou_egal_a.est_inferieur_ou_egal
|
||||
end
|
||||
let verification_age_inferieur_ou_egal_a_of_jsoo
|
||||
(verification_age_inferieur_ou_egal_a
|
||||
: verification_age_inferieur_ou_egal_a Js.t) :
|
||||
VerificationAgeInferieurOuEgalA.t =
|
||||
{
|
||||
est_inferieur_ou_egal =
|
||||
Js.to_bool verification_age_inferieur_ou_egal_a##.estInferieurOuEgal
|
||||
}
|
||||
|
||||
class type verification_age_superieur_a =
|
||||
object method estSuperieur: bool Js.t Js.readonly_prop
|
||||
end
|
||||
let verification_age_superieur_a_to_jsoo (verification_age_superieur_a
|
||||
: VerificationAgeSuperieurA.t) : verification_age_superieur_a Js.t =
|
||||
object%js
|
||||
val estSuperieur = Js.bool verification_age_superieur_a.est_superieur
|
||||
end
|
||||
let verification_age_superieur_a_of_jsoo
|
||||
(verification_age_superieur_a : verification_age_superieur_a Js.t) :
|
||||
VerificationAgeSuperieurA.t =
|
||||
{est_superieur = Js.to_bool verification_age_superieur_a##.estSuperieur
|
||||
}
|
||||
|
||||
class type smic =
|
||||
object method brutHoraire: Js.number Js.t Js.readonly_prop
|
||||
end
|
||||
@ -677,6 +711,66 @@ class type allocations_familiales_in =
|
||||
allocations_familiales_in##.avaitEnfantAChargeAvant1erJanvier2012In
|
||||
}
|
||||
|
||||
class type verification_age_inferieur_ou_egal_a_in =
|
||||
object
|
||||
method dateNaissanceIn: Js.js_string Js.t Js.readonly_prop
|
||||
method dateCouranteIn: Js.js_string Js.t Js.readonly_prop
|
||||
method anneesIn: Runtime_jsoo.Runtime.duration Js.t Js.readonly_prop
|
||||
end
|
||||
let verification_age_inferieur_ou_egal_a_in_to_jsoo
|
||||
(verification_age_inferieur_ou_egal_a_in
|
||||
: VerificationAgeInferieurOuEgalAIn.t)
|
||||
: verification_age_inferieur_ou_egal_a_in Js.t =
|
||||
object%js
|
||||
val dateNaissanceIn =
|
||||
date_to_jsoo verification_age_inferieur_ou_egal_a_in.date_naissance_in
|
||||
val dateCouranteIn =
|
||||
date_to_jsoo verification_age_inferieur_ou_egal_a_in.date_courante_in
|
||||
val anneesIn =
|
||||
duration_to_jsoo verification_age_inferieur_ou_egal_a_in.annees_in
|
||||
end
|
||||
let verification_age_inferieur_ou_egal_a_in_of_jsoo
|
||||
(verification_age_inferieur_ou_egal_a_in
|
||||
: verification_age_inferieur_ou_egal_a_in Js.t) :
|
||||
VerificationAgeInferieurOuEgalAIn.t =
|
||||
{
|
||||
date_naissance_in =
|
||||
date_of_jsoo
|
||||
verification_age_inferieur_ou_egal_a_in##.dateNaissanceIn;
|
||||
date_courante_in =
|
||||
date_of_jsoo verification_age_inferieur_ou_egal_a_in##.dateCouranteIn;
|
||||
annees_in =
|
||||
duration_of_jsoo verification_age_inferieur_ou_egal_a_in##.anneesIn
|
||||
}
|
||||
|
||||
class type verification_age_superieur_a_in =
|
||||
object
|
||||
method dateNaissanceIn: Js.js_string Js.t Js.readonly_prop
|
||||
method dateCouranteIn: Js.js_string Js.t Js.readonly_prop
|
||||
method anneesIn: Runtime_jsoo.Runtime.duration Js.t Js.readonly_prop
|
||||
end
|
||||
let verification_age_superieur_a_in_to_jsoo
|
||||
(verification_age_superieur_a_in : VerificationAgeSuperieurAIn.t)
|
||||
: verification_age_superieur_a_in Js.t =
|
||||
object%js
|
||||
val dateNaissanceIn =
|
||||
date_to_jsoo verification_age_superieur_a_in.date_naissance_in
|
||||
val dateCouranteIn =
|
||||
date_to_jsoo verification_age_superieur_a_in.date_courante_in
|
||||
val anneesIn =
|
||||
duration_to_jsoo verification_age_superieur_a_in.annees_in
|
||||
end
|
||||
let verification_age_superieur_a_in_of_jsoo
|
||||
(verification_age_superieur_a_in : verification_age_superieur_a_in Js.t) :
|
||||
VerificationAgeSuperieurAIn.t =
|
||||
{
|
||||
date_naissance_in =
|
||||
date_of_jsoo verification_age_superieur_a_in##.dateNaissanceIn;
|
||||
date_courante_in =
|
||||
date_of_jsoo verification_age_superieur_a_in##.dateCouranteIn;
|
||||
annees_in = duration_of_jsoo verification_age_superieur_a_in##.anneesIn
|
||||
}
|
||||
|
||||
class type smic_in =
|
||||
object
|
||||
method dateCouranteIn: Js.js_string Js.t Js.readonly_prop
|
||||
@ -797,6 +891,24 @@ let enfant_le_plus_age (enfant_le_plus_age_in : enfant_le_plus_age_in Js.t)
|
||||
|> enfant_le_plus_age_to_jsoo
|
||||
|
||||
|
||||
let verification_age_inferieur_ou_egal_a
|
||||
(verification_age_inferieur_ou_egal_a_in : verification_age_inferieur_ou_egal_a_in Js.t)
|
||||
: verification_age_inferieur_ou_egal_a Js.t =
|
||||
verification_age_inferieur_ou_egal_a_in
|
||||
|> verification_age_inferieur_ou_egal_a_in_of_jsoo
|
||||
|> verification_age_inferieur_ou_egal_a
|
||||
|> verification_age_inferieur_ou_egal_a_to_jsoo
|
||||
|
||||
|
||||
let verification_age_superieur_a
|
||||
(verification_age_superieur_a_in : verification_age_superieur_a_in Js.t)
|
||||
: verification_age_superieur_a Js.t =
|
||||
verification_age_superieur_a_in
|
||||
|> verification_age_superieur_a_in_of_jsoo
|
||||
|> verification_age_superieur_a
|
||||
|> verification_age_superieur_a_to_jsoo
|
||||
|
||||
|
||||
let smic (smic_in : smic_in Js.t)
|
||||
: smic Js.t =
|
||||
smic_in |> smic_in_of_jsoo |> smic |> smic_to_jsoo
|
||||
@ -848,6 +960,12 @@ let _ =
|
||||
method enfantLePlusAge : (enfant_le_plus_age_in Js.t -> enfant_le_plus_age Js.t) Js.callback =
|
||||
Js.wrap_callback enfant_le_plus_age
|
||||
|
||||
method verificationAgeInferieurOuEgalA : (verification_age_inferieur_ou_egal_a_in Js.t -> verification_age_inferieur_ou_egal_a Js.t) Js.callback =
|
||||
Js.wrap_callback verification_age_inferieur_ou_egal_a
|
||||
|
||||
method verificationAgeSuperieurA : (verification_age_superieur_a_in Js.t -> verification_age_superieur_a Js.t) Js.callback =
|
||||
Js.wrap_callback verification_age_superieur_a
|
||||
|
||||
method smic : (smic_in Js.t -> smic Js.t) Js.callback =
|
||||
Js.wrap_callback smic
|
||||
|
||||
|
@ -19,6 +19,7 @@ type money = Z.t
|
||||
type integer = Z.t
|
||||
type decimal = Q.t
|
||||
type date = Dates_calc.Dates.date
|
||||
type date_rounding = Dates_calc.Dates.date_rounding
|
||||
type duration = Dates_calc.Dates.period
|
||||
type 'a eoption = ENone of unit | ESome of 'a
|
||||
|
||||
@ -637,7 +638,7 @@ module Oper = struct
|
||||
let o_add_int_int i1 i2 = Z.add i1 i2
|
||||
let o_add_rat_rat i1 i2 = Q.add i1 i2
|
||||
let o_add_mon_mon m1 m2 = Z.add m1 m2
|
||||
let o_add_dat_dur da du = Dates_calc.Dates.add_dates da du
|
||||
let o_add_dat_dur r da du = Dates_calc.Dates.add_dates ~round:r da du
|
||||
let o_add_dur_dur = Dates_calc.Dates.add_periods
|
||||
let o_sub_int_int i1 i2 = Z.sub i1 i2
|
||||
let o_sub_rat_rat i1 i2 = Q.sub i1 i2
|
||||
|
@ -23,6 +23,7 @@ type money
|
||||
type integer
|
||||
type decimal
|
||||
type date
|
||||
type date_rounding = Dates_calc.Dates.date_rounding
|
||||
type duration
|
||||
|
||||
type source_position = {
|
||||
@ -314,7 +315,7 @@ module Oper : sig
|
||||
val o_add_int_int : integer -> integer -> integer
|
||||
val o_add_rat_rat : decimal -> decimal -> decimal
|
||||
val o_add_mon_mon : money -> money -> money
|
||||
val o_add_dat_dur : date -> duration -> date
|
||||
val o_add_dat_dur : date_rounding -> date -> duration -> date
|
||||
val o_add_dur_dur : duration -> duration -> duration
|
||||
val o_sub_int_int : integer -> integer -> integer
|
||||
val o_sub_rat_rat : decimal -> decimal -> decimal
|
||||
|
19
tests/test_date/bad/rounding_option.catala_en
Normal file
19
tests/test_date/bad/rounding_option.catala_en
Normal file
@ -0,0 +1,19 @@
|
||||
```catala
|
||||
declaration scope Test:
|
||||
context bday content date
|
||||
context today content date
|
||||
context ambiguous content boolean
|
||||
|
||||
scope Test:
|
||||
definition bday equals |2000-02-29|
|
||||
definition today equals |2018-03-01|
|
||||
definition ambiguous equals bday + 18 year <= today
|
||||
```
|
||||
|
||||
```catala-test-inline
|
||||
$ catala Interpret -s Test
|
||||
catala: internal error, uncaught exception:
|
||||
Dates_calc.Dates.AmbiguousComputation
|
||||
|
||||
#return code 125#
|
||||
```
|
19
tests/test_date/bad/rounding_option.catala_fr
Normal file
19
tests/test_date/bad/rounding_option.catala_fr
Normal file
@ -0,0 +1,19 @@
|
||||
```catala
|
||||
déclaration champ d'application Test:
|
||||
contexte bday contenu date
|
||||
contexte today contenu date
|
||||
contexte ambiguité contenu booléen
|
||||
|
||||
champ d'application Test:
|
||||
définition bday égal à |2000-02-29|
|
||||
définition today égal à |2018-03-01|
|
||||
définition ambiguité égal à bday + 18 an <= today
|
||||
```
|
||||
|
||||
```catala-test-inline
|
||||
$ catala Interpret -s Test
|
||||
catala: internal error, uncaught exception:
|
||||
Dates_calc.Dates.AmbiguousComputation
|
||||
|
||||
#return code 125#
|
||||
```
|
42
tests/test_date/bad/rounding_option_conflict.catala_en
Normal file
42
tests/test_date/bad/rounding_option_conflict.catala_en
Normal file
@ -0,0 +1,42 @@
|
||||
```catala
|
||||
|
||||
declaration scope CheckAgeIsLessThan:
|
||||
input bday content date
|
||||
input today content date
|
||||
input age content duration
|
||||
output r content boolean
|
||||
|
||||
scope CheckAgeIsLessThan:
|
||||
date round decreasing
|
||||
definition r equals bday + age <= today
|
||||
date round increasing
|
||||
|
||||
declaration scope Test:
|
||||
output r content boolean
|
||||
|
||||
scope Test:
|
||||
definition r equals (output of CheckAgeIsLessThan with
|
||||
{ -- bday: |2000-02-29|
|
||||
-- today: |2018-03-01|
|
||||
-- age: 18 year}).r
|
||||
assertion r
|
||||
|
||||
```
|
||||
|
||||
```catala-test-inline
|
||||
$ catala Interpret -s Test
|
||||
[ERROR] You cannot set multiple date rounding modes
|
||||
|
||||
┌─⯈ tests/test_date/bad/rounding_option_conflict.catala_en:10.13-23:
|
||||
└──┐
|
||||
10 │ date round decreasing
|
||||
│ ‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
|
||||
┌─⯈ tests/test_date/bad/rounding_option_conflict.catala_en:12.13-23:
|
||||
└──┐
|
||||
12 │ date round increasing
|
||||
│ ‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
#return code 255#
|
||||
```
|
29
tests/test_date/good/rounding_option.catala_en
Normal file
29
tests/test_date/good/rounding_option.catala_en
Normal file
@ -0,0 +1,29 @@
|
||||
```catala
|
||||
|
||||
declaration scope CheckAgeIsLessThan:
|
||||
input bday content date
|
||||
input today content date
|
||||
input age content duration
|
||||
output r content boolean
|
||||
|
||||
scope CheckAgeIsLessThan:
|
||||
definition r equals bday + age <= today
|
||||
date round increasing
|
||||
|
||||
declaration scope Test:
|
||||
output r content boolean
|
||||
|
||||
scope Test:
|
||||
definition r equals (output of CheckAgeIsLessThan with
|
||||
{ -- bday: |2000-02-29|
|
||||
-- today: |2018-03-01|
|
||||
-- age: 18 year}).r
|
||||
assertion r
|
||||
|
||||
```
|
||||
|
||||
```catala-test-inline
|
||||
$ catala Interpret -s Test
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] r = true
|
||||
```
|
29
tests/test_date/good/rounding_option.catala_fr
Normal file
29
tests/test_date/good/rounding_option.catala_fr
Normal file
@ -0,0 +1,29 @@
|
||||
```catala
|
||||
|
||||
déclaration champ d'application VérificationÂgeInférieurOuÉgalÀ:
|
||||
entrée date_naissance contenu date
|
||||
entrée date_courante contenu date
|
||||
entrée années contenu durée
|
||||
résultat r contenu booléen
|
||||
|
||||
champ d'application VérificationÂgeInférieurOuÉgalÀ:
|
||||
définition r égal à date_naissance + années <= date_courante
|
||||
date arrondi croissant
|
||||
|
||||
déclaration champ d'application Test:
|
||||
résultat r contenu booléen
|
||||
|
||||
champ d'application Test:
|
||||
définition r égal à (résultat de VérificationÂgeInférieurOuÉgalÀ avec
|
||||
{ -- date_naissance: |2000-02-29|
|
||||
-- date_courante: |2018-03-01|
|
||||
-- années: 18 an}).r
|
||||
assertion r
|
||||
|
||||
```
|
||||
|
||||
```catala-test-inline
|
||||
$ catala Interpret -s Test
|
||||
[RESULT] Computation successful! Results:
|
||||
[RESULT] r = true
|
||||
```
|
Loading…
Reference in New Issue
Block a user