def test_coefficient_proratisation_only_contract_periods_wide(): tax_benefit_system = FranceTaxBenefitSystem() scenario = tax_benefit_system.new_scenario() scenario.init_single_entity(period='2017', # wide: we simulate for the year parent1=dict(salaire_de_base={'2017-11':2300}, effectif_entreprise=1, code_postal_entreprise="75001", categorie_salarie=u'prive_non_cadre', contrat_de_travail_debut='2017-11-1', contrat_de_travail_fin='2017-12-01', allegement_fillon_mode_recouvrement=u'progressif')) simulation = scenario.new_simulation() assert_equal(simulation.calculate('coefficient_proratisation','2017-11'),1) assert_equal(simulation.calculate('coefficient_proratisation','2017-12'),0) assert_equal(simulation.calculate('coefficient_proratisation','2017-10'),0) assert_equal(simulation.calculate_add('coefficient_proratisation','2017'),1)
def test_coefficient_proratisation_only_contract_periods_wide(): tax_benefit_system = FranceTaxBenefitSystem() scenario = tax_benefit_system.new_scenario() init_single_entity(scenario, period='2017', # wide: we simulate for the year parent1=dict(salaire_de_base={'2017-11': 2300}, effectif_entreprise=1, code_postal_entreprise="75001", categorie_salarie=u'prive_non_cadre', contrat_de_travail_debut={2017: '2017-11-01'}, contrat_de_travail_fin={2017: '2017-12-01'}, allegement_fillon_mode_recouvrement=u'progressif')) simulation = scenario.new_simulation() assert simulation.calculate('coefficient_proratisation', '2017-11') == 1 assert simulation.calculate('coefficient_proratisation', '2017-12') == 0 assert simulation.calculate('coefficient_proratisation', '2017-10') == 0 assert simulation.calculate_add('coefficient_proratisation', '2017') == 1
def test_coefficient_proratisation_only_contract_periods_narrow(): tax_benefit_system = FranceTaxBenefitSystem() scenario = tax_benefit_system.new_scenario() init_single_entity( scenario, period='2017-11', # narrow: we simulate for the month parent1=dict(salaire_de_base={'2017-11': 2300}, effectif_entreprise=1, code_postal_entreprise="75001", categorie_salarie='prive_non_cadre', contrat_de_travail_debut={2017: '2017-11-01'}, contrat_de_travail_fin={2017: '2017-12-01'}, allegement_fillon_mode_recouvrement='progressif')) simulation = scenario.new_simulation() assert simulation.calculate('coefficient_proratisation', '2017-11') == 1 assert simulation.calculate('coefficient_proratisation', '2017-12') == 0 assert simulation.calculate('coefficient_proratisation', '2017-10') == 0 assert simulation.calculate_add('coefficient_proratisation', '2017') == 1
from openfisca_france import FranceTaxBenefitSystem tax_benefit_system = FranceTaxBenefitSystem() scenario = tax_benefit_system.new_scenario() scenario.init_single_entity( period = 2015, parent1 = dict( age = 30, salaire_de_base = 50000, ), enfants = [ dict(age = 12), dict(age = 18), ], ) simulation = scenario.new_simulation() #Some variable can only be computed on a monthly basis #simulation.calculate('af', '2015') print(simulation.calculate('af', '2015-01')) #calculate variable af for January 2015 simulation.calculate_add("af", "2015") #to sum on the whole year #Some variable can only be computed on a anual basis simulation.calculate('irpp', period = '2015') scenario.init_single_entity( period = 2019, parent1 = dict( age = 30, salaire_de_base = 70000, ), )
from copy import deepcopy import pprint from openfisca_france import FranceTaxBenefitSystem from tests.test_entities import TEST_CASE_AGES tbs = FranceTaxBenefitSystem() period = '2020' test_case = deepcopy(TEST_CASE_AGES) test_case['period'] = period # pprint.pprint(test_case) simulation = tbs.new_scenario().init_from_dict(test_case).new_simulation() print(simulation.calculate('revenu_disponible', period))
from openfisca_france import FranceTaxBenefitSystem import matplotlib.pylab as plt import numpy as np import pandas as pd #Create a df to store my alloc salaire_de_base = np.linspace(0, 100000, 100) print(salaire_de_base) # Create a new scenario from openfisca_france tax_benefit_system = FranceTaxBenefitSystem() scenario = tax_benefit_system.new_scenario() scenario.init_single_entity( # Axe declaration axes=[ dict( # in a dictionary count=100, # 'count' : indicates the number of step min=0, max=100000, name='salaire_de_base', # the variable you want to make evolve ), ], period=2014, parent1=dict(date_naissance='1980-01-01', )) simulation = scenario.new_simulation() #Add variable related to irpp income_tax = -simulation.calculate('irpp', 2014)
csg_ded_ap = reform_simulation.calculate("csg_deductible_salaire", "2018-01") crds_ap = reform_simulation.calculate("crds", "2018") net_ap = reform_simulation.calculate('revenu_net', '2018') ir_ap = reform_simulation.calculate('irpp', '2018') presta_ap = reform_simulation.calculate("prestations_sociales", "2018") famille_ap = reform_simulation.calculate("prestations_familiales", "2018") minima_ap = reform_simulation.calculate("minima_sociaux", "2018") al_ap = reform_simulation.calculate("aide_logement", "2018-12") ppa_ap = reform_simulation.calculate("ppa", "2018-12") rd_ap = reform_simulation.calculate('revenu_disponible', '2018') ################################### # Computation of th ecounterfactual ################################### #Indicate that you want to perfom the standard system on this scenario reference_scenario = init_profile(tax_benefit_system.new_scenario()) #Simulate the standard scenario reference_simulation = reference_scenario.new_simulation() # Variables in the counterfactual situation s_brut_av = reference_simulation.calculate("salaire_de_base", "2018-01") cot_soc_av = reference_simulation.calculate("cotisations_salariales", "2018-01") cot_cho_av = reference_simulation.calculate("chomage_salarie", "2018-01") csg_av = reference_simulation.calculate("csg", "2018") csg_ded_av = reference_simulation.calculate("csg_deductible_salaire", "2018-01") crds_av = reference_simulation.calculate("crds", "2018") net_av = reference_simulation.calculate('revenu_net', '2018') ir_av = reference_simulation.calculate('irpp', '2018')