This commit is contained in:
Denis Merigoux 2023-11-22 15:02:40 +01:00
parent b25944a148
commit 67d1665afc
No known key found for this signature in database
GPG Key ID: EE99DCFA365C3EE3
2 changed files with 8 additions and 8 deletions

View File

@ -48,7 +48,7 @@ def get_simulation(bearer, payload_json):
response = requests.request("POST", url, headers=headers, data=payload) response = requests.request("POST", url, headers=headers, data=payload)
response_json = response.json() response_json = response.json()
print(response_json) # print(response_json)
if response_json['possedeDesDroits']: if response_json['possedeDesDroits']:
return int(response_json['montantDroit']) return int(response_json['montantDroit'])
else: else:
@ -149,8 +149,8 @@ def format_payload(input: CnafSimulatorInput):
household_members.extend(children) household_members.extend(children)
flgColocation = False flgColocation = False
if isinstance(logement, AppartementOuMaison): if isinstance(input.logement, AppartementOuMaison):
if logement.typ_v == AppartementOuMaisonType.Colocation: if input.logement.typ_v == AppartementOuMaisonType.Colocation:
flgColocation = True flgColocation = True
result = { result = {
"rattachementLogementList": [ "rattachementLogementList": [
@ -173,6 +173,6 @@ def format_payload(input: CnafSimulatorInput):
def run_simulator(input: CnafSimulatorInput) -> int: def run_simulator(input: CnafSimulatorInput) -> int:
payload = format_payload(input) payload = format_payload(input)
print(payload) # print(payload)
bearer = get_bearer() bearer = get_bearer()
return (get_simulation(bearer, payload)) return (get_simulation(bearer, payload))

View File

@ -5,17 +5,17 @@ from .cnaf_to_catala import run_catala_by_converting_cnaf_input
# input identical to the JS test of the housing benefits # input identical to the JS test of the housing benefits
sample_input = CnafSimulatorInput( sample_input = CnafSimulatorInput(
zone=Zone.Zone2, zone=Zone.Zone1,
logement=AppartementOuMaison( logement=AppartementOuMaison(
AppartementOuMaisonType.Location, meuble=False), AppartementOuMaisonType.Colocation, meuble=False),
loyer=450, loyer=1600,
seul_ou_couple=SeulOuCouple.EnCouple, seul_ou_couple=SeulOuCouple.EnCouple,
enfants=[Enfant(age=7, remuneration_derniere_annee=0), enfants=[Enfant(age=7, remuneration_derniere_annee=0),
Enfant(age=8, remuneration_derniere_annee=0)], Enfant(age=8, remuneration_derniere_annee=0)],
revenu_pris_en_compte=11_500 revenu_pris_en_compte=11_500
) )
# Or a random input # Or a random input
sample_input = generate_random_input() # sample_input = generate_random_input()
print("🏡 Description du ménage") print("🏡 Description du ménage")
print(sample_input) print(sample_input)
housing_benefits_catala = run_catala_by_converting_cnaf_input(sample_input) housing_benefits_catala = run_catala_by_converting_cnaf_input(sample_input)