{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "ename": "ImportError", "evalue": "cannot import name last_duration_last_value", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mopenfisca_france\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0minit_country\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mopenfisca_france\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbase\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[1;33m*\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;32m/home/openfisca/openfisca-france/openfisca_france/model/base.py\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 7\u001b[0m PeriodSizeIndependentIntCol, StrCol)\n\u001b[0;32m 8\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mopenfisca_core\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0menumerations\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mEnum\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 9\u001b[1;33m from openfisca_core.formulas import (calculate_output_add, calculate_output_add_divide, calculate_output_divide,\n\u001b[0m\u001b[0;32m 10\u001b[0m \u001b[0mdated_function\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mDatedVariable\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mEntityToPersonColumn\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlast_duration_last_value\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmissing_value\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mPersonToEntityColumn\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[0mrequested_period_added_value\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrequested_period_default_value\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrequested_period_last_value\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mImportError\u001b[0m: cannot import name last_duration_last_value" ] } ], "source": [ "from datetime import date\n", "\n", "from openfisca_france import init_country\n", "from openfisca_france.model.base import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adaptation pour faciliter l'usage de ce notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "_Ce correctif permet de redéfinir plusieurs fois la même variable sans provoquer d'erreur._" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import functools\n", "\n", "from openfisca_core.formulas import make_reference_formula_decorator\n", "from openfisca_france.entities import entity_class_by_symbol\n", "\n", "reference_formula = make_reference_formula_decorator(entity_class_by_symbol = entity_class_by_symbol, update = True)\n", "reference_input_variable = functools.partial(reference_input_variable, update = True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Système socio-fiscal" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "TaxBenefitSystem = init_country()\n", "tax_benefit_system = TaxBenefitSystem()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from openfisca_core import reforms" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ReformeRevenuDeBase = reforms.build_reform(\n", " name = u\"Réforme Revenu de base\",\n", " reference = tax_benefit_system,\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Réforme : 1. Revenu de base enfant" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from numpy import logical_not as not_, minimum as min_, maximum as max_\n", "\n", "@ReformeRevenuDeBase.formula\n", "class nbptr(SimpleFormulaColumn):\n", " reference = FoyersFiscaux.column_by_name['nbptr']\n", "\n", " # On enlève les enfants du calcul du nbptr (quotient_familial.enf*)\n", " \n", " def function(self, simulation, period):\n", " '''\n", " Nombre de parts du foyer\n", " 'foy'\n", " note 1 enfants et résidence alternée (formulaire 2041 GV page 10)\n", "\n", " quotient_familial.conj : nb part associées au conjoint d'un couple marié ou pacsé\n", " quotient_familial.enf1 : nb part 2 premiers enfants\n", " quotient_familial.enf2 : nb part enfants de rang 3 ou plus\n", " quotient_familial.inv1 : nb part supp enfants invalides (I, G)\n", " quotient_familial.inv2 : nb part supp adultes invalides (R)\n", " quotient_familial.not31 : nb part supp note 3 : cases W ou G pour veuf, celib ou div\n", " quotient_familial.not32 : nb part supp note 3 : personne seule ayant élevé des enfants\n", " quotient_familial.not41 : nb part supp adultes invalides (vous et/ou conjoint) note 4\n", " quotient_familial.not42 : nb part supp adultes anciens combattants (vous et/ou conjoint) note 4\n", " quotient_familial.not6 : nb part supp note 6\n", " quotient_familial.isol : demi-part parent isolé (T)\n", " quotient_familial.edcd : enfant issu du mariage avec conjoint décédé;\n", " '''\n", " period = period.start.offset('first-of', 'month').period('year')\n", " nb_pac = simulation.calculate('nb_pac', period)\n", " marpac = simulation.calculate('marpac', period)\n", " celdiv = simulation.calculate('celdiv', period)\n", " veuf = simulation.calculate('veuf', period)\n", " jveuf = simulation.calculate('jveuf', period)\n", " nbF = simulation.calculate('nbF', period)\n", " nbG = simulation.calculate('nbG', period)\n", " nbH = simulation.calculate('nbH', period)\n", " nbI = simulation.calculate('nbI', period)\n", " nbR = simulation.calculate('nbR', period)\n", " nbJ = simulation.calculate('nbJ', period)\n", " caseP = simulation.calculate('caseP', period)\n", " caseW = simulation.calculate('caseW', period)\n", " caseG = simulation.calculate('caseG', period)\n", " caseE = simulation.calculate('caseE', period)\n", " caseK = simulation.calculate('caseK', period)\n", " caseN = simulation.calculate('caseN', period)\n", " caseF = simulation.calculate('caseF', period)\n", " caseS = simulation.calculate('caseS', period)\n", " caseL = simulation.calculate('caseL', period)\n", " caseT = simulation.calculate('caseT', period)\n", " quotient_familial = simulation.legislation_at(period.start).ir.quotient_familial\n", "\n", " no_pac = nb_pac == 0 # Aucune personne à charge en garde exclusive\n", " has_pac = not_(no_pac)\n", " no_alt = nbH == 0 # Aucun enfant à charge en garde alternée\n", " has_alt = not_(no_alt)\n", "\n", " # # nombre de parts liées aux enfants à charge\n", " # que des enfants en résidence alternée\n", " enf1 = (no_pac & has_alt) * (quotient_familial.enf1 * min_(nbH, 2) * 0.5\n", " + quotient_familial.enf2 * max_(nbH - 2, 0) * 0.5)\n", " # pas que des enfants en résidence alternée\n", " enf2 = (has_pac & has_alt) * ((nb_pac == 1) * (quotient_familial.enf1 * min_(nbH, 1) * 0.5\n", " + quotient_familial.enf2 * max_(nbH - 1, 0) * 0.5) + (nb_pac > 1) * (quotient_familial.enf2 * nbH * 0.5))\n", " # pas d'enfant en résidence alternée\n", " enf3 = quotient_familial.enf1 * min_(nb_pac, 2) + quotient_familial.enf2 * max_((nb_pac - 2), 0)\n", "\n", " enf = enf1 + enf2 + enf3\n", " # # note 2 : nombre de parts liées aux invalides (enfant + adulte)\n", " n2 = quotient_familial.inv1 * (nbG + nbI / 2) + quotient_familial.inv2 * nbR\n", "\n", " # # note 3 : Pas de personne à charge\n", " # - invalide\n", "\n", " n31a = quotient_familial.not31a * (no_pac & no_alt & caseP)\n", " # - ancien combatant\n", " n31b = quotient_familial.not31b * (no_pac & no_alt & (caseW | caseG))\n", " n31 = max_(n31a, n31b)\n", " # - personne seule ayant élevé des enfants\n", " n32 = quotient_familial.not32 * (no_pac & no_alt & ((caseE | caseK) & not_(caseN)))\n", " n3 = max_(n31, n32)\n", " # # note 4 Invalidité de la personne ou du conjoint pour les mariés ou\n", " # # jeunes veuf(ve)s\n", " n4 = max_(quotient_familial.not41 * (1 * caseP + 1 * caseF), quotient_familial.not42 * (caseW | caseS))\n", "\n", " # # note 5\n", " # - enfant du conjoint décédé\n", " n51 = quotient_familial.cdcd * (caseL & ((nbF + nbJ) > 0))\n", " # - enfant autre et parent isolé\n", " n52 = quotient_familial.isol * caseT * (((no_pac & has_alt) * ((nbH == 1) * 0.5 + (nbH >= 2))) + 1 * has_pac)\n", " n5 = max_(n51, n52)\n", "\n", " # # note 6 invalide avec personne à charge\n", " n6 = quotient_familial.not6 * (caseP & (has_pac | has_alt))\n", "\n", " # # note 7 Parent isolé\n", " n7 = quotient_familial.isol * caseT * ((no_pac & has_alt) * ((nbH == 1) * 0.5 + (nbH >= 2)) + 1 * has_pac)\n", "\n", " # # Régime des mariés ou pacsés\n", " #m = 1 + quotient_familial.conj + enf + n2 + n4\n", " m = 1 + quotient_familial.conj + n2 + n4\n", " \n", " # # veufs hors jveuf\n", " # v = 1 + enf + n2 + n3 + n5 + n6\n", " v = 1 + n2 + n3 + n5 + n6\n", " \n", " # # celib div\n", " #c = 1 + enf + n2 + n3 + n6 + n7\n", " c = 1 + n2 + n3 + n6 + n7\n", "\n", " return period, (marpac | jveuf) * m + (veuf & not_(jveuf)) * v + celdiv * c\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "\n", "# Suppression des allocations familiales\n", "@ReformeRevenuDeBase.formula\n", "class af(SimpleFormulaColumn):\n", " reference = Familles.column_by_name['af']\n", "\n", " def function(self, simulation, period):\n", " period = period.start.offset('first-of', 'month').period('month')\n", " af_base = simulation.calculate('af_base', period)\n", " af_majo = simulation.calculate('af_majo', period)\n", " af_forf = simulation.calculate('af_forf', period)\n", "\n", " #return period, af_base + af_majo + af_forf\n", " return period, af_base * 0" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from numpy import round\n", "\n", "# Suppression du complément familial\n", "\n", "@ReformeRevenuDeBase.formula\n", "class cf(SimpleFormulaColumn):\n", " reference = Familles.column_by_name['cf']\n", "\n", " def function(self, simulation, period):\n", " '''\n", " L'allocation de base de la paje n'est pas cumulable avec le complément familial\n", " '''\n", " period = period.start.offset('first-of', 'month').period('year')\n", " paje_base_temp = simulation.calculate('paje_base_temp', period)\n", " apje_temp = simulation.calculate('apje_temp', period)\n", " ape_temp = simulation.calculate('ape_temp', period)\n", " cf_temp = simulation.calculate('cf_temp', period)\n", " residence_mayotte = simulation.calculate('residence_mayotte', period)\n", "\n", " cf_brut = (paje_base_temp < cf_temp) * (apje_temp <= cf_temp) * (ape_temp <= cf_temp) * cf_temp\n", " #return period, not_(residence_mayotte) * round(cf_brut, 2)\n", " return period, not_(residence_mayotte) * round(cf_brut, 2) * 0" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "\n", "# Suppression de l'allocation de rentrée scolaire\n", "\n", "@ReformeRevenuDeBase.formula\n", "class ars(SimpleFormulaColumn):\n", " reference = Familles.column_by_name['ars']\n", "\n", " def function(self, simulation, period):\n", " '''\n", " Allocation de rentrée scolaire brute de CRDS\n", " '''\n", " \n", " period = period.start.offset('first-of', 'month').period('year')\n", " age_holder = simulation.compute('age', period)\n", " af_nbenf = simulation.calculate('af_nbenf', period)\n", " smic55_holder = simulation.compute('smic55', period)\n", " br_pf = simulation.calculate('br_pf', period)\n", "\n", " return period, br_pf * 0" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "\n", "# Suppression du nombre d'enfants dans le calcul du RSA socle\n", "\n", "@ReformeRevenuDeBase.formula\n", "class rsa_socle(SimpleFormulaColumn):\n", " reference = Familles.column_by_name['rsa_socle']\n", "\n", " def function(self, simulation, period):\n", " period = period.start.offset('first-of', 'month').period('month')\n", " age_holder = simulation.compute('age', period)\n", " smic55_holder = simulation.compute('smic55', period)\n", " activite_holder = simulation.compute('activite', period)\n", " nb_par = simulation.calculate('nb_par', period)\n", " rmi = simulation.legislation_at(period.start).minim.rmi\n", "\n", " age_parents = self.split_by_roles(age_holder, roles = [CHEF, PART])\n", " activite_parents = self.split_by_roles(activite_holder, roles = [CHEF, PART])\n", " age_enf = self.split_by_roles(age_holder, roles = ENFS)\n", " smic55_enf = self.split_by_roles(smic55_holder, roles = ENFS)\n", "\n", " nbp = nb_par\n", "\n", " eligib = (\n", " (age_parents[CHEF] >= rmi.age_pac)\n", " *\n", " not_(activite_parents[CHEF] == 2)\n", " ) | (\n", " (age_parents[PART] >= rmi.age_pac) * not_(activite_parents[PART] == 2)\n", " )\n", "\n", " taux = (\n", " 1 + (nbp >= 2) * rmi.txp2 +\n", " (nbp >= 3) * rmi.txp3 +\n", " (nbp >= 4) * ((nb_par == 1) * rmi.txps + (nb_par != 1) * rmi.txp3) +\n", " max_(nbp - 4, 0) * rmi.txps\n", " )\n", " return period, eligib * rmi.rmi * taux" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Suppression du nombre d'enfants dans le calcul du RSA forfait logement\n", "\n", "@ReformeRevenuDeBase.formula\n", "class rmi_nbp(SimpleFormulaColumn):\n", " reference = Familles.column_by_name['rmi_nbp']\n", "\n", " def function(self, simulation, period):\n", " period = period.start.offset('first-of', 'month').period('month')\n", " age_holder = simulation.compute('age', period)\n", " smic55_holder = simulation.compute('smic55', period)\n", " nb_par = simulation.calculate('nb_par', period)\n", " P = simulation.legislation_at(period.start).minim.rmi\n", "\n", " age = self.split_by_roles(age_holder, roles = ENFS)\n", " smic55 = self.split_by_roles(smic55_holder, roles = ENFS)\n", "\n", " return period, nb_par # + nb_enf(age, smic55, 0, P.age_pac - 1)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Suppression de la cotisation patronale famille \n", "\n", "@ReformeRevenuDeBase.formula\n", "class famille(SimpleFormulaColumn):\n", " reference = Individus.column_by_name['famille']\n", "\n", " def function(self, simulation, period):\n", " period = period.start.period(u'month').offset('first-of')\n", " salbrut = simulation.calculate('salbrut', period)\n", " \n", " return period, salbrut * 0" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Baisse de l'éxonération Fillon\n", "\n", "# /!\\ CHANGER LES PARAMÈTRES DE L'ÉXONÉRATION FILLON (-5,25%)\n", "\n", "#@ReformeRevenuDeBase.formula\n", "#def taux_exo_fillon(ratio_smic_salaire, majoration, P):\n", "# '''\n", "# Exonération Fillon\n", "# http://www.securite-sociale.fr/comprendre/dossiers/exocotisations/exoenvigueur/fillon.htm\n", "# '''\n", "# # La divison par zéro engendre un warning\n", "# # Le montant maximum de l’allègement dépend de l’effectif de l’entreprise.\n", "# # Le montant est calculé chaque année civile, pour chaque salarié ;\n", "# # il est égal au produit de la totalité de la rémunération annuelle telle\n", "# # que visée à l’article L. 242-1 du code de la Sécurité sociale par un\n", "# # coefficient.\n", "# # Ce montant est majoré de 10 % pour les entreprises de travail temporaire\n", "# # au titre des salariés temporaires pour lesquels elle est tenue à\n", "# # l’obligation d’indemnisation compensatrice de congés payés.\n", "\n", "# Pf = P.exo_bas_sal.fillon\n", "# seuil = Pf.seuil\n", "# tx_max = (Pf.tx_max * not_(majoration) + Pf.tx_max2 * majoration) - 0.0525\n", "# if seuil <= 1:\n", "# return 0\n", "# # règle d'arrondi: 4 décimales au dix-millième le plus proche\n", "# taux_fillon = round_(tx_max * min_(1, max_(seuil * ratio_smic_salaire - 1, 0) / (seuil - 1)), 4)\n", "# return taux_fillon" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Création d'un revenu de base enfant - Version famille\n", "\n", "from openfisca_france.model.pfam import nb_enf\n", "\n", "@ReformeRevenuDeBase.formula\n", "class rdb_enfant_famille(SimpleFormulaColumn):\n", " column = FloatCol\n", " entity_class = Familles\n", " label = u\"Revenu de base enfant\"\n", "\n", " def function(self, simulation, period):\n", " period = period.start.offset('first-of', 'month').period('month')\n", " age_holder = simulation.compute('age', period)\n", " P = simulation.legislation_at(period.start).fam.af \n", " bmaf = P.bmaf\n", "\n", " \n", " smic55_holder = simulation.compute('smic55', period)\n", " smic55 = self.split_by_roles(smic55_holder, roles = ENFS) \n", " age = self.split_by_roles(age_holder, roles = ENFS)\n", " \n", " smic5 = {\n", " role: array * 0\n", " for role, array in smic55.iteritems()\n", " }\n", " nbenf_inf13 = nb_enf(age, smic5, 0, 13)\n", " nbenf_sup14 = nb_enf(age, smic5, 14, 18)\n", " \n", " return period, (nbenf_inf13 * 0.41 + nbenf_sup14 * 0.57) * bmaf\n", "\n", "# Les taux 0,41 et 0,16 (0,57-0,41) sont issus des allocations familiales\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Création d'un revenu de base enfant - Version individus\n", "\n", "@ReformeRevenuDeBase.formula\n", "class rdb_enf(SimpleFormulaColumn):\n", " column = FloatCol\n", " entity_class = Individus\n", " label = u\"Revenu de base enfant\"\n", "\n", " def function(self, simulation, period):\n", " period = period.start.offset('first-of', 'month').period('month')\n", " age = simulation.calculate('age')\n", " P = simulation.legislation_at(period.start).fam.af \n", " bmaf = P.bmaf\n", " \n", " return period, ((age < 14) * 0.41 + not_(age < 14) * 0.57) * bmaf * (age <= 18)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Création d'une CSG enfant\n", "\n", "@ReformeRevenuDeBase.formula\n", "class csgenf(SimpleFormulaColumn):\n", " column = FloatCol\n", " entity_class = Individus\n", " label = u\"CSG enfant\"\n", "\n", " def function(self, simulation, period):\n", " period = period.start.offset('first-of', 'month').period('month')\n", " revnet = simulation.calculate('revenu_net_individu', period)\n", "\n", " montant_csg = revnet * 0.025\n", " return period, - montant_csg\n", "\n", "@ReformeRevenuDeBase.formula\n", "class csg(SimpleFormulaColumn):\n", " reference = Individus.column_by_name['csg']\n", "\n", " def function(self, simulation, period):\n", " \"\"\"Contribution sociale généralisée\"\"\"\n", " period = period.start.offset('first-of', 'month').period('year')\n", " csgsali = simulation.calculate('csgsali', period)\n", " csgsald = simulation.calculate('csgsald', period)\n", " csgchoi = simulation.calculate('csgchoi', period)\n", " csgchod = simulation.calculate('csgchod', period)\n", " csgrsti = simulation.calculate('csgrsti', period)\n", " csgrstd = simulation.calculate('csgrstd', period)\n", " csg_fon_holder = simulation.compute('csg_fon', period)\n", " csg_cap_lib_declarant1 = simulation.calculate('csg_cap_lib_declarant1', period)\n", " csg_cap_bar_declarant1 = simulation.calculate('csg_cap_bar_declarant1', period)\n", " csg_pv_mo_holder = simulation.compute('csg_pv_mo', period)\n", " csg_pv_immo_holder = simulation.compute('csg_pv_immo', period)\n", " \n", " csgenfant = simulation.calculate('csgenf', period)\n", "\n", " csg_fon = self.cast_from_entity_to_role(csg_fon_holder, role = VOUS)\n", " csg_pv_immo = self.cast_from_entity_to_role(csg_pv_immo_holder, role = VOUS)\n", " csg_pv_mo = self.cast_from_entity_to_role(csg_pv_mo_holder, role = VOUS)\n", "\n", " return period, (csgsali + csgsald + csgchoi + csgchod + csgrsti + csgrstd +\n", " csg_fon + csg_cap_lib_declarant1 + csg_pv_mo + csg_pv_immo + csg_cap_bar_declarant1 + csgenfant)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "@ReformeRevenuDeBase.formula\n", "class revdisp(SimpleFormulaColumn):\n", " reference = Menages.column_by_name['revdisp']\n", "\n", " def function(self, simulation, period):\n", " '''\n", " Revenu disponible - ménage\n", " 'men'\n", " '''\n", " period = period.start.offset('first-of', 'month').period('year')\n", " rev_trav_holder = simulation.compute('rev_trav', period)\n", " pen_holder = simulation.compute('pen', period)\n", " rev_cap_holder = simulation.compute('rev_cap', period)\n", " psoc_holder = simulation.compute('psoc', period)\n", " ppe_holder = simulation.compute('ppe', period)\n", " impo = simulation.calculate('impo', period)\n", " rdb_enfant_holder = simulation.compute('rdb_enf', period)\n", "\n", " pen = self.sum_by_entity(pen_holder)\n", " ppe = self.cast_from_entity_to_role(ppe_holder, role = VOUS)\n", " ppe = self.sum_by_entity(ppe)\n", " psoc = self.cast_from_entity_to_role(psoc_holder, role = CHEF)\n", " psoc = self.sum_by_entity(psoc)\n", " rev_cap = self.sum_by_entity(rev_cap_holder)\n", " rev_trav = self.sum_by_entity(rev_trav_holder)\n", " rdb_enfant = self.sum_by_entity(rdb_enfant_holder)\n", "\n", " return period, rev_trav + pen + rev_cap + psoc + ppe + impo + rdb_enfant" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Tests" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform = ReformeRevenuDeBase()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation = tax_benefit_system.new_scenario().init_single_entity(\n", " period = 2014,\n", " parent1 = dict(\n", " birth = date(1980, 1, 1),\n", " sali = 12000,\n", " statmarit = u'Marié',\n", " ),\n", " parent2 = dict(\n", " birth = date(1980, 1, 1),\n", " sali = 46000,\n", " statmarit = u'Marié',\n", " ),\n", " enfants = [\n", " dict(\n", " birth = date(2010, 1, 1),\n", " ),\n", " dict(\n", " birth = date(2005, 1, 1),\n", " ),\n", " dict(\n", " birth = date(1999, 1, 1),\n", " ),\n", " ],\n", " ).new_simulation(debug = True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation_pauvre = tax_benefit_system.new_scenario().init_single_entity(\n", " period = 2014,\n", " parent1 = dict(\n", " birth = date(1980, 1, 1),\n", " sali = 12000,\n", " statmarit = u'Marié',\n", " ),\n", " parent2 = dict(\n", " birth = date(1980, 1, 1),\n", " sali = 6000,\n", " statmarit = u'Marié',\n", " ),\n", " enfants = [\n", " dict(\n", " birth = date(2010, 1, 1),\n", " ),\n", " dict(\n", " birth = date(2005, 1, 1),\n", " ),\n", " dict(\n", " birth = date(1999, 1, 1),\n", " ),\n", " ],\n", " ).new_simulation(debug = True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation = reform.new_scenario().init_single_entity(\n", " period = 2014,\n", " parent1 = dict(\n", " birth = date(1980, 1, 1),\n", " sali = 12000,\n", " statmarit = u'Marié',\n", " ),\n", " parent2 = dict(\n", " birth = date(1980, 1, 1),\n", " sali = 46000,\n", " statmarit = u'Marié',\n", " ),\n", " enfants = [\n", " dict(\n", " birth = date(2010, 1, 1),\n", " ),\n", " dict(\n", " birth = date(2005, 1, 1),\n", " ),\n", " dict(\n", " birth = date(1999, 1, 1),\n", " ),\n", " ],\n", " ).new_simulation(debug = True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation_pauvre = reform.new_scenario().init_single_entity(\n", " period = 2014,\n", " parent1 = dict(\n", " birth = date(1980, 1, 1),\n", " sali = 12000,\n", " statmarit = u'Marié',\n", " ),\n", " parent2 = dict(\n", " birth = date(1980, 1, 1),\n", " sali = 6000,\n", " statmarit = u'Marié',\n", " ),\n", " enfants = [\n", " dict(\n", " birth = date(2010, 1, 1),\n", " ),\n", " dict(\n", " birth = date(2005, 1, 1),\n", " ),\n", " dict(\n", " birth = date(1999, 1, 1),\n", " ),\n", " ],\n", " ).new_simulation(debug = True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('nbptr')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('nbptr')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('af')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('af')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('cf')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('cf')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('ars')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('ars')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('rsa')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('rsa')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('rmi_nbp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('rmi_nbp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('famille')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('famille')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('rdb_enfant_famille')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('rdb_enf')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('csgenf')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('csg')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('csg')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('revdisp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('revdisp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation_pauvre.calculate('revdisp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation_pauvre.calculate('revdisp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('sali')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('sali')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('salsuperbrut')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('salsuperbrut')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('salnet')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('salnet')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('pfam')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('pfam')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation_pauvre.calculate('psoc')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('cotisations_salariales')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation_pauvre.calculate('pfam')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('irpp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('irpp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation.calculate('allegement_fillon')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }