Ejemplo n.º 1
0
    def function(self, simulation, period):
        period = period.this_month
        chomage_brut = simulation.calculate('chomage_brut', period)
        csg_imposable_chomage = simulation.calculate('csg_imposable_chomage',
                                                     period)
        taux_csg_remplacement = simulation.calculate('taux_csg_remplacement',
                                                     period)
        law = simulation.legislation_at(period.start)
        montant_csg = montant_csg_crds(
            base_avec_abattement=chomage_brut,
            indicatrice_taux_plein=(taux_csg_remplacement == 3),
            indicatrice_taux_reduit=(taux_csg_remplacement == 2),
            law_node=law.csg.chomage.deductible,
            plafond_securite_sociale=law.cotsoc.gen.plafond_securite_sociale,
        )
        nbh_travail = 35 * 52 / 12  # = 151.67  # TODO: depuis 2001 mais avant ?
        cho_seuil_exo = law.csg.chomage.min_exo * nbh_travail * law.cotsoc.gen.smic_h_b
        csg_deductible_chomage = max_(
            -montant_csg - max_(
                cho_seuil_exo -
                (chomage_brut + csg_imposable_chomage + montant_csg), 0),
            0,
        )

        return period, -csg_deductible_chomage
Ejemplo n.º 2
0
 def calculate(self, base, getT = False):
     '''
     Computes the tax using a a nonlinear tax scale using marginal tax rates
     Note: base is the base of the tax, in column
     '''
     k = self.nb
     n = len(base)
     if not self._linear_avg_rate:
         assi = np.tile(base, (k, 1)).T
         seui = np.tile(np.hstack((self.thresholds, np.inf)), (n, 1))
         a = max_(min_(assi, seui[:, 1:]) - seui[:, :-1], 0)
         i = np.dot(self.rates, a.T)
         if getT:
             t = np.squeeze(max_(np.dot((a > 0), np.ones((k, 1))) - 1, 0))
             return i, t
         else:
             return i
     else:
         if len(self.rates_average) == 1:
             i = base * self.rates_average[0]
         else:
             assi = np.tile(base, (k - 1, 1)).T
             seui = np.tile(np.hstack(self.thresholds), (n, 1))
             k = self.t_x().T
             a = (assi >= seui[:, :-1]) * (assi < seui[:, 1:])
             A = np.dot(a, self.t_x().T)
             B = np.dot(a, np.array(self.thresholds[1:]))
             C = np.dot(a, np.array(self.rates_average[:-1]))
             i = base * (A * (base - B) + C) + max_(base - self.thresholds[-1], 0) * self.rates_average[-1] + (base >= self.thresholds[-1]) * self.thresholds[-1] * self.rates_average[-2]
         if getT:
             t = np.squeeze(max_(np.dot((a > 0), np.ones((k, 1))) - 1, 0))
             return i, t
         else:
             return i
Ejemplo n.º 3
0
 def calc(self, assiette, getT = False):
     '''
     Calcule un impôt selon le barême non linéaire exprimé en tranches de taux marginaux.
     'assiette' est l'assiette de l'impôt, en colonne
     '''
     k = self.nb
     n = len(assiette)
     if not self._linear_taux_moy:
         assi = np.tile(assiette, (k, 1)).T
         seui = np.tile(np.hstack((self.seuils, np.inf)), (n, 1))
         a = max_(min_(assi, seui[:, 1:]) - seui[:, :-1], 0)
         i = np.dot(self.taux, a.T)
         if getT:
             t = np.squeeze(max_(np.dot((a > 0), np.ones((k, 1))) - 1, 0))
             return i, t
         else:
             return i
     else:
         if len(self.tauxM) == 1:
             i = assiette * self.tauxM[0]
         else:
             assi = np.tile(assiette, (k - 1, 1)).T
             seui = np.tile(np.hstack(self.seuils), (n, 1))
             k = self.t_x().T
             a = (assi >= seui[:, :-1]) * (assi < seui[:, 1:])
             A = np.dot(a, self.t_x().T)
             B = np.dot(a, np.array(self.seuils[1:]))
             C = np.dot(a, np.array(self.tauxM[:-1]))
             i = assiette * (A * (assiette - B) + C) + max_(assiette - self.seuils[-1], 0) * self.tauxM[-1] + (assiette >= self.seuils[-1]) * self.seuils[-1] * self.tauxM[-2]
         if getT:
             t = np.squeeze(max_(np.dot((a > 0), np.ones((k, 1))) - 1, 0))
             return i, t
         else:
             return i
Ejemplo n.º 4
0
def _aged(age,
          smic55,
          br_pf,
          ape_taux_partiel,
          dep_trim,
          _P,
          _option={
              'age': ENFS,
              'smic55': ENFS
          }):
    '''
    Allocation garde d'enfant à domicile
    '''
    # TODO: trimestrialiser
    # les deux conjoints actif et revenu min requis
    # A complêter

    P = _P.fam
    nbenf = nb_enf(age, smic55, 0, P.aged.age1 - 1)
    nbenf2 = nb_enf(age, smic55, 0, P.aged.age2 - 1)
    elig1 = (nbenf > 0)
    elig2 = not_(elig1) * (nbenf2 > 0) * ape_taux_partiel
    depenses = 4 * dep_trim  # gérer les dépenses trimestrielles
    aged3 = elig1 * (
        max_(P.aged.remb_plaf1 - P.aged.remb_taux1 * depenses, 0) *
        (br_pf > P.aged.revenus_plaf) + (br_pf <= P.aged.revenus_plaf) *
        max_(P.aged.remb_taux2 * depenses - P.aged.remb_plaf1, 0))
    aged6 = elig2 * max_(P.aged.remb_taux2 * depenses - P.aged.remb_plaf2, 0)
    return 12 * (aged3 + aged6)  # annualisé
Ejemplo n.º 5
0
def _ars(age, smic55, br_pf, _P, _option={'age': ENFS, 'smic55': ENFS}):
    '''
    Allocation de rentrée scolaire
    '''
    # TODO convention sur la mensualisation
    # On tient compte du fait qu'en cas de léger dépassement du plafond, une allocation dégressive
    # (appelée allocation différentielle), calculée en fonction des revenus, peut être versée.

    # TODO à partir de 2008, les taux sont différenciés suivant l'âge.
    P = _P.fam
    bmaf = P.af.bmaf
    # On prend l'âge en septembre
    enf_05 = nb_enf(age, smic55, P.ars.agep - 1,
                    P.ars.agep - 1)  # 6 ans avant le 31 janvier
    # Un enfant scolarisé qui n'a pas encore atteint l'âge de 6 ans
    # avant le 1er février 2012 peut donner droit à l'ARS à condition qu'il
    # soit inscrit à l'école primaire. Il faudra alors présenter un
    # certificat de scolarité.
    enf_primaire = enf_05 + nb_enf(age, smic55, P.ars.agep, P.ars.agec - 1)
    enf_college = nb_enf(age, smic55, P.ars.agec, P.ars.agel - 1)
    enf_lycee = nb_enf(age, smic55, P.ars.agel, P.ars.ages)

    arsnbenf = enf_primaire + enf_college + enf_lycee

    ars_plaf_res = P.ars.plaf * (1 + arsnbenf * P.ars.plaf_enf_supp)
    arsbase = bmaf * (P.ars.tx0610 * enf_primaire +
                      P.ars.tx1114 * enf_college + P.ars.tx1518 * enf_lycee)
    # Forme de l'ARS  en fonction des enfants a*n - (rev-plaf)/n
    ars = max_(
        0, (ars_plaf_res + arsbase * arsnbenf - max_(br_pf, ars_plaf_res)) /
        max_(1, arsnbenf))
    return ars * (ars >= P.ars.seuil_nv)
Ejemplo n.º 6
0
def _apje(br_pf,
          age,
          smic55,
          isol,
          biact,
          _P,
          _option={
              'age': ENFS,
              'smic55': ENFS
          }):
    '''
    Allocation pour jeune enfant
    '''
    # TODO: APJE courte voir doc ERF 2006
    P = _P.fam
    nbenf = nb_enf(age, smic55, 0, P.apje.age - 1)
    bmaf = P.af.bmaf
    bmaf_n_2 = P.af.bmaf_n_2
    base = round(P.apje.taux * bmaf, 2)
    base2 = round(P.apje.taux * bmaf_n_2, 2)

    plaf_tx = (nbenf > 0) + P.apje.plaf_tx1 * min_(
        nbenf, 2) + P.apje.plaf_tx2 * max_(nbenf - 2, 0)
    majo = isol | biact
    plaf = P.apje.plaf * plaf_tx + P.apje.plaf_maj * majo
    plaf2 = plaf + 12 * base2

    apje = (nbenf >= 1) * ((br_pf <= plaf) * base +
                           (br_pf > plaf) * max_(plaf2 - br_pf, 0) / 12.0)
    # Non cummul APE APJE CF
    #  - L’allocation parentale d’éducation (APE), sauf pour les femmes enceintes.
    #    L’APJE est alors versée du 5ème mois de grossesse jusqu’à la naissance de l’enfant.
    #  - Le CF
    return 12 * apje  # annualisé
Ejemplo n.º 7
0
 def function(individu, period, legislation):
     period = period.this_month
     chomage_brut = individu('chomage_brut', period)
     csg_imposable_chomage = individu('csg_imposable_chomage', period)
     taux_csg_remplacement = individu('taux_csg_remplacement', period)
     legislation = legislation(period.start)
     montant_csg = montant_csg_crds(
         base_avec_abattement=chomage_brut,
         indicatrice_taux_plein=(taux_csg_remplacement == 3),
         indicatrice_taux_reduit=(taux_csg_remplacement == 2),
         law_node=legislation.prelevements_sociaux.contributions.csg.
         chomage.deductible,
         plafond_securite_sociale=legislation.cotsoc.gen.
         plafond_securite_sociale,
     )
     nbh_travail = 35 * 52 / 12  # = 151.67  # TODO: depuis 2001 mais avant ?
     cho_seuil_exo = (
         legislation.prelevements_sociaux.contributions.csg.chomage.min_exo
         * nbh_travail * legislation.cotsoc.gen.smic_h_b)
     csg_deductible_chomage = max_(
         -montant_csg - max_(
             cho_seuil_exo -
             (chomage_brut + csg_imposable_chomage + montant_csg), 0),
         0,
     )
     return period, -csg_deductible_chomage
Ejemplo n.º 8
0
    def function(self, simulation, period):
        period = period.this_month
        chomage_brut = simulation.calculate('chomage_brut', period)
        csg_deductible_chomage = simulation.calculate('csg_deductible_chomage', period)
        csg_imposable_chomage = simulation.calculate('csg_imposable_chomage', period)
        taux_csg_remplacement = simulation.calculate('taux_csg_remplacement', period)
        law = simulation.legislation_at(period.start)

        smic_h_b = law.cotsoc.gen.smic_h_b
        # salaire_mensuel_reference = chomage_brut / .7
        # heures_mensuelles = min_(salaire_mensuel_reference / smic_h_b, 35 * 52 / 12)  # TODO: depuis 2001 mais avant ?
        heures_mensuelles = 35 * 52 / 12
        cho_seuil_exo = law.csg.chomage.min_exo * heures_mensuelles * smic_h_b

        montant_crds = montant_csg_crds(
            base_avec_abattement = chomage_brut,
            law_node = law.crds.activite,
            plafond_securite_sociale = law.cotsoc.gen.plafond_securite_sociale,
            ) * (2 <= taux_csg_remplacement)

        crds_chomage = max_(
            -montant_crds - max_(
                cho_seuil_exo - (chomage_brut + csg_imposable_chomage + csg_deductible_chomage + montant_crds), 0
                ), 0
            )
        return period, -crds_chomage
Ejemplo n.º 9
0
def _aidper(marpac, nb_pac2, f7wf, f7wi, f7wj, f7wl, f7sf, f7si, _P):
    '''
    Crédits d’impôt pour dépenses en faveur de l’aide aux personnes
    (cases 7WI, 7WJ, 7WL et 7SF).
    2002-
    '''
    P = _P.ir.credits_impot.aidper

    n = nb_pac2
    if _P.datesim.year <= 2005:
        max0 = P.max * (1 + marpac) + P.pac1 * (n >= 1) + P.pac2 * (
            n >= 2) + P.pac2 * (max_(n - 2, 0))

    elif _P.datesim.year >= 2006:
        max0 = P.max * (1 + marpac) + P.pac1 * n

    if _P.datesim.year in (2002, 2003):
        return P.taux_wi * min_(f7wi,
                                max0)  # TODO: enfant en résidence altérnée
    elif _P.datesim.year <= 2009:
        max1 = max_(0, max0 - f7wj)
        return (P.taux_wj * min_(f7wj, max0) + P.taux_wi * min_(f7wi, max1))
    elif _P.datesim.year == 2010:
        max1 = max_(0, max0 - f7wl)
        max2 = max_(0, max1 - f7sf)
        max3 = max_(0, max2 - f7wj)
        return (P.taux_wl * min_(f7wl, max0) + P.taux_sf * min_(f7sf, max1) +
                P.taux_wj * min_(f7wj, max2) + P.taux_wi * min_(f7si, max3))
    else:
        return 0 * marpac  # TODO 2011, 2012, 2013
Ejemplo n.º 10
0
    def function(self, simulation, period):
        period = period.this_month
        rev_coll_holder = simulation.compute('rev_coll', period.n_2)
        rev_coll = self.sum_by_entity(rev_coll_holder)
        biact = simulation.calculate('biact', period)
        Pr = simulation.legislation_at(period.start).al.ressources
        br_pf_i_holder = simulation.compute('br_pf_i', period)
        br_pf_parents = self.sum_by_entity(br_pf_i_holder, roles = [CHEF, PART])
        abattement_chomage_indemnise_holder = simulation.compute('aide_logement_abattement_chomage_indemnise', period)
        abattement_chomage_indemnise = self.sum_by_entity(abattement_chomage_indemnise_holder, roles = [CHEF, PART])
        abattement_depart_retraite_holder = simulation.compute('aide_logement_abattement_depart_retraite', period)
        abattement_depart_retraite = self.sum_by_entity(abattement_depart_retraite_holder, roles = [CHEF, PART])
        neutralisation_rsa = simulation.calculate('aide_logement_neutralisation_rsa', period)
        abattement_ressources_enfant = simulation.legislation_at(period.n_2.stop).minim.aspa.plaf_seul * 1.25
        br_enfants = self.sum_by_entity(
            max_(0, br_pf_i_holder.array - abattement_ressources_enfant), roles = ENFS)
        ressources = (
            br_pf_parents + br_enfants + rev_coll -
            (abattement_chomage_indemnise + abattement_depart_retraite + neutralisation_rsa)
        )

        # Abattement forfaitaire pour double activité
        abattement_double_activite = biact * Pr.dar_1

        # Arrondi aux 100 euros supérieurs
        result = max_(ressources - abattement_double_activite, 0)

        return period, result
Ejemplo n.º 11
0
def _plus_value_nette(plus_value_brute, dur_det_immo, _P):
    """
    Calcul de la plus value immobilière nette
    """
    # 40. ABATTEMENT POUR DUREE DE DETENTION
    # 41. NOMBRE D’ANNEES DE DETENTION AU-DELA DE LA 5EME ANNEE
    P = _P.irpp.pv_immo

    if P.datesim:  # TODO:
        taux_reduc = max_(dur_det_immo - P.ann_det1, 0) * P.taux1
    else:
        taux_reduc = (
            max_(dur_det_immo - P.ann_det3, 0) * P.taux3 +
            max_(min_(dur_det_immo, P.ann_det3) - P.ann_det2, 0) * P.taux2 +
            max_(min_(dur_det_immo, P.ann_det2) - P.ann_det1, 0) * P.taux1)

    taux_reduc = min_(taux_reduc, 1.0)
    pv_impos = (1 - taux_reduc) * plus_value_brute

    #    45. MONTANT DE LA PLUS-VALUE BENEFICIANT, SOUS CONDITIONS, DE L’EXONERATION AU TITRE DE LA
    #    PREMIERE CESSION D’UN LOGEMENT EN VUE DE L’ACQUISITION DE LA RESIDENCE PRINCIPALE
    #    (CGI, 1° BIS DU II DE L’ARTICLE 150 U) TODO:
    exo = 0

    pv_net_impos = max_(
        pv_impos - exo, 0
    )  #46. PLUS-VALUE NETTE IMPOSABLE [LIGNE 44 OU (LIGNE 44 – LIGNE 45)] = €
    # 50. PLUS-VALUE NETTE IMPOSABLE GLOBALE =
    # (LIGNE 46 OU TOTAL DES LIGNES 46 SI PLUSIEURS 2048-IMM-SD PAGE 2)

    #Lorsqu’une même cession porte sur des biens pour lesquels sont prévues des règles différentes (acquisitions successives de fractions divises ou indivises notamment),
    #il convient de remplir les lignes 10 à 46 pour chacune des fractions (utiliser plusieurs 2048-IMM-SD page 2).
    return pv_net_impos
Ejemplo n.º 12
0
def _aspa_coexist_asi(asi_aspa_elig, maries, marpac, br_mv, _P):
    '''
    Montant de l'ASPA quand une personne perçoit l'ASPA et l'autre l'ASI
    '''
    P = _P.minim
    # Une personne peçoit l'ASI et l'autre l'ASPA
    # Les persones sont mariées
    index = asi_aspa_elig * maries
    montant_max = where(
        index, (.5 * P.asi.montant_couple + .5 * P.aspa.montant_couple), 0)
    ressources = where(index, br_mv + montant_max, 0)
    plafond_ressources = where(index, P.aspa.plaf_couple, 0)
    depassement = ressources - plafond_ressources
    montant_servi_aspa_m = where(
        index, max_(.5 * P.aspa.montant_couple - 0.5 * depassement, 0), 0) / 12
    # Les deux persones ne sont pas mariées mais concubins ou pacsés
    index = asi_aspa_elig * (marpac & not_(maries))
    montant_max = where(index, P.asi.montant_seul + .5 * P.aspa.montant_couple,
                        0)
    ressources = where(index, br_mv + montant_max, 0)
    plafond_ressources = where(index, P.aspa.plaf_couple, 0)
    depassement = ressources - plafond_ressources
    montant_servi_aspa_c = where(
        index, max_(.5 * P.aspa.montant_couple - 0.5 * depassement, 0), 0) / 12
    return 12 * (montant_servi_aspa_m + montant_servi_aspa_c)  # annualisé
Ejemplo n.º 13
0
    def function(famille, period, legislation):
        period = period.this_month
        af_nbenf = famille('af_nbenf', period)
        af_forfaitaire_nbenf = famille('af_allocation_forfaitaire_nb_enfants',
                                       period)
        pfam = legislation(period).prestations.prestations_familiales.af
        nb_enf_tot = af_nbenf + af_forfaitaire_nbenf
        base_ressources = famille('prestations_familiales_base_ressources',
                                  period)
        af_allocation_forfaitaire = famille('af_allocation_forfaitaire',
                                            period)
        modulation = pfam.modulation
        plafond1 = modulation.plafond_tranche_1 + max_(
            af_nbenf - 2,
            0) * modulation.majoration_plafond_par_enfant_supplementaire
        plafond2 = modulation.plafond_tranche_2 + max_(
            af_nbenf - 2,
            0) * modulation.majoration_plafond_par_enfant_supplementaire

        depassement_plafond1 = max_(0, base_ressources - plafond1)
        depassement_plafond2 = max_(0, base_ressources - plafond2)

        depassement_mensuel = (
            (depassement_plafond2 == 0) * depassement_plafond1 +
            (depassement_plafond2 > 0) * depassement_plafond2) / 12

        return period, max_(0, af_allocation_forfaitaire -
                            depassement_mensuel) * (depassement_mensuel > 0)
Ejemplo n.º 14
0
 def calc(self, assiette, getT = False):
     '''
     Calcule un impôt selon le barême non linéaire exprimé en tranches de taux marginaux.
     'assiette' est l'assiette de l'impôt, en colonne
     '''
     k = self.nb
     n = len(assiette)
     if not self._linear_taux_moy:
         assi = np.tile(assiette, (k, 1)).T
         seui = np.tile(np.hstack((self.seuils, np.inf)), (n, 1))
         a = max_(min_(assi, seui[:, 1:]) - seui[:, :-1], 0)
         i = np.dot(self.taux, a.T)
         if getT:
             t = np.squeeze(max_(np.dot((a > 0), np.ones((k, 1))) - 1, 0))
             return i, t
         else:
             return i
     else:
         if len(self.tauxM) == 1:
             i = assiette * self.tauxM[0]
         else:
             assi = np.tile(assiette, (k - 1, 1)).T
             seui = np.tile(np.hstack(self.seuils), (n, 1))
             k = self.t_x().T
             a = (assi >= seui[:, :-1]) * (assi < seui[:, 1:])
             A = np.dot(a, self.t_x().T)
             B = np.dot(a, np.array(self.seuils[1:]))
             C = np.dot(a, np.array(self.tauxM[:-1]))
             i = assiette * (A * (assiette - B) + C) + max_(assiette - self.seuils[-1], 0) * self.tauxM[-1] + (assiette >= self.seuils[-1]) * self.seuils[-1] * self.tauxM[-2]
         if getT:
             t = np.squeeze(max_(np.dot((a > 0), np.ones((k, 1))) - 1, 0))
             return i, t
         else:
             return i
Ejemplo n.º 15
0
def _rev_cat_rvcm(marpac, deficit_rcm, f2ch, f2dc, f2ts, f2ca, f2fu, f2go, f2gr, f2tr, _P):
    ''' REVENUS DES VALEURS ET CAPITAUX MOBILIERS '''
    P = _P.ir.rvcm
    if _P.datesim.year > 2004: f2gr = 0

    ## Calcul du revenu catégoriel
    #1.2 Revenus des valeurs et capitaux mobiliers
    b12 = min_(f2ch, P.abat_assvie*(1 + marpac))
    TOT1 = f2ch-b12
    # Part des frais s'imputant sur les revenus déclarés case DC
    den = ((f2dc + f2ts)!=0)*(f2dc + f2ts) + ((f2dc + f2ts)==0)
    F1 =  f2ca/den*f2dc
    
    # Revenus de capitaux mobiliers nets de frais, ouvrant droit à abattement
    # partie négative (à déduire des autres revenus nets de frais d'abattements
    g12a = - min_(f2dc*P.abatmob_taux - F1,0)
    # partie positive
    g12b = max_(f2dc*P.abatmob_taux - F1,0)
    
    rev = g12b + f2gr + f2fu*P.abatmob_taux

    # Abattements, limité au revenu
    h12 = P.abatmob*(1 + marpac)
    TOT2 = max_(0,rev - h12)
    i121= -min_(0,rev - h12)
    
    # Pars des frais s'imputant sur les revenus déclarés ligne TS
    F2 = f2ca - F1
    TOT3 = (f2ts - F2) + f2go*P.majGO + f2tr - g12a

    DEF = deficit_rcm

    return max_(TOT1 + TOT2 + TOT3 - DEF, 0)
Ejemplo n.º 16
0
    def function_2009__(self, simulation, period):
        period = period.start.offset('first-of', 'year').period('year')
        age_holder = simulation.compute('age', period)
        smic55_holder = simulation.compute('smic55', period)
        af_nbenf = simulation.calculate('af_nbenf', period)
        nb_par = simulation.calculate('nb_par', period)
        ass = simulation.calculate('ass', period)
        aer_holder = simulation.compute('aer', period)
        api = simulation.calculate('api', period)
        rsa = simulation.calculate('rsa', period)
        P = simulation.legislation_at(period.start).minim.aefa
        af = simulation.legislation_at(period.start).fam.af

        age = self.split_by_roles(age_holder, roles = ENFS)
        aer = self.sum_by_entity(aer_holder)
        smic55 = self.split_by_roles(smic55_holder, roles = ENFS)
        dummy_ass = ass > 0
        dummy_aer = aer > 0
        dummy_api = api > 0
        dummy_rmi = rsa > 0
        maj = 0  # TODO
        condition = (dummy_ass + dummy_aer + dummy_api + dummy_rmi > 0)
        if hasattr(af, "age3"):
            nbPAC = nb_enf(age, smic55, af.age1, af.age3)
        else:
            nbPAC = af_nbenf
        # TODO check nombre de PAC pour une famille
        aefa = condition * P.mon_seul * (
            1 + (nb_par == 2) * P.tx_2p +
            nbPAC * P.tx_supp * (nb_par <= 2) +
            nbPAC * P.tx_3pac * max_(nbPAC - 2, 0)
            )
        aefa_maj = P.mon_seul * maj
        aefa = max_(aefa_maj, aefa)
        return period, aefa
Ejemplo n.º 17
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
Ejemplo n.º 18
0
def _aefa(age, smic55, af_nbenf, nb_par, ass ,aer, api, rsa, _P, _option = {'age': ENFS, 'smic55': ENFS}):
    '''
    Aide exceptionelle de fin d'année (prime de Noël)
    '''
    # Insituée en 1998        
    # Apparaît sous le nom de complément de rmi dans les ERF    
    P = _P
    dummy_ass = ass > 0
    dummy_aer = aer > 0
    dummy_api = api > 0
    dummy_rmi = rsa > 0

    # Le montant de l’aide mentionnée à l’article 1er versée aux bénéficiaires de l’allocation de solidarité
    # spécifique à taux majoré servie aux allocataires âgés de cinquante-cinq ans ou plus justifiant de vingt années
    # d’activité salariée, aux allocataires âgés de cinquante-sept ans et demi ou plus justifiant de dix années d’activité
    # salariée ainsi qu’aux allocataires justifiant d’au moins 160 trimestres validés dans les régimes d’assurance
    # vieillesse ou de périodes reconnues équivalentes est égal à        
    maj = 0  # TODO
    
    condition = (dummy_ass+dummy_aer+dummy_api+dummy_rmi > 0)
    
    if hasattr(P.fam.af,"age3"): nbPAC = nb_enf(age, smic55, P.fam.af.age1,P.fam.af.age3)
    else: nbPAC = af_nbenf
    # TODO check nombre de PAC pour une famille
    P = _P.minim
    aefa = condition*P.aefa.mon_seul*(1 + (nb_par==2)*P.aefa.tx_2p
              + nbPAC*P.aefa.tx_supp*(nb_par<=2)
              + nbPAC*P.aefa.tx_3pac*max_(nbPAC-2,0))
    
    if _P.datesim.year==2008: aefa += condition*P.aefa.forf2008
               
    aefa_maj  = P.aefa.mon_seul*maj
    aefa = max_(aefa_maj,aefa)   
    return aefa 
Ejemplo n.º 19
0
def _plus_values(f3vg, f3vh, f3vl, f3vm, f3vi, f3vf, f3vd, f3sd, f3si, f3sf, f3sa, rpns_pvce, _P):
    """
    Taxation des plus value
    TODO: f3vt, 2013 f3Vg au barème / tout refaire
    """
    P = _P.ir.plus_values
        # revenus taxés à un taux proportionnel
    rdp = max_(0, f3vg - f3vh) + f3vl + rpns_pvce + f3vm + f3vi + f3vf
    out = (P.pvce * rpns_pvce +
           P.taux1 * max_(0, f3vg - f3vh) +
           P.caprisque * f3vl +
           P.pea * f3vm +
           P.taux3 * f3vi +
           P.taux4 * f3vf)
    if _P.datesim.year >= 2008:
        # revenus taxés à un taux proportionnel
        rdp += f3vd
        out += P.taux1 * f3vd
    if _P.datesim.year == 2012:
        out = P.taux2 * f3vd + P.taux3 * f3vi + P.taux4 * f3vf + P.taux1 * max_(0, f3vg - f3vh)
        out = (P.taux2 * (f3vd + f3sd) + P.taux3 * (f3vi + f3si) +
               P.taux4 * (f3vf + f3sf) + P.taux1 * max_(0, f3vg - f3vh) + P.pvce * f3sa)  # TODO: chek this rpns missing ?
    if _P.datesim.year > 2012:
        out = f3vg * 0  # TODO: completely undone

    return round(out)
Ejemplo n.º 20
0
def _apje(br_pf, age, smic55, isol, biact, _P, _option={'age': ENFS, 'smic55': ENFS}):
    '''
    Allocation pour jeune enfant
    '''
    # TODO: APJE courte voir doc ERF 2006
    P = _P.fam
    nbenf = nb_enf(age, smic55, 0, P.apje.age - 1)
    bmaf = P.af.bmaf
    bmaf_n_2 = P.af.bmaf_n_2
    base = round(P.apje.taux * bmaf, 2)
    base2 = round(P.apje.taux * bmaf_n_2, 2)

    plaf_tx = (nbenf > 0) + P.apje.plaf_tx1 * min_(nbenf, 2) + P.apje.plaf_tx2 * max_(nbenf - 2, 0)
    majo = isol | biact
    plaf = P.apje.plaf * plaf_tx + P.apje.plaf_maj * majo
    plaf2 = plaf + 12 * base2

    apje = (nbenf >= 1) * ((br_pf <= plaf) * base
                            + (br_pf > plaf) * max_(plaf2 - br_pf, 0) / 12.0)

    # Pour bénéficier de cette allocation, il faut que tous les enfants du foyer soient nés, adoptés, ou recueillis en vue d’une adoption avant le 1er janvier 2004, et qu’au moins l’un d’entre eux ait moins de 3 ans.
    # Cette allocation est verséE du 5ème mois de grossesse jusqu’au mois précédant le 3ème anniversaire de l’enfant.

    # Non cumul APE APJE CF
    #  - L’allocation parentale d’éducation (APE), sauf pour les femmes enceintes.
    #    L’APJE est alors versée du 5ème mois de grossesse jusqu’à la naissance de l’enfant.
    #  - Le CF
    return 12*apje  # annualisé
Ejemplo n.º 21
0
    def function(self, simulation, period):
        period = period.this_month
        biactivite = simulation.calculate('biactivite', period)
        Pr = simulation.legislation_at(period.start).prestations.aides_logement.ressources
        base_ressources_holder = simulation.compute('prestations_familiales_base_ressources_individu', period)
        base_ressources_parents = self.sum_by_entity(base_ressources_holder, roles = [CHEF, PART])
        abattement_chomage_indemnise_holder = simulation.compute('aide_logement_abattement_chomage_indemnise', period)
        abattement_chomage_indemnise = self.sum_by_entity(abattement_chomage_indemnise_holder, roles = [CHEF, PART])
        abattement_depart_retraite_holder = simulation.compute('aide_logement_abattement_depart_retraite', period)
        abattement_depart_retraite = self.sum_by_entity(abattement_depart_retraite_holder, roles = [CHEF, PART])
        neutralisation_rsa = simulation.calculate('aide_logement_neutralisation_rsa', period)
        abattement_ressources_enfant = simulation.legislation_at(period.n_2.stop).prestations.minima_sociaux.aspa.plafond_ressources_seul * 1.25
        br_enfants = self.sum_by_entity(
            max_(0, base_ressources_holder.array - abattement_ressources_enfant), roles = ENFS)

        # Revenus du foyer fiscal
        rev_coll = simulation.famille.demandeur.foyer_fiscal('rev_coll', period.n_2)

        ressources = (
            base_ressources_parents + br_enfants + rev_coll -
            (abattement_chomage_indemnise + abattement_depart_retraite + neutralisation_rsa)
            )

        # Abattement forfaitaire pour double activité
        abattement_double_activite = biactivite * Pr.dar_1

        # Arrondi aux 100 euros supérieurs
        result = max_(ressources - abattement_double_activite, 0)

        return period, result
Ejemplo n.º 22
0
    def function(famille, period, legislation, mois_demande):
        period = period.this_month
        forfait_logement = famille('rsa_forfait_logement', mois_demande)
        ppa_majoree_eligibilite = famille('rsa_majore_eligibilite', mois_demande)

        elig = famille('ppa_eligibilite', period, extra_params = [mois_demande])
        pente = legislation(mois_demande).prestations.minima_sociaux.ppa.pente
        mff_non_majore = famille(
            'ppa_montant_forfaitaire_familial_non_majore', period, extra_params = [mois_demande])
        mff_majore = famille(
            'ppa_montant_forfaitaire_familial_majore', period, extra_params = [mois_demande])
        montant_forfaitaire_familialise = where(ppa_majoree_eligibilite, mff_majore, mff_non_majore)
        ppa_base_ressources = famille('ppa_base_ressources', period, extra_params = [mois_demande])
        ppa_revenu_activite = famille('ppa_revenu_activite', period, extra_params = [mois_demande])
        bonification_i = famille.members('ppa_bonification', period, extra_params = [mois_demande])
        bonification = famille.sum(bonification_i)

        ppa_montant_base = (
            montant_forfaitaire_familialise +
            bonification +
            pente * ppa_revenu_activite - ppa_base_ressources - forfait_logement
            )

        ppa_deduction = (
            montant_forfaitaire_familialise - ppa_base_ressources - forfait_logement
            )

        ppa_fictive = ppa_montant_base - max_(ppa_deduction, 0)
        ppa_fictive = max_(ppa_fictive, 0)
        return period, elig * ppa_fictive
Ejemplo n.º 23
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('month')
        apl = simulation.calculate('apl', period)
        als = simulation.calculate('als', period)
        alf = simulation.calculate('alf', period)

        return period, max_(max_(apl, als), alf)
Ejemplo n.º 24
0
    def function(self, simulation, period):
        period = period.this_month
        apl = simulation.calculate('apl', period)
        als = simulation.calculate('als', period)
        alf = simulation.calculate('alf', period)

        return period, max_(max_(apl, als), alf)
Ejemplo n.º 25
0
    def function__2008_(self, simulation, period):
        period = period.this_year
        af_nbenf = simulation.calculate('af_nbenf', period)
        nb_parents = simulation.calculate('nb_parents', period)
        ass = simulation.calculate_add('ass', period)
        aer_holder = simulation.compute('aer', period)
        api = simulation.calculate_add('api', period)
        rsa = simulation.calculate('rsa', period)
        P = simulation.legislation_at(period.start).prestations.minima_sociaux.aefa
        af = simulation.legislation_at(period.start).prestations.prestations_familiales.af

        aer = self.sum_by_entity(aer_holder)
        dummy_ass = ass > 0
        dummy_aer = aer > 0
        dummy_api = api > 0
        dummy_rmi = rsa > 0
        maj = 0  # TODO
        condition = (dummy_ass + dummy_aer + dummy_api + dummy_rmi > 0)
        if hasattr(af, "age3"):
            nbPAC = nb_enf(simulation.famille, period, af.age1, af.age3)
        else:
            nbPAC = af_nbenf
        # TODO check nombre de PAC pour une famille
        aefa = condition * P.mon_seul * (
            1 + (nb_parents == 2) * P.tx_2p +
            nbPAC * P.tx_supp * (nb_parents <= 2) +
            nbPAC * P.tx_3pac * max_(nbPAC - 2, 0)
            )
        aefa_maj = P.mon_seul * maj
        aefa = max_(aefa_maj, aefa)
        return period, aefa
Ejemplo n.º 26
0
    def function__2008_(famille, period, legislation):
        period = period.this_year
        af_nbenf = famille('af_nbenf', period)
        nb_parents = famille('nb_parents', period)
        ass = famille('ass', period, options=[ADD])
        api = famille('api', period, options=[ADD])
        rsa = famille('rsa', period)
        P = legislation(period).prestations.minima_sociaux.aefa
        af = legislation(period).prestations.prestations_familiales.af

        aer_i = famille.members('aer', period)
        aer = famille.sum(aer_i)
        dummy_ass = ass > 0
        dummy_aer = aer > 0
        dummy_api = api > 0
        dummy_rmi = rsa > 0
        maj = 0  # TODO
        condition = (dummy_ass + dummy_aer + dummy_api + dummy_rmi > 0)
        if hasattr(af, "age3"):
            nbPAC = nb_enf(famille, period, af.age1, af.age3)
        else:
            nbPAC = af_nbenf
        # TODO check nombre de PAC pour une famille
        aefa = condition * P.mon_seul * (
            1 + (nb_parents == 2) * P.tx_2p + nbPAC * P.tx_supp *
            (nb_parents <= 2) + nbPAC * P.tx_3pac * max_(nbPAC - 2, 0))
        aefa_maj = P.mon_seul * maj
        aefa = max_(aefa_maj, aefa)
        return period, aefa
Ejemplo n.º 27
0
def _plus_values(f3vg, f3vh, f3vl, f3vm, f3vi, f3vf, f3vd, f3sd, f3si, f3sf, f3sa, rpns_pvce, _P):
    """
    Taxation des plus value
    TODO: f3vt, 2013 f3Vg au barème / tout refaire
    """
    P = _P.ir.plus_values
        # revenus taxés à un taux proportionnel
    rdp = max_(0, f3vg - f3vh) + f3vl + rpns_pvce + f3vm + f3vi + f3vf
    out = (P.pvce * rpns_pvce +
           P.taux1 * max_(0, f3vg - f3vh) +
           P.caprisque * f3vl +
           P.pea * f3vm +
           P.taux3 * f3vi +
           P.taux4 * f3vf)
    if _P.datesim.year >= 2008:
        # revenus taxés à un taux proportionnel
        rdp += f3vd
        out += P.taux1 * f3vd
    if _P.datesim.year == 2012:
        out = P.taux2 * f3vd + P.taux3 * f3vi + P.taux4 * f3vf + P.taux1 * max_(0, f3vg - f3vh)
        out = (P.taux2 * (f3vd + f3sd) + P.taux3 * (f3vi + f3si) +
               P.taux4 * (f3vf + f3sf) + P.taux1 * max_(0, f3vg - f3vh) + P.pvce * f3sa)  # TODO: chek this rpns missing ?
    if _P.datesim.year > 2012:
        out = f3vg * 0  # TODO: completely undone

    return round(out)
Ejemplo n.º 28
0
def _aged(age,
          smic55,
          br_pf,
          ape_taux_partiel,
          dep_trim,
          _P,
          _option={
              'age': ENFS,
              'smic55': ENFS
          }):
    '''
    Allocation garde d'enfant à domicile
    '''
    # TODO: trimestrialiser
    # les deux conjoints actif et revenu min requis, jusqu'aux 6 ans de l'enfant né avant le 01/01/2004, emploi d'une garde A DOMICILE
    # cette allocation consiste en une prise en charge partielle des charges sociales inhérentes à l'emploi d'une personne à domicile.
    # Si vous avez au moins un enfant  de moins de 3 ans gardé au domicile, 2 cas :
    # Revenus 2005 > 37 241  € : la CAF prend en charge 50% des charges sociales (plafonné à 1 106 € par trimestre),
    # Revenus 2005 < 37 341  € : la CAF prend en charge 75% des charges sociales (plafonné à 1 659 € par trimestre).
    # Si vous avez un enfant de plus de 3 ans gardé au domicile (1 seul cas, sans condition de ressources) :
    # la CAF prend en charge 50% des charges sociales (plafonné à 553 € par trimestre)

    P = _P.fam
    nbenf = nb_enf(age, smic55, 0, P.aged.age1 - 1)
    nbenf2 = nb_enf(age, smic55, 0, P.aged.age2 - 1)
    elig1 = (nbenf > 0)
    elig2 = not_(elig1) * (nbenf2 > 0) * ape_taux_partiel
    depenses = 4 * dep_trim  # gérer les dépenses trimestrielles
    aged3 = elig1 * (
        max_(P.aged.remb_plaf1 - P.aged.remb_taux1 * depenses, 0) *
        (br_pf > P.aged.revenus_plaf) + (br_pf <= P.aged.revenus_plaf) *
        max_(P.aged.remb_taux2 * depenses - P.aged.remb_plaf1, 0))
    aged6 = elig2 * max_(P.aged.remb_taux2 * depenses - P.aged.remb_plaf2, 0)
    return 12 * (aged3 + aged6)  # annualisé
Ejemplo n.º 29
0
    def function_2005_07_01(self, simulation, period):
        period = period.this_month
        law = simulation.legislation_at(period.start).prestations

        garantie_ressources = law.minima_sociaux.caah.garantie_ressources
        aah_montant = law.minima_sociaux.aah.montant

        aah = simulation.calculate('aah', period)
        asi_eligibilite = simulation.calculate('asi_eligibilite', period)
        asi_holder = simulation.compute('asi',
                                        period)  # montant asi de la famille
        asi = self.cast_from_entity_to_roles(
            asi_holder)  # attribué à tous les membres de la famille
        benef_asi = (asi_eligibilite * (asi > 0))
        al_holder = simulation.compute(
            'aide_logement_montant',
            period)  # montant allocs logement de la famille
        al = self.cast_from_entity_to_roles(
            al_holder)  # attribué à tout individu membre de la famille

        elig_cpl = ((aah > 0) | (benef_asi > 0))
        # TODO: & logement indépendant & inactif 12 derniers mois
        # & capa de travail < 5% & taux d'incapacité >= 80%
        compl_ress = elig_cpl * max_(garantie_ressources - aah_montant, 0)

        elig_mva = (al > 0) * ((aah > 0) | (benef_asi > 0))
        # TODO: & logement indépendant & pas de revenus professionnels
        # propres & capa de travail < 5% & taux d'incapacité >= 80%
        mva = 0.0 * elig_mva  # TODO: rentrer mva dans paramètres. mva (mensuelle) = 104,77 en 2015, était de 101,80 en 2006, et de 119,72 en 2007

        return period, max_(compl_ress, mva)
Ejemplo n.º 30
0
def _ars(self, age_holder, af_nbenf, smic55_holder, br_pf, P = law.fam):
    '''
    Allocation de rentrée scolaire brute de CRDS
    '''
    # TODO: convention sur la mensualisation
    # On tient compte du fait qu'en cas de léger dépassement du plafond, une allocation dégressive
    # (appelée allocation différentielle), calculée en fonction des revenus, peut être versée.
    age = self.split_by_roles(age_holder, roles = ENFS)
    smic55 = self.split_by_roles(smic55_holder, roles = ENFS)

    bmaf = P.af.bmaf
    # On doit prendre l'âge en septembre
    enf_05 = nb_enf(age, smic55, P.ars.agep - 1, P.ars.agep - 1)  # 5 ans et 6 ans avant le 31 décembre
    # enf_05 = 0
    # Un enfant scolarisé qui n'a pas encore atteint l'âge de 6 ans
    # avant le 1er février 2012 peut donner droit à l'ARS à condition qu'il
    # soit inscrit à l'école primaire. Il faudra alors présenter un
    # certificat de scolarité.
    enf_primaire = enf_05 + nb_enf(age, smic55, P.ars.agep, P.ars.agec - 1)
    enf_college = nb_enf(age, smic55, P.ars.agec, P.ars.agel - 1)
    enf_lycee = nb_enf(age, smic55, P.ars.agel, P.ars.ages)

    arsnbenf = enf_primaire + enf_college + enf_lycee

    # Plafond en fonction du nb d'enfants A CHARGE (Cf. article R543)
    ars_plaf_res = P.ars.plaf * (1 + af_nbenf * P.ars.plaf_enf_supp)
    arsbase = bmaf * (P.ars.tx0610 * enf_primaire +
                     P.ars.tx1114 * enf_college +
                     P.ars.tx1518 * enf_lycee)
    # Forme de l'ARS  en fonction des enfants a*n - (rev-plaf)/n
    # ars_diff = (ars_plaf_res + arsbase - br_pf) / arsnbenf
    ars = (arsnbenf > 0) * max_(0, arsbase - max_(0, (br_pf - ars_plaf_res) / max_(1, arsnbenf)))
    # Calcul net de crds : ars_net = (P.ars.enf0610 * enf_primaire + P.ars.enf1114 * enf_college + P.ars.enf1518 * enf_lycee)

    return ars * (ars >= P.ars.seuil_nv)
Ejemplo n.º 31
0
 def attribution(self, assiette, getT = False):
     '''
     renvoie un vecteur associant les bonnes valeurs de la variable (selon génération)
     '''
     k = self.nb
     n = len(assiette)
     if not self._linear_taux_moy:
         assi = np.tile(assiette, (k, 1)).T
         seui = np.tile(np.hstack((self.seuils, np.inf)), (n, 1))
         a = max_(min_(assi, seui[:, 1:]) - seui[:, :-1], 0)
         i = np.dot(self.taux, a.T)
         if getT:
             t = np.squeeze(max_(np.dot((a > 0), np.ones((k, 1))) - 1, 0))
             return i, t
         else:
             return i
     else:
         if len(self.tauxM) == 1:
             i = assiette * self.tauxM[0]
         else:
             assi = np.tile(assiette, (k - 1, 1)).T
             seui = np.tile(np.hstack(self.seuils), (n, 1))
             k = self.t_x().T
             a = (assi >= seui[:, :-1]) * (assi < seui[:, 1:])
             A = np.dot(a, self.t_x().T)
             B = np.dot(a, np.array(self.seuils[1:]))
             C = np.dot(a, np.array(self.tauxM[:-1]))
             i = assiette * (A * (assiette - B) + C) + max_(assiette - self.seuils[-1], 0) * self.tauxM[-1] + (assiette >= self.seuils[-1]) * self.seuils[-1] * self.tauxM[-2]
         if getT:
             t = np.squeeze(max_(np.dot((a > 0), np.ones((k, 1))) - 1, 0))
             return i, t
         else:
             return i
Ejemplo n.º 32
0
def _ars(age, smic55, br_pf, _P, _option={'age': ENFS, 'smic55': ENFS}):
    '''
    Allocation de rentrée scolaire
    '''
    # TODO: convention sur la mensualisation
    # On tient compte du fait qu'en cas de léger dépassement du plafond, une allocation dégressive
    # (appelée allocation différentielle), calculée en fonction des revenus, peut être versée.

    P = _P.fam
    bmaf = P.af.bmaf
    # On doit prendre l'âge en septembre
    enf_05 = nb_enf(age, smic55, P.ars.agep - 1, P.ars.agep - 1)  # 6 ans avant le 31 décembre
    #enf_05 = 0
    # Un enfant scolarisé qui n'a pas encore atteint l'âge de 6 ans
    # avant le 1er février 2012 peut donner droit à l'ARS à condition qu'il
    # soit inscrit à l'école primaire. Il faudra alors présenter un
    # certificat de scolarité.
    enf_primaire = enf_05 + nb_enf(age, smic55, P.ars.agep, P.ars.agec - 1)
    enf_college = nb_enf(age, smic55, P.ars.agec, P.ars.agel - 1)
    enf_lycee = nb_enf(age, smic55, P.ars.agel, P.ars.ages)

    arsnbenf = enf_primaire + enf_college + enf_lycee

    ars_plaf_res = P.ars.plaf * (1 + arsnbenf * P.ars.plaf_enf_supp)
    arsbase = bmaf * (P.ars.tx0610 * enf_primaire +
                     P.ars.tx1114 * enf_college +
                     P.ars.tx1518 * enf_lycee)
    # Forme de l'ARS  en fonction des enfants a*n - (rev-plaf)/n
    ars = max_(0, (ars_plaf_res + arsbase * arsnbenf - max_(br_pf, ars_plaf_res)) / max_(1, arsnbenf))
    return ars * (ars >= P.ars.seuil_nv)
Ejemplo n.º 33
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'month').period('month')
        apl = simulation.calculate('apl', period)
        als = simulation.calculate('als', period)
        alf = simulation.calculate('alf', period)

        return period, max_(max_(apl, als), alf)
Ejemplo n.º 34
0
def _isf_apres_plaf(tot_impot, revetproduits, isf_avant_plaf, _P):
    """
    Impôt sur la fortune après plafonnement
    """
    ## si ISF avant plafonnement n'excède pas seuil 1= la limitation du plafonnement ne joue pas ##
    ## si entre les deux seuils; l'allègement est limité au 1er seuil ##
    ## si ISF avant plafonnement est supérieur au 2nd seuil, l'allègement qui résulte du plafonnement est limité à 50% de l'ISF ##

    P = _P.isf.plaf
    # Plafonnement supprimé pour l'année 2012
    if _P.datesim.year <= 2011:
        plafonnement = max_(tot_impot - revetproduits, 0)
        limitationplaf = (
            (isf_avant_plaf <= P.seuil1) * plafonnement +
            (P.seuil1 <= isf_avant_plaf) *
            (isf_avant_plaf <= P.seuil2) * min_(plafonnement, P.seuil1) +
            (isf_avant_plaf >= P.seuil2) *
            min_(isf_avant_plaf * P.taux, plafonnement))
        return max_(isf_avant_plaf - limitationplaf, 0)

    elif _P.datesim.year == 2012:
        return isf_avant_plaf

    else:
        plafond = max_(0, tot_impot -
                       revetproduits)  # case PU sur la déclaration d'impôt
        return max_(isf_avant_plaf - plafond, 0)
Ejemplo n.º 35
0
    def function_2005_07_01(self, simulation, period):
        period = period.this_month
        law = simulation.legislation_at(period.start)

        grph = law.minim.caah.grph
        aah_montant = law.minim.aah.montant

        aah = simulation.calculate('aah', period)
        asi_eligibilite = simulation.calculate('asi_eligibilite', period)
        asi_holder = simulation.compute('asi', period)  # montant asi de la famille
        asi = self.cast_from_entity_to_roles(asi_holder)  # attribué à tous les membres de la famille
        benef_asi = (asi_eligibilite * (asi > 0))
        al_holder = simulation.compute('aide_logement_montant', period)  # montant allocs logement de la famille
        al = self.cast_from_entity_to_roles(al_holder)  # attribué à tout individu membre de la famille

        elig_cpl = ((aah > 0) | (benef_asi > 0))
        # TODO: & logement indépendant & inactif 12 derniers mois
        # & capa de travail < 5% & taux d'incapacité >= 80%
        compl_ress = elig_cpl * max_(grph - aah_montant, 0)

        elig_mva = (al > 0) * ((aah > 0) | (benef_asi > 0))
        # TODO: & logement indépendant & pas de revenus professionnels
        # propres & capa de travail < 5% & taux d'incapacité >= 80%
        mva = 0.0 * elig_mva  # TODO: rentrer mva dans paramètres. mva (mensuelle) = 104,77 en 2015, était de 101,80 en 2006, et de 119,72 en 2007

        return period, max_(compl_ress, mva)
def _prcomp(f7wm, f7wn, f7wo, f7wp, _P):
    """
    Prestations compensatoires
    2002-2010
    """
    P = _P.ir.reductions_impots.prcomp
    div = (f7wo == 0) * 1 + f7wo  # Pour éviter les divisions par zéro

    return (
        (f7wm == 0)
        * (
            (f7wn == f7wo) * P.taux * min_(f7wn, P.seuil)
            + (f7wn < f7wo) * (f7wo <= P.seuil) * P.taux * f7wn
            + max_(0, (f7wn < f7wo) * (f7wo > P.seuil) * P.taux * P.seuil * f7wn / div)
            + P.taux * f7wp
        )
        + (f7wm != 0)
        * (
            (f7wn == f7wm) * (f7wo <= P.seuil) * P.taux * f7wm
            + max_(0, (f7wn == f7wm) * (f7wo >= P.seuil) * P.taux * f7wm / div)
            + (f7wn > f7wm) * (f7wo <= P.seuil) * P.taux * f7wn
            + max_(0, (f7wn > f7wm) * (f7wo >= P.seuil) * P.taux * f7wn / div)
        )
        + P.taux * f7wp
    )
Ejemplo n.º 37
0
    def function(self, simulation, period):
        period = period.this_month
        chomage_brut = simulation.calculate('chomage_brut', period)
        csg_deductible_chomage = simulation.calculate('csg_deductible_chomage', period)
        csg_imposable_chomage = simulation.calculate('csg_imposable_chomage', period)
        taux_csg_remplacement = simulation.calculate('taux_csg_remplacement', period)
        law = simulation.legislation_at(period.start)

        smic_h_b = law.cotsoc.gen.smic_h_b
        # salaire_mensuel_reference = chomage_brut / .7
        # heures_mensuelles = min_(salaire_mensuel_reference / smic_h_b, 35 * 52 / 12)  # TODO: depuis 2001 mais avant ?
        heures_mensuelles = 35 * 52 / 12
        cho_seuil_exo = law.csg.chomage.min_exo * heures_mensuelles * smic_h_b

        montant_crds = montant_csg_crds(
            base_avec_abattement = chomage_brut,
            law_node = law.crds.activite,
            plafond_securite_sociale = law.cotsoc.gen.plafond_securite_sociale,
            ) * (2 <= taux_csg_remplacement)

        crds_chomage = max_(
            -montant_crds - max_(
                cho_seuil_exo - (chomage_brut + csg_imposable_chomage + csg_deductible_chomage + montant_crds), 0
                ), 0
            )
        return period, -crds_chomage
Ejemplo n.º 38
0
    def function(self, simulation, period):
        period = period.start.offset('first-of', 'year').period('year')
        frag_impo = simulation.calculate('frag_impo', period)
        nrag_impg = simulation.calculate('nrag_impg', period)
        nbic_impn = simulation.calculate('nbic_impn', period)
        nbic_imps = simulation.calculate('nbic_imps', period)
        nbic_defn = simulation.calculate('nbic_defn', period)
        nbic_defs = simulation.calculate('nbic_defs', period)
        nacc_impn = simulation.calculate('nacc_impn', period)
        nacc_meup = simulation.calculate('nacc_meup', period)
        nacc_defn = simulation.calculate('nacc_defn', period)
        nacc_defs = simulation.calculate('nacc_defs', period)
        nbnc_impo = simulation.calculate('nbnc_impo', period)
        nbnc_defi = simulation.calculate('nbnc_defi', period)
        P = simulation.legislation_at(period.start).ir.rpns

        nbic_timp = (nbic_impn + nbic_imps) - (nbic_defn + nbic_defs)

        # C revenus industriels et commerciaux non professionnels
        # (revenus accesoires du foyers en nomenclature INSEE)
        nacc_timp = max_(0, (nacc_impn + nacc_meup) - (nacc_defn + nacc_defs))

        # régime de la déclaration contrôlée ne bénéficiant pas de l'abattement association agréée
        nbnc_timp = nbnc_impo - nbnc_defi

        # Totaux
        ntimp = nrag_impg + nbic_timp + nacc_timp + nbnc_timp

        return period, max_(0, P.cga_taux2 * (ntimp + frag_impo))
def _aidper(marpac, nb_pac2, f7wf, f7wi, f7wj, f7wl, f7sf, f7si, _P):
    '''
    Crédits d’impôt pour dépenses en faveur de l’aide aux personnes
    (cases 7WI, 7WJ, 7WL et 7SF).
    2002-
    '''
    P = _P.ir.credits_impot.aidper

    n = nb_pac2
    if _P.datesim.year <= 2005:
        max0 = P.max * (1 + marpac) + P.pac1 * (n >= 1) + P.pac2 * (n >= 2) + P.pac2 * (max_(n - 2, 0))

    elif _P.datesim.year >= 2006:
        max0 = P.max * (1 + marpac) + P.pac1 * n

    if _P.datesim.year in (2002, 2003):
        return P.taux_wi * min_(f7wi, max0)  # TODO: enfant en résidence altérnée
    elif _P.datesim.year <= 2009:
        max1 = max_(0, max0 - f7wj)
        return (P.taux_wj * min_(f7wj, max0) +
                P.taux_wi * min_(f7wi, max1))
    elif _P.datesim.year == 2010:
        max1 = max_(0, max0 - f7wl)
        max2 = max_(0, max1 - f7sf)
        max3 = max_(0, max2 - f7wj)
        return (P.taux_wl * min_(f7wl, max0) +
                P.taux_sf * min_(f7sf, max1) +
                P.taux_wj * min_(f7wj, max2) +
                P.taux_wi * min_(f7si, max3))
    else:
        return 0 * marpac  # TODO 2011, 2012, 2013
Ejemplo n.º 40
0
    def function_2009__(self, simulation, period):
        period = period.this_year
        age_holder = simulation.compute('age', period)
        smic55_holder = simulation.compute('smic55', period, accept_other_period = True)
        af_nbenf = simulation.calculate('af_nbenf', period)
        nb_par = simulation.calculate('nb_par', period)
        ass = simulation.calculate_add('ass', period)
        aer_holder = simulation.compute('aer', period)
        api = simulation.calculate_add('api', period)
        rsa = simulation.calculate_add('rsa', period)
        P = simulation.legislation_at(period.start).minim.aefa
        af = simulation.legislation_at(period.start).fam.af

        age = self.split_by_roles(age_holder, roles = ENFS)
        aer = self.sum_by_entity(aer_holder)
        smic55 = self.split_by_roles(smic55_holder, roles = ENFS)
        dummy_ass = ass > 0
        dummy_aer = aer > 0
        dummy_api = api > 0
        dummy_rmi = rsa > 0
        maj = 0  # TODO
        condition = (dummy_ass + dummy_aer + dummy_api + dummy_rmi > 0)
        if hasattr(af, "age3"):
            nbPAC = nb_enf(age, smic55, af.age1, af.age3)
        else:
            nbPAC = af_nbenf
        # TODO check nombre de PAC pour une famille
        aefa = condition * P.mon_seul * (
            1 + (nb_par == 2) * P.tx_2p +
            nbPAC * P.tx_supp * (nb_par <= 2) +
            nbPAC * P.tx_3pac * max_(nbPAC - 2, 0)
            )
        aefa_maj = P.mon_seul * maj
        aefa = max_(aefa_maj, aefa)
        return period, aefa
    def function(self, simulation, period):
        period = period.this_month
        apl = simulation.calculate('apl', period)
        als = simulation.calculate('als', period)
        alf = simulation.calculate('alf', period)

        return period, max_(max_(apl, als), alf)
Ejemplo n.º 42
0
    def function(self, simulation, period, reference_period):
        period = period.this_month
        forfait_logement = simulation.calculate('rsa_forfait_logement', reference_period)
        ppa_majoree_eligibilite = simulation.calculate('rsa_majore_eligibilite', reference_period)

        elig = simulation.calculate('ppa_eligibilite', period)
        pente = simulation.legislation_at(period.start).minim.ppa.pente
        mff_non_majore = simulation.calculate('ppa_montant_forfaitaire_familial_non_majore', period)
        mff_majore = simulation.calculate('ppa_montant_forfaitaire_familial_majore', period)
        montant_forfaitaire_familialise = where(ppa_majoree_eligibilite, mff_majore, mff_non_majore)
        ppa_base_ressources = simulation.calculate('ppa_base_ressources', period, extra_params = [reference_period])
        ppa_revenu_activite = simulation.calculate('ppa_revenu_activite', period)
        bonification_individus = simulation.compute('ppa_bonification', period)
        bonification = self.sum_by_entity(bonification_individus)

        ppa_montant_base = (
            montant_forfaitaire_familialise +
            bonification +
            pente * ppa_revenu_activite - ppa_base_ressources
            - forfait_logement
            )

        ppa_deduction = (
            montant_forfaitaire_familialise
            - ppa_base_ressources
            - forfait_logement
            )

        ppa_fictive = ppa_montant_base - max_(ppa_deduction,0)
        ppa_fictive = max_(ppa_fictive, 0)
        return period, elig * ppa_fictive
def _plus_value_nette(period, plus_value_brute, dur_det_immo, pv_immo = law.ir.pv_immo):
    """
    Calcul de la plus value immobilière nette
    """
    # 40. ABATTEMENT POUR DUREE DE DETENTION
    # 41. NOMBRE D’ANNEES DE DETENTION AU-DELA DE LA 5EME ANNEE
    if period.start:  # TODO:
        taux_reduc = max_(dur_det_immo - pv_immo.ann_det1, 0) * pv_immo.taux1
    else:
        taux_reduc = (max_(dur_det_immo - pv_immo.ann_det3, 0) * pv_immo.taux3
            + max_(min_(dur_det_immo, pv_immo.ann_det3) - pv_immo.ann_det2, 0) * pv_immo.taux2
            + max_(min_(dur_det_immo, pv_immo.ann_det2) - pv_immo.ann_det1, 0) * pv_immo.taux1)

    taux_reduc = min_(taux_reduc, 1.0)
    pv_impos = (1 - taux_reduc) * plus_value_brute

    # 45. MONTANT DE LA PLUS-VALUE BENEFICIANT, SOUS CONDITIONS, DE L’EXONERATION AU TITRE DE LA
    # PREMIERE CESSION D’UN LOGEMENT EN VUE DE L’ACQUISITION DE LA RESIDENCE PRINCIPALE
    # (CGI, 1° BIS DU II DE L’ARTICLE 150 U) TODO:
    exo = 0

    pv_net_impos = max_(pv_impos - exo, 0)  # 46. PLUS-VALUE NETTE IMPOSABLE [LIGNE 44 OU (LIGNE 44 – LIGNE 45)] = €
    # 50. PLUS-VALUE NETTE IMPOSABLE GLOBALE =
    # (LIGNE 46 OU TOTAL DES LIGNES 46 SI PLUSIEURS 2048-IMM-SD PAGE 2)

    # Lorsqu’une même cession porte sur des biens pour lesquels sont prévues des règles différentes (acquisitions
    # successives de fractions divises ou indivises notamment), il convient de remplir les lignes 10 à 46 pour chacune
    # des fractions (utiliser plusieurs 2048-IMM-SD page 2).
    return pv_net_impos
Ejemplo n.º 44
0
def _cf(age, br_pf, isol, biact, smic55, _P, _option={'age': ENFS, 'smic55': ENFS}):
    """
    Complément familial
    Vous avez au moins 3 enfants à charge tous âgés de plus de 3 ans.
    Vos ressources ne dépassent pas certaines limites.
    Vous avez peut-être droit au Complément Familial à partir du mois
    suivant les 3 ans du 3ème, 4ème, etc. enfant.

    # TODO:
    # En théorie, il faut comparer les revenus de l'année n-2 à la bmaf de
    # l'année n-2 pour déterminer l'éligibilité avec le cf_seuil. Il faudrait
    # pouvoir déflater les revenus de l'année courante pour en tenir compte.
    """
    P = _P.fam
    bmaf = P.af.bmaf
    bmaf2 = P.af.bmaf_n_2
    cf_nbenf = nb_enf(age, smic55, P.cf.age1, P.cf.age2)

    cf_base_n_2 = P.cf.tx * bmaf2
    cf_base = P.cf.tx * bmaf

    cf_plaf_tx = 1 + P.cf.plaf_tx1 * min_(cf_nbenf, 2) + P.cf.plaf_tx2 * max_(cf_nbenf - 2, 0)
    cf_majo = isol | biact
    cf_plaf = P.cf.plaf * cf_plaf_tx + P.cf.plaf_maj * cf_majo
    cf_plaf2 = cf_plaf + 12 * cf_base_n_2

    cf = (cf_nbenf >= 3) * ((br_pf <= cf_plaf) * cf_base +
                             (br_pf > cf_plaf) * max_(cf_plaf2 - br_pf, 0) / 12.0)
    return 12 * cf
Ejemplo n.º 45
0
def _aged(self, age_holder, smic55_holder, br_pf, ape_taux_partiel, dep_trim, P = law.fam):
    '''
    Allocation garde d'enfant à domicile

    les deux conjoints actif et revenu min requis, jusqu'aux 6 ans de l'enfant né avant le 01/01/2004, emploi d'une garde A DOMICILE
    cette allocation consiste en une prise en charge partielle des charges sociales inhérentes à l'emploi d'une personne à domicile.
    Si vous avez au moins un enfant  de moins de 3 ans gardé au domicile, 2 cas :
    Revenus 2005 > 37 241  € : la CAF prend en charge 50% des charges sociales (plafonné à 1 106 € par trimestre),
    Revenus 2005 < 37 341  € : la CAF prend en charge 75% des charges sociales (plafonné à 1 659 € par trimestre).
    Si vous avez un enfant de plus de 3 ans gardé au domicile (1 seul cas, sans condition de ressources) :
    la CAF prend en charge 50% des charges sociales (plafonné à 553 € par trimestre)
    '''
    # TODO: trimestrialiser
    age = self.split_by_roles(age_holder, roles = ENFS)
    smic55 = self.split_by_roles(smic55_holder, roles = ENFS)

    nbenf = nb_enf(age, smic55, 0, P.aged.age1 - 1)
    nbenf2 = nb_enf(age, smic55, 0, P.aged.age2 - 1)
    elig1 = (nbenf > 0)
    elig2 = not_(elig1) * (nbenf2 > 0) * ape_taux_partiel
    depenses = 4 * dep_trim  # gérer les dépenses trimestrielles
    aged3 = elig1 * (max_(P.aged.remb_plaf1 - P.aged.remb_taux1 * depenses, 0) * (br_pf > P.aged.revenus_plaf)
       + (br_pf <= P.aged.revenus_plaf) * max_(P.aged.remb_taux2 * depenses - P.aged.remb_plaf1, 0))
    aged6 = elig2 * max_(P.aged.remb_taux2 * depenses - P.aged.remb_plaf2, 0)
    return 12 * (aged3 + aged6)  # annualisé
Ejemplo n.º 46
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
Ejemplo n.º 47
0
    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
Ejemplo n.º 48
0
    def function(self, simulation, period):
        period = period.start.period(u'month').offset('first-of')
        type_sal = simulation.calculate('type_sal', period)
        traitement_indiciaire_brut = simulation.calculate('traitement_indiciaire_brut', period)
        af_nbenf_holder = simulation.compute('af_nbenf', period)
        _P = simulation.legislation_at(period.start)

        fonc_nbenf = self.cast_from_entity_to_role(af_nbenf_holder, role = CHEF)
        P = _P.fonc.supp_fam
        part_fixe_1 = P.fixe.enf1
        part_fixe_2 = P.fixe.enf2
        part_fixe_supp = P.fixe.enfsupp
        part_fixe = (
            part_fixe_1 * (fonc_nbenf == 1) + part_fixe_2 * (fonc_nbenf == 2)
            + part_fixe_supp * max_(0, fonc_nbenf - 2)
            )
        # pct_variable_1 = 0
        pct_variable_2 = P.prop.enf2
        pct_variable_3 = P.prop.enf3
        pct_variable_supp = P.prop.enfsupp
        pct_variable = (
            pct_variable_2 * (fonc_nbenf == 2) + (pct_variable_3) * (fonc_nbenf == 3)
            + pct_variable_supp * max_(0, fonc_nbenf - 3))

        indice_maj_min = P.IM_min
        indice_maj_max = P.IM_max

        traitement_brut_mensuel_min = _traitement_brut_mensuel(indice_maj_min, _P)
        plancher_mensuel_1 = part_fixe
        plancher_mensuel_2 = part_fixe + traitement_brut_mensuel_min * pct_variable_2
        plancher_mensuel_3 = part_fixe + traitement_brut_mensuel_min * pct_variable_3
        plancher_mensuel_supp = traitement_brut_mensuel_min * pct_variable_supp

        plancher = (plancher_mensuel_1 * (fonc_nbenf == 1) +
                    plancher_mensuel_2 * (fonc_nbenf == 2) +
                    plancher_mensuel_3 * (fonc_nbenf >= 3) +
                    plancher_mensuel_supp * max_(0, fonc_nbenf - 3))

        traitement_brut_mensuel_max = _traitement_brut_mensuel(indice_maj_max, _P)
        plafond_mensuel_1 = part_fixe
        plafond_mensuel_2 = part_fixe + traitement_brut_mensuel_max * pct_variable_2
        plafond_mensuel_3 = part_fixe + traitement_brut_mensuel_max * pct_variable_3
        plafond_mensuel_supp = traitement_brut_mensuel_max * pct_variable_supp

        plafond = (plafond_mensuel_1 * (fonc_nbenf == 1) + plafond_mensuel_2 * (fonc_nbenf == 2) +
                   plafond_mensuel_3 * (fonc_nbenf == 3) +
                   plafond_mensuel_supp * max_(0, fonc_nbenf - 3))

        sft = min_(max_(part_fixe + pct_variable * traitement_indiciaire_brut, plancher), plafond) * (type_sal >= 2)
        # Nota Bene:
        # type_sal is an EnumCol which enum is:
        # CAT = Enum(['prive_non_cadre',
        #             'prive_cadre',
        #             'public_titulaire_etat',
        #             'public_titulaire_militaire',
        #             'public_titulaire_territoriale',
        #             'public_titulaire_hospitaliere',
        #             'public_non_titulaire'])
        return period, sft
Ejemplo n.º 49
0
def _salcho_imp(rev_sal, cho_ld, fra, abatpro = law.ir.tspr.abatpro):
    """
    Salaires après abattements
    'ind'
    """
    amin = abatpro.min * not_(cho_ld) + abatpro.min2 * cho_ld
    abatfor = round(min_(max_(abatpro.taux * rev_sal, amin), abatpro.max))
    return (fra > abatfor) * (rev_sal - fra) + (fra <= abatfor) * max_(0, rev_sal - abatfor)
Ejemplo n.º 50
0
 def function(famille, period):
     period = period.this_month
     rsa = famille('rsa', period, period)
     rsa_base_ressources = famille('rsa_base_ressources', period)
     rsa_socle = famille('rsa_socle', period)
     rsa_forfait_logement = famille('rsa_forfait_logement', period)
     rmi = max_(0, rsa_socle - rsa_forfait_logement - rsa_base_ressources)
     return period, max_(rsa - rmi, 0)
Ejemplo n.º 51
0
def _salcho_imp(rev_sal, cho_ld, fra, _P):
    """
    Salaires après abattements
    'ind'
    """
    P = _P.ir.tspr.abatpro
    amin = P.min * not_(cho_ld) + P.min2 * cho_ld
    abatfor = round(min_(max_(P.taux * rev_sal, amin), P.max))
    return (fra > abatfor) * (rev_sal - fra) + (fra <= abatfor) * max_(0, rev_sal - abatfor)
Ejemplo n.º 52
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
Ejemplo n.º 53
0
def _ppe_elig(rfr, ppe_coef, ppe_rev, marpac, veuf, celdiv, nbptr, ppe = law.ir.credits_impot.ppe):
    '''
    PPE: eligibilité à la ppe, condition sur le revenu fiscal de référence
    'foy'
    CF ligne 1: http://bofip.impots.gouv.fr/bofip/3913-PGP.html
    '''
    seuil = (veuf | celdiv) * (ppe.eligi1 + 2 * max_(nbptr - 1, 0) * ppe.eligi3) \
            + marpac * (ppe.eligi2 + 2 * max_(nbptr - 2, 0) * ppe.eligi3)
    return (rfr * ppe_coef) <= seuil
Ejemplo n.º 54
0
def _salcho_imp(rev_sal, cho_ld, fra, _P):
    """
    Salaires après abattements
    'ind'
    """
    P = _P.ir.tspr.abatpro
    amin = P.min * not_(cho_ld) + P.min2 * cho_ld
    abatfor = round(min_(max_(P.taux * rev_sal, amin), P.max))
    return (fra > abatfor) * (rev_sal - fra) + (fra <= abatfor) * max_(0, rev_sal - abatfor)
Ejemplo n.º 55
0
def _supp_familial_traitement(type_sal, salbrut, af_nbenf, _P):
    '''
    Supplément familial de traitement
    Attention : par hypothèse ne peut êre attribué qu'à la tête du ménage
    TODO: gérer le cas encore problématique du conjoint fonctionnaire
    '''
    # TODO: un seul sft par couple où est présent un fonctionnaire
    fonc_nbenf = af_nbenf
    P = _P.fonc.supp_fam

    part_fixe_1 = P.fixe.enf1
    part_fixe_2 = P.fixe.enf2
    part_fixe_supp = P.fixe.enfsupp
    part_fixe = (part_fixe_1 * (fonc_nbenf == 1) + part_fixe_2 * (fonc_nbenf == 2) +
                  part_fixe_supp * max_(0, fonc_nbenf - 2))

    # pct_variable_1 = 0
    pct_variable_2 = P.prop.enf2
    pct_variable_3 = P.prop.enf3
    pct_variable_supp = P.prop.enfsupp
    pct_variable = (pct_variable_2 * (fonc_nbenf == 2) + (pct_variable_3) * (fonc_nbenf == 3) +
                      pct_variable_supp * max_(0, fonc_nbenf - 3))

    indice_maj_min = P.IM_min
    indice_maj_max = P.IM_max

    plancher_mensuel_1 = part_fixe
    plancher_mensuel_2 = part_fixe + _traitement_brut_mensuel(indice_maj_min, _P) * pct_variable_2
    plancher_mensuel_3 = part_fixe + _traitement_brut_mensuel(indice_maj_min, _P) * pct_variable_3
    plancher_mensuel_supp = _traitement_brut_mensuel(indice_maj_min, _P) * pct_variable_supp

    plancher = (plancher_mensuel_1 * (fonc_nbenf == 1) +
                plancher_mensuel_2 * (fonc_nbenf == 2) +
                plancher_mensuel_3 * (fonc_nbenf >= 3) +
                plancher_mensuel_supp * max_(0, fonc_nbenf - 3))

    plafond_mensuel_1 = part_fixe
    plafond_mensuel_2 = part_fixe + _traitement_brut_mensuel(indice_maj_max, _P) * pct_variable_2
    plafond_mensuel_3 = part_fixe + _traitement_brut_mensuel(indice_maj_max, _P) * pct_variable_3
    plafond_mensuel_supp = _traitement_brut_mensuel(indice_maj_max, _P) * pct_variable_supp

    plafond = (plafond_mensuel_1 * (fonc_nbenf == 1) + plafond_mensuel_2 * (fonc_nbenf == 2) +
               plafond_mensuel_3 * (fonc_nbenf == 3) +
               plafond_mensuel_supp * max_(0, fonc_nbenf - 3))

    sft = min_(max_(part_fixe + pct_variable * salbrut / 12, plancher), plafond) * (type_sal >= 2)
    # Nota Bene:
    # type_sal is an EnumCol which enum is:
    # CAT = Enum(['prive_non_cadre',
    #             'prive_cadre',
    #             'public_titulaire_etat',
    #             'public_titulaire_militaire',
    #             'public_titulaire_territoriale',
    #             'public_titulaire_hospitaliere',
    #             'public_non_titulaire'])
    return 12 * sft
Ejemplo n.º 56
0
    def function(self, simulation, period):
        period = period.this_month
        mois_precedent = period.offset(-1)
        last_day_reference_year = period.n_2.stop
        base_ressources_defaut = simulation.calculate(
            'aide_logement_base_ressources_defaut', period)
        base_ressources_eval_forfaitaire = simulation.calculate(
            'aide_logement_base_ressources_eval_forfaitaire', period)
        en_couple = simulation.calculate('en_couple', period)
        aah_holder = simulation.compute('aah', mois_precedent)
        aah = self.sum_by_entity(aah_holder, roles=[CHEF, PART])
        age_holder = simulation.compute('age', period)
        age = self.split_by_roles(age_holder, roles=[CHEF, PART])
        smic_horaire_brut_n2 = simulation.legislation_at(
            last_day_reference_year).cotsoc.gen.smic_h_b
        salaire_imposable_holder = simulation.compute('salaire_imposable',
                                                      period.offset(-1))
        somme_salaires = self.sum_by_entity(salaire_imposable_holder,
                                            roles=[CHEF, PART])

        plafond_eval_forfaitaire = 1015 * smic_horaire_brut_n2

        plafond_salaire_jeune_isole = simulation.legislation_at(
            period.start).prestations.aides_logement.ressources.dar_8
        plafond_salaire_jeune_couple = simulation.legislation_at(
            period.start).prestations.aides_logement.ressources.dar_9
        plafond_salaire_jeune = where(en_couple, plafond_salaire_jeune_couple,
                                      plafond_salaire_jeune_isole)

        neutral_jeune = or_(age[CHEF] < 25, and_(en_couple, age[PART] < 25))
        neutral_jeune &= somme_salaires < plafond_salaire_jeune

        eval_forfaitaire = base_ressources_defaut <= plafond_eval_forfaitaire
        eval_forfaitaire &= base_ressources_eval_forfaitaire > 0
        eval_forfaitaire &= aah == 0
        eval_forfaitaire &= not_(neutral_jeune)

        ressources = where(eval_forfaitaire, base_ressources_eval_forfaitaire,
                           base_ressources_defaut)

        # Planchers de ressources pour étudiants
        # Seul le statut étudiant (et boursier) du demandeur importe, pas celui du conjoint
        Pr = simulation.legislation_at(
            period.start).prestations.aides_logement.ressources
        etudiant_holder = simulation.compute('etudiant', period)
        boursier_holder = simulation.compute('boursier', period)
        etudiant = self.split_by_roles(etudiant_holder, roles=[CHEF, PART])
        boursier = self.split_by_roles(boursier_holder, roles=[CHEF, PART])
        montant_plancher_ressources = max_(
            0, etudiant[CHEF] * Pr.dar_4 - boursier[CHEF] * Pr.dar_5)
        ressources = max_(ressources, montant_plancher_ressources)

        # Arrondi aux 100 euros supérieurs
        ressources = ceil(ressources / 100) * 100

        return period, ressources