Last active
December 13, 2022 09:04
-
-
Save clementbiron/9b3c8f6c563a1187f1a50f128fea8a77 to your computer and use it in GitHub Desktop.
OpenFisca run a simulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install OpenFisca-Country-Template | |
from pprint import pprint | |
from openfisca_core.simulation_builder import SimulationBuilder | |
from openfisca_country_template import CountryTaxBenefitSystem | |
tax_benefit_system = CountryTaxBenefitSystem() | |
entities = { | |
"persons": { | |
"_": { | |
"birth": { | |
"ETERNITY": "2000-01-01" | |
}, | |
"salary": { | |
"month:2022-01:12": 60000 | |
}, | |
} | |
}, | |
} | |
builder = SimulationBuilder() | |
simulation = builder.build_from_entities(tax_benefit_system, entities) | |
tax_nov = simulation.calculate("total_taxes", "2022-11").round(2) | |
tax_acc = simulation.calculate_add("total_taxes", "month:2022-01:11").round(2) | |
tax_tot = simulation.calculate_add("total_taxes", 2022).round(2) | |
pprint({"November Taxes": str(tax_nov), "Accumulated Taxes": str(tax_acc), "Total Expected Taxes in 2022": str(tax_tot)}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment