def _quaenv_2010_2011(marpac, nb_pac2, f7we, f7wf, f7wg, f7wh, f7wk, f7wq, f7sb, f7sd, f7se, f7sh, rfr, _P):
    '''
    Crédits d’impôt pour dépenses en faveur de la qualité environnementale
    (cases 7WF, 7WH, 7WK, 7WQ, 7SB, 7SD, 7SE et 7SH)
    2010-2011
    '''
    P = _P.ir.credits_impot.quaenv
    max0 = P.max * (1 + marpac) + P.pac1 * nb_pac2

    max1 = max_(0, max0 - f7wf)
    max2 = max_(0, max1 - f7se)
    max3 = max_(0, max2 - f7wk)
    max4 = max_(0, max3 - f7sd)
    max5 = max_(0, max4 - f7wh)
    max6 = max_(0, max5 - f7sb)
    max7 = max_(0, max6 - f7wq)
    return not_(f7wg) * or_(not_(f7we), (rfr < 45000)) * (
                P.taux_wf * min_(f7wf, max0) +
                P.taux_se * min_(f7se, max1) +
                P.taux_wk * min_(f7wk, max2) +
                P.taux_sd * min_(f7sd, max3) +
                P.taux_wh * min_(f7wh, max4) +
                P.taux_sb * min_(f7sb, max5) +
                P.taux_wq * min_(f7wq, max6) +
                P.taux_sh * min_(f7sh, max7))
Esempio n. 2
0
def _rsa_socle(self, age_holder, smic55_holder, activite_holder, nb_par, rmi = law.minim.rmi):
    '''
    Rsa socle / Rmi
    'fam'
    '''
    age_parents = self.split_by_roles(age_holder, roles = [CHEF, PART])
    activite_parents = self.split_by_roles(activite_holder, roles = [CHEF, PART])
    age_enf = self.split_by_roles(age_holder, roles = ENFS)
    smic55_enf = self.split_by_roles(smic55_holder, roles = ENFS)

    nbp = nb_par + nb_enf(age_enf, smic55_enf, 0, rmi.age_pac)

    eligib = (
        (age_parents[CHEF] >= rmi.age_pac)
        *
        not_(activite_parents[CHEF] == 2)
        ) | (
            (age_parents[PART] >= rmi.age_pac) * not_(activite_parents[PART] == 2)
            )

    taux = (1 + (nbp >= 2) * rmi.txp2
                 + (nbp >= 3) * rmi.txp3
                 + (nbp >= 4) * ((nb_par == 1) * rmi.txps + (nb_par != 1) * rmi.txp3)
                 + max_(nbp - 4, 0) * rmi.txps)

    return eligib * rmi.rmi * taux * 12
    def function(famille, period, legislation):
        period = period.this_month
        al = legislation(period).prestations.aides_logement
        couple = famille('al_couple', period)
        al_nb_pac = famille('al_nb_personnes_a_charge', period)
        residence_dom = famille.demandeur.menage('residence_dom')

        TF_metropole = (
            al.taux_participation_fam.taux_1_adulte * (not_(couple)) *
            (al_nb_pac == 0) + al.taux_participation_fam.taux_2_adulte *
            (couple) * (al_nb_pac == 0) +
            al.taux_participation_fam.taux_1_enf * (al_nb_pac == 1) +
            al.taux_participation_fam.taux_2_enf * (al_nb_pac == 2) +
            al.taux_participation_fam.taux_3_enf * (al_nb_pac == 3) +
            al.taux_participation_fam.taux_4_enf * (al_nb_pac >= 4) +
            al.taux_participation_fam.taux_enf_supp * (al_nb_pac > 4) *
            (al_nb_pac - 4))

        TF_dom = (al.taux_participation_fam.dom.taux1 * (not_(couple)) *
                  (al_nb_pac == 0) + al.taux_participation_fam.dom.taux2 *
                  (couple) * (al_nb_pac == 0) +
                  al.taux_participation_fam.dom.taux3 * (al_nb_pac == 1) +
                  al.taux_participation_fam.dom.taux4 * (al_nb_pac == 2) +
                  al.taux_participation_fam.dom.taux5 * (al_nb_pac == 3) +
                  al.taux_participation_fam.dom.taux6 * (al_nb_pac == 4) +
                  al.taux_participation_fam.dom.taux7 * (al_nb_pac == 5) +
                  al.taux_participation_fam.dom.taux8 * (al_nb_pac >= 6))

        return period, where(residence_dom, TF_dom, TF_metropole)
Esempio n. 4
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('year')
        rfr = simulation.calculate('rfr', period.start.offset('first-of', 'year').period('year').offset(-2))
        age_holder = simulation.compute('age', period)
        scolarite_holder = simulation.compute('scolarite', period)
        P = simulation.legislation_at(period.start).bourses_education.bourse_college

        ages = self.split_by_roles(age_holder, roles = ENFS)
        nb_enfants = zeros(len(rfr))
        for age in ages.itervalues():
            nb_enfants += age >= 0

        plafond_taux_1 = P.plafond_taux_1 + P.plafond_taux_1 * nb_enfants * P.coeff_enfant_supplementaire
        plafond_taux_2 = P.plafond_taux_2 + P.plafond_taux_2 * nb_enfants * P.coeff_enfant_supplementaire
        plafond_taux_3 = P.plafond_taux_3 + P.plafond_taux_3 * nb_enfants * P.coeff_enfant_supplementaire

        eligible_taux_3 = rfr < plafond_taux_3
        eligible_taux_2 = not_(eligible_taux_3) * (rfr < plafond_taux_2)
        eligible_taux_1 = not_(or_(eligible_taux_2, eligible_taux_3)) * (rfr < plafond_taux_1)

        scolarites = self.split_by_roles(scolarite_holder, roles = ENFS)
        nb_enfants_college = zeros(len(rfr))
        for scolarite in scolarites.itervalues():
            nb_enfants_college += scolarite == SCOLARITE_COLLEGE

        montant = (
            eligible_taux_3 * P.montant_taux_3 +
            eligible_taux_2 * P.montant_taux_2 +
            eligible_taux_1 * P.montant_taux_1
            )

        montant *= nb_enfants_college

        return period, montant
Esempio n. 5
0
def _saldom2(nb_pac2, f7db, f7dg, f7dl, f7dq, _P):
    '''
    Crédit d’impôt emploi d’un salarié à domicile (cases 7DB, 7DG)
    2007-
    '''
    P = _P.ir.reductions_impots.saldom

    isinvalid = f7dg

    if _P.datesim.year in (2007, 2008):
        nbpacmin = nb_pac2 + f7dl
        maxBase = P.max1
        maxDuMaxNonInv = P.max2
        maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv)
        maxEffectif = maxNonInv * not_(isinvalid) + P.max3 * isinvalid

    elif _P.datesim.year in (2009, 2010):
        annee1 = f7dq
        nbpacmin = nb_pac2 + f7dl
        maxBase = P.max1 * not_(annee1) + P.max1_1ereAnnee * annee1
        maxDuMaxNonInv = P.max2 * not_(annee1) + P.max2_1ereAnnee * annee1
        maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv)
        maxEffectif = maxNonInv * not_(isinvalid) + P.max3 * isinvalid

    elif _P.datesim.year >= 2011:
        # TODO:
        maxEffectif = 0

    return P.taux * min_(f7db, maxEffectif)
    def function(self, simulation, period):
        period = period.this_month
        al = simulation.legislation_at(period.start).al
        couple = simulation.calculate('al_couple', period)
        al_nb_pac = simulation.calculate('al_nb_personnes_a_charge', period)
        residence_dom = simulation.calculate('residence_dom')

        TF_metropole = (
            al.TF.taux1 * (not_(couple)) * (al_nb_pac == 0) +
            al.TF.taux2 * (couple) * (al_nb_pac == 0) +
            al.TF.taux3 * (al_nb_pac == 1) +
            al.TF.taux4 * (al_nb_pac == 2) +
            al.TF.taux5 * (al_nb_pac == 3) +
            al.TF.taux6 * (al_nb_pac >= 4) +
            al.TF.taux7 * (al_nb_pac > 4) * (al_nb_pac - 4)
            )

        TF_dom = (
            al.TF.dom.taux1 * (not_(couple)) * (al_nb_pac == 0) +
            al.TF.dom.taux2 * (couple) * (al_nb_pac == 0) +
            al.TF.dom.taux3 * (al_nb_pac == 1) +
            al.TF.dom.taux4 * (al_nb_pac == 2) +
            al.TF.dom.taux5 * (al_nb_pac == 3) +
            al.TF.dom.taux6 * (al_nb_pac == 4) +
            al.TF.dom.taux7 * (al_nb_pac == 5) +
            al.TF.dom.taux8 * (al_nb_pac >= 6)
        )

        return period, where(residence_dom, TF_dom, TF_metropole)
Esempio n. 7
0
    def function(self, simulation, period):
        period = period.this_month
        asi_elig_holder = simulation.compute('asi_eligibilite', period)
        aspa_elig_holder = simulation.compute('aspa_eligibilite', period)
        maries = simulation.calculate('maries', period)
        en_couple = simulation.calculate('en_couple', period)
        asi_aspa_nb_alloc = simulation.calculate('asi_aspa_nb_alloc', period)
        base_ressources = simulation.calculate('asi_aspa_base_ressources',
                                               period)
        P = simulation.legislation_at(period.start).minim

        asi_eligibilite = self.split_by_roles(asi_elig_holder,
                                              roles=[CHEF, PART])
        aspa_eligibilite = self.split_by_roles(aspa_elig_holder,
                                               roles=[CHEF, PART])

        # Un seul éligible
        elig1 = ((asi_aspa_nb_alloc == 1) &
                 (asi_eligibilite[CHEF] | asi_eligibilite[PART]))
        # Couple d'éligibles mariés
        elig2 = asi_eligibilite[CHEF] & asi_eligibilite[PART] & maries
        # Couple d'éligibles non mariés
        elig3 = asi_eligibilite[CHEF] & asi_eligibilite[PART] & not_(maries)
        # Un seul éligible et époux éligible ASPA
        elig4 = ((asi_eligibilite[CHEF] & aspa_eligibilite[PART]) |
                 (asi_eligibilite[PART] & aspa_eligibilite[CHEF])) & maries
        # Un seul éligible et conjoint non marié éligible ASPA
        elig5 = (
            (asi_eligibilite[CHEF] & aspa_eligibilite[PART]) |
            (asi_eligibilite[PART] & aspa_eligibilite[CHEF])) & not_(maries)

        elig = elig1 | elig2 | elig3 | elig4 | elig5

        montant_max = (
            elig1 * P.asi.montant_seul + elig2 * P.asi.montant_couple +
            elig3 * 2 * P.asi.montant_seul + elig4 *
            (P.asi.montant_couple / 2 + P.aspa.montant_couple / 2) + elig5 *
            (P.asi.montant_seul + P.aspa.montant_couple / 2)) / 12

        ressources = base_ressources + montant_max

        plafond_ressources = (
            elig1 *
            (P.asi.plaf_seul * not_(en_couple) + P.asi.plaf_couple * en_couple)
            + elig2 * P.asi.plaf_couple + elig3 * P.asi.plaf_couple +
            elig4 * P.aspa.plaf_couple + elig5 * P.aspa.plaf_couple) / 12

        depassement = max_(ressources - plafond_ressources, 0)

        diff = ((elig1 | elig2 | elig3) * (montant_max - depassement) + elig4 *
                (P.asi.montant_couple / 12 / 2 - depassement / 2) + elig5 *
                (P.asi.montant_seul / 12 - depassement / 2))

        # Montant mensuel servi (sous réserve d'éligibilité)
        montant_servi_asi = max_(diff, 0)

        # TODO: Faute de mieux, on verse l'asi à la famille plutôt qu'aux individus
        # asi[CHEF] = asi_eligibilite[CHEF]*montant_servi_asi*(elig1*1 + elig2/2 + elig3/2)
        # asi[PART] = asi_eligibilite[PART]*montant_servi_asi*(elig1*1 + elig2/2 + elig3/2)
        return period, elig * montant_servi_asi
Esempio n. 8
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('month')
        age_holder = simulation.compute('age', period)
        smic55_holder = simulation.compute('smic55', period)
        activite_holder = simulation.compute('activite', period)
        nb_par = simulation.calculate('nb_par', period)
        rmi = simulation.legislation_at(period.start).minim.rmi

        age_parents = self.split_by_roles(age_holder, roles = [CHEF, PART])
        activite_parents = self.split_by_roles(activite_holder, roles = [CHEF, PART])
        age_enf = self.split_by_roles(age_holder, roles = ENFS)
        smic55_enf = self.split_by_roles(smic55_holder, roles = ENFS)

        nbp = nb_par + nb_enf(age_enf, smic55_enf, 0, rmi.age_pac)

        eligib = (
            (age_parents[CHEF] >= rmi.age_pac)
            &
            not_(activite_parents[CHEF] == 2)
            ) | (
                (age_parents[PART] >= rmi.age_pac) & not_(activite_parents[PART] == 2)
                )

        taux = (
            1 + (nbp >= 2) * rmi.txp2 +
            (nbp >= 3) * rmi.txp3 +
            (nbp >= 4) * ((nb_par == 1) * rmi.txps + (nb_par != 1) * rmi.txp3) +
            max_(nbp - 4, 0) * rmi.txps
            )
        return period, eligib * rmi.rmi * taux
Esempio n. 9
0
    def function(self, simulation, period):
        '''
        L’Allocation de Solidarité Spécifique (ASS) est une allocation versée aux
        personnes ayant épuisé leurs droits à bénéficier de l'assurance chômage.

        Le prétendant doit avoir épuisé ses droits à l’assurance chômage.
        Il doit être inscrit comme demandeur d’emploi et justifier de recherches actives.
        Il doit être apte à travailler.
        Il doit justifier de 5 ans d’activité salariée au cours des 10 ans précédant le chômage.
        À partir de 60 ans, il doit répondre à des conditions particulières.

        Les ressources prises en compte pour apprécier ces plafonds, comprennent l'allocation de solidarité elle-même
        ainsi que les autres ressources de l'intéressé, et de son conjoint, partenaire pacsé ou concubin,
        soumises à impôt sur le revenu.
        Ne sont pas prises en compte, pour déterminer le droit à ASS :
          l'allocation d'assurance chômage précédemment perçue,
          les prestations familiales,
          l'allocation de logement,
          la majoration de l'ASS,
          la prime forfaitaire mensuelle de retour à l'emploi,
          la pension alimentaire ou la prestation compensatoire due par l'intéressé.

        Conditions de versement de l'ASS majorée
            Pour les allocataires admis au bénéfice de l'ASS majorée (avant le 1er janvier 2004),
            le montant de l'ASS majorée est fixé à 22,07 € par jour.
            Pour mémoire, jusqu'au 31 décembre 2003, pouvaient bénéficier de l'ASS majorée, les allocataires :
            âgés de 55 ans ou plus et justifiant d'au moins 20 ans d'activité salariée,
            ou âgés de 57 ans et demi ou plus et justifiant de 10 ans d'activité salariée,
            ou justifiant d'au moins 160 trimestres de cotisation retraite.
        '''
        period = period.start.offset('first-of', 'month').period('year')
        ass_base_ressources = simulation.calculate('ass_base_ressources',
                                                   period)
        ass_eligibilite_i_holder = simulation.compute('ass_eligibilite_i',
                                                      period)
        concub = simulation.calculate('concub', period)
        ass_params = simulation.legislation_at(period.start).minim.ass

        ass_eligibilite_i = self.split_by_roles(ass_eligibilite_i_holder,
                                                roles=[CHEF, PART])

        majo = 0  # TODO
        elig = or_(ass_eligibilite_i[CHEF], ass_eligibilite_i[PART])
        plafond_mensuel = ass_params.plaf_seul * not_(
            concub) + ass_params.plaf_coup * concub
        plafond = plafond_mensuel * 12
        montant_mensuel = 30 * (ass_params.montant_plein * not_(majo) +
                                majo * ass_params.montant_maj)

        revenus = ass_base_ressources + 12 * montant_mensuel

        ass = 12 * montant_mensuel * (
            revenus <= plafond) + (revenus > plafond) * max_(
                plafond + 12 * montant_mensuel - revenus, 0)
        ass = ass * elig
        ass = ass * not_(
            ass / 12 < ass_params.montant_plein
        )  # pas d'ASS si montant mensuel < montant journalier de base

        return period, ass
Esempio n. 10
0
    def function(self, simulation, period):
        '''
        type de menage
        'men'
        TODO: prendre les enfants du ménage et non ceux de la famille
        '''
        period = period.this_year
        en_couple_holder = simulation.compute('en_couple', period)
        af_nbenf_holder = simulation.compute('af_nbenf', period)

        af_nbenf = self.cast_from_entity_to_role(af_nbenf_holder, role = CHEF)
        af_nbenf = self.sum_by_entity(af_nbenf)
        isole = not_(self.cast_from_entity_to_role(en_couple_holder, role = CHEF))
        isole = self.sum_by_entity(isole)

        _0_kid = af_nbenf == 0
        _1_kid = af_nbenf == 1
        _2_kid = af_nbenf == 2
        _3_kid = af_nbenf >= 3

        return period, (0 * (isole & _0_kid) +  # Célibataire
                1 * (not_(isole) & _0_kid) +  # Couple sans enfants
                2 * (not_(isole) & _1_kid) +  # Couple un enfant
                3 * (not_(isole) & _2_kid) +  # Couple deux enfants
                4 * (not_(isole) & _3_kid) +  # Couple trois enfants et plus
                5 * (isole & _1_kid) +  # Famille monoparentale un enfant
                6 * (isole & _2_kid) +  # Famille monoparentale deux enfants
                7 * (isole & _3_kid))  # Famille monoparentale trois enfants et plus
Esempio n. 11
0
def _aspa_pure(aspa_elig, marpac, maries, asi_aspa_nb_alloc, br_mv, _P, _option = {'aspa_elig': [CHEF, PART]}):
    '''
    Calcule l'ASPA lorsqu'il y a un ou deux bénéficiaire de l'ASPA et aucun bénéficiaire de l'ASI
    '''
    # La notion de couple change au 1er janvier 2007 (réforme de 2006)
    if _P.datesim.year >= 2007:
        couple = marpac
    else:
        couple = maries

    P = _P.minim

    elig1 = ((asi_aspa_nb_alloc == 1) & (aspa_elig[CHEF] | aspa_elig[PART]))
    elig2 = (aspa_elig[CHEF] & aspa_elig[PART]) * couple  # couple d'allocataire
#     elig = elig1 | elig2
#
#     montant_max = elig1 * P.aspa.montant_seul + elig2 * P.aspa.montant_couple
#     ressources = elig * (br_mv + montant_max)
#     plafond_ressources = elig1 * (P.aspa.plaf_seul * not_(couple) + P.aspa.plaf_couple * couple) + elig2 * P.aspa.plaf_couple
#     depassement = ressources - plafond_ressources
#
#     montant_servi_aspa = max_(montant_max - depassement, 0) / 12

    diff_plaf = P.aspa.plaf_couple - P.aspa.plaf_seul

    plafond_ressources = (elig1 * not_(couple)) * P.aspa.plaf_seul + (elig2 | elig1 * couple) * P.aspa.plaf_couple
    montant_max = (elig1 * not_(couple)) * P.aspa.montant_seul + elig2 * P.aspa.montant_couple + (elig1 * couple) * ((br_mv <= diff_plaf) * (P.aspa.montant_seul + br_mv) + (br_mv > diff_plaf) * P.aspa.montant_couple)
    montant_servi_aspa = max_(montant_max - br_mv, 0) * (br_mv <= plafond_ressources) / 12

    # TODO: Faute de mieux, on verse l'aspa à la famille plutôt qu'aux individus
    # aspa[CHEF] = aspa_elig[CHEF]*montant_servi_aspa*(elig1 + elig2/2)
    # aspa[PART] = aspa_elig[PART]*montant_servi_aspa*(elig1 + elig2/2)

    return 12 * (aspa_elig[CHEF] + aspa_elig[PART]) * montant_servi_aspa * (elig1 + elig2 / 2)  # annualisé
Esempio n. 12
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('month')
        rfr = simulation.calculate('rfr', period.start.offset('first-of', 'year').period('year').offset(-2))
        age_holder = simulation.compute('age', period)
        scolarite_holder = simulation.compute('scolarite', period)
        P = simulation.legislation_at(period.start).bourses_education.bourse_college

        ages = self.split_by_roles(age_holder, roles = ENFS)
        nb_enfants = zeros(len(rfr))
        for age in ages.itervalues():
            nb_enfants += age >= 0

        plafond_taux_1 = P.plafond_taux_1 + P.plafond_taux_1 * nb_enfants * P.coeff_enfant_supplementaire
        plafond_taux_2 = P.plafond_taux_2 + P.plafond_taux_2 * nb_enfants * P.coeff_enfant_supplementaire
        plafond_taux_3 = P.plafond_taux_3 + P.plafond_taux_3 * nb_enfants * P.coeff_enfant_supplementaire

        eligible_taux_3 = rfr < plafond_taux_3
        eligible_taux_2 = not_(eligible_taux_3) * (rfr < plafond_taux_2)
        eligible_taux_1 = not_(or_(eligible_taux_2, eligible_taux_3)) * (rfr < plafond_taux_1)

        scolarites = self.split_by_roles(scolarite_holder, roles = ENFS)
        nb_enfants_college = zeros(len(rfr))
        for scolarite in scolarites.itervalues():
            nb_enfants_college += scolarite == SCOLARITE_COLLEGE

        montant = nb_enfants_college * (
            eligible_taux_3 * P.montant_taux_3 +
            eligible_taux_2 * P.montant_taux_2 +
            eligible_taux_1 * P.montant_taux_1
            )

        return period, montant / 12
Esempio n. 13
0
        def function(self, simulation, period):
            period = period.start.offset('first-of', 'month').period('month')
            age_holder = simulation.compute('age', period)
            # smic55_holder = simulation.compute('smic55', period)
            activite_holder = simulation.compute('activite', period)
            nb_par = simulation.calculate('nb_par', period)
            rmi = simulation.legislation_at(period.start).minim.rmi

            age_parents = self.split_by_roles(age_holder, roles=[CHEF, PART])
            activite_parents = self.split_by_roles(activite_holder,
                                                   roles=[CHEF, PART])
            # age_enf = self.split_by_roles(age_holder, roles = ENFS)
            # smic55_enf = self.split_by_roles(smic55_holder, roles = ENFS)

            nbp = nb_par

            eligib = ((age_parents[CHEF] >= rmi.age_pac) *
                      not_(activite_parents[CHEF] == 2)) | (
                          (age_parents[PART] >= rmi.age_pac) *
                          not_(activite_parents[PART] == 2))

            taux = (1 + (nbp >= 2) * rmi.txp2 + (nbp >= 3) * rmi.txp3 +
                    (nbp >= 4) * ((nb_par == 1) * rmi.txps +
                                  (nb_par != 1) * rmi.txp3) +
                    max_(nbp - 4, 0) * rmi.txps)
            return period, eligib * rmi.rmi * taux
Esempio n. 14
0
    def function__2009(self, simulation, period):
        """
        Allocation de parent isolé
        """
        period = period.this_month
        age_en_mois_holder = simulation.compute('age_en_mois', period)
        age_holder = simulation.compute('age', period)
        autonomie_financiere_holder = simulation.compute('autonomie_financiere', period)
        isole = not_(simulation.calculate('en_couple', period))
        rsa_forfait_logement = simulation.calculate('rsa_forfait_logement', period)
        rsa_base_ressources = simulation.calculate('rsa_base_ressources', period)
        af_majoration = simulation.calculate('af_majoration', period)
        rsa = simulation.calculate('rsa', period)
        af = simulation.legislation_at(period.start).fam.af
        api = simulation.legislation_at(period.start).minim.api

        age = self.split_by_roles(age_holder, roles = ENFS)
        age_en_mois = self.split_by_roles(age_en_mois_holder, roles = ENFS)
        autonomie_financiere = self.split_by_roles(autonomie_financiere_holder, roles = ENFS)
        # TODO:
        #    Majoration pour isolement
        #    Si vous êtes parent isolé, c’est-à-dire célibataire, divorcé(e), séparé(e) ou veuf(ve) avec des enfants
        #    à charge ou enceinte, le montant forfaitaire garanti est majoré.
        #    Ce montant forfaitaire majoré est accordé à partir du mois au cours duquel survient l'un des événements
        #    suivants :
        #    - déclaration de grossesse,
        #    - naissance d'un enfant,
        #    - prise en charge d'un enfant,
        #    - séparation, veuvage,
        #    - dépôt de la demande si l’événement est antérieur.
        #
        #    Le montant forfaitaire majoré peut être accordé pendant 12 mois, continus ou discontinus, au cours
        #    d’une période de 18 mois suivant l’événement.
        #    Si votre plus jeune enfant à charge a moins de 3 ans, le montant forfaitaire majoré vous est accordé
        #    jusqu'à ses 3 ans.
        benjamin = age_en_mois_benjamin(age_en_mois)
        enceinte = (benjamin < 0) * (benjamin > -6)
        # TODO: quel mois mettre ?
        # TODO: pas complètement exact
        # L'allocataire perçoit l'API :
        # jusqu'�� ce que le plus jeune enfant ait 3 ans,
        # ou pendant 12 mois consécutifs si les enfants sont âgés de plus de 3 ans
        #    et s'il a présenté sa demande dans les 6 mois à partir du moment où il
        #    assure seul la charge de l'enfant.
        # TODO: API courte gens pour les gens qui ont divorcés dans l'année
        # Le droit à l'allocation est réétudié tous les 3 mois.
        # # Calcul de l'année et mois de naissance du benjamin

        condition = (floor(benjamin / 12) <= api.age - 1)
        eligib = isole * ((enceinte != 0) | (nb_enf(age, autonomie_financiere, 0, api.age - 1) > 0)) * condition

        # moins de 20 ans avant inclusion dans rsa
        # moins de 25 ans après inclusion dans rsa
        api1 = eligib * af.bmaf * (api.base + api.enf_sup * nb_enf(age, autonomie_financiere, af.age1, api.age_pac - 1))
        rsa = (api.age_pac >= 25)  # dummy passage au rsa majoré
        br_api = rsa_base_ressources + af_majoration * not_(rsa)
        # On pourrait mensualiser RMI, BRrmi et forfait logement
        api = max_(0, api1 - rsa_forfait_logement / 12 - br_api / 12 - rsa / 12)
        # L'API est exonérée de CRDS
        return period, api  # annualisé
Esempio n. 15
0
        def ouvre_droit_majoration():
            enceinte_fam = simulation.calculate('enceinte_fam', period)
            isole = not_(simulation.calculate('en_couple', period))
            isolement_recent = simulation.calculate('rsa_isolement_recent', period)
            presence_autres_enfants = self.sum_by_entity(enfant * not_(autonomie_financiere) * (age <= P_rsa.age_pac), entity = "famille") > 1

            return self.cast_from_entity_to_roles(not_(enceinte_fam) * isole * isolement_recent * not_(presence_autres_enfants), entity = 'famille')
def _saldom2(nb_pac2, f7db, f7dg, f7dl, f7dq, _P):
    '''
    Crédit d’impôt emploi d’un salarié à domicile (cases 7DB, 7DG)
    2007-
    '''
    P = _P.ir.reductions_impots.saldom

    isinvalid = f7dg

    if _P.datesim.year in (2007, 2008):
        nbpacmin = nb_pac2 + f7dl
        maxBase = P.max1
        maxDuMaxNonInv = P.max2
        maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv)
        maxEffectif = maxNonInv * not_(isinvalid) + P.max3 * isinvalid

    elif _P.datesim.year in (2009, 2010):
        annee1 = f7dq
        nbpacmin = nb_pac2 + f7dl
        maxBase = P.max1 * not_(annee1) + P.max1_1ereAnnee * annee1
        maxDuMaxNonInv = P.max2 * not_(annee1) + P.max2_1ereAnnee * annee1
        maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv)
        maxEffectif = maxNonInv * not_(isinvalid) + P.max3 * isinvalid

    elif _P.datesim.year >= 2011:
        # TODO:
        maxEffectif = 0

    return P.taux * min_(f7db, maxEffectif)
Esempio n. 17
0
    def function(famille, period, legislation):
        period = period.this_month

        np_pers = famille('nb_parents', period) + famille(
            'rsa_nb_enfants', period)
        aide_logement = famille('aide_logement', period)
        statut_occupation_logement = famille.demandeur.menage(
            'statut_occupation_logement', period)
        participation_frais = famille.demandeur.menage('participation_frais',
                                                       period)
        loyer = famille.demandeur.menage('loyer', period)

        avantage_nature = or_(
            (statut_occupation_logement == 2) * not_(loyer),
            (statut_occupation_logement == 6) * not_(participation_frais))
        avantage_al = aide_logement > 0

        # Les parametres ont changé de nom au moment où le RMI est devenu le RSA
        # Pour le RSA, on utilise les taux des textes de lois, pour le RMI ils sont déjà aggrégés
        # Il faudrait uniformiser, mais les taux légaux pour le RMI commencent par "1", et ne passent pas en python
        if period.start.date >= date(2009, 6, 01):
            params = legislation(period).prestations.minima_sociaux.rsa
            montant_base = params.montant_de_base_du_rsa
            taux_2p = 1 + params.majoration_rsa.taux_deuxieme_personne
            taux_3p = taux_2p + params.majoration_rsa.taux_troisieme_personne
            forf_logement_taux_1p = params.forfait_logement.taux_1_personne
            forf_logement_taux_2p = params.forfait_logement.taux_2_personnes * taux_2p
            forf_logement_taux_3p = params.forfait_logement.taux_3_personnes_ou_plus * taux_3p
Esempio n. 18
0
    def formula(famille, period, parameters):

        nb_personnes = famille.nb_persons()
        personnes_a_charge = famille('al_nb_personnes_a_charge', period)
        personne_seule = (famille.nb_persons(Famille.PARENT)
                          == 1) * (personnes_a_charge == 0)

        # Jeune ménage : Couple marié, concubins ou pacsés, sans personne à charge,
        # dont la somme des âges des deux conjoints est inférieure ou égale à 55 ans
        age = famille.members('age', period)
        sum_age = famille.sum(age, role=Famille.PARENT)
        jeune_menage = (not_(personne_seule) * (sum_age <= 55))

        return select(
            [
                personne_seule,
                # Deux personnes ne comportant aucune personne à charge, à l'exclusion des jeunes ménages.
                ((nb_personnes == 2) *
                 (personnes_a_charge == 0) * not_(jeune_menage)),
                # Trois personnes, ou une personne seule avec une personne à charge, ou jeune ménage sans personne à charge.
                (personnes_a_charge == 1) + (jeune_menage *
                                             (personnes_a_charge == 0)),
                # Quatre personnes, ou une personne seule avec deux personnes à charge.
                (personnes_a_charge == 2),
                # Cinq personnes, ou une personne seule avec trois personnes à charge.
                (personnes_a_charge == 3)
            ],
            [
                CategorieMenageLogementSocial.categorie_1,
                CategorieMenageLogementSocial.categorie_2,
                CategorieMenageLogementSocial.categorie_3,
                CategorieMenageLogementSocial.categorie_4,
                CategorieMenageLogementSocial.categorie_5
            ],
            default=CategorieMenageLogementSocial.categorie_6)
Esempio n. 19
0
def _asi_pure(asi_elig,
              marpac,
              maries,
              asi_aspa_nb_alloc,
              br_mv,
              _P,
              _option={'asi_elig': [CHEF, PART]}):
    '''
    Calcule l'ASI lorsqu'il y a un ou deux bénéficiaire de l'ASI et aucun bénéficiaire de l'ASPA
    '''
    P = _P.minim
    # 1 A Un ou deux bénéficiaire(s) de l'ASI et aucun bénéficiaire de l'ASPA
    elig1 = ((asi_aspa_nb_alloc == 1) & (asi_elig[CHEF] | asi_elig[PART])
             )  # un seul éligible
    elig2 = (asi_elig[CHEF]
             & asi_elig[PART]) * maries  # couple d'éligible marié
    elig3 = (asi_elig[CHEF] & asi_elig[PART]) * (
        marpac & not_(maries))  # couple d'éligible non marié
    elig = elig1 | elig2

    montant_max = elig1 * P.asi.montant_seul + elig2 * P.asi.montant_couple + elig3 * 2 * P.asi.montant_seul
    ressources = elig * (br_mv + montant_max)
    plafond_ressources = elig1 * (
        P.asi.plaf_seul * not_(marpac) + P.aspa.plaf_couple *
        marpac) + elig2 * P.aspa.plaf_couple + elig3 * P.asi.plaf_couple
    depassement = ressources - plafond_ressources
    montant_servi_asi = max_(montant_max - depassement, 0) / 12
    # Faute de mieux, on verse l'asi à la famille plutôt qu'aux individus
    # asi[CHEF] = asi_elig[CHEF]*montant_servi_asi*(elig1*1 + elig2/2 + elig3/2)
    # asi[PART] = asi_elig[PART]*montant_servi_asi*(elig1*1 + elig2/2 + elig3/2)
    return 12 * (asi_elig[CHEF] + asi_elig[PART]) * montant_servi_asi * (
        elig1 * 1 + elig2 / 2 + elig3 / 2)  # annualisé
Esempio n. 20
0
    def function(self, simulation, period):
        '''
        Type de menage
        TODO: prendre les enfants du ménage et non ceux de la famille
        '''
        period = period.this_year
        en_couple_holder = simulation.compute('en_couple', period)
        af_nbenf_holder = simulation.compute('af_nbenf', period)

        af_nbenf = self.cast_from_entity_to_role(af_nbenf_holder, role = CHEF)
        af_nbenf = self.sum_by_entity(af_nbenf)
        isole = not_(self.cast_from_entity_to_role(en_couple_holder, role = CHEF))
        isole = self.sum_by_entity(isole)

        _0_kid = af_nbenf == 0
        _1_kid = af_nbenf == 1
        _2_kid = af_nbenf == 2
        _3_kid = af_nbenf >= 3

        return period, (
            0 * (isole & _0_kid) +  # Célibataire
            1 * (not_(isole) & _0_kid) +  # Couple sans enfants
            2 * (not_(isole) & _1_kid) +  # Couple un enfant
            3 * (not_(isole) & _2_kid) +  # Couple deux enfants
            4 * (not_(isole) & _3_kid) +  # Couple trois enfants et plus
            5 * (isole & _1_kid) +  # Famille monoparentale un enfant
            6 * (isole & _2_kid) +  # Famille monoparentale deux enfants
            7 * (isole & _3_kid))  # Famille monoparentale trois enfants et plus
        def function(self, simulation, period):
            period = period.start.offset("first-of", "month").period("month")
            age_holder = simulation.compute("age", period)
            # smic55_holder = simulation.compute('smic55', period)
            activite_holder = simulation.compute("activite", period)
            nb_par = simulation.calculate("nb_par", period)
            rmi = simulation.legislation_at(period.start).minim.rmi

            age_parents = self.split_by_roles(age_holder, roles=[CHEF, PART])
            activite_parents = self.split_by_roles(activite_holder, roles=[CHEF, PART])
            # age_enf = self.split_by_roles(age_holder, roles = ENFS)
            # smic55_enf = self.split_by_roles(smic55_holder, roles = ENFS)

            nbp = nb_par

            eligib = ((age_parents[CHEF] >= rmi.age_pac) * not_(activite_parents[CHEF] == 2)) | (
                (age_parents[PART] >= rmi.age_pac) * not_(activite_parents[PART] == 2)
            )

            taux = (
                1
                + (nbp >= 2) * rmi.txp2
                + (nbp >= 3) * rmi.txp3
                + (nbp >= 4) * ((nb_par == 1) * rmi.txps + (nb_par != 1) * rmi.txp3)
                + max_(nbp - 4, 0) * rmi.txps
            )
            return period, eligib * rmi.rmi * taux
Esempio n. 22
0
    def function(self, simulation, period):
        period = period.this_month

        ass_base_ressources = simulation.calculate('ass_base_ressources',
                                                   period)
        ass_eligibilite_i_holder = simulation.compute(
            'ass_eligibilite_individu', period)
        en_couple = simulation.calculate('en_couple', period)
        ass_params = simulation.legislation_at(
            period.start).prestations.minima_sociaux.ass

        ass_eligibilite_i = self.split_by_roles(ass_eligibilite_i_holder,
                                                roles=[CHEF, PART])

        elig = or_(ass_eligibilite_i[CHEF], ass_eligibilite_i[PART])
        montant_journalier = ass_params.montant_plein
        montant_mensuel = 30 * montant_journalier
        plafond_mensuel = montant_journalier * (
            ass_params.plaf_seul * not_(en_couple) +
            ass_params.plaf_coup * en_couple)
        revenus = ass_base_ressources / 12

        ass = min_(montant_mensuel, plafond_mensuel - revenus)
        ass = max_(ass, 0)
        ass = ass * elig
        ass = ass * not_(
            ass < ass_params.montant_plein
        )  # pas d'ASS si montant mensuel < montant journalier de base

        return period, ass
Esempio n. 23
0
    def function(famille, period, legislation):
        """
        Allocation de parent isolé
        """
        period = period.this_month
        isole = not_(famille('en_couple', period))
        rsa_forfait_logement = famille('rsa_forfait_logement', period)
        rsa_base_ressources = famille('rsa_base_ressources', period)
        af_majoration = famille('af_majoration', period)
        rsa = famille('rsa', period)
        af = legislation(period).prestations.prestations_familiales.af
        api = legislation(period).prestations.minima_sociaux.api

        # TODO:
        #    Majoration pour isolement
        #    Si vous êtes parent isolé, c’est-à-dire célibataire, divorcé(e), séparé(e) ou veuf(ve) avec des enfants
        #    à charge ou enceinte, le montant forfaitaire garanti est majoré.
        #    Ce montant forfaitaire majoré est accordé à partir du mois au cours duquel survient l'un des événements
        #    suivants :
        #    - déclaration de grossesse,
        #    - naissance d'un enfant,
        #    - prise en charge d'un enfant,
        #    - séparation, veuvage,
        #    - dépôt de la demande si l’événement est antérieur.
        #
        #    Le montant forfaitaire majoré peut être accordé pendant 12 mois, continus ou discontinus, au cours
        #    d’une période de 18 mois suivant l’événement.
        #    Si votre plus jeune enfant à charge a moins de 3 ans, le montant forfaitaire majoré vous est accordé
        #    jusqu'à ses 3 ans.
        age_en_mois_i = famille.members('age_en_mois', period)
        age_en_mois_benjamin = famille.min(age_en_mois_i, role=Famille.ENFANT)
        enceinte = (age_en_mois_benjamin < 0) * (age_en_mois_benjamin > -6)
        # TODO: quel mois mettre ?
        # TODO: pas complètement exact
        # L'allocataire perçoit l'API :
        # jusqu'�� ce que le plus jeune enfant ait 3 ans,
        # ou pendant 12 mois consécutifs si les enfants sont âgés de plus de 3 ans
        #    et s'il a présenté sa demande dans les 6 mois à partir du moment où il
        #    assure seul la charge de l'enfant.
        # TODO: API courte gens pour les gens qui ont divorcés dans l'année
        # Le droit à l'allocation est réétudié tous les 3 mois.
        # # Calcul de l'année et mois de naissance du benjamin

        condition = (floor(age_en_mois_benjamin / 12) <= api.age_limite - 1)
        eligib = isole * (
            (enceinte != 0) |
            (nb_enf(famille, period, 0, api.age_limite - 1) > 0)) * condition

        # moins de 20 ans avant inclusion dans rsa
        # moins de 25 ans après inclusion dans rsa
        api1 = eligib * af.bmaf * (
            api.base + api.supplement_par_enfant *
            nb_enf(famille, period, af.age1, api.age_pac - 1))
        rsa = (api.age_pac >= 25)  # dummy passage au rsa majoré
        br_api = rsa_base_ressources + af_majoration * not_(rsa)
        # On pourrait mensualiser RMI, BRrmi et forfait logement
        api = max_(0,
                   api1 - rsa_forfait_logement / 12 - br_api / 12 - rsa / 12)
        # L'API est exonérée de CRDS
        return period, api  # annualisé
Esempio n. 24
0
    def function(famille, period, legislation):
        period = period.this_month
        al = legislation(period).prestations.aides_logement
        couple = famille('al_couple', period)
        al_nb_pac = famille('al_nb_personnes_a_charge', period)
        residence_dom = famille.demandeur.menage('residence_dom')

        TF_metropole = (
            al.taux_participation_fam.taux_1_adulte * (not_(couple)) * (al_nb_pac == 0) +
            al.taux_participation_fam.taux_2_adulte * (couple) * (al_nb_pac == 0) +
            al.taux_participation_fam.taux_1_enf * (al_nb_pac == 1) +
            al.taux_participation_fam.taux_2_enf * (al_nb_pac == 2) +
            al.taux_participation_fam.taux_3_enf * (al_nb_pac == 3) +
            al.taux_participation_fam.taux_4_enf * (al_nb_pac >= 4) +
            al.taux_participation_fam.taux_enf_supp * (al_nb_pac > 4) * (al_nb_pac - 4)
            )

        TF_dom = (
            al.taux_participation_fam.dom.taux1 * (not_(couple)) * (al_nb_pac == 0) +
            al.taux_participation_fam.dom.taux2 * (couple) * (al_nb_pac == 0) +
            al.taux_participation_fam.dom.taux3 * (al_nb_pac == 1) +
            al.taux_participation_fam.dom.taux4 * (al_nb_pac == 2) +
            al.taux_participation_fam.dom.taux5 * (al_nb_pac == 3) +
            al.taux_participation_fam.dom.taux6 * (al_nb_pac == 4) +
            al.taux_participation_fam.dom.taux7 * (al_nb_pac == 5) +
            al.taux_participation_fam.dom.taux8 * (al_nb_pac >= 6)
            )

        return period, where(residence_dom, TF_dom, TF_metropole)
Esempio n. 25
0
    def function_2016(individu, period):
        period = period.this_month
        last_3_months = period.last_3_months

        # Note Auto-entrepreneurs:
        # D'après les caisses, le revenu pris en compte pour les AE pour le RSA ne prend en compte que
        # l'abattement standard sur le CA, mais pas les cotisations pour charges sociales.

        types_revenus_activite = [
            'salaire_net',
            'indemnites_chomage_partiel',
            'indemnites_volontariat',
            'revenus_stage_formation_pro',
            'bourse_recherche',
            'hsup',
            'etr',
            'tns_auto_entrepreneur_benefice',
            'rsa_indemnites_journalieres_activite',
        ]

        has_ressources_substitution = individu(
            'rsa_has_ressources_substitution', period)

        # Les revenus pros interrompus au mois M sont neutralisés s'il n'y a pas de revenus de substitution.
        return period, sum(
            individu(type_revenu, last_3_months, options=[ADD]) *
            not_((individu(type_revenu, period.this_month) == 0) *
                 (individu(type_revenu, period.last_month) > 0) *
                 not_(has_ressources_substitution))
            for type_revenu in types_revenus_activite) / 3
Esempio n. 26
0
    def function(self, simulation, period):
        period = period.this_month
        last_3_months = period.last_3_months

        # Note Auto-entrepreneurs:
        # D'après les caisses, le revenu pris en compte pour les AE pour le RSA ne prend en compte que
        # l'abattement standard sur le CA, mais pas les cotisations pour charges sociales.

        types_revenus_activite = [
            'salaire_net',
            'indemnites_chomage_partiel',
            'indemnites_volontariat',
            'revenus_stage_formation_pro',
            'bourse_recherche',
            'hsup',
            'etr',
            'tns_auto_entrepreneur_benefice',
            'rsa_indemnites_journalieres_activite',
            ]

        has_ressources_substitution = simulation.calculate('rsa_has_ressources_substitution', period)

        # Les revenus pros interrompus au mois M sont neutralisés s'il n'y a pas de revenus de substitution.
        return period, sum(
            simulation.calculate_add(type_revenu, last_3_months) * not_(
                (simulation.calculate(type_revenu, period.this_month) == 0) *
                (simulation.calculate(type_revenu, period.last_month) > 0) *
                not_(has_ressources_substitution)
                )
            for type_revenu in types_revenus_activite
            ) / 3
Esempio n. 27
0
    def function(self, simulation, period):
        '''
        type de menage
        'men'
        TODO: prendre les enfants du ménage et non ceux de la famille
        '''
        period = period.start.offset('first-of', 'month').period('year')
        isol_holder = simulation.compute('isol', period)
        af_nbenf_holder = simulation.compute('af_nbenf', period)

        af_nbenf = self.cast_from_entity_to_role(af_nbenf_holder, role=CHEF)
        af_nbenf = self.sum_by_entity(af_nbenf)
        isol = self.cast_from_entity_to_role(isol_holder, role=CHEF)
        isol = self.sum_by_entity(isol)

        _0_kid = af_nbenf == 0
        _1_kid = af_nbenf == 1
        _2_kid = af_nbenf == 2
        _3_kid = af_nbenf >= 3

        return period, (
            0 * (isol & _0_kid) +  # Célibataire
            1 * (not_(isol) & _0_kid) +  # Couple sans enfants
            2 * (not_(isol) & _1_kid) +  # Couple un enfant
            3 * (not_(isol) & _2_kid) +  # Couple deux enfants
            4 * (not_(isol) & _3_kid) +  # Couple trois enfants et plus
            5 * (isol & _1_kid) +  # Famille monoparentale un enfant
            6 * (isol & _2_kid) +  # Famille monoparentale deux enfants
            7 * (isol & _3_kid))  # Famille monoparentale trois enfants et plus
Esempio n. 28
0
def _br_al(etu, boursier, br_pf_i, rev_coll, biact, _P ,_option = {'boursier': [CHEF, PART], 'etu': [CHEF, PART], 'br_pf_i': [CHEF, PART]}):
    '''
    Base ressource des allocations logement
    '''
    # On ne considère que les revenus des 2 conjoints et les revenus non
    # individualisables
    #   0 - non étudiant
    #   1 - étudiant non boursier
    #   2 - éutidant boursier
    # revCatvous et self.conj : somme des revenus catégoriel après abatement
    # revColl : autres revenus du ménage non individualisable
    # ALabat : abatement prix en compte pour le calcul de la base ressources
    # des allocattions logement
    # plancher de ressources pour les etudiants
    P = _P
    Pr = P.al.ressources

    etuC = (etu[CHEF]) & (not_(etu[PART]))
    etuP = not_(etu[CHEF]) & (etu[PART])
    etuCP = (etu[CHEF]) & (etu[PART])
    # Boursiers
    # TODO: distinguer boursier foyer/boursier locatif
    etuCB = etu[CHEF]&boursier[CHEF]
    etuPB = etu[PART]&boursier[PART]
    # self.etu = (self.etu[CHEF]>=1)|(self.etuP>=1)

    revCatVous = max_(br_pf_i[CHEF],etuC*(Pr.dar_4-(etuCB)*Pr.dar_5))
    revCatConj = max_(br_pf_i[PART],etuP*(Pr.dar_4-(etuPB)*Pr.dar_5))
    revCatVsCj = not_(etuCP)*(revCatVous + revCatConj) + \
                    etuCP*max_(br_pf_i[CHEF] + br_pf_i[PART], Pr.dar_4 -(etuCB|etuPB)*Pr.dar_5 + Pr.dar_7)

    # TODO: ajouter les paramètres pour les étudiants en foyer (boursier et non boursier), les inclure dans le calcul
    # somme des revenus catégoriels après abatement
    revCat = revCatVsCj + rev_coll
    
    # TODO: charges déductibles : pension alimentaires et abatements spéciaux
    revNet = revCat

    # On ne considère pas l'abattement sur les ressources de certaines
    # personnes (enfant, ascendants ou grands infirmes).

    # abattement forfaitaire double activité
    abatDoubleAct = biact*Pr.dar_1

    # TODO: neutralisation des ressources
    # ...

    # TODO: abbattement sur les ressources
    # ...

    # TODO: évaluation forfaitaire des ressources (première demande)

    # TODO :double résidence pour raisons professionnelles

    # Base ressource des aides au logement (arrondies aux 100 euros supérieurs)

    br_al = ceil(max_(revNet - abatDoubleAct,0)/100)*100

    return br_al
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('month')
        three_previous_months = period.start.period('month', 3).offset(-3)
        aspa_elig = simulation.calculate('aspa_elig', period)
        aspa_couple_holder = simulation.compute('aspa_couple', period)
        salaire_de_base = simulation.calculate('salaire_de_base', three_previous_months)
        chonet = simulation.calculate('chonet', three_previous_months)
        rstbrut = simulation.calculate('rstbrut', three_previous_months)
        pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', three_previous_months)
        rto_declarant1 = simulation.calculate_add_divide('rto_declarant1', three_previous_months)
        rpns = simulation.calculate_add_divide('rpns', three_previous_months)
        rev_cap_bar_holder = simulation.compute_add_divide('rev_cap_bar', three_previous_months)
        rev_cap_lib_holder = simulation.compute_add_divide('rev_cap_lib', three_previous_months)
        rfon_ms = simulation.calculate_add_divide('rfon_ms', three_previous_months)
        div_ms = simulation.calculate_add_divide('div_ms', three_previous_months)
        revenus_stage_formation_pro = simulation.calculate('revenus_stage_formation_pro', three_previous_months)
        allocation_securisation_professionnelle = simulation.calculate('allocation_securisation_professionnelle', three_previous_months)
        prime_forfaitaire_mensuelle_reprise_activite = simulation.calculate('prime_forfaitaire_mensuelle_reprise_activite', three_previous_months)
        dedommagement_victime_amiante = simulation.calculate('dedommagement_victime_amiante', three_previous_months)
        prestation_compensatoire = simulation.calculate('prestation_compensatoire', three_previous_months)
        pensions_invalidite = simulation.calculate('pensions_invalidite', three_previous_months)
        gains_exceptionnels = simulation.calculate('gains_exceptionnels', three_previous_months)
        indemnites_journalieres_maternite = simulation.calculate('indemnites_journalieres_maternite', three_previous_months)
        indemnites_journalieres_maladie = simulation.calculate('indemnites_journalieres_maladie', three_previous_months)
        indemnites_journalieres_maladie_professionnelle = simulation.calculate('indemnites_journalieres_maladie_professionnelle', three_previous_months)
        indemnites_journalieres_accident_travail = simulation.calculate('indemnites_journalieres_accident_travail', three_previous_months)
        indemnites_chomage_partiel = simulation.calculate('indemnites_chomage_partiel', three_previous_months)
        indemnites_volontariat = simulation.calculate('indemnites_volontariat', three_previous_months)
        tns_total_revenus = simulation.calculate_add('tns_total_revenus', three_previous_months)
        rsa_base_ressources_patrimoine_i = simulation.calculate_add('rsa_base_ressources_patrimoine_i', three_previous_months)
        aah = simulation.calculate('aah', three_previous_months)

        legislation = simulation.legislation_at(period.start)
        leg_1er_janvier = simulation.legislation_at(period.start.offset('first-of', 'year'))

        aspa_couple = self.cast_from_entity_to_role(aspa_couple_holder, role = VOUS)
        rev_cap_bar = self.cast_from_entity_to_role(rev_cap_bar_holder, role = VOUS)
        rev_cap_lib = self.cast_from_entity_to_role(rev_cap_lib_holder, role = VOUS)

        # Inclus l'AAH si conjoint non pensionné ASPA, retraite et pension invalidité
        aah = aah * not_(aspa_elig)

        # Abattement sur les salaires (appliqué sur une base trimestrielle)
        abattement_forfaitaire_base = leg_1er_janvier.cotsoc.gen.smic_h_b * legislation.minim.aspa.abattement_forfaitaire_nb_h
        abattement_forfaitaire_taux = (aspa_couple * legislation.minim.aspa.abattement_forfaitaire_tx_couple +
            not_(aspa_couple) * legislation.minim.aspa.abattement_forfaitaire_tx_seul
            )
        abattement_forfaitaire = abattement_forfaitaire_base * abattement_forfaitaire_taux
        salaire_de_base = max_(0, salaire_de_base - abattement_forfaitaire)

        return period, (salaire_de_base + chonet + rstbrut + pensions_alimentaires_percues + rto_declarant1 + rpns +
               max_(0, rev_cap_bar) + max_(0, rev_cap_lib) + max_(0, rfon_ms) + max_(0, div_ms) +
               # max_(0,etr) +
               revenus_stage_formation_pro + allocation_securisation_professionnelle + prime_forfaitaire_mensuelle_reprise_activite +
               dedommagement_victime_amiante + prestation_compensatoire + pensions_invalidite + gains_exceptionnels +
               indemnites_journalieres_maternite + indemnites_journalieres_maladie + indemnites_journalieres_maladie_professionnelle +
               indemnites_journalieres_accident_travail + indemnites_chomage_partiel + indemnites_volontariat + tns_total_revenus +
               rsa_base_ressources_patrimoine_i + aah
               ) / 3
    def compare(self, seuil_abs = 100, seuil_rel = 0.10):
        '''
        Fonction qui comparent les calculs d'OF et et de TaxIPP
        Gestion des outputs
        '''
        dta_output = self.paths['dta_output']
        ipp_output = read_stata(dta_output).fillna(0)
        dta_input = self.paths['dta_input']
        ipp_input =  read_stata(dta_input).fillna(0)
        openfisca_output = self.openfisca_outputput.fillna(0)
        openfisca_input = self.simulation.input_table.table
        ipp2of_output_variables = self.dic_var_output

        check_list = ['csg_sal_ded', 'irpp_net_foy', 'af_foys'] # 'csg_sal_ded',
        print self.dic_param
        
        for ipp_var in check_list:
            of_var = ipp2of_output_variables[ipp_var]
            entity = self.simulation.prestation_by_name[of_var].entity
            
            if entity == 'ind':
                conflict = ((ipp_output[ipp_var] - openfisca_output[of_var].abs()).abs() < THRESHOLD)
                print conflict.to_string()
                print ipp_output.loc[not_(conflict), ipp_var].to_string()
                print openfisca_output.loc[not_(conflict), of_var].to_string()
                                
                print ipp_input.loc[not_(conflict), ].to_string()
                print openfisca_input.loc[not_(conflict), self.relevant_input_variables()].to_string()

                #error_diag()
                
                # TODO: finish by calling error_diag
            elif entity == "fam":
            
                pass
            
            
            elif entity == "foy":
                openfisca_foy = openfisca_output.loc[ openfisca_input.quifoy == 0, of_var]             
                ipp_foy = ipp_output.loc[ openfisca_input.quifoy == 0, ipp_var] 
                print ipp_foy

                conflict = ((ipp_foy - openfisca_foy.abs()).abs() > THRESHOLD)
                print conflict.to_string()
                
            elif entity == "men":
                pass
        def _diff(seuil_abs, seuil_rel):
            for k, v in dic.items() :
                diff_abs =  ipp_output[k].mean() - openfisca_output[v].mean()
                
                if diff_abs > seuil_abs :
                    print " Différence absolue pour ", k, ' : ', diff_abs

                diff_rel = (ipp_output.loc[(ipp_output[k] != 0) & (openfisca_output[v] != 0), k] /openfisca_output.loc[(ipp_output[k] != 0) & (openfisca_output[v] != 0), v] ).mean()

                if (diff_rel > seuil_rel) & (diff_rel is not None) :
                    print " Différence relative pour  ", k, ' : ', diff_rel
