def core(self,x): if self.core_name == 'sigmoid': res = 1/(1+np.exp(-x)) elif self.core_name == 'softplus': res = np.log(np.exp(x)+1) elif self.core_name == 'relu': std = (np.std(x,axis=(1,2,3)) + 1) res = x*1 for i in range(res.shape[0]): res[i,:,:,:] /= std[i] res[res<0] = 0 elif self.core_name == 'abstanh': res = np.abs_(np.tanh(x)) elif self.core_name == 'linear': res = x * 1.0 elif self.core_name == 'one_relu': res = x*1 res[res>1] = 1 res[res<-1] = -1 elif self.core_name == 'strelu': res = x*1 res[res<0] = 0 else: res = 1/(1+np.exp(-x)) return res
def core(self,x,core_name): if core_name == 'sigmoid': res = 1/(1+np.exp(-x)) elif core_name == 'softplus': res = np.log(np.exp(x)+1) elif core_name == 'relu': res = x / (np.std(x,axis=0).reshape((-1,1)) + 1) res[res<0] = 0 elif core_name == 'abstanh': res = np.abs_(np.tanh(x)) elif core_name == 'tanh': res = np.tanh(x) elif core_name == 'linear': res = x * 1.0 elif core_name == 'one_relu': res = x*1 res[res>1] = 1 res[res<-1] = -1 elif self.core_name == 'strelu': res = x*1 res[res<0] = 0 else: res = 1/(1+np.exp(-x)) return res
def function(self, simulation, period): salaire_net = simulation.calculate('salaire_net', period) chonet = simulation.calculate('chonet', period) rstnet = simulation.calculate('rstnet', period) pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', period) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', period) rsa_base_ressources_patrimoine_i = simulation.calculate_add('rsa_base_ressources_patrimoine_i', period) indemnites_journalieres_imposables = simulation.calculate('indemnites_journalieres_imposables', period) indemnites_stage = simulation.calculate('indemnites_stage', period) revenus_stage_formation_pro = simulation.calculate('revenus_stage_formation_pro', period) allocation_securisation_professionnelle = simulation.calculate( 'allocation_securisation_professionnelle', period) prestation_compensatoire = simulation.calculate('prestation_compensatoire', period) pensions_invalidite = simulation.calculate('pensions_invalidite', period) indemnites_chomage_partiel = simulation.calculate('indemnites_chomage_partiel', period) bourse_recherche = simulation.calculate('bourse_recherche', period) gains_exceptionnels = simulation.calculate('gains_exceptionnels', period) tns_total_revenus_net = simulation.calculate_add('tns_total_revenus_net', period) result = ( salaire_net + indemnites_chomage_partiel + indemnites_stage + chonet + rstnet + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + rsa_base_ressources_patrimoine_i + allocation_securisation_professionnelle + indemnites_journalieres_imposables + prestation_compensatoire + pensions_invalidite + bourse_recherche + gains_exceptionnels + tns_total_revenus_net + revenus_stage_formation_pro ) return period, result
def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') previous_year = period.start.period('year').offset(-1) salaire_imposable = simulation.calculate_add('salaire_imposable', previous_year) salaire_imposable_this_month = simulation.calculate('salaire_imposable', period) salaire_imposable_interrompu = (salaire_imposable > 0) * (salaire_imposable_this_month == 0) # Le Salaire d'une activité partielle est neutralisé en cas d'interruption salaire_imposable = (1 - salaire_imposable_interrompu) * salaire_imposable rstnet = simulation.calculate('rstnet', previous_year) tns_auto_entrepreneur_benefice = simulation.calculate_add('tns_auto_entrepreneur_benefice', previous_year) tns_micro_entreprise_benefice = simulation.calculate_add('tns_micro_entreprise_benefice', period) tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', period) tns_autres_revenus = simulation.calculate('tns_autres_revenus', period) pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', previous_year) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', previous_year ) aah = simulation.calculate_add('aah', previous_year) indemnites_stage = simulation.calculate('indemnites_stage', previous_year) revenus_stage_formation_pro = simulation.calculate('revenus_stage_formation_pro', previous_year) return period, ( salaire_imposable + rstnet + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + tns_auto_entrepreneur_benefice + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus )
def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') previous_year = period.start.period('year').offset(-1) last_month = period.start.period('month').offset(-1) has_ressources_substitution = ( simulation.calculate('chonet', last_month) + simulation.calculate('indemnites_journalieres', last_month) + simulation.calculate('rstnet', last_month) ) > 0 def calculateWithAbatement(ressourceName, neutral_totale = False): ressource_year = simulation.calculate_add(ressourceName, previous_year) ressource_last_month = simulation.calculate(ressourceName, last_month) ressource_interrompue = (ressource_year > 0) * (ressource_last_month == 0) # Les ressources interrompues sont abattues différement si elles sont substituées ou non. # http://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000020398006&cidTexte=LEGITEXT000006072050 tx_abat_partiel = simulation.legislation_at(period.start).minim.ass.abat_rev_subst_conj tx_abat_total = simulation.legislation_at(period.start).minim.ass.abat_rev_non_subst_conj abat_partiel = ressource_interrompue * has_ressources_substitution * (1 - neutral_totale) abat_total = ressource_interrompue * (1 - abat_partiel) tx_abat_applique = abat_partiel * tx_abat_partiel + abat_total * tx_abat_total return (1 - tx_abat_applique) * ressource_year salaire_imposable = calculateWithAbatement('salaire_imposable') indemnites_stage = calculateWithAbatement('indemnites_stage', neutral_totale = True) revenus_stage_formation_pro = calculateWithAbatement('revenus_stage_formation_pro') chonet = calculateWithAbatement('chonet', neutral_totale = True) indemnites_journalieres = calculateWithAbatement('indemnites_journalieres') aah = calculateWithAbatement('aah') rstnet = calculateWithAbatement('rstnet') pensions_alimentaires_percues = calculateWithAbatement('pensions_alimentaires_percues') tns_auto_entrepreneur_benefice = calculateWithAbatement('tns_auto_entrepreneur_benefice') tns_micro_entreprise_benefice = simulation.calculate_add('tns_micro_entreprise_benefice', period) tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', period) tns_autres_revenus = simulation.calculate('tns_autres_revenus', period) pensions_alimentaires_versees_individu = simulation.calculate_add( 'pensions_alimentaires_versees_individu', previous_year ) result = ( salaire_imposable + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + rstnet + chonet + indemnites_journalieres + tns_auto_entrepreneur_benefice + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus ) return period, result
def formula(individu, period): # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year salaire_imposable = individu('salaire_imposable', previous_year, options=[ADD]) salaire_imposable_this_month = individu('salaire_imposable', period) salaire_imposable_interrompu = (salaire_imposable > 0) * ( salaire_imposable_this_month == 0) # Le Salaire d'une activité partielle est neutralisé en cas d'interruption salaire_imposable = (1 - salaire_imposable_interrompu) * salaire_imposable retraite_nette = individu('retraite_nette', previous_year, options=[ADD]) revenus_capital = individu('revenus_capital', period) * individu.has_role( FoyerFiscal.DECLARANT_PRINCIPAL) def revenus_tns(): revenus_auto_entrepreneur = individu( 'tns_auto_entrepreneur_benefice', previous_year, options=[ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu( 'tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = individu( 'tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = individu('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus pensions_alimentaires_percues = individu( 'pensions_alimentaires_percues', previous_year, options=[ADD]) pensions_alimentaires_versees_individu = individu( 'pensions_alimentaires_versees_individu', previous_year, options=[ADD]) aah = individu('aah', previous_year, options=[ADD]) indemnites_stage = individu('indemnites_stage', previous_year, options=[ADD]) revenus_stage_formation_pro = individu('revenus_stage_formation_pro', previous_year, options=[ADD]) return (salaire_imposable + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + revenus_tns() + revenus_capital)
def formula(individu, period, parameters): # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year last_month = period.last_month P = parameters(period).cs.cmu ressources_a_inclure = [ 'aah', 'allocation_securisation_professionnelle', 'asi', 'ass', 'bourse_recherche', 'caah', 'chomage_net', 'dedommagement_victime_amiante', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_stage', 'indemnites_compensatrices_conges_payes', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_combattant', 'retraite_nette', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_net', 'rente_accident_travail', ] boursier = individu('boursier', period) bourse = not_(boursier) * individu('bourse_enseignement_sup', period) ressources = sum([ individu(ressource, previous_year, options=[ADD]) for ressource in ressources_a_inclure ]) pensions_alim_versees = abs_( individu('pensions_alimentaires_versees_individu', previous_year, options=[ADD])) return (ressources + bourse + revenus_tns(individu, previous_year, last_year) - pensions_alim_versees - abbattement_chomage(individu, period, previous_year, P) - neutralisation_stage_formation_pro(individu, previous_year, last_month))
def function(individu, period, legislation): last_year = period.last_year salaire_net = individu('salaire_net', period) indemnites_stage = individu('indemnites_stage', period) smic = legislation(period).paris.smic_net_mensuel indemnites_stage_imposable = where((smic >= indemnites_stage), indemnites_stage, 0) revenus_stage_formation_pro = individu('revenus_stage_formation_pro', period) chomage_net = individu('chomage_net', period) allocation_securisation_professionnelle = individu( 'allocation_securisation_professionnelle', period) indemnites_journalieres = individu('indemnites_journalieres', period) indemnites_chomage_partiel = individu('indemnites_chomage_partiel', period) indemnites_volontariat = individu('indemnites_volontariat', period) pensions_alimentaires_percues = individu( 'pensions_alimentaires_percues', period) pensions_alimentaires_versees_individu = individu( 'pensions_alimentaires_versees_individu', period) prestation_compensatoire = individu('prestation_compensatoire', period) retraite_nette = individu('retraite_nette', period) pensions_invalidite = individu('pensions_invalidite', period) def revenus_tns(): revenus_auto_entrepreneur = individu( 'tns_auto_entrepreneur_benefice', period, options=[ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu( 'tns_micro_entreprise_benefice', last_year) / 12 tns_benefice_exploitant_agricole = individu( 'tns_benefice_exploitant_agricole', last_year) / 12 tns_autres_revenus = individu('tns_autres_revenus', last_year) / 12 return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus result = (salaire_net + indemnites_chomage_partiel + chomage_net + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + allocation_securisation_professionnelle + prestation_compensatoire + pensions_invalidite + revenus_tns() + revenus_stage_formation_pro + indemnites_stage_imposable + indemnites_journalieres + indemnites_volontariat) return result
def formula(individu, period, parameters): # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year salaire_imposable = calculateWithAbatement(individu, parameters, period, 'salaire_imposable') revenus_stage_formation_pro = calculateWithAbatement( individu, parameters, period, 'revenus_stage_formation_pro') aah = calculateWithAbatement(individu, parameters, period, 'aah') retraite_nette = calculateWithAbatement(individu, parameters, period, 'retraite_nette') pensions_alimentaires_percues = calculateWithAbatement( individu, parameters, period, 'pensions_alimentaires_percues') indemnites_stage = calculateWithAbatement(individu, parameters, period, 'indemnites_stage') pensions_invalidite = individu('pensions_invalidite', previous_year, options=[ADD]) revenus_locatifs = individu('revenus_locatifs', previous_year, options=[ADD]) revenus_capital = individu('revenus_capital', period) * individu.has_role( FoyerFiscal.DECLARANT_PRINCIPAL) def revenus_tns(): revenus_auto_entrepreneur = individu( 'tns_auto_entrepreneur_benefice', previous_year, options=[ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu( 'tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = individu( 'tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = individu('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus pensions_alimentaires_versees_individu = individu( 'pensions_alimentaires_versees_individu', previous_year, options=[ADD]) return (salaire_imposable + retraite_nette + pensions_invalidite + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + revenus_tns() + revenus_locatifs + revenus_capital)
def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') previous_year = period.start.period('year').offset(-1) last_month = period.start.period('month').offset(-1) activite = simulation.calculate('activite', period) salaire_net = simulation.calculate_add('salaire_net', previous_year) chonet = simulation.calculate('chonet', previous_year) rstnet = simulation.calculate('rstnet', previous_year) pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', previous_year) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', previous_year ) rsa_base_ressources_patrimoine_i = simulation.calculate_add('rsa_base_ressources_patrimoine_i', previous_year) aah = simulation.calculate_add('aah', previous_year) indemnites_journalieres = simulation.calculate('indemnites_journalieres', previous_year) indemnites_stage = simulation.calculate('indemnites_stage', previous_year) revenus_stage_formation_pro_annee = simulation.calculate('revenus_stage_formation_pro', previous_year) revenus_stage_formation_pro_dernier_mois = simulation.calculate('revenus_stage_formation_pro', last_month) allocation_securisation_professionnelle = simulation.calculate( 'allocation_securisation_professionnelle', previous_year ) prime_forfaitaire_mensuelle_reprise_activite = simulation.calculate( 'prime_forfaitaire_mensuelle_reprise_activite', previous_year ) dedommagement_victime_amiante = simulation.calculate('dedommagement_victime_amiante', previous_year) prestation_compensatoire = simulation.calculate('prestation_compensatoire', previous_year) retraite_combattant = simulation.calculate('retraite_combattant', previous_year) pensions_invalidite = simulation.calculate('pensions_invalidite', previous_year) indemnites_chomage_partiel = simulation.calculate('indemnites_chomage_partiel', previous_year) bourse_enseignement_sup = simulation.calculate('bourse_enseignement_sup', previous_year) bourse_recherche = simulation.calculate('bourse_recherche', previous_year) gains_exceptionnels = simulation.calculate('gains_exceptionnels', previous_year) tns_total_revenus_net = simulation.calculate_add('tns_total_revenus_net', previous_year) P = simulation.legislation_at(period.start).cmu # Revenus de stage de formation professionnelle exclus si plus perçus depuis 1 mois revenus_stage_formation_pro = revenus_stage_formation_pro_annee * (revenus_stage_formation_pro_dernier_mois > 0) # Abattement sur revenus d'activité si chômage ou formation professionnelle abattement_chomage_fp = or_(activite == 1, revenus_stage_formation_pro_dernier_mois > 0) return period, ((salaire_net + indemnites_chomage_partiel) * (1 - abattement_chomage_fp * P.abattement_chomage) + indemnites_stage + aah + chonet + rstnet + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + rsa_base_ressources_patrimoine_i + allocation_securisation_professionnelle + indemnites_journalieres + prime_forfaitaire_mensuelle_reprise_activite + dedommagement_victime_amiante + prestation_compensatoire + retraite_combattant + pensions_invalidite + bourse_enseignement_sup + bourse_recherche + gains_exceptionnels + tns_total_revenus_net + revenus_stage_formation_pro)
def function(self, simulation, period): period = period.this_month # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year salaire_imposable = simulation.calculate_add('salaire_imposable', previous_year) salaire_imposable_this_month = simulation.calculate( 'salaire_imposable', period) salaire_imposable_interrompu = (salaire_imposable > 0) * ( salaire_imposable_this_month == 0) # Le Salaire d'une activité partielle est neutralisé en cas d'interruption salaire_imposable = (1 - salaire_imposable_interrompu) * salaire_imposable retraite_nette = simulation.calculate('retraite_nette', previous_year) def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add( 'tns_auto_entrepreneur_benefice', previous_year) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate( 'tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = simulation.calculate( 'tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus pensions_alimentaires_percues = simulation.calculate( 'pensions_alimentaires_percues', previous_year) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', previous_year) aah = simulation.calculate_add('aah', previous_year) indemnites_stage = simulation.calculate('indemnites_stage', previous_year) revenus_stage_formation_pro = simulation.calculate( 'revenus_stage_formation_pro', previous_year) return period, (salaire_imposable + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + revenus_tns())
def formula(individu, period): # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year salaire_imposable = individu('salaire_imposable', previous_year, options = [ADD]) salaire_imposable_this_month = individu('salaire_imposable', period) salaire_imposable_interrompu = (salaire_imposable > 0) * (salaire_imposable_this_month == 0) # Le Salaire d'une activité partielle est neutralisé en cas d'interruption salaire_imposable = (1 - salaire_imposable_interrompu) * salaire_imposable retraite_nette = individu('retraite_nette', previous_year, options = [ADD]) revenus_locatifs = individu('revenus_locatifs', previous_year, options = [ADD]) revenus_capital = individu('revenus_capital', period) * individu.has_role(FoyerFiscal.DECLARANT_PRINCIPAL) pensions_invalidite = individu('pensions_invalidite', previous_year, options = [ADD]) def revenus_tns(): revenus_auto_entrepreneur = individu('tns_auto_entrepreneur_benefice', previous_year, options = [ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu('tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = individu('tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = individu('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus pensions_alimentaires_percues = individu('pensions_alimentaires_percues', previous_year, options = [ADD]) # Article R5423-4 du code du travail pensions_alimentaires_versees_individu = individu('pensions_alimentaires_versees_individu', previous_year, options = [ADD]) aah = individu('aah', previous_year, options = [ADD]) indemnites_stage = individu('indemnites_stage', previous_year, options = [ADD]) revenus_stage_formation_pro = individu('revenus_stage_formation_pro', previous_year, options = [ADD]) return ( salaire_imposable + retraite_nette + pensions_invalidite + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + revenus_tns() + revenus_locatifs + revenus_capital )
def function(individu, period, legislation): period = period.this_month last_year = period.last_year salaire_net = individu('salaire_net', period) indemnites_stage = individu('indemnites_stage', period) smic = legislation(period).paris.smic_net_mensuel indemnites_stage_imposable = where((smic >= indemnites_stage), indemnites_stage, 0) revenus_stage_formation_pro = individu('revenus_stage_formation_pro', period) chomage_net = individu('chomage_net', period) allocation_securisation_professionnelle = individu( 'allocation_securisation_professionnelle', period) indemnites_journalieres = individu('indemnites_journalieres', period) indemnites_chomage_partiel = individu('indemnites_chomage_partiel', period) indemnites_volontariat = individu('indemnites_volontariat', period) pensions_alimentaires_percues = individu('pensions_alimentaires_percues', period) pensions_alimentaires_versees_individu = individu( 'pensions_alimentaires_versees_individu', period) prestation_compensatoire = individu('prestation_compensatoire', period) retraite_nette = individu('retraite_nette', period) pensions_invalidite = individu('pensions_invalidite', period) def revenus_tns(): revenus_auto_entrepreneur = individu('tns_auto_entrepreneur_benefice', period, options = [ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu('tns_micro_entreprise_benefice', last_year) / 12 tns_benefice_exploitant_agricole = individu('tns_benefice_exploitant_agricole', last_year) / 12 tns_autres_revenus = individu('tns_autres_revenus', last_year) / 12 return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus result = ( salaire_net + indemnites_chomage_partiel + chomage_net + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + allocation_securisation_professionnelle + prestation_compensatoire + pensions_invalidite + revenus_tns() + revenus_stage_formation_pro + indemnites_stage_imposable + indemnites_journalieres + indemnites_volontariat ) return period, result
def function(self, simulation, period): period = period.this_month three_previous_months = period.start.period('month', 3).offset(-3) last_year = period.last_year salaire_net = simulation.calculate_add('salaire_net', three_previous_months) chomage_net = simulation.calculate_add('chomage_net', three_previous_months) retraite_nette = simulation.calculate_add('retraite_nette', three_previous_months) pensions_alimentaires_percues = simulation.calculate_add('pensions_alimentaires_percues', three_previous_months) pensions_alimentaires_versees_individu = simulation.calculate_add( 'pensions_alimentaires_versees_individu', three_previous_months) rsa_base_ressources_patrimoine_i = simulation.calculate_add('rsa_base_ressources_patrimoine_individu', three_previous_months) indemnites_journalieres_imposables = simulation.calculate_add('indemnites_journalieres_imposables', three_previous_months) indemnites_stage = simulation.calculate_add('indemnites_stage', three_previous_months) revenus_stage_formation_pro = simulation.calculate_add('revenus_stage_formation_pro', three_previous_months) allocation_securisation_professionnelle = simulation.calculate_add( 'allocation_securisation_professionnelle', three_previous_months) prestation_compensatoire = simulation.calculate_add('prestation_compensatoire', three_previous_months) pensions_invalidite = simulation.calculate_add('pensions_invalidite', three_previous_months) indemnites_chomage_partiel = simulation.calculate_add('indemnites_chomage_partiel', three_previous_months) bourse_recherche = simulation.calculate_add('bourse_recherche', three_previous_months) gains_exceptionnels = simulation.calculate_add('gains_exceptionnels', three_previous_months) def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add('tns_auto_entrepreneur_benefice', three_previous_months) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate('tns_micro_entreprise_benefice', last_year) * 3 / 12 tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', last_year) * 3 / 12 tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) * 3 / 12 return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus result = ( salaire_net + indemnites_chomage_partiel + indemnites_stage + chomage_net + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + rsa_base_ressources_patrimoine_i + allocation_securisation_professionnelle + indemnites_journalieres_imposables + prestation_compensatoire + pensions_invalidite + bourse_recherche + gains_exceptionnels + revenus_tns() + revenus_stage_formation_pro ) return period, result * 4
def function(self, simulation, period): period = period.this_month last_year = period.last_year salaire_net = simulation.calculate('salaire_net', period) chomage_net = simulation.calculate('chomage_net', period) retraite_nette = simulation.calculate('retraite_nette', period) pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', period) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', period) rsa_base_ressources_patrimoine_i = simulation.calculate_add('rsa_base_ressources_patrimoine_individu', period) indemnites_journalieres_imposables = simulation.calculate('indemnites_journalieres_imposables', period) indemnites_stage = simulation.calculate('indemnites_stage', period) revenus_stage_formation_pro = simulation.calculate('revenus_stage_formation_pro', period) allocation_securisation_professionnelle = simulation.calculate( 'allocation_securisation_professionnelle', period) prestation_compensatoire = simulation.calculate('prestation_compensatoire', period) pensions_invalidite = simulation.calculate('pensions_invalidite', period) indemnites_chomage_partiel = simulation.calculate('indemnites_chomage_partiel', period) bourse_recherche = simulation.calculate('bourse_recherche', period) gains_exceptionnels = simulation.calculate('gains_exceptionnels', period) def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add('tns_auto_entrepreneur_benefice', period) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate('tns_micro_entreprise_benefice', last_year) / 12 tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', last_year) / 12 tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) / 12 return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus result = ( salaire_net + indemnites_chomage_partiel + indemnites_stage + chomage_net + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + rsa_base_ressources_patrimoine_i + allocation_securisation_professionnelle + indemnites_journalieres_imposables + prestation_compensatoire + pensions_invalidite + bourse_recherche + gains_exceptionnels + revenus_tns() + revenus_stage_formation_pro ) return period, result
def function(self, simulation, period): period = period.this_month # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year salaire_imposable = simulation.calculate_add('salaire_imposable', previous_year) salaire_imposable_this_month = simulation.calculate('salaire_imposable', period) salaire_imposable_interrompu = (salaire_imposable > 0) * (salaire_imposable_this_month == 0) # Le Salaire d'une activité partielle est neutralisé en cas d'interruption salaire_imposable = (1 - salaire_imposable_interrompu) * salaire_imposable retraite_nette = simulation.calculate('retraite_nette', previous_year) def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add('tns_auto_entrepreneur_benefice', previous_year) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate('tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', previous_year) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', previous_year ) aah = simulation.calculate_add('aah', previous_year) indemnites_stage = simulation.calculate('indemnites_stage', previous_year) revenus_stage_formation_pro = simulation.calculate('revenus_stage_formation_pro', previous_year) return period, ( salaire_imposable + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + revenus_tns() )
def function(self, simulation, period): period = period.this_month # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year last_month = period.last_month salaire_net = simulation.calculate_add('salaire_net', previous_year) chomage_net = simulation.calculate('chomage_net', previous_year) retraite_nette = simulation.calculate('retraite_nette', previous_year) pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', previous_year) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', previous_year ) rsa_base_ressources_patrimoine_i = simulation.calculate_add('rsa_base_ressources_patrimoine_individu', previous_year) aah = simulation.calculate_add('aah', previous_year) indemnites_journalieres = simulation.calculate('indemnites_journalieres', previous_year) indemnites_stage = simulation.calculate('indemnites_stage', previous_year) revenus_stage_formation_pro_annee = simulation.calculate('revenus_stage_formation_pro', previous_year) allocation_securisation_professionnelle = simulation.calculate( 'allocation_securisation_professionnelle', previous_year ) prime_forfaitaire_mensuelle_reprise_activite = simulation.calculate( 'prime_forfaitaire_mensuelle_reprise_activite', previous_year ) dedommagement_victime_amiante = simulation.calculate('dedommagement_victime_amiante', previous_year) prestation_compensatoire = simulation.calculate('prestation_compensatoire', previous_year) retraite_combattant = simulation.calculate('retraite_combattant', previous_year) pensions_invalidite = simulation.calculate('pensions_invalidite', previous_year) indemnites_chomage_partiel = simulation.calculate('indemnites_chomage_partiel', previous_year) bourse_enseignement_sup = simulation.calculate('bourse_enseignement_sup', previous_year) bourse_recherche = simulation.calculate('bourse_recherche', previous_year) gains_exceptionnels = simulation.calculate('gains_exceptionnels', previous_year) revenus_stage_formation_pro_last_month = simulation.calculate('revenus_stage_formation_pro', last_month) chomage_last_month = simulation.calculate('chomage_net', last_month) def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add('tns_auto_entrepreneur_benefice', previous_year) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate('tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus P = simulation.legislation_at(period.start).cmu # Revenus de stage de formation professionnelle exclus si plus perçus depuis 1 mois revenus_stage_formation_pro = revenus_stage_formation_pro_annee * (revenus_stage_formation_pro_last_month > 0) # Abattement sur revenus d'activité si chômage ou formation professionnelle abattement_chomage_fp = or_(chomage_last_month > 0, revenus_stage_formation_pro_last_month > 0) return period, ((salaire_net + indemnites_chomage_partiel) * (1 - abattement_chomage_fp * P.abattement_chomage) + indemnites_stage + aah + chomage_net + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + rsa_base_ressources_patrimoine_i + allocation_securisation_professionnelle + indemnites_journalieres + prime_forfaitaire_mensuelle_reprise_activite + dedommagement_victime_amiante + prestation_compensatoire + retraite_combattant + pensions_invalidite + bourse_enseignement_sup + bourse_recherche + gains_exceptionnels + revenus_tns() + revenus_stage_formation_pro)
def function(self, simulation, period): period = period.this_month # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_month = period.last_month P = simulation.legislation_at(period.start).cmu ressources_a_inclure = [ 'aah', 'allocation_securisation_professionnelle', 'bourse_enseignement_sup', 'bourse_recherche', 'chomage_net', 'dedommagement_victime_amiante', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_stage', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_combattant', 'retraite_nette', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_net', ] ressources = sum([ simulation.calculate_add(ressource, previous_year) for ressource in ressources_a_inclure ]) pensions_alim_versees = abs_( simulation.calculate_add('pensions_alimentaires_versees_individu', previous_year)) revenus_stage_formation_pro_last_month = simulation.calculate( 'revenus_stage_formation_pro', last_month) # Abattement sur revenus d'activité si chômage ou formation professionnelle def abbattement_chomage(): indemnites_chomage_partiel = simulation.calculate( 'indemnites_chomage_partiel', previous_year) salaire_net = simulation.calculate_add('salaire_net', previous_year) chomage_last_month = simulation.calculate('chomage_net', last_month) condition = or_(chomage_last_month > 0, revenus_stage_formation_pro_last_month > 0) assiette = indemnites_chomage_partiel + salaire_net return condition * assiette * P.abattement_chomage # Revenus de stage de formation professionnelle exclus si plus perçus depuis 1 mois def neutralisation_stage_formation_pro(): revenus_stage_formation_pro_annee = simulation.calculate_add( 'revenus_stage_formation_pro', previous_year) return (revenus_stage_formation_pro_last_month == 0) * revenus_stage_formation_pro_annee def revenus_tns(): last_year = period.last_year revenus_auto_entrepreneur = simulation.calculate_add( 'tns_auto_entrepreneur_benefice', previous_year) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate( 'tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = simulation.calculate( 'tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus return period, ressources + revenus_tns( ) - pensions_alim_versees - abbattement_chomage( ) - neutralisation_stage_formation_pro()
def formula(individu, period, parameters): three_previous_months = period.start.period('month', 3).offset(-3) last_year = period.last_year salaire_net = individu('salaire_net', three_previous_months, options=[ADD]) chomage_net = individu('chomage_net', three_previous_months, options=[ADD]) retraite_nette = individu('retraite_nette', three_previous_months, options=[ADD]) pensions_alimentaires_percues = individu( 'pensions_alimentaires_percues', three_previous_months, options=[ADD]) pensions_alimentaires_versees_individu = individu( 'pensions_alimentaires_versees_individu', three_previous_months, options=[ADD]) rsa_base_ressources_patrimoine_i = individu( 'rsa_base_ressources_patrimoine_individu', three_previous_months, options=[ADD]) indemnites_journalieres_imposables = individu( 'indemnites_journalieres_imposables', three_previous_months, options=[ADD]) indemnites_stage = individu('indemnites_stage', three_previous_months, options=[ADD]) revenus_stage_formation_pro = individu('revenus_stage_formation_pro', three_previous_months, options=[ADD]) allocation_securisation_professionnelle = individu( 'allocation_securisation_professionnelle', three_previous_months, options=[ADD]) prestation_compensatoire = individu('prestation_compensatoire', three_previous_months, options=[ADD]) pensions_invalidite = individu('pensions_invalidite', three_previous_months, options=[ADD]) indemnites_chomage_partiel = individu('indemnites_chomage_partiel', three_previous_months, options=[ADD]) bourse_recherche = individu('bourse_recherche', three_previous_months, options=[ADD]) gains_exceptionnels = individu('gains_exceptionnels', three_previous_months, options=[ADD]) def revenus_tns(): revenus_auto_entrepreneur = individu( 'tns_auto_entrepreneur_benefice', three_previous_months, options=[ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu( 'tns_micro_entreprise_benefice', last_year) * 3 / 12 tns_benefice_exploitant_agricole = individu( 'tns_benefice_exploitant_agricole', last_year) * 3 / 12 tns_autres_revenus = individu('tns_autres_revenus', last_year) * 3 / 12 return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus result = (salaire_net + indemnites_chomage_partiel + indemnites_stage + chomage_net + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + rsa_base_ressources_patrimoine_i + allocation_securisation_professionnelle + indemnites_journalieres_imposables + prestation_compensatoire + pensions_invalidite + bourse_recherche + gains_exceptionnels + revenus_tns() + revenus_stage_formation_pro) return result * 4
def function(self, simulation, period): period = period.this_month last_year = period.last_year three_previous_months = period.last_3_months aspa_eligibilite = simulation.calculate('aspa_eligibilite', period) aspa_couple_holder = simulation.compute('aspa_couple', period) salaire_de_base = simulation.calculate_add('salaire_de_base', three_previous_months) chomage_net = simulation.calculate_add('chomage_net', three_previous_months) retraite_brute = simulation.calculate_add('retraite_brute', three_previous_months) pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', three_previous_months) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', three_previous_months ) retraite_titre_onereux_declarant1 = simulation.calculate_add('retraite_titre_onereux_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) revenus_fonciers_minima_sociaux = simulation.calculate_add('revenus_fonciers_minima_sociaux', three_previous_months) div_ms = simulation.calculate_add('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_chomage_partiel = simulation.calculate('indemnites_chomage_partiel', three_previous_months) indemnites_journalieres = simulation.calculate('indemnites_journalieres', three_previous_months) indemnites_volontariat = simulation.calculate('indemnites_volontariat', three_previous_months) def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add('tns_auto_entrepreneur_benefice', three_previous_months) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate('tns_micro_entreprise_benefice', last_year) * (3 / 12) tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', last_year) * (3 / 12) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) * (3 / 12) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus rsa_base_ressources_patrimoine_i = simulation.calculate_add( 'rsa_base_ressources_patrimoine_individu', three_previous_months ) aah = simulation.calculate_add('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é # FIXME Il faudrait vérifier que le conjoint est pensionné ASPA, pas qu'il est juste éligible ! aah = aah * not_(aspa_eligibilite) # Abattement sur les salaires (appliqué sur une base trimestrielle) abattement_forfaitaire_base = ( leg_1er_janvier.cotsoc.gen.smic_h_b * legislation.cotsoc.gen.nb_heure_travail_mensuel ) 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 + chomage_net + retraite_brute + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + retraite_titre_onereux_declarant1 + rpns + max_(0, rev_cap_bar) + max_(0, rev_cap_lib) + max_(0, revenus_fonciers_minima_sociaux) + 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 + indemnites_chomage_partiel + indemnites_volontariat + revenus_tns() + rsa_base_ressources_patrimoine_i + aah ) / 3
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_add('salaire_de_base', three_previous_months) chonet = simulation.calculate_add('chonet', three_previous_months) rstbrut = simulation.calculate_add('rstbrut', three_previous_months) pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', three_previous_months) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', three_previous_months ) rto_declarant1 = simulation.calculate_add('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_chomage_partiel = simulation.calculate('indemnites_chomage_partiel', three_previous_months) indemnites_journalieres = simulation.calculate('indemnites_journalieres', three_previous_months) indemnites_volontariat = simulation.calculate('indemnites_volontariat', three_previous_months) tns_total_revenus_net = simulation.calculate_add('tns_total_revenus_net', three_previous_months) rsa_base_ressources_patrimoine_i = simulation.calculate_add( 'rsa_base_ressources_patrimoine_i', three_previous_months ) aah = simulation.calculate_add('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é # FIXME Il faudrait vérifier que le conjoint est pensionné ASPA, pas qu'il est juste éligible ! 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 - abs_(pensions_alimentaires_versees_individu) + 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 + indemnites_chomage_partiel + indemnites_volontariat + tns_total_revenus_net + rsa_base_ressources_patrimoine_i + aah ) / 3
def formula(individu, period, parameters): last_year = period.last_year three_previous_months = period.last_3_months law = parameters(period) leg_1er_janvier = parameters(period.start.offset('first-of', 'year')) ressources_incluses = [ 'allocation_securisation_professionnelle', 'chomage_net', 'dedommagement_victime_amiante', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_volontariat', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_brute', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_de_base', ] # Revenus du foyer fiscal que l'on projette sur le premier invidividu rente_viagere_titre_onereux_foyer_fiscal = individu.foyer_fiscal('rente_viagere_titre_onereux', three_previous_months, options = [ADD]) revenus_foyer_fiscal_individu = rente_viagere_titre_onereux_foyer_fiscal * individu.has_role(FoyerFiscal.DECLARANT_PRINCIPAL) plus_values = individu.foyer_fiscal('assiette_csg_plus_values', period.this_year) * individu.has_role(FoyerFiscal.DECLARANT_PRINCIPAL) * (3 / 12) def revenus_tns(): revenus_auto_entrepreneur = individu('tns_auto_entrepreneur_benefice', three_previous_months, options = [ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu('tns_micro_entreprise_benefice', last_year) * (3 / 12) tns_benefice_exploitant_agricole = individu('tns_benefice_exploitant_agricole', last_year) * (3 / 12) tns_autres_revenus = individu('tns_autres_revenus', last_year) * (3 / 12) return ( revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus ) pension_invalidite = (individu('pensions_invalidite', period) > 0) aspa_eligibilite = individu('aspa_eligibilite', period) asi_eligibilite = individu('asi_eligibilite', period) # Exclut l'AAH si éligible ASPA, retraite ou pension invalidité # en application du II.B. de http://www.legislation.cnav.fr/Pages/texte.aspx?Nom=LE_MIN_19031982 aah = individu('aah', three_previous_months, options = [ADD], max_nb_cycles = 0) aah = aah * not_(aspa_eligibilite) * not_(asi_eligibilite) * not_(pension_invalidite) pensions_alimentaires_versees = individu( 'pensions_alimentaires_versees_individu', three_previous_months, options = [ADD] ) def abattement_salaire(): aspa_couple = individu.famille('aspa_couple', period) # Abattement sur les salaires (appliqué sur une base trimestrielle) abattement_forfaitaire_base = ( leg_1er_janvier.cotsoc.gen.smic_h_b * law.cotsoc.gen.nb_heure_travail_mensuel ) taux_abattement_forfaitaire = where( aspa_couple, law.prestations.minima_sociaux.aspa.abattement_forfaitaire_tx_couple, law.prestations.minima_sociaux.aspa.abattement_forfaitaire_tx_seul ) abattement_forfaitaire = abattement_forfaitaire_base * taux_abattement_forfaitaire salaire_de_base = individu('salaire_de_base', three_previous_months, options = [ADD]) return min_(salaire_de_base, abattement_forfaitaire) base_ressources_3_mois = sum( max_(0, individu(ressource_type, three_previous_months, options = [ADD])) for ressource_type in ressources_incluses ) + aah + revenus_foyer_fiscal_individu + revenus_tns() - abs_(pensions_alimentaires_versees) - abattement_salaire() + plus_values return base_ressources_3_mois / 3
def formula(individu, period, parameters): ''' N'intègre pas l'exception citée à l'article R5423-2 du Code du Travail sur les conjoints chefs d'entreprises entrant dans le champ d'application de l'article 50-0 du CGI ''' last_month = period.start.period('month').offset(-1) # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year has_ressources_substitution = ( individu('chomage_net', last_month) + individu('indemnites_journalieres', last_month) + individu('retraite_nette', last_month) ) > 0 def calculateWithAbatement(ressourceName, neutral_totale = False): ressource_year = individu(ressourceName, previous_year, options = [ADD]) ressource_last_month = individu(ressourceName, last_month) ressource_interrompue = (ressource_year > 0) * (ressource_last_month == 0) # Les ressources interrompues sont abattues différement si elles sont substituées ou non. # http://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000020398006&cidTexte=LEGITEXT000006072050 tx_abat_partiel = parameters(period).prestations.minima_sociaux.ass.abat_rev_subst_conj tx_abat_total = parameters(period).prestations.minima_sociaux.ass.abat_rev_non_subst_conj abat_partiel = ressource_interrompue * has_ressources_substitution * (1 - neutral_totale) abat_total = ressource_interrompue * (1 - abat_partiel) tx_abat_applique = abat_partiel * tx_abat_partiel + abat_total * tx_abat_total return (1 - tx_abat_applique) * ressource_year salaire_imposable = calculateWithAbatement('salaire_imposable') indemnites_stage = calculateWithAbatement('indemnites_stage', neutral_totale = True) revenus_stage_formation_pro = calculateWithAbatement('revenus_stage_formation_pro') chomage_net = calculateWithAbatement('chomage_net', neutral_totale = True) indemnites_journalieres = calculateWithAbatement('indemnites_journalieres') aah = calculateWithAbatement('aah') retraite_nette = calculateWithAbatement('retraite_nette') pensions_alimentaires_percues = calculateWithAbatement('pensions_alimentaires_percues') pensions_invalidite = individu('pensions_invalidite', previous_year, options = [ADD]) revenus_locatifs = individu('revenus_locatifs', previous_year, options = [ADD]) revenus_capital = individu('revenus_capital', period) * individu.has_role(FoyerFiscal.DECLARANT_PRINCIPAL) def revenus_tns(): revenus_auto_entrepreneur = individu('tns_auto_entrepreneur_benefice', previous_year, options = [ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu('tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = individu('tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = individu('tns_autres_revenus', last_year, options = [ADD]) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus pensions_alimentaires_versees_individu = individu('pensions_alimentaires_versees_individu', previous_year, options = [ADD]) result = ( salaire_imposable + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + retraite_nette + pensions_invalidite + chomage_net + indemnites_journalieres + revenus_tns() + revenus_locatifs + revenus_capital ) return result
def function(self, simulation, period): period = period.this_month last_month = period.start.period('month').offset(-1) # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year has_ressources_substitution = ( simulation.calculate('chomage_net', last_month) + simulation.calculate('indemnites_journalieres', last_month) + simulation.calculate('retraite_nette', last_month)) > 0 def calculateWithAbatement(ressourceName, neutral_totale=False): ressource_year = simulation.calculate_add(ressourceName, previous_year) ressource_last_month = simulation.calculate( ressourceName, last_month) ressource_interrompue = (ressource_year > 0) * (ressource_last_month == 0) # Les ressources interrompues sont abattues différement si elles sont substituées ou non. # http://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000020398006&cidTexte=LEGITEXT000006072050 tx_abat_partiel = simulation.legislation_at( period.start ).prestations.minima_sociaux.ass.abat_rev_subst_conj tx_abat_total = simulation.legislation_at( period.start ).prestations.minima_sociaux.ass.abat_rev_non_subst_conj abat_partiel = ressource_interrompue * has_ressources_substitution * ( 1 - neutral_totale) abat_total = ressource_interrompue * (1 - abat_partiel) tx_abat_applique = abat_partiel * tx_abat_partiel + abat_total * tx_abat_total return (1 - tx_abat_applique) * ressource_year salaire_imposable = calculateWithAbatement('salaire_imposable') indemnites_stage = calculateWithAbatement('indemnites_stage', neutral_totale=True) revenus_stage_formation_pro = calculateWithAbatement( 'revenus_stage_formation_pro') chomage_net = calculateWithAbatement('chomage_net', neutral_totale=True) indemnites_journalieres = calculateWithAbatement( 'indemnites_journalieres') aah = calculateWithAbatement('aah') retraite_nette = calculateWithAbatement('retraite_nette') pensions_alimentaires_percues = calculateWithAbatement( 'pensions_alimentaires_percues') def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add( 'tns_auto_entrepreneur_benefice', previous_year) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate( 'tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = simulation.calculate( 'tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus pensions_alimentaires_versees_individu = simulation.calculate_add( 'pensions_alimentaires_versees_individu', previous_year) result = (salaire_imposable + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + retraite_nette + chomage_net + indemnites_journalieres + revenus_tns()) return period, result
def formula(individu, period, parameters): last_year = period.last_year three_previous_months = period.last_3_months law = parameters(period) leg_1er_janvier = parameters(period.start.offset('first-of', 'year')) ressources_incluses = [ 'allocation_securisation_professionnelle', 'chomage_net', 'dedommagement_victime_amiante', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_volontariat', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_brute', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_de_base', ] # Revenus du foyer fiscal que l'on projette sur le premier invidividu rente_viagere_titre_onereux_foyer_fiscal = individu.foyer_fiscal( 'rente_viagere_titre_onereux', three_previous_months, options=[ADD]) revenus_foyer_fiscal_individu = rente_viagere_titre_onereux_foyer_fiscal * individu.has_role( FoyerFiscal.DECLARANT_PRINCIPAL) plus_values = individu.foyer_fiscal( 'assiette_csg_plus_values', period.this_year) * individu.has_role( FoyerFiscal.DECLARANT_PRINCIPAL) * (3 / 12) def revenus_tns(): revenus_auto_entrepreneur = individu( 'tns_auto_entrepreneur_benefice', three_previous_months, options=[ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu( 'tns_micro_entreprise_benefice', last_year) * (3 / 12) tns_benefice_exploitant_agricole = individu( 'tns_benefice_exploitant_agricole', last_year) * (3 / 12) tns_autres_revenus = individu('tns_autres_revenus', last_year) * (3 / 12) return (revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus) pension_invalidite = (individu('pensions_invalidite', period) > 0) aspa_eligibilite = individu('aspa_eligibilite', period) asi_eligibilite = individu('asi_eligibilite', period) # Exclut l'AAH si éligible ASPA, retraite ou pension invalidité # en application du II.B. de http://www.legislation.cnav.fr/Pages/texte.aspx?Nom=LE_MIN_19031982 aah = individu('aah', three_previous_months, options=[ADD], max_nb_cycles=0) aah = aah * not_(aspa_eligibilite) * not_(asi_eligibilite) * not_( pension_invalidite) pensions_alimentaires_versees = individu( 'pensions_alimentaires_versees_individu', three_previous_months, options=[ADD]) def abattement_salaire(): aspa_couple = individu.famille('aspa_couple', period) # Abattement sur les salaires (appliqué sur une base trimestrielle) abattement_forfaitaire_base = ( leg_1er_janvier.cotsoc.gen.smic_h_b * law.cotsoc.gen.nb_heure_travail_mensuel) taux_abattement_forfaitaire = where( aspa_couple, law.prestations.minima_sociaux.aspa. abattement_forfaitaire_tx_couple, law.prestations. minima_sociaux.aspa.abattement_forfaitaire_tx_seul) abattement_forfaitaire = abattement_forfaitaire_base * taux_abattement_forfaitaire salaire_de_base = individu('salaire_de_base', three_previous_months, options=[ADD]) return min_(salaire_de_base, abattement_forfaitaire) base_ressources_3_mois = sum( max_( 0, individu(ressource_type, three_previous_months, options=[ADD])) for ressource_type in ressources_incluses ) + aah + revenus_foyer_fiscal_individu + revenus_tns() - abs_( pensions_alimentaires_versees) - abattement_salaire() + plus_values return base_ressources_3_mois / 3
def function(self, simulation, period): period = period.this_month # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year last_month = period.last_month salaire_net = simulation.calculate_add('salaire_net', previous_year) chomage_net = simulation.calculate('chomage_net', previous_year) retraite_nette = simulation.calculate('retraite_nette', previous_year) pensions_alimentaires_percues = simulation.calculate( 'pensions_alimentaires_percues', previous_year) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', previous_year) rsa_base_ressources_patrimoine_i = simulation.calculate_add( 'rsa_base_ressources_patrimoine_individu', previous_year) aah = simulation.calculate_add('aah', previous_year) indemnites_journalieres = simulation.calculate( 'indemnites_journalieres', previous_year) indemnites_stage = simulation.calculate('indemnites_stage', previous_year) revenus_stage_formation_pro_annee = simulation.calculate( 'revenus_stage_formation_pro', previous_year) allocation_securisation_professionnelle = simulation.calculate( 'allocation_securisation_professionnelle', previous_year) prime_forfaitaire_mensuelle_reprise_activite = simulation.calculate( 'prime_forfaitaire_mensuelle_reprise_activite', previous_year) dedommagement_victime_amiante = simulation.calculate( 'dedommagement_victime_amiante', previous_year) prestation_compensatoire = simulation.calculate( 'prestation_compensatoire', previous_year) retraite_combattant = simulation.calculate('retraite_combattant', previous_year) pensions_invalidite = simulation.calculate('pensions_invalidite', previous_year) indemnites_chomage_partiel = simulation.calculate( 'indemnites_chomage_partiel', previous_year) bourse_enseignement_sup = simulation.calculate( 'bourse_enseignement_sup', previous_year) bourse_recherche = simulation.calculate('bourse_recherche', previous_year) gains_exceptionnels = simulation.calculate('gains_exceptionnels', previous_year) revenus_stage_formation_pro_last_month = simulation.calculate( 'revenus_stage_formation_pro', last_month) chomage_last_month = simulation.calculate('chomage_net', last_month) def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add( 'tns_auto_entrepreneur_benefice', previous_year) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate( 'tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = simulation.calculate( 'tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus P = simulation.legislation_at(period.start).cmu # Revenus de stage de formation professionnelle exclus si plus perçus depuis 1 mois revenus_stage_formation_pro = revenus_stage_formation_pro_annee * ( revenus_stage_formation_pro_last_month > 0) # Abattement sur revenus d'activité si chômage ou formation professionnelle abattement_chomage_fp = or_(chomage_last_month > 0, revenus_stage_formation_pro_last_month > 0) return period, ((salaire_net + indemnites_chomage_partiel) * (1 - abattement_chomage_fp * P.abattement_chomage) + indemnites_stage + aah + chomage_net + retraite_nette + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + rsa_base_ressources_patrimoine_i + allocation_securisation_professionnelle + indemnites_journalieres + prime_forfaitaire_mensuelle_reprise_activite + dedommagement_victime_amiante + prestation_compensatoire + retraite_combattant + pensions_invalidite + bourse_enseignement_sup + bourse_recherche + gains_exceptionnels + revenus_tns() + revenus_stage_formation_pro)
def function(individu, period, legislation): period = period.this_month last_year = period.last_year three_previous_months = period.last_3_months law = legislation(period) leg_1er_janvier = legislation(period.start.offset('first-of', 'year')) ressources_incluses = [ 'allocation_securisation_professionnelle', 'chomage_net', 'dedommagement_victime_amiante', 'div_ms', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_volontariat', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_brute', 'revenus_fonciers_minima_sociaux', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_de_base', ] # Revenus du foyer fiscal que l'on projette sur le premier invidividus rev_cap_bar_foyer_fiscal = max_(0, individu.foyer_fiscal('rev_cap_bar', three_previous_months, options = [ADD, DIVIDE])) rev_cap_lib_foyer_fiscal = max_(0, individu.foyer_fiscal('rev_cap_lib', three_previous_months, options = [ADD, DIVIDE])) retraite_titre_onereux_foyer_fiscal = individu.foyer_fiscal('retraite_titre_onereux', three_previous_months, options = [ADD, DIVIDE]) revenus_foyer_fiscal = rev_cap_bar_foyer_fiscal + rev_cap_lib_foyer_fiscal + retraite_titre_onereux_foyer_fiscal revenus_foyer_fiscal_individu = revenus_foyer_fiscal * individu.has_role(FoyerFiscal.DECLARANT_PRINCIPAL) def revenus_tns(): revenus_auto_entrepreneur = individu('tns_auto_entrepreneur_benefice', three_previous_months, options = [ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu('tns_micro_entreprise_benefice', last_year) * (3 / 12) tns_benefice_exploitant_agricole = individu('tns_benefice_exploitant_agricole', last_year) * (3 / 12) tns_autres_revenus = individu('tns_autres_revenus', last_year) * (3 / 12) return ( revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus ) pension_invalidite = (individu('pensions_invalidite', period) > 0) aspa_eligibilite = individu('aspa_eligibilite', period) asi_eligibilite = individu('asi_eligibilite', period) # Inclus l'AAH si conjoint non éligible ASPA, retraite et pension invalidité aah = individu('aah', three_previous_months, options = [ADD]) aah = aah * not_(aspa_eligibilite) * not_(asi_eligibilite) * not_(pension_invalidite) pensions_alimentaires_versees = individu( 'pensions_alimentaires_versees_individu', three_previous_months, options = [ADD] ) def abattement_salaire(): aspa_couple = individu.famille('aspa_couple', period) # Abattement sur les salaires (appliqué sur une base trimestrielle) abattement_forfaitaire_base = ( leg_1er_janvier.cotsoc.gen.smic_h_b * law.cotsoc.gen.nb_heure_travail_mensuel ) taux_abattement_forfaitaire = where( aspa_couple, law.prestations.minima_sociaux.aspa.abattement_forfaitaire_tx_couple, law.prestations.minima_sociaux.aspa.abattement_forfaitaire_tx_seul ) abattement_forfaitaire = abattement_forfaitaire_base * taux_abattement_forfaitaire salaire_de_base = individu('salaire_de_base', three_previous_months, options = [ADD]) return min_(salaire_de_base, abattement_forfaitaire) base_ressources_3_mois = sum( max_(0, individu(ressource_type, three_previous_months, options = [ADD])) for ressource_type in ressources_incluses ) + aah + revenus_foyer_fiscal_individu + revenus_tns() - abs_(pensions_alimentaires_versees) - abattement_salaire() return period, base_ressources_3_mois / 3
def formula(individu, period, parameters): # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_month = period.last_month P = parameters(period).cmu ressources_a_inclure = [ 'aah', 'allocation_securisation_professionnelle', 'asi', 'ass', 'bourse_enseignement_sup', 'bourse_recherche', 'caah', 'chomage_net', 'dedommagement_victime_amiante', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_stage', 'indemnites_compensatrices_conges_payes', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_combattant', 'retraite_nette', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_net', 'rente_accident_travail', ] ressources = sum([ individu(ressource, previous_year, options=[ADD]) for ressource in ressources_a_inclure ]) pensions_alim_versees = abs_( individu('pensions_alimentaires_versees_individu', previous_year, options=[ADD])) revenus_stage_formation_pro_last_month = individu( 'revenus_stage_formation_pro', last_month) # Abattement sur revenus d'activité si : # - IJ maladie # - chômage # - ass # - formation professionnelle def abbattement_chomage(): indemnites_journalieres_maladie = individu( 'indemnites_journalieres_maladie', period) chomage = individu('activite', period) == TypesActivite.chomeur indemnites_chomage_partiel = individu('indemnites_chomage_partiel', period) chomage_net = individu('chomage_net', period) ass = individu('ass', period) revenus_stage_formation_pro = individu( 'revenus_stage_formation_pro', period) condition_ij_maladie = indemnites_journalieres_maladie > 0 condition_chomage = chomage * ( (indemnites_chomage_partiel + chomage_net) > 0) condition_ass = ass > 0 condition_revenus_formation_pro = revenus_stage_formation_pro > 0 eligibilite_abattement_chomage = or_( condition_ij_maladie, or_(condition_chomage, or_(condition_ass, condition_revenus_formation_pro))) salaire_net = individu('salaire_net', previous_year, options=[ADD]) return eligibilite_abattement_chomage * salaire_net * P.abattement_chomage # Revenus de stage de formation professionnelle exclus si plus perçus depuis 1 mois def neutralisation_stage_formation_pro(): revenus_stage_formation_pro_annee = individu( 'revenus_stage_formation_pro', previous_year, options=[ADD]) return (revenus_stage_formation_pro_last_month == 0) * revenus_stage_formation_pro_annee def revenus_tns(): last_year = period.last_year revenus_auto_entrepreneur = individu( 'tns_auto_entrepreneur_benefice', previous_year, options=[ADD]) # Les revenus TNS hors AE sont estimés en se basant sur N-1 tns_micro_entreprise_benefice = individu( 'tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = individu( 'tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = individu('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus return (ressources + revenus_tns() - pensions_alim_versees - abbattement_chomage() - neutralisation_stage_formation_pro())
def formula(individu, period, parameters): # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_month = period.last_month P = parameters(period).cmu ressources_a_inclure = [ 'aah', 'allocation_securisation_professionnelle', 'asi', 'ass', 'bourse_enseignement_sup', 'bourse_recherche', 'caah', 'chomage_net', 'dedommagement_victime_amiante', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_stage', 'indemnites_compensatrices_conges_payes', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_combattant', 'retraite_nette', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_net', 'rente_accident_travail', ] ressources = sum([ individu(ressource, previous_year, options = [ADD]) for ressource in ressources_a_inclure ]) pensions_alim_versees = abs_(individu( 'pensions_alimentaires_versees_individu', previous_year, options = [ADD]) ) revenus_stage_formation_pro_last_month = individu('revenus_stage_formation_pro', last_month) # Abattement sur revenus d'activité si : # - IJ maladie # - chômage # - ass # - formation professionnelle def abbattement_chomage(): indemnites_journalieres_maladie = individu('indemnites_journalieres_maladie', period) chomage = individu('activite', period) == TypesActivite.chomeur indemnites_chomage_partiel = individu('indemnites_chomage_partiel', period) chomage_net = individu('chomage_net', period) ass = individu('ass', period) revenus_stage_formation_pro = individu('revenus_stage_formation_pro', period) condition_ij_maladie = indemnites_journalieres_maladie > 0 condition_chomage = chomage * ((indemnites_chomage_partiel + chomage_net) > 0) condition_ass = ass > 0 condition_revenus_formation_pro = revenus_stage_formation_pro > 0 eligibilite_abattement_chomage = or_(condition_ij_maladie, or_(condition_chomage, or_(condition_ass, condition_revenus_formation_pro))) salaire_net = individu('salaire_net', previous_year, options = [ADD]) return eligibilite_abattement_chomage * salaire_net * P.abattement_chomage # Revenus de stage de formation professionnelle exclus si plus perçus depuis 1 mois def neutralisation_stage_formation_pro(): revenus_stage_formation_pro_annee = individu('revenus_stage_formation_pro', previous_year, options = [ADD]) return (revenus_stage_formation_pro_last_month == 0) * revenus_stage_formation_pro_annee def revenus_tns(): last_year = period.last_year revenus_auto_entrepreneur = individu('tns_auto_entrepreneur_benefice', previous_year, options = [ADD]) # Les revenus TNS hors AE sont estimés en se basant sur N-1 tns_micro_entreprise_benefice = individu('tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = individu('tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = individu('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus return ( ressources + revenus_tns() - pensions_alim_versees - abbattement_chomage() - neutralisation_stage_formation_pro() )
def formula(individu, period, parameters): ''' N'intègre pas l'exception citée à l'article R5423-2 du Code du Travail sur les conjoints chefs d'entreprises entrant dans le champ d'application de l'article 50-0 du CGI ''' last_month = period.start.period('month').offset(-1) # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_year = period.last_year has_ressources_substitution = ( individu('chomage_net', last_month) + individu('indemnites_journalieres', last_month) + individu('retraite_nette', last_month)) > 0 def calculateWithAbatement(ressourceName, neutral_totale=False): ressource_year = individu(ressourceName, previous_year, options=[ADD]) ressource_last_month = individu(ressourceName, last_month) ressource_interrompue = (ressource_year > 0) * (ressource_last_month == 0) # Les ressources interrompues sont abattues différement si elles sont substituées ou non. # http://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000020398006&cidTexte=LEGITEXT000006072050 tx_abat_partiel = parameters( period).prestations.minima_sociaux.ass.abat_rev_subst_conj tx_abat_total = parameters( period).prestations.minima_sociaux.ass.abat_rev_non_subst_conj abat_partiel = ressource_interrompue * has_ressources_substitution * ( 1 - neutral_totale) abat_total = ressource_interrompue * (1 - abat_partiel) tx_abat_applique = abat_partiel * tx_abat_partiel + abat_total * tx_abat_total return (1 - tx_abat_applique) * ressource_year salaire_imposable = calculateWithAbatement('salaire_imposable') indemnites_stage = calculateWithAbatement('indemnites_stage', neutral_totale=True) revenus_stage_formation_pro = calculateWithAbatement( 'revenus_stage_formation_pro') chomage_net = calculateWithAbatement('chomage_net', neutral_totale=True) indemnites_journalieres = calculateWithAbatement( 'indemnites_journalieres') aah = calculateWithAbatement('aah') retraite_nette = calculateWithAbatement('retraite_nette') pensions_alimentaires_percues = calculateWithAbatement( 'pensions_alimentaires_percues') revenus_capital = individu('revenus_capital', period) * individu.has_role( FoyerFiscal.DECLARANT_PRINCIPAL) def revenus_tns(): revenus_auto_entrepreneur = individu( 'tns_auto_entrepreneur_benefice', previous_year, options=[ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu( 'tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = individu( 'tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = individu('tns_autres_revenus', last_year, options=[ADD]) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus pensions_alimentaires_versees_individu = individu( 'pensions_alimentaires_versees_individu', previous_year, options=[ADD]) result = (salaire_imposable + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + aah + indemnites_stage + revenus_stage_formation_pro + retraite_nette + chomage_net + indemnites_journalieres + revenus_tns() + revenus_capital) return result
def function(individu, period, legislation): period = period.this_month last_year = period.last_year three_previous_months = period.last_3_months law = legislation(period) leg_1er_janvier = legislation(period.start.offset('first-of', 'year')) ressources_incluses = [ 'allocation_securisation_professionnelle', 'chomage_net', 'dedommagement_victime_amiante', 'div_ms', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_volontariat', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_brute', 'revenus_fonciers_minima_sociaux', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_de_base', ] # Revenus du foyer fiscal que l'on projette sur le premier invidividus rev_cap_bar_foyer_fiscal = max_( 0, individu.foyer_fiscal('rev_cap_bar', three_previous_months, options=[ADD, DIVIDE])) rev_cap_lib_foyer_fiscal = max_( 0, individu.foyer_fiscal('rev_cap_lib', three_previous_months, options=[ADD, DIVIDE])) retraite_titre_onereux_foyer_fiscal = individu.foyer_fiscal( 'retraite_titre_onereux', three_previous_months, options=[ADD, DIVIDE]) revenus_foyer_fiscal = rev_cap_bar_foyer_fiscal + rev_cap_lib_foyer_fiscal + retraite_titre_onereux_foyer_fiscal revenus_foyer_fiscal_individu = revenus_foyer_fiscal * individu.has_role( FoyerFiscal.DECLARANT_PRINCIPAL) def revenus_tns(): revenus_auto_entrepreneur = individu( 'tns_auto_entrepreneur_benefice', three_previous_months, options=[ADD]) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = individu( 'tns_micro_entreprise_benefice', last_year) * (3 / 12) tns_benefice_exploitant_agricole = individu( 'tns_benefice_exploitant_agricole', last_year) * (3 / 12) tns_autres_revenus = individu('tns_autres_revenus', last_year) * (3 / 12) return (revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus) pension_invalidite = (individu('pensions_invalidite', period) > 0) aspa_eligibilite = individu('aspa_eligibilite', period) asi_eligibilite = individu('asi_eligibilite', period) # Inclus l'AAH si conjoint non éligible ASPA, retraite et pension invalidité aah = individu('aah', three_previous_months, options=[ADD]) aah = aah * not_(aspa_eligibilite) * not_(asi_eligibilite) * not_( pension_invalidite) pensions_alimentaires_versees = individu( 'pensions_alimentaires_versees_individu', three_previous_months, options=[ADD]) def abattement_salaire(): aspa_couple = individu.famille('aspa_couple', period) # Abattement sur les salaires (appliqué sur une base trimestrielle) abattement_forfaitaire_base = ( leg_1er_janvier.cotsoc.gen.smic_h_b * law.cotsoc.gen.nb_heure_travail_mensuel) taux_abattement_forfaitaire = where( aspa_couple, law.prestations.minima_sociaux.aspa. abattement_forfaitaire_tx_couple, law.prestations. minima_sociaux.aspa.abattement_forfaitaire_tx_seul) abattement_forfaitaire = abattement_forfaitaire_base * taux_abattement_forfaitaire salaire_de_base = individu('salaire_de_base', three_previous_months, options=[ADD]) return min_(salaire_de_base, abattement_forfaitaire) base_ressources_3_mois = sum( max_( 0, individu(ressource_type, three_previous_months, options=[ADD])) for ressource_type in ressources_incluses ) + aah + revenus_foyer_fiscal_individu + revenus_tns() - abs_( pensions_alimentaires_versees) - abattement_salaire() return period, base_ressources_3_mois / 3
def function(self, simulation, period): period = period.this_month last_year = period.last_year three_previous_months = period.last_3_months aspa_eligibilite = simulation.calculate('aspa_eligibilite', period) aspa_couple_holder = simulation.compute('aspa_couple', period) salaire_de_base = simulation.calculate_add('salaire_de_base', three_previous_months) chomage_net = simulation.calculate_add('chomage_net', three_previous_months) retraite_brute = simulation.calculate_add('retraite_brute', three_previous_months) pensions_alimentaires_percues = simulation.calculate( 'pensions_alimentaires_percues', three_previous_months) pensions_alimentaires_versees_individu = simulation.calculate( 'pensions_alimentaires_versees_individu', three_previous_months) retraite_titre_onereux_declarant1 = simulation.calculate_add( 'retraite_titre_onereux_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) revenus_fonciers_minima_sociaux = simulation.calculate_add( 'revenus_fonciers_minima_sociaux', three_previous_months) div_ms = simulation.calculate_add('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_chomage_partiel = simulation.calculate( 'indemnites_chomage_partiel', three_previous_months) indemnites_journalieres = simulation.calculate( 'indemnites_journalieres', three_previous_months) indemnites_volontariat = simulation.calculate('indemnites_volontariat', three_previous_months) def revenus_tns(): revenus_auto_entrepreneur = simulation.calculate_add( 'tns_auto_entrepreneur_benefice', three_previous_months) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate( 'tns_micro_entreprise_benefice', last_year) * (3 / 12) tns_benefice_exploitant_agricole = simulation.calculate( 'tns_benefice_exploitant_agricole', last_year) * (3 / 12) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) * (3 / 12) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus rsa_base_ressources_patrimoine_i = simulation.calculate_add( 'rsa_base_ressources_patrimoine_individu', three_previous_months) aah = simulation.calculate_add('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é # FIXME Il faudrait vérifier que le conjoint est pensionné ASPA, pas qu'il est juste éligible ! aah = aah * not_(aspa_eligibilite) # Abattement sur les salaires (appliqué sur une base trimestrielle) abattement_forfaitaire_base = ( leg_1er_janvier.cotsoc.gen.smic_h_b * legislation.cotsoc.gen.nb_heure_travail_mensuel) 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 + chomage_net + retraite_brute + pensions_alimentaires_percues - abs_(pensions_alimentaires_versees_individu) + retraite_titre_onereux_declarant1 + rpns + max_(0, rev_cap_bar) + max_(0, rev_cap_lib) + max_(0, revenus_fonciers_minima_sociaux) + 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 + indemnites_chomage_partiel + indemnites_volontariat + revenus_tns() + rsa_base_ressources_patrimoine_i + aah) / 3
def function(self, simulation, period): period = period.this_month # Rolling year previous_year = period.start.period('year').offset(-1) # N-1 last_month = period.last_month P = simulation.legislation_at(period.start).cmu ressources_a_inclure = [ 'aah', 'allocation_securisation_professionnelle', 'bourse_enseignement_sup', 'bourse_recherche', 'chomage_net', 'dedommagement_victime_amiante', 'gains_exceptionnels', 'indemnites_chomage_partiel', 'indemnites_journalieres', 'indemnites_stage', 'pensions_alimentaires_percues', 'pensions_invalidite', 'prestation_compensatoire', 'prime_forfaitaire_mensuelle_reprise_activite', 'retraite_combattant', 'retraite_nette', 'revenus_stage_formation_pro', 'rsa_base_ressources_patrimoine_individu', 'salaire_net', ] ressources = sum( [simulation.calculate_add(ressource, previous_year) for ressource in ressources_a_inclure] ) pensions_alim_versees = abs_(simulation.calculate_add('pensions_alimentaires_versees_individu', previous_year)) revenus_stage_formation_pro_last_month = simulation.calculate('revenus_stage_formation_pro', last_month) # Abattement sur revenus d'activité si chômage ou formation professionnelle def abbattement_chomage(): indemnites_chomage_partiel = simulation.calculate('indemnites_chomage_partiel', previous_year) salaire_net = simulation.calculate_add('salaire_net', previous_year) chomage_last_month = simulation.calculate('chomage_net', last_month) condition = or_(chomage_last_month > 0, revenus_stage_formation_pro_last_month > 0) assiette = indemnites_chomage_partiel + salaire_net return condition * assiette * P.abattement_chomage # Revenus de stage de formation professionnelle exclus si plus perçus depuis 1 mois def neutralisation_stage_formation_pro(): revenus_stage_formation_pro_annee = simulation.calculate_add('revenus_stage_formation_pro', previous_year) return (revenus_stage_formation_pro_last_month == 0) * revenus_stage_formation_pro_annee def revenus_tns(): last_year = period.last_year revenus_auto_entrepreneur = simulation.calculate_add('tns_auto_entrepreneur_benefice', previous_year) # Les revenus TNS hors AE sont estimés en se basant sur le revenu N-1 tns_micro_entreprise_benefice = simulation.calculate('tns_micro_entreprise_benefice', last_year) tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', last_year) tns_autres_revenus = simulation.calculate('tns_autres_revenus', last_year) return revenus_auto_entrepreneur + tns_micro_entreprise_benefice + tns_benefice_exploitant_agricole + tns_autres_revenus return period, ressources + revenus_tns() - pensions_alim_versees - abbattement_chomage() - neutralisation_stage_formation_pro()