Esempio n. 31
0
    def function(famille, period):
        period = period.this_month
        pensions_alimentaires_percues = famille.members('pensions_alimentaires_percues', period)
        pas_de_pensions = not_(famille.sum(pensions_alimentaires_percues))

        isole = not_(famille('en_couple', period))
        residence_mayotte = famille.demandeur.menage('residence_mayotte', period)

        return period, not_(residence_mayotte) * isole * pas_de_pensions  # Parent isolé et ne résident pas à Mayotte
Esempio n. 32
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('month')
        pensions_alimentaires_percues_holder = simulation.compute('pensions_alimentaires_percues', period)
        pensions_alimentaires_percues = self.sum_by_entity(pensions_alimentaires_percues_holder)

        isol = simulation.calculate('isol', period)
        residence_mayotte = simulation.calculate('residence_mayotte', period)

        return period, not_(residence_mayotte) * isol * not_(pensions_alimentaires_percues)  # Parent isolé et ne résident pas à Mayotte
Esempio n. 33
0
    def function(famille, period):
        period = period.this_month
        pensions_alimentaires_percues = famille.members('pensions_alimentaires_percues', period)
        pas_de_pensions = not_(famille.sum(pensions_alimentaires_percues))

        isole = not_(famille('en_couple', period))
        residence_mayotte = famille.demandeur.menage('residence_mayotte', period)

        return period, not_(residence_mayotte) * isole * pas_de_pensions  # Parent isolé et ne résident pas à Mayotte
Esempio n. 34
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('month')
        two_years_ago = period.start.offset('first-of', 'year').period('year').offset(-2)
        etu_holder = simulation.compute('etu', period)
        boursier_holder = simulation.compute('boursier', period)
        br_pf_i_holder = simulation.compute('br_pf_i', two_years_ago)
        rev_coll_holder = simulation.compute('rev_coll', two_years_ago)
        biact = simulation.calculate('biact', period)
        Pr = simulation.legislation_at(period.start).al.ressources

        boursier = self.split_by_roles(boursier_holder, roles = [CHEF, PART])
        br_pf_i = self.split_by_roles(br_pf_i_holder, roles = [CHEF, PART])
        etu = self.split_by_roles(etu_holder, roles = [CHEF, PART])
        rev_coll = self.sum_by_entity(rev_coll_holder)
        etuC = (etu[CHEF]) & (not_(etu[PART]))
        etuP = not_(etu[CHEF]) & (etu[PART])
        etuCP = (etu[CHEF]) & (etu[PART])
        # Boursiers
        # TODO: distinguer boursier foyer/boursier locatif
        etuCB = etu[CHEF] & boursier[CHEF]
        etuPB = etu[PART] & boursier[PART]
        # self.etu = (self.etu[CHEF]>=1)|(self.etuP>=1)
        revCatVous = max_(br_pf_i[CHEF], etuC * (Pr.dar_4 - (etuCB) * Pr.dar_5))
        revCatConj = max_(br_pf_i[PART], etuP * (Pr.dar_4 - (etuPB) * Pr.dar_5))
        revCatVsCj = (
            not_(etuCP) * (revCatVous + revCatConj) +
            etuCP * max_(br_pf_i[CHEF] + br_pf_i[PART], Pr.dar_4 - (etuCB | etuPB) * Pr.dar_5 + Pr.dar_7)
            )

        # TODO: ajouter les paramètres pour les étudiants en foyer (boursier et non boursier),
        # les inclure dans le calcul somme des revenus catégoriels après abatement
        revCat = revCatVsCj + rev_coll

        # TODO: charges déductibles : pension alimentaires et abatements spéciaux
        revNet = revCat

        # On ne considère pas l'abattement sur les ressources de certaines
        # personnes (enfant, ascendants ou grands infirmes).

        # abattement forfaitaire double activité
        abatDoubleAct = biact * Pr.dar_1

        # TODO: neutralisation des ressources
        # ...

        # TODO: abbattement sur les ressources
        # ...

        # TODO: évaluation forfaitaire des ressources (première demande)

        # TODO :double résidence pour raisons professionnelles

        # Base ressource des aides au logement (arrondies aux 100 euros supérieurs)

        br_al = ceil(max_(revNet - abatDoubleAct, 0) / 100) * 100

        return period, br_al
Esempio n. 35
0
    def function(self, simulation, period):
        period = period.this_month
        pensions_alimentaires_percues_holder = simulation.compute('pensions_alimentaires_percues', period)
        pensions_alimentaires_percues = self.sum_by_entity(pensions_alimentaires_percues_holder)

        isole = not_(simulation.calculate('en_couple', period))
        residence_mayotte = simulation.calculate('residence_mayotte', period)

        return period, not_(residence_mayotte) * isole * not_(pensions_alimentaires_percues)  # Parent isolé et ne résident pas à Mayotte
Esempio n. 36
0
        def ouvre_droit_majoration():
            famille = individu.famille
            enceinte_fam = famille('enceinte_fam', period)
            isole = not_(famille('en_couple', period))
            isolement_recent = famille('rsa_isolement_recent', period)

            presence_autres_enfants = famille.sum(enfant * not_(autonomie_financiere) * (age <= age_pac)) > 1

            # individu.famille.sum retourne un résultat qui n'est pas implicitement projeté sur l'individu.
            return not_(enceinte_fam) * isole * isolement_recent * not_(famille.project(presence_autres_enfants))
Esempio n. 37
0
    def function(self, simulation, period):
        period = period.start.period('month').offset('first-of')

        cmu_c = simulation.calculate('cmu_c', period)
        cmu_base_ressources = simulation.calculate('cmu_base_ressources', period)
        acs_plafond = simulation.calculate('acs_plafond', period)
        acs_montant = simulation.calculate('acs_montant', period)
        residence_mayotte = simulation.calculate('residence_mayotte', period)

        return period, not_(residence_mayotte) * not_(cmu_c) * (cmu_base_ressources <= acs_plafond) * acs_montant / 12
Esempio n. 38
0
def _als_nonet(self, al, al_pac, etu_holder, so_holder, proprietaire_proche_famille):
    '''
    Allocation logement sociale (non étudiante)
    '''
    # variable ménage à redistribuer
    so = self.cast_from_entity_to_roles(so_holder)
    so = self.filter_role(so, role = CHEF)

    etu = self.split_by_roles(etu_holder, roles = [CHEF, PART])
    return (al_pac == 0) * (so != 3) * not_(proprietaire_proche_famille) * not_(etu[CHEF] | etu[PART]) * al
Esempio n. 39
0
    def function(individu, period, legislation):
        period = period.this_month

        # Revenus professionels
        types_revenus_pros = [
            'chomage_net',
            'retraite_nette',
            ]

        has_ressources_substitution = individu('rsa_has_ressources_substitution', period)

        # Les revenus pros interrompus au mois M sont neutralisés s'il n'y a pas de revenus de substitution.
        revenus_pro = sum(
            individu(type_revenu, period.last_3_months, options = [ADD]) * not_(
                (individu(type_revenu, period.this_month) == 0) *
                (individu(type_revenu, period.last_month) > 0) *
                not_(has_ressources_substitution)
                )
            for type_revenu in types_revenus_pros
            )

        types_revenus_non_pros = [
            'allocation_aide_retour_emploi',
            'allocation_securisation_professionnelle',
            'dedommagement_victime_amiante',
            'div_ms',
            'gains_exceptionnels',
            'pensions_alimentaires_percues',
            'pensions_invalidite',
            'prestation_compensatoire',
            'prime_forfaitaire_mensuelle_reprise_activite',
            'revenus_fonciers_minima_sociaux',
            'rsa_base_ressources_patrimoine_individu',
            'rsa_indemnites_journalieres_hors_activite',
            ]

        # Les revenus non-pro interrompus au mois M sont neutralisés dans la limite d'un montant forfaitaire,
        # sans condition de revenu de substitution.
        neutral_max_forfaitaire = 3 * legislation(period).prestations.minima_sociaux.rmi.rmi
        revenus_non_pros = sum(
            max_(0, individu(type_revenu, period.last_3_months, options = [ADD]) - neutral_max_forfaitaire * (
                (individu(type_revenu, period.this_month) == 0) *
                (individu(type_revenu, period.last_month) > 0)
                ))
            for type_revenu in types_revenus_non_pros
            )

        # Revenus du foyer fiscal que l'on projette sur le premier invidividus
        rev_cap_bar = max_(0, individu.foyer_fiscal('rev_cap_bar', period.last_3_months, options = [ADD]))
        rev_cap_lib = max_(0, individu.foyer_fiscal('rev_cap_lib', period.last_3_months, options = [ADD]))
        retraite_titre_onereux = individu.foyer_fiscal('retraite_titre_onereux', period.last_3_months, options = [ADD])
        revenus_foyer_fiscal = rev_cap_bar + rev_cap_lib + retraite_titre_onereux
        revenus_foyer_fiscal_projetes = revenus_foyer_fiscal * individu.has_role(FoyerFiscal.DECLARANT_PRINCIPAL)

        return period, (revenus_pro + revenus_non_pros + revenus_foyer_fiscal_projetes) / 3
Esempio n. 40
0
    def function(self, simulation, period):
        period = period.this_month
        effectif_entreprise = simulation.calculate('effectif_entreprise', period)
        apprenti = simulation.calculate('apprenti', period)
        contrat_de_travail_duree = simulation.calculate('contrat_de_travail_duree', period)
        contrat_de_travail_debut = simulation.calculate('contrat_de_travail_debut', period)
        contrat_de_travail_fin = simulation.calculate('contrat_de_travail_fin', period)
        coefficient_proratisation = simulation.calculate('coefficient_proratisation', period)
        exoneration_cotisations_employeur_jei = simulation.calculate('exoneration_cotisations_employeur_jei', period)

        # Cette aide est temporaire.
        # TODO : Si toutefois elle est reconduite et modifiée pour 2017, les dates et le montant seront à
        # implémenter comme des params xml.

        eligible_contrat = and_(
            contrat_de_travail_debut >= datetime64("2015-06-09"),
            contrat_de_travail_debut <= datetime64("2016-12-31")
            )
        # Si CDD, durée du contrat doit être > 1 an
        eligible_duree = or_(
            # durée indéterminée
            contrat_de_travail_duree == 0,
            # durée déterminée supérieure à 1 an
            and_(
                contrat_de_travail_duree == 1,  # CDD
                # > 6 mois
                (contrat_de_travail_fin - contrat_de_travail_debut).astype('timedelta64[M]') >= timedelta64(6, 'M')
                # Initialement, la condition était d'un contrat >= 12 mois,
                # pour les demandes transmises jusqu'au 26 janvier.
            )
        )

        eligible_date = datetime64(period.offset(-24, 'month').start) < contrat_de_travail_debut
        eligible = \
            (effectif_entreprise == 1) * not_(apprenti) * eligible_contrat * eligible_duree * eligible_date

        # somme sur 24 mois, à raison de 500 € maximum par trimestre
        montant_max = 4000

        # non cumul avec le dispositif Jeune Entreprise Innovante (JEI)
        non_cumulee = not_(exoneration_cotisations_employeur_jei)


        # TODO comment implémenter la condition "premier employé" ? L'effectif est insuffisant en cas de rupture
        # d'un premier contrat
        # Condition : l’entreprise n’a pas conclu de contrat de travail avec un salarié,
        # au-delà de la période d’essai, dans les 12 mois précédant la nouvelle
        # embauche.

        # Si le salarié est embauché à temps partiel,
        # l’aide est proratisée en fonction de sa durée de travail.
        # TODO cette multiplication par le coefficient de proratisation suffit-elle pour le cas du temps partiel ?
        # A tester
        return period, eligible * (montant_max / 24) * coefficient_proratisation * non_cumulee
Esempio n. 41
0
    def function(self, simulation, period):
        period = period.this_month
        age = simulation.calculate('age', period)
        autonomie_financiere = simulation.calculate('autonomie_financiere', period)
        date_naissance = simulation.calculate('date_naissance', period)
        ne_avant_2014 = datetime64('2014-04-01') > date_naissance
        age_limite = simulation.legislation_at(period.start).fam.paje.base.age

        # L'allocation de base est versée jusqu'au dernier jour du mois civil précédant
        # celui au cours duquel l'enfant atteint l'âge de 3 ans.
        return period, (age < age_limite) * not_(autonomie_financiere) * not_(ne_avant_2014)
Esempio n. 42
0
    def formula(famille, period):
        cmu_c = famille('cmu_c', period)
        cmu_base_ressources = famille('cmu_base_ressources', period)
        acs_plafond = famille('acs_plafond', period)
        acs_montant = famille('acs_montant', period)
        residence_mayotte = famille.demandeur.menage('residence_mayotte',
                                                     period)
        cmu_acs_eligibilite = famille('cmu_acs_eligibilite', period)

        return (cmu_acs_eligibilite * not_(residence_mayotte) * not_(cmu_c) *
                (cmu_base_ressources <= acs_plafond) * acs_montant)
Esempio n. 43
0
    def function(self, simulation, period):
        period = period.this_month
        age = simulation.calculate('age', period)
        smic55 = simulation.calculate('smic55', period)
        birth = simulation.calculate('birth', period)
        ne_avant_2014 = datetime64('2014-04-01') > birth
        age_limite = simulation.legislation_at(period.start).fam.paje.base.age

        # L'allocation de base est versée jusqu'au dernier jour du mois civil précédant
        # celui au cours duquel l'enfant atteint l'âge de 3 ans.
        return period, (age < age_limite) * not_(smic55) * not_(ne_avant_2014)
Esempio n. 44
0
def age_aine(ages, smic55, ag1, ag2):
    '''
    renvoi un vecteur avec l'âge de l'ainé (au sens des allocations
    familiales) de chaque famille
    '''
    ageaine = -9999
    for key, age in ages.iteritems():
        ispacaf = ((ag1 <= age) & (age <= ag2)) * not_(smic55[key])
        isaine = ispacaf & (age > ageaine)
        ageaine = isaine * age + not_(isaine) * ageaine
    return ageaine
Esempio n. 45
0
    def function(individu, period, legislation):
        period = period.this_month
        age = individu('age', period)
        autonomie_financiere = individu('autonomie_financiere', period)
        date_naissance = individu('date_naissance', period)
        ne_avant_2014 = datetime64('2014-04-01') > date_naissance
        age_limite = legislation(period.start).prestations.prestations_familiales.paje.base.age_max_enfant

        # L'allocation de base est versée jusqu'au dernier jour du mois civil précédant
        # celui au cours duquel l'enfant atteint l'âge de 3 ans.
        return period, (age < age_limite) * not_(autonomie_financiere) * not_(ne_avant_2014)
Esempio n. 46
0
    def function(self, simulation, period):
        period = period.this_month
        effectif_entreprise = simulation.calculate('effectif_entreprise', period)
        apprenti = simulation.calculate('apprenti', period)
        contrat_de_travail_duree = simulation.calculate('contrat_de_travail_duree', period)
        contrat_de_travail_debut = simulation.calculate('contrat_de_travail_debut', period)
        contrat_de_travail_fin = simulation.calculate('contrat_de_travail_fin', period)
        coefficient_proratisation = simulation.calculate('coefficient_proratisation', period)
        exoneration_cotisations_employeur_jei = simulation.calculate('exoneration_cotisations_employeur_jei', period)

        # Cette aide est temporaire.
        # TODO : Si toutefois elle est reconduite et modifiée pour 2017, les dates et le montant seront à
        # implémenter comme des params xml.

        eligible_contrat = and_(
            contrat_de_travail_debut >= datetime64("2015-06-09"),
            contrat_de_travail_debut <= datetime64("2016-12-31")
            )
        # Si CDD, durée du contrat doit être > 1 an
        eligible_duree = or_(
            # durée indéterminée
            contrat_de_travail_duree == 0,
            # durée déterminée supérieure à 1 an
            and_(
                contrat_de_travail_duree == 1,  # CDD
                # > 6 mois
                (contrat_de_travail_fin - contrat_de_travail_debut).astype('timedelta64[M]') >= timedelta64(6, 'M')
                # Initialement, la condition était d'un contrat >= 12 mois,
                # pour les demandes transmises jusqu'au 26 janvier.
            )
        )

        eligible_date = datetime64(period.offset(-24, 'month').start) < contrat_de_travail_debut
        eligible = \
            (effectif_entreprise == 1) * not_(apprenti) * eligible_contrat * eligible_duree * eligible_date

        # somme sur 24 mois, à raison de 500 € maximum par trimestre
        montant_max = 4000

        # non cumul avec le dispositif Jeune Entreprise Innovante (JEI)
        non_cumulee = not_(exoneration_cotisations_employeur_jei)


        # TODO comment implémenter la condition "premier employé" ? L'effectif est insuffisant en cas de rupture
        # d'un premier contrat
        # Condition : l’entreprise n’a pas conclu de contrat de travail avec un salarié,
        # au-delà de la période d’essai, dans les 12 mois précédant la nouvelle
        # embauche.

        # Si le salarié est embauché à temps partiel,
        # l’aide est proratisée en fonction de sa durée de travail.
        # TODO cette multiplication par le coefficient de proratisation suffit-elle pour le cas du temps partiel ?
        # A tester
        return period, eligible * (montant_max / 24) * coefficient_proratisation * non_cumulee
Esempio n. 47
0
def age_aine(ages, smic55, ag1, ag2):
    '''
    renvoi un vecteur avec l'âge de l'ainé (au sens des allocations
    familiales) de chaque famille
    '''
    ageaine = -9999
    for key, age in ages.iteritems():
        ispacaf = ((ag1 <= age) & (age <= ag2)) * not_(smic55[key])
        isaine = ispacaf & (age > ageaine)
        ageaine = isaine * age + not_(isaine) * ageaine
    return ageaine
Esempio n. 48
0
    def function(self, simulation, period):
        period = period.this_month
        age = simulation.calculate('age', period)
        autonomie_financiere = simulation.calculate('autonomie_financiere', period)
        date_naissance = simulation.calculate('date_naissance', period)
        ne_avant_2014 = datetime64('2014-04-01') > date_naissance
        age_limite = simulation.legislation_at(period.start).prestations.prestations_familiales.paje.base.age_max_enfant

        # L'allocation de base est versée jusqu'au dernier jour du mois civil précédant
        # celui au cours duquel l'enfant atteint l'âge de 3 ans.
        return period, (age < age_limite) * not_(autonomie_financiere) * not_(ne_avant_2014)
Esempio n. 49
0
        def ouvre_droit_majoration():
            famille = individu.famille
            enceinte_fam = famille('enceinte_fam', period)
            isole = not_(famille('en_couple', period))
            isolement_recent = famille('rsa_isolement_recent', period)

            presence_autres_enfants = famille.sum(
                enfant * not_(autonomie_financiere) * (age <= age_pac)) > 1

            # individu.famille.sum retourne un résultat qui n'est pas implicitement projeté sur l'individu.
            return not_(enceinte_fam) * isole * isolement_recent * not_(
                famille.project(presence_autres_enfants))
Esempio n. 50
0
    def function(self, simulation, period):
        period = period.this_month

        cmu_c = simulation.calculate('cmu_c', period)
        cmu_base_ressources = simulation.calculate('cmu_base_ressources',
                                                   period)
        acs_plafond = simulation.calculate('acs_plafond', period)
        acs_montant = simulation.calculate('acs_montant', period)
        residence_mayotte = simulation.calculate('residence_mayotte', period)

        return period, not_(residence_mayotte) * not_(cmu_c) * (
            cmu_base_ressources <= acs_plafond) * acs_montant / 12
Esempio n. 51
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('month')
        asi_elig_holder = simulation.compute('asi_elig', period)
        aspa_elig_holder = simulation.compute('aspa_elig', period)
        maries = simulation.calculate('maries', period)
        concub = simulation.calculate('concub', period)
        asi_aspa_nb_alloc = simulation.calculate('asi_aspa_nb_alloc', period)
        br_mv = simulation.calculate('br_mv', period)
        P = simulation.legislation_at(period.start).minim

        asi_elig = self.split_by_roles(asi_elig_holder, roles = [CHEF, PART])
        aspa_elig = self.split_by_roles(aspa_elig_holder, roles = [CHEF, PART])

        # Un seul éligible
        elig1 = ((asi_aspa_nb_alloc == 1) & (asi_elig[CHEF] | asi_elig[PART]))
        # Couple d'éligibles mariés
        elig2 = asi_elig[CHEF] & asi_elig[PART] & maries
        # Couple d'éligibles non mariés
        elig3 = asi_elig[CHEF] & asi_elig[PART] & not_(maries)
        # Un seul éligible et époux éligible ASPA
        elig4 = ((asi_elig[CHEF] & aspa_elig[PART]) | (asi_elig[PART] & aspa_elig[CHEF])) & maries
        # Un seul éligible et conjoint non marié éligible ASPA
        elig5 = ((asi_elig[CHEF] & aspa_elig[PART]) | (asi_elig[PART] & aspa_elig[CHEF])) & not_(maries)

        elig = elig1 | elig2 | elig3 | elig4 | elig5

        montant_max = (elig1 * P.asi.montant_seul +
            elig2 * P.asi.montant_couple +
            elig3 * 2 * P.asi.montant_seul +
            elig4 * (P.asi.montant_couple / 2 + P.aspa.montant_couple / 2) +
            elig5 * (P.asi.montant_seul + P.aspa.montant_couple / 2)) / 12

        ressources = br_mv + montant_max

        plafond_ressources = (elig1 * (P.asi.plaf_seul * not_(concub) + P.asi.plaf_couple * concub) +
            elig2 * P.asi.plaf_couple +
            elig3 * P.asi.plaf_couple +
            elig4 * P.aspa.plaf_couple +
            elig5 * P.aspa.plaf_couple) / 12

        depassement = max_(ressources - plafond_ressources, 0)

        diff = ((elig1 | elig2 | elig3) * (montant_max - depassement) +
            elig4 * (P.asi.montant_couple / 12 / 2 - depassement / 2) +
            elig5 * (P.asi.montant_seul / 12 - depassement / 2))

        # Montant mensuel servi (sous réserve d'éligibilité)
        montant_servi_asi = max_(diff, 0)

        # TODO: Faute de mieux, on verse l'asi à la famille plutôt qu'aux individus
        # asi[CHEF] = asi_elig[CHEF]*montant_servi_asi*(elig1*1 + elig2/2 + elig3/2)
        # asi[PART] = asi_elig[PART]*montant_servi_asi*(elig1*1 + elig2/2 + elig3/2)
        return period, elig * montant_servi_asi
Esempio n. 52
0
    def function(self, simulation, period):
        period = period.this_month
        pensions_alimentaires_percues_holder = simulation.compute(
            'pensions_alimentaires_percues', period)
        pensions_alimentaires_percues = self.sum_by_entity(
            pensions_alimentaires_percues_holder)

        isole = not_(simulation.calculate('en_couple', period))
        residence_mayotte = simulation.calculate('residence_mayotte', period)

        return period, not_(residence_mayotte) * isole * not_(
            pensions_alimentaires_percues
        )  # Parent isolé et ne résident pas à Mayotte
Esempio n. 53
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('year')
        this_month = period.start.period('month')
        cmu_c = simulation.calculate('cmu_c', this_month)
        cmu_base_ressources = simulation.calculate('cmu_base_ressources',
                                                   this_month)
        acs_plafond = simulation.calculate('acs_plafond', this_month)
        acs_montant = simulation.calculate('acs_montant', this_month)
        residence_mayotte = simulation.calculate('residence_mayotte',
                                                 this_month)

        return period, not_(residence_mayotte) * not_(cmu_c) * (
            cmu_base_ressources <= acs_plafond) * acs_montant
Esempio n. 54
0
    def function(famille, period, legislation):
        '''
        L'allocation de base de la paje n'est pas cumulable avec le complément familial
        '''
        period = period.this_month
        paje_base = famille('paje_base', period)
        apje_avant_cumul = famille('apje_avant_cumul', period)
        ape_avant_cumul = famille('ape_avant_cumul', period)
        cf_montant = famille('cf_montant', period)
        residence_mayotte = famille.demandeur.menage('residence_mayotte', period)

        cf_brut = not_(paje_base) * (apje_avant_cumul <= cf_montant) * (ape_avant_cumul <= cf_montant) * cf_montant
        return period, not_(residence_mayotte) * round(cf_brut, 2)
Esempio n. 55
0
    def function_2013_(self, simulation, period):
        period = period.this_month
        assiette_allegement = simulation.calculate('assiette_allegement', period)
        jeune_entreprise_innovante = simulation.calculate('jeune_entreprise_innovante', period)
        smic_proratise = simulation.calculate('smic_proratise', period)
        stagiaire = simulation.calculate('stagiaire', period)
        legislation = simulation.legislation_at(period.start)
        taux_cice = taux_exo_cice(assiette_allegement, smic_proratise, legislation)
        credit_impot_competitivite_emploi = taux_cice * assiette_allegement
        non_cumul = not_(stagiaire)
        association = simulation.calculate('entreprise_est_association_non_lucrative', period)

        return period, credit_impot_competitivite_emploi * non_cumul * not_(association)
Esempio n. 56
0
    def function(self, simulation, period):
        period = period.this_month
        aide_logement_montant = simulation.calculate('aide_logement_montant', period)
        al_nb_pac = simulation.calculate('al_nb_personnes_a_charge', period)
        etudiant_holder = simulation.compute('etudiant', period)
        statut_occupation_logement = simulation.calculate('statut_occupation_logement_famille', period)
        proprietaire_proche_famille = simulation.calculate('proprietaire_proche_famille', period)

        etudiant = self.split_by_roles(etudiant_holder, roles = [CHEF, PART])
        return period, (
            (al_nb_pac == 0) * (statut_occupation_logement != 3) * not_(proprietaire_proche_famille) *
            not_(etudiant[CHEF] | etudiant[PART]) * aide_logement_montant
        )
Esempio n. 57
0
    def function(self, simulation, period):
        '''
        L'allocation de base de la paje n'est pas cumulable avec le complément familial
        '''
        period = period.this_month
        paje_base = simulation.calculate('paje_base', period)
        apje_avant_cumul = simulation.calculate('apje_avant_cumul', period)
        ape_avant_cumul = simulation.calculate('ape_avant_cumul', period)
        cf_montant = simulation.calculate('cf_montant', period)
        residence_mayotte = simulation.calculate('residence_mayotte', period)

        cf_brut = not_(paje_base) * (apje_avant_cumul <= cf_montant) * (
            ape_avant_cumul <= cf_montant) * cf_montant
        return period, not_(residence_mayotte) * round(cf_brut, 2)
    def function(famille, period):
        period = period.this_month
        aide_logement_montant = famille('aide_logement_montant', period)
        al_nb_pac = famille('al_nb_personnes_a_charge', period)
        statut_occupation_logement = famille.demandeur.menage(
            'statut_occupation_logement', period)
        proprietaire_proche_famille = famille('proprietaire_proche_famille',
                                              period)

        etudiant = famille.members('etudiant', period)
        no_parent_etudiant = not_(famille.any(etudiant, role=Famille.PARENT))

        return period, ((al_nb_pac == 0) * (statut_occupation_logement != 3) *
                        not_(proprietaire_proche_famille) *
                        no_parent_etudiant * aide_logement_montant)
Esempio n. 59
0
def _aspa_pure(aspa_elig,
               marpac,
               concub,
               maries,
               asi_aspa_nb_alloc,
               br_mv,
               _P,
               _option={'aspa_elig': [CHEF, PART]}):
    '''
    Calcule l'ASPA lorsqu'il y a un ou deux bénéficiaire de l'ASPA et aucun bénéficiaire de l'ASI
    '''
    # La notion de couple change au 1er janvier 2007 (réforme de 2006)
    if _P.datesim.year >= 2007:
        couple = marpac | concub
    else:
        couple = maries

    P = _P.minim

    elig1 = ((asi_aspa_nb_alloc == 1) & (aspa_elig[CHEF] | aspa_elig[PART]))
    elig2 = (aspa_elig[CHEF]
             & aspa_elig[PART]) * couple  # couple d'allocataire
    #     elig = elig1 | elig2
    #
    #     montant_max = elig1 * P.aspa.montant_seul + elig2 * P.aspa.montant_couple
    #     ressources = elig * (br_mv + montant_max)
    #     plafond_ressources = elig1 * (P.aspa.plaf_seul * not_(couple) + P.aspa.plaf_couple * couple) + elig2 * P.aspa.plaf_couple
    #     depassement = ressources - plafond_ressources
    #
    #     montant_servi_aspa = max_(montant_max - depassement, 0) / 12

    diff_plaf = P.aspa.plaf_couple - P.aspa.plaf_seul

    plafond_ressources = (elig1 * not_(couple)) * P.aspa.plaf_seul + (
        elig2 | elig1 * couple) * P.aspa.plaf_couple
    montant_max = (elig1 * not_(couple)
                   ) * P.aspa.montant_seul + elig2 * P.aspa.montant_couple + (
                       elig1 * couple) * (
                           (br_mv <= diff_plaf) *
                           (P.aspa.montant_seul + br_mv) +
                           (br_mv > diff_plaf) * P.aspa.montant_couple)
    montant_servi_aspa = max_(montant_max - br_mv,
                              0) * (br_mv <= plafond_ressources) / 12
    # TODO: Faute de mieux, on verse l'aspa à la famille plutôt qu'aux individus
    # aspa[CHEF] = aspa_elig[CHEF]*montant_servi_aspa*(elig1 + elig2/2)
    # aspa[PART] = aspa_elig[PART]*montant_servi_aspa*(elig1 + elig2/2)
    elig_indiv = (aspa_elig[CHEF] + aspa_elig[PART])
    return 12 * elig_indiv * montant_servi_aspa * (elig1 + elig2)  # annualisé