PKoz= 18): new_famille[u'parents'].append(individu_id) else: new_famille[u'enfants'].append(individu_id) if new_famille_id is None: new_famille[u'id'] = new_famille_id = unicode(uuid.uuid4()) test_case[u'familles'].append(new_famille) familles_individus_id.remove(individu_id) # Affecte à un foyer fiscal chaque individu qui n'appartient à aucun d'entre eux. new_foyer_fiscal = dict( declarants = [], personnes_a_charge = [], ) new_foyer_fiscal_id = None for individu_id in foyers_fiscaux_individus_id[:]: # Tente d'affecter l'individu à un foyer fiscal d'après sa famille. famille, famille_role = find_famille_and_role(test_case, individu_id) if famille_role == u'parents' and len(famille[u'parents']) == 2: for parent_id in famille[u'parents']: if parent_id != individu_id: foyer_fiscal, other_role = find_foyer_fiscal_and_role(test_case, parent_id) if other_role == u'declarants' and len(foyer_fiscal[u'declarants']) == 1: # Quand l'individu n'est pas encore dans un foyer fiscal, mais qu'il est parent # dans une famille, qu'il y a un autre parent dans cette famille et que cet autre # parent est seul déclarant dans son foyer fiscal, alors ajoute l'individu comme # autre déclarant de ce foyer fiscal. foyer_fiscal[u'declarants'].append(individu_id) foyers_fiscaux_individus_id.remove(individu_id) break elif famille_role == u'enfants' and famille[u'parents']: for parent_id in famille[u'parents']: foyer_fiscal, other_role = find_foyer_fiscal_and_role(test_case, parent_id) if other_role == u'declarants': # Quand l'individu n'est pas encore dans un foyer fiscal, mais qu'il est enfant dans une # famille, qu'il y a un parent dans cette famille et que ce parent est déclarant dans # son foyer fiscal, alors ajoute l'individu comme personne à charge de ce foyer fiscal. foyer_fiscal[u'personnes_a_charge'].append(individu_id) foyers_fiscaux_individus_id.remove(individu_id) break if individu_id in foyers_fiscaux_individus_id: # L'individu n'est toujours pas affecté à un foyer fiscal. # Tente d'affecter l'individu à un foyer fiscal d'après son ménage. menage, menage_role = find_menage_and_role(test_case, individu_id) if menage_role == u'personne_de_reference': conjoint_id = menage[u'conjoint'] if conjoint_id is not None: foyer_fiscal, other_role = find_foyer_fiscal_and_role(test_case, conjoint_id) if other_role == u'declarants' and len(foyer_fiscal[u'declarants']) == 1: # Quand l'individu n'est pas encore dans un foyer fiscal, mais qu'il est personne de # référence dans un ménage, qu'il y a un conjoint dans ce ménage et que ce # conjoint est seul déclarant dans un foyer fiscal, alors ajoute l'individu comme # autre déclarant de ce foyer fiscal. foyer_fiscal[u'declarants'].append(individu_id) foyers_fiscaux_individus_id.remove(individu_id) elif menage_role == u'conjoint': personne_de_reference_id = menage[u'personne_de_reference'] if personne_de_reference_id is not None: foyer_fiscal, other_role = find_foyer_fiscal_and_role(test_case, personne_de_reference_id) if other_role == u'declarants' and len(foyer_fiscal[u'declarants']) == 1: # Quand l'individu n'est pas encore dans un foyer fiscal, mais qu'il est conjoint # dans un ménage, qu'il y a une personne de référence dans ce ménage et que # cette personne est seul déclarant dans un foyer fiscal, alors ajoute l'individu # comme autre déclarant de ce foyer fiscal. foyer_fiscal[u'declarants'].append(individu_id) foyers_fiscaux_individus_id.remove(individu_id) elif menage_role == u'enfants' and (menage['personne_de_reference'] is not None or menage[u'conjoint'] is not None): for other_id in (menage['personne_de_reference'], menage[u'conjoint']): if other_id is None: continue foyer_fiscal, other_role = find_foyer_fiscal_and_role(test_case, other_id) if other_role == u'declarants': # Quand l'individu n'est pas encore dans un foyer fiscal, mais qu'il est enfant dans # un ménage, qu'il y a une personne à charge ou un conjoint dans ce ménage et que # celui-ci est déclarant dans un foyer fiscal, alors ajoute l'individu comme # personne à charge de ce foyer fiscal. foyer_fiscal[u'declarants'].append(individu_id) foyers_fiscaux_individus_id.remove(individu_id) break if individu_id in foyers_fiscaux_individus_id: # L'individu n'est toujours pas affecté à un foyer fiscal. individu = individu_by_id[individu_id] age = find_age(individu, period.start.date) if len(new_foyer_fiscal[u'declarants']) < 2 and (age is None or age >= 18): new_foyer_fiscal[u'declarants'].append(individu_id) else: new_foyer_fiscal[u'personnes_a_charge'].append(individu_id) if new_foyer_fiscal_id is None: new_foyer_fiscal[u'id'] = new_foyer_fiscal_id = unicode(uuid.uuid4()) test_case[u'foyers_fiscaux'].append(new_foyer_fiscal) foyers_fiscaux_individus_id.remove(individu_id) # Affecte à un ménage chaque individu qui n'appartient à aucun d'entre eux. new_menage = dict( autres = [], conjoint = None, enfants = [], personne_de_reference = None, ) new_menage_id = None for individu_id in menages_individus_id[:]: # Tente d'affecter l'individu à un ménage d'après sa famille. famille, famille_role = find_famille_and_role(test_case, individu_id) if famille_role == u'parents' and len(famille[u'parents']) == 2: for parent_id in famille[u'parents']: if parent_id != individu_id: menage, other_role = find_menage_and_role(test_case, parent_id) if other_role == u'personne_de_reference' and menage[u'conjoint'] is None: # Quand l'individu n'est pas encore dans un ménage, mais qu'il est parent # dans une famille, qu'il y a un autre parent dans cette famille et que cet autre # parent est personne de référence dans un ménage et qu'il n'y a pas de conjoint # dans ce ménage, alors ajoute l'individu comme conjoint de ce ménage. menage[u'conjoint'] = individu_id menages_individus_id.remove(individu_id) elif other_role == u'conjoint' and menage[u'personne_de_reference'] is None: # Quand l'individu n'est pas encore dans un ménage, mais qu'il est parent # dans une famille, qu'il y a un autre parent dans cette famille et que cet autre # parent est conjoint dans un ménage et qu'il n'y a pas de personne de référence # dans ce ménage, alors ajoute l'individu comme personne de référence de ce ménage. menage[u'personne_de_reference'] = individu_id menages_individus_id.remove(individu_id) break elif famille_role == u'enfants' and famille[u'parents']: for parent_id in famille[u'parents']: menage, other_role = find_menage_and_role(test_case, parent_id) if other_role in (u'personne_de_reference', u'conjoint'): # Quand l'individu n'est pas encore dans un ménage, mais qu'il est enfant dans une # famille, qu'il y a un parent dans cette famille et que ce parent est personne de # référence ou conjoint dans un ménage, alors ajoute l'individu comme enfant de ce # ménage. menage[u'enfants'].append(individu_id) menages_individus_id.remove(individu_id) break if individu_id in menages_individus_id: # L'individu n'est toujours pas affecté à un ménage. # Tente d'affecter l'individu à un ménage d'après son foyer fiscal. foyer_fiscal, foyer_fiscal_role = find_foyer_fiscal_and_role(test_case, individu_id) if foyer_fiscal_role == u'declarants' and len(foyer_fiscal[u'declarants']) == 2: for declarant_id in foyer_fiscal[u'declarants']: if declarant_id != individu_id: menage, other_role = find_menage_and_role(test_case, declarant_id) if other_role == u'personne_de_reference' and menage[u'conjoint'] is None: # Quand l'individu n'est pas encore dans un ménage, mais qu'il est déclarant # dans un foyer fiscal, qu'il y a un autre déclarant dans ce foyer fiscal et que # cet autre déclarant est personne de référence dans un ménage et qu'il n'y a # pas de conjoint dans ce ménage, alors ajoute l'individu comme conjoint de ce # ménage. menage[u'conjoint'] = individu_id menages_individus_id.remove(individu_id) elif other_role == u'conjoint' and menage[u'personne_de_reference'] is None: # Quand l'individu n'est pas encore dans un ménage, mais qu'il est déclarant # dans une foyer fiscal, qu'il y a un autre déclarant dans ce foyer fiscal et # que cet autre déclarant est conjoint dans un ménage et qu'il n'y a pas de # personne de référence dans ce ménage, alors ajoute l'individu comme personne # de référence de ce ménage. menage[u'personne_de_reference'] = individu_id menages_individus_id.remove(individu_id) break elif foyer_fiscal_role == u'personnes_a_charge' and foyer_fiscal[u'declarants']: for declarant_id in foyer_fiscal[u'declarants']: menage, other_role = find_menage_and_role(test_case, declarant_id) if other_role in (u'personne_de_reference', u'conjoint'): # Quand l'individu n'est pas encore dans un ménage, mais qu'il est personne à charge # dans un foyer fiscal, qu'il y a un déclarant dans ce foyer fiscal et que ce # déclarant est personne de référence ou conjoint dans un ménage, alors ajoute # l'individu comme enfant de ce ménage. menage[u'enfants'].append(individu_id) menages_individus_id.remove(individu_id) break if individu_id in menages_individus_id: # L'individu n'est toujours pas affecté à un ménage. if new_menage[u'personne_de_reference'] is None: new_menage[u'personne_de_reference'] = individu_id elif new_menage[u'conjoint'] is None: new_menage[u'conjoint'] = individu_id else: new_menage[u'enfants'].append(individu_id) if new_menage_id is None: new_menage[u'id'] = new_menage_id = unicode(uuid.uuid4()) test_case[u'menages'].append(new_menage) menages_individus_id.remove(individu_id) remaining_individus_id = set(familles_individus_id).union(foyers_fiscaux_individus_id, menages_individus_id) if remaining_individus_id: individu_index_by_id = { individu[u'id']: individu_index for individu_index, individu in enumerate(test_case[u'individus']) } if error is None: error = {} for individu_id in remaining_individus_id: error.setdefault('individus', {})[individu_index_by_id[individu_id]] = state._( u"Individual is missing from {}").format( state._(u' & ').join( word for word in [ u'familles' if individu_id in familles_individus_id else None, u'foyers_fiscaux' if individu_id in foyers_fiscaux_individus_id else None, u'menages' if individu_id in menages_individus_id else None, ] if word is not None )) if error is not None: return test_case, error # Third validation step parents_id = set( parent_id for famille in test_case['familles'] for parent_id in famille['parents'] ) test_case, error = conv.struct( dict( familles = conv.pipe( conv.uniform_sequence( conv.struct( dict( enfants = conv.uniform_sequence( conv.test( lambda individu_id: individu_by_id[individu_id].get('invalide', False) or find_age(individu_by_id[individu_id], period.start.date, default = 0) <= 25, error = u"Une personne à charge d'un foyer fiscal doit avoir moins de" u" 25 ans ou être invalide", ), ), parents = conv.pipe( conv.empty_to_none, conv.not_none, conv.test(lambda parents: len(parents) <= 2, error = N_(u'A "famille" must have at most 2 "parents"')) ), ), default = conv.noop, ), ), conv.empty_to_none, conv.not_none, ), foyers_fiscaux = conv.pipe( conv.uniform_sequence( conv.struct( dict( declarants = conv.pipe( conv.empty_to_none, conv.not_none, conv.test( lambda declarants: len(declarants) <= 2, error = N_(u'A "foyer_fiscal" must have at most 2 "declarants"'), ), conv.uniform_sequence(conv.pipe( # conv.test(lambda individu_id: # find_age(individu_by_id[individu_id], period.start.date, # default = 100) >= 18, # error = u"Un déclarant d'un foyer fiscal doit être agé d'au moins 18" # u" ans", # ), conv.test( lambda individu_id: individu_id in parents_id, error = u"Un déclarant ou un conjoint sur la déclaration d'impôt, doit" u" être un parent dans sa famille", ), )), ), personnes_a_charge = conv.uniform_sequence( conv.test( lambda individu_id: individu_by_id[individu_id].get('invalide', False) or find_age(individu_by_id[individu_id], period.start.date, default = 0) <= 25, error = u"Une personne à charge d'un foyer fiscal doit avoir moins de" u" 25 ans ou être invalide", ), ), ), default = conv.noop, ), ), conv.empty_to_none, conv.not_none, ), # individus = conv.uniform_sequence( # conv.struct( # dict( # birth = conv.test( # lambda birth: period.start.date - birth >= datetime.timedelta(0), # error = u"L'individu doit être né au plus tard le jour de la simulation", # ), # ), # default = conv.noop, # drop_none_values = 'missing', # ), # ), menages = conv.pipe( conv.uniform_sequence( conv.struct( dict( personne_de_reference = conv.not_none, ), default = conv.noop, ), ), conv.empty_to_none, conv.not_none, ), ), default = conv.noop, )(test_case, state = state) return test_case, error return json_or_python_to_test_case def suggest(self): """Returns a dict of suggestions and modifies self.test_case applying those suggestions.""" test_case = self.test_case if test_case is None: return None period_start_date = self.period.start.date period_start_year = self.period.start.year suggestions = dict() for individu in test_case['individus']: individu_id = individu['id'] if individu.get('age') is None and individu.get('age_en_mois') is None and individu.get('birth') is None: # Add missing birth date to person (a parent is 40 years old and a child is 10 years old. is_parent = any(individu_id in famille['parents'] for famille in test_case['familles']) birth_year = period_start_year - 40 if is_parent else period_start_year - 10 birth = datetime.date(birth_year, 1, 1) individu['birth'] = birth suggestions.setdefault('test_case', {}).setdefault('individus', {}).setdefault(individu_id, {})[ 'birth'] = birth.isoformat() if individu.get('activite') is None: if find_age(individu, period_start_date) < 16: individu['activite'] = 2 # Étudiant, élève suggestions.setdefault('test_case', {}).setdefault('individus', {}).setdefault(individu_id, {})[ 'activite'] = u'2' # Étudiant, élève individu_by_id = { individu['id']: individu for individu in test_case['individus'] } for foyer_fiscal in test_case['foyers_fiscaux']: if len(foyer_fiscal['declarants']) == 1 and foyer_fiscal['personnes_a_charge']: # Suggest "parent isolé" when foyer_fiscal contains a single "declarant" with "personnes_a_charge". if foyer_fiscal.get('caseT') is None: suggestions.setdefault('test_case', {}).setdefault('foyers_fiscaux', {}).setdefault( foyer_fiscal['id'], {})['caseT'] = foyer_fiscal['caseT'] = True elif len(foyer_fiscal['declarants']) == 2: # Suggest "PACSé" or "Marié" instead of "Célibataire" when foyer_fiscal contains 2 "declarants" without # "statmarit". statmarit = 5 # PACSé for individu_id in foyer_fiscal['declarants']: individu = individu_by_id[individu_id] if individu.get('statmarit') == 1: # Marié statmarit = 1 for individu_id in foyer_fiscal['declarants']: individu = individu_by_id[individu_id] if individu.get('statmarit') is None: individu['statmarit'] = statmarit suggestions.setdefault('test_case', {}).setdefault('individus', {}).setdefault(individu_id, {})[ 'statmarit'] = unicode(statmarit) return suggestions or None def to_json(self): self_json = collections.OrderedDict() if self.axes is not None: self_json['axes'] = self.axes if self.period is not None: self_json['period'] = str(self.period) test_case = self.test_case if test_case is not None: column_by_name = self.tax_benefit_system.column_by_name test_case_json = collections.OrderedDict() familles_json = [] for famille in (test_case.get('familles') or []): famille_json = collections.OrderedDict() famille_json['id'] = famille['id'] parents = famille.get('parents') if parents: famille_json['parents'] = parents enfants = famille.get('enfants') if enfants: famille_json['enfants'] = enfants for column_name, variable_value in famille.iteritems(): column = column_by_name.get(column_name) if column is not None and column.entity == 'fam': variable_value_json = column.transform_value_to_json(variable_value) if variable_value_json is not None: famille_json[column_name] = variable_value_json familles_json.append(famille_json) if familles_json: test_case_json['familles'] = familles_json foyers_fiscaux_json = [] for foyer_fiscal in (test_case.get('foyers_fiscaux') or []): foyer_fiscal_json = collections.OrderedDict() foyer_fiscal_json['id'] = foyer_fiscal['id'] declarants = foyer_fiscal.get('declarants') if declarants: foyer_fiscal_json['declarants'] = declarants personnes_a_charge = foyer_fiscal.get('personnes_a_charge') if personnes_a_charge: foyer_fiscal_json['personnes_a_charge'] = personnes_a_charge for column_name, variable_value in foyer_fiscal.iteritems(): column = column_by_name.get(column_name) if column is not None and column.entity == 'foy': variable_value_json = column.transform_value_to_json(variable_value) if variable_value_json is not None: foyer_fiscal_json[column_name] = variable_value_json foyers_fiscaux_json.append(foyer_fiscal_json) if foyers_fiscaux_json: test_case_json['foyers_fiscaux'] = foyers_fiscaux_json individus_json = [] for individu in (test_case.get('individus') or []): individu_json = collections.OrderedDict() individu_json['id'] = individu['id'] for column_name, variable_value in individu.iteritems(): column = column_by_name.get(column_name) if column is not None and column.entity == 'ind': variable_value_json = column.transform_value_to_json(variable_value) if variable_value_json is not None: individu_json[column_name] = variable_value_json individus_json.append(individu_json) if individus_json: test_case_json['individus'] = individus_json menages_json = [] for menage in (test_case.get('menages') or []): menage_json = collections.OrderedDict() menage_json['id'] = menage['id'] personne_de_reference = menage.get('personne_de_reference') if personne_de_reference is not None: menage_json['personne_de_reference'] = personne_de_reference conjoint = menage.get('conjoint') if conjoint is not None: menage_json['conjoint'] = conjoint enfants = menage.get('enfants') if enfants: menage_json['enfants'] = enfants autres = menage.get('autres') if autres: menage_json['autres'] = autres for column_name, variable_value in menage.iteritems(): column = column_by_name.get(column_name) if column is not None and column.entity == 'men': variable_value_json = column.transform_value_to_json(variable_value) if variable_value_json is not None: menage_json[column_name] = variable_value_json menages_json.append(menage_json) if menages_json: test_case_json['menages'] = menages_json self_json['test_case'] = test_case_json return self_json # Finders def find_age(individu, date, default = None): birth = individu.get('birth') if isinstance(birth, dict): birth = birth.values()[0] if birth else None if birth is not None: age = date.year - birth.year if date.month < birth.month or date.month == birth.month and date.day < birth.day: age -= 1 return age age = individu.get('age') if isinstance(age, dict): age = age.values()[0] if age else None if age is not None: return age age_en_mois = individu.get('age_en_mois') if isinstance(age_en_mois, dict): age_en_mois = age_en_mois.values()[0] if age_en_mois else None if age_en_mois is not None: return age_en_mois / 12.0 return default def find_famille_and_role(test_case, individu_id): for famille in test_case['familles']: for role in (u'parents', u'enfants'): if individu_id in famille[role]: return famille, role return None, None def find_foyer_fiscal_and_role(test_case, individu_id): for foyer_fiscal in test_case['foyers_fiscaux']: for role in (u'declarants', u'personnes_a_charge'): if individu_id in foyer_fiscal[role]: return foyer_fiscal, role return None, None def find_menage_and_role(test_case, individu_id): for menage in test_case['menages']: for role in (u'personne_de_reference', u'conjoint'): if menage[role] == individu_id: return menage, role for role in (u'enfants', u'autres'): if individu_id in menage[role]: return menage, role return None, None PKoz Their order can't be compared. continue return -1 sorted_relative_ipp_paths = sorted(unsorted_relative_ipp_paths, cmp = compare_relative_ipp_paths) for start, row in sorted_row_by_start: for relative_ipp_path in sorted_relative_ipp_paths: value = row for fragment in relative_ipp_path: value = value.get(fragment) if value is None: break if value in (u'-', u'na', u'nc'): # Value is unknown. Previous value must be propagated. continue ipp_path = relative_file_path.split(os.sep)[:-1] + [sheet_name] + list(relative_ipp_path) remaining_path = ipp_path[:] skip_ipp_path = False sub_tree = tree translations = ipp_translations translated_path = [] while remaining_path: fragment = remaining_path.pop(0) type = None if translations is not None: translations = translations.get(fragment, fragment) if translations is None: skip_ipp_path = True break elif isinstance(translations, dict): translation = translations.get('RENAME') if translation is not None: fragment = translation type = translations.get('TYPE') assert type in (None, u'BAREME') else: fragment = translations translations = None sub_path = [fragment] if isinstance(fragment, basestring) else fragment[:] while sub_path: fragment = sub_path.pop(0) translated_path.append(fragment) if fragment == u'ASSIETTE': assert sub_tree.get('TYPE') == u'BAREME', str((translated_path, sub_path, sub_tree)) assert not sub_path slice_name = remaining_path.pop(0) assert not remaining_path sub_tree = sub_tree.setdefault(u'ASSIETTE', collections.OrderedDict()).setdefault( slice_name, []) elif fragment == u'BAREME': existing_type = sub_tree.get('TYPE') if existing_type is None: sub_tree['TYPE'] = fragment else: assert existing_type == fragment elif fragment == u'MONTANT': assert sub_tree.get('TYPE') == u'BAREME', str((translated_path, sub_path, sub_tree)) assert not sub_path slice_name = remaining_path.pop(0) assert not remaining_path sub_tree = sub_tree.setdefault(u'MONTANT', collections.OrderedDict()).setdefault( slice_name, []) elif fragment == u'SEUIL': assert sub_tree.get('TYPE') == u'BAREME', str((translated_path, sub_path, sub_tree)) assert not sub_path slice_name = remaining_path.pop(0) assert not remaining_path sub_tree = sub_tree.setdefault(u'SEUIL', collections.OrderedDict()).setdefault( slice_name, []) elif fragment == u'TAUX': assert sub_tree.get('TYPE') == u'BAREME', str((translated_path, sub_path, sub_tree)) assert not sub_path slice_name = remaining_path.pop(0) assert not remaining_path sub_tree = sub_tree.setdefault(u'TAUX', collections.OrderedDict()).setdefault( slice_name, []) elif sub_path or remaining_path: sub_tree = sub_tree.setdefault(fragment, collections.OrderedDict()) if type is not None: existing_type = sub_tree.get('TYPE') if existing_type is None: sub_tree['TYPE'] = type else: assert existing_type == type else: sub_tree = sub_tree.setdefault(fragment, []) if skip_ipp_path: continue if sub_tree: last_leaf = sub_tree[-1] if last_leaf['value'] == value: continue last_leaf['stop'] = start - datetime.timedelta(days = 1) sub_tree.append(dict( start = start, value = value, )) root_element = transform_node_to_element(u'root', tree) root_element.set('deb', original_root_element.get('deb')) root_element.set('fin', original_root_element.get('fin')) merge_elements(root_element, original_root_element) sort_elements(root_element) reindent(root_element) element_tree = etree.ElementTree(root_element) element_tree.write(args.target, encoding = 'utf-8') return 0 def merge_elements(element, original_element, path = None): if path is None: path = [] else: path = path[:] path.append(element.get('code')) assert element.tag == original_element.tag, 'At {}, IPP element "{}"" differs from original element "{}"'.format( '.'.join(path), element.tag, original_element.tag) if element.tag == 'NODE': for original_child in original_element: for child in element: if child.get('code') == original_child.get('code'): merge_elements(child, original_child) break else: # A child with the same code as the original child doesn't exist yet. element.append(original_child) def sort_elements(element): if element.tag in ('BAREME', 'NODE', 'TRANCHE'): if element.tag == 'NODE': children = list(element) for child in children: element.remove(child) children.sort(key = lambda child: child.get('code')) element.extend(children) for child in element: sort_elements(child) else: children = list(element) for child in children: element.remove(child) children.sort(key = lambda child: child.get('deb') or '', reverse = True) element.extend(children) def prepare_xml_values(name, leafs): leafs = list(reversed([ leaf for leaf in leafs if leaf['value'] is not None ])) format = None type = None for leaf in leafs: value = leaf['value'] if isinstance(value, basestring): split_value = value.split() if len(split_value) == 2 and split_value[1] in ( u'%', u'AF', # anciens francs u'CFA', # francs CFA # u'COTISATIONS', u'EUR', u'FRF', ): value = float(split_value[0]) unit = split_value[1] if unit == u'%': if format is None: format = u'percent' elif format != u'percent': log.warning(u'Non constant percent format {} in {}: {}'.format(format, name, leafs)) return None, format, type value = value / 100 else: if format is None: format = u'float' elif format != u'float': log.warning(u'Non constant float format {} in {}: {}'.format(format, name, leafs)) return None, format, type if type is None: type = u'monetary' elif type != u'monetary': log.warning(u'Non constant monetary type {} in {}: {}'.format(type, name, leafs)) return None, format, type else: assert type == u'monetary', type # elif unit == u'AF': # # Convert "anciens francs" to €. # value = round(value / (100 * 6.55957), 2) # elif unit == u'FRF': # # Convert "nouveaux francs" to €. # if month < year_1960: # value /= 100 # value = round(value / 6.55957, 2) if isinstance(value, float) and value == int(value): value = int(value) leaf['value'] = value return leafs, format, type def reindent(elem, depth = 0): # cf http://effbot.org/zone/element-lib.htm indent = "\n" + depth * " " if len(elem): if not elem.text or not elem.text.strip(): elem.text = indent + " " if not elem.tail or not elem.tail.strip(): elem.tail = indent for elem in elem: reindent(elem, depth + 1) if not elem.tail or not elem.tail.strip(): elem.tail = indent else: if depth and (not elem.tail or not elem.tail.strip()): elem.tail = indent def transform_node_to_element(name, node): if isinstance(node, dict): if node.get('TYPE') == u'BAREME': scale_element = etree.Element('BAREME', attrib = dict( code = strings.slugify(name, separator = u'_'), )) for slice_name in node.get('SEUIL', {}).keys(): slice_element = etree.Element('TRANCHE', attrib = dict( code = strings.slugify(slice_name, separator = u'_'), )) threshold_element = etree.Element('SEUIL') values, format, type = prepare_xml_values(name, node.get('SEUIL', {}).get(slice_name, [])) for value in values: value_element = transform_value_to_element(value) if value_element is not None: threshold_element.append(value_element) if len(threshold_element) > 0: slice_element.append(threshold_element) amount_element = etree.Element('MONTANT') values, format, type = prepare_xml_values(name, node.get('MONTANT', {}).get(slice_name, [])) for value in values: value_element = transform_value_to_element(value) if value_element is not None: amount_element.append(value_element) if len(amount_element) > 0: slice_element.append(amount_element) rate_element = etree.Element('TAUX') values, format, type = prepare_xml_values(name, node.get('TAUX', {}).get(slice_name, [])) for value in values: value_element = transform_value_to_element(value) if value_element is not None: rate_element.append(value_element) if len(rate_element) > 0: slice_element.append(rate_element) base_element = etree.Element('ASSIETTE') values, format, type = prepare_xml_values(name, node.get('ASSIETTE', {}).get(slice_name, [])) for value in values: value_element = transform_value_to_element(value) if value_element is not None: base_element.append(value_element) if len(base_element) > 0: slice_element.append(base_element) if len(slice_element) > 0: scale_element.append(slice_element) return scale_element if len(scale_element) > 0 else None else: node_element = etree.Element('NODE', attrib = dict( code = strings.slugify(name, separator = u'_'), )) for key, value in node.iteritems(): child_element = transform_node_to_element(key, value) if child_element is not None: node_element.append(child_element) return node_element if len(node_element) > 0 else None else: assert isinstance(node, list), node values, format, type = prepare_xml_values(name, node) if not values: return None code_element = etree.Element('CODE', attrib = dict( code = strings.slugify(name, separator = u'_'), )) if format is not None: code_element.set('format', format) if type is not None: code_element.set('type', type) for value in values: value_element = transform_value_to_element(value) if value_element is not None: code_element.append(value_element) return code_element if len(code_element) > 0 else None def transform_value_to_element(leaf): value = leaf.get('value') if value is None: return None value_element = etree.Element('VALUE', attrib = dict( valeur = unicode(value), )) start = leaf.get('start') if start is not None: value_element.set('deb', start.isoformat()) stop = leaf.get('stop') if stop is not None: value_element.set('fin', stop.isoformat()) return value_element if __name__ == "__main__": sys.exit(main()) PKoz', u' / '.join(starts_by_ipp_path.keys()[0]) # if len(starts_by_ipp_path) > 1: # print u'.'.join(openfisca_path), '->', starts_by_ipp_path # for ipp_path, starts_by_openfisca_path in sorted(starts_by_openfisca_path_by_ipp_path.iteritems()): # if len(starts_by_openfisca_path) == 1: # print u' / '.join(ipp_path), '->', u'.'.join( # unicode(fragment) # for fragment in starts_by_openfisca_path.keys()[0] # ) ## if len(starts_by_openfisca_path) > 1: ## print u' / '.join(ipp_path), '->', u'.'.join( ## unicode(fragment) ## for fragment in starts_by_openfisca_path.keys()[0] ## ) openfisca_path_by_ipp_tree = collections.OrderedDict() for ipp_path, starts_by_openfisca_path in sorted(starts_by_openfisca_path_by_ipp_path.iteritems()): openfisca_path_by_ipp_sub_tree = openfisca_path_by_ipp_tree for ipp_name in ipp_path[:-1]: openfisca_path_by_ipp_sub_tree = openfisca_path_by_ipp_sub_tree.setdefault(ipp_name, collections.OrderedDict()) ipp_name = ipp_path[-1] openfisca_path_by_ipp_sub_tree[ipp_name] = [ u'.'.join( unicode(fragment) for fragment in openfisca_name ) for openfisca_name in sorted(starts_by_openfisca_path) ] with open(args.target, 'w') as target_file: yaml.dump(openfisca_path_by_ipp_tree, target_file, allow_unicode = True, default_flow_style = False, indent = 2, width = 120) return 0 if __name__ == "__main__": sys.exit(main()) PKoz 2: test('_' + v) elif var is not None: if len(var) > 1: test('_' + var) with codecs.open(os.path.join('dates_variables.json'),'w', encoding='utf-8') as fichier: json.dump(dates, fichier, encoding='utf-8', ensure_ascii=False, indent=2, sort_keys=True) main() PKoz 0 value_by_name.setdefault(other_entity.index_for_person_variable_name, other_entity.count - 1) role = value_by_name.get(other_entity.role_for_person_variable_name) assert role is not None, "Missing role {} in person arguments: {}".format( other_entity.role_for_person_variable_name, value_by_name) if role >= other_entity.roles_count: other_entity.roles_count = role + 1 # Set arguments in variables. for variable_name, value in value_by_name.iteritems(): variable_holder = entity.get_or_new_holder(variable_name) column = variable_holder.column if isinstance(value, dict): for period, period_value in value.iteritems(): array = variable_holder.get_array(period) if array is None: array = np.empty(entity.count, dtype = column.dtype) array.fill(column.default) variable_holder.set_array(period, array) array[member_index] = period_value else: period = simulation.period array = variable_holder.get_array(period) if array is None: array = np.empty(entity.count, dtype = column.dtype) array.fill(column.default) variable_holder.set_array(period, array) array[member_index] = value return member_index def timeit(method): def timed(*args, **kwargs): start_time = time.time() result = method(*args, **kwargs) # print '%r (%r, %r) %2.9f s' % (method.__name__, args, kw, time.time() - start_time) print '{:2.6f} s'.format(time.time() - start_time) return result return timed TaxBenefitSystem = init_country() tax_benefit_system = TaxBenefitSystem() @timeit def test_irpp(year, irpp, **variables_value_by_name): simulation = simulations.Simulation(period = periods.period(year), tax_benefit_system = tax_benefit_system, debug = args.verbose) famille = simulation.entity_by_key_singular['famille'] foyer_fiscal = simulation.entity_by_key_singular['foyer_fiscal'] individu = simulation.entity_by_key_singular['individu'] menage = simulation.entity_by_key_singular['menage'] # Dispatch arguments to their respective entities. variables_value_by_name_by_entity = {} for variable_name, value in variables_value_by_name.iteritems(): variable_holder = simulation.get_or_new_holder(variable_name) entity_variables_value_by_name = variables_value_by_name_by_entity.setdefault(variable_holder.entity, {}) entity_variables_value_by_name[variable_name] = value add_member(famille, **variables_value_by_name_by_entity.get(famille, {})) add_member(foyer_fiscal, **variables_value_by_name_by_entity.get(foyer_fiscal, {})) add_member(menage, **variables_value_by_name_by_entity.get(menage, {})) add_member(individu, quifam = 1, quifoy = 1, quimen = 1, **variables_value_by_name_by_entity.get(individu, {})) assert_near(simulation.calculate('irpp'), irpp, absolute_error_margin = 0.51) def main(): parser = argparse.ArgumentParser(description = __doc__) parser.add_argument('-v', '--verbose', action = 'store_true', default = False, help = "increase output verbosity") global args args = parser.parse_args() logging.basicConfig(level = logging.DEBUG if args.verbose else logging.WARNING, stream = sys.stdout) print 'salaire_imposable' test_irpp(2010, -1181, salaire_imposable = 20000) test_irpp(2010, -7934, salaire_imposable = 50000) test_irpp(2010, -42338, salaire_imposable = 150000) test_irpp(2011, -1181, salaire_imposable = 20000) test_irpp(2011, -7934, salaire_imposable = 50000) test_irpp(2011, -42338, salaire_imposable = 150000) test_irpp(2012, -1181, salaire_imposable = 20000) test_irpp(2012, -7934, salaire_imposable = 50000) test_irpp(2012, -43222, salaire_imposable = 150000) test_irpp(2013, -1170, salaire_imposable = 20000) test_irpp(2013, -7889, salaire_imposable = 50000) test_irpp(2013, -43076, salaire_imposable = 150000) print 'rst' test_irpp(2010, -1181, rst = 20000) test_irpp(2010, -8336, rst = 50000) test_irpp(2010, -46642, rst = 150000) test_irpp(2011, -1181, rst = 20000) test_irpp(2011, -8336, rst = 50000) test_irpp(2011, -46642, rst = 150000) test_irpp(2012, -1181, rst = 20000) test_irpp(2012, -8336, rst = 50000) test_irpp(2012, -46642, rst = 150000) test_irpp(2013, -1170, rst = 20000) test_irpp(2013, -8283, rst = 50000) test_irpp(2013, -46523, rst = 150000) print 'f2da' test_irpp(2010, 0, f2da = 20000) test_irpp(2010, 0, f2da = 50000) test_irpp(2010, 0, f2da = 150000) test_irpp(2011, 0, f2da = 20000) test_irpp(2011, 0, f2da = 50000) test_irpp(2011, 0, f2da = 150000) test_irpp(2012, 0, f2da = 20000) test_irpp(2012, 0, f2da = 50000) test_irpp(2012, 0, f2da = 150000) # test_irpp(2013, 0, f2da = 20000) # test_irpp(2013, 0, f2da = 50000) # test_irpp(2013, 0, f2da = 150000) print 'f2dc' test_irpp(2010, 0, f2dc = 20000) test_irpp(2010, -2976, f2dc = 50000) test_irpp(2010, -22917, f2dc = 150000) test_irpp(2011, 0, f2dc = 20000) test_irpp(2011, -2976, f2dc = 50000) test_irpp(2011, -22917, f2dc = 150000) test_irpp(2012, 0, f2dc = 20000) test_irpp(2012, -3434, f2dc = 50000) test_irpp(2012, -23542, f2dc = 150000) # test_irpp(2013, 0, f2dc = 20000) # test_irpp(2013, 0, f2dc = 50000) # test_irpp(2013, 0, f2dc = 150000) print 'f2dh' test_irpp(2010, 345, f2dh = 20000) test_irpp(2010, 345, f2dh = 50000) test_irpp(2010, 345, f2dh = 150000) test_irpp(2011, 345, f2dh = 20000) test_irpp(2011, 345, f2dh = 50000) test_irpp(2011, 345, f2dh = 150000) test_irpp(2012, 345, f2dh = 20000) test_irpp(2012, 345, f2dh = 50000) test_irpp(2012, 345, f2dh = 150000) test_irpp(2013, 345, f2dh = 20000) test_irpp(2013, 345, f2dh = 50000) test_irpp(2013, 345, f2dh = 150000) print 'f2tr' test_irpp(2010, -1461, f2tr = 20000) test_irpp(2010, -9434, f2tr = 50000) test_irpp(2010, -48142, f2tr = 150000) test_irpp(2011, -1461, f2tr = 20000) test_irpp(2011, -9434, f2tr = 50000) test_irpp(2011, -48142, f2tr = 150000) test_irpp(2012, -1461, f2tr = 20000) test_irpp(2012, -9434, f2tr = 50000) test_irpp(2012, -48142, f2tr = 150000) test_irpp(2013, -1450, f2tr = 20000) test_irpp(2013, -9389, f2tr = 50000) test_irpp(2013, -48036, f2tr = 150000) print 'f2ts' test_irpp(2010, -1461, f2ts = 20000) test_irpp(2010, -9434, f2ts = 50000) test_irpp(2010, -48142, f2ts = 150000) test_irpp(2011, -1461, f2ts = 20000) test_irpp(2011, -9434, f2ts = 50000) test_irpp(2011, -48142, f2ts = 150000) test_irpp(2012, -1461, f2ts = 20000) test_irpp(2012, -9434, f2ts = 50000) test_irpp(2012, -48142, f2ts = 150000) test_irpp(2013, -1450, f2ts = 20000) test_irpp(2013, -9389, f2ts = 50000) test_irpp(2013, -48036, f2ts = 150000) print 'f3vg' test_irpp(2010, -3600, f3vg = 20000) test_irpp(2010, -9000, f3vg = 50000) test_irpp(2010, -27000, f3vg = 150000) test_irpp(2011, -3800, f3vg = 20000) test_irpp(2011, -9500, f3vg = 50000) test_irpp(2011, -28500, f3vg = 150000) test_irpp(2012, -4800, f3vg = 20000) test_irpp(2012, -12000, f3vg = 50000) test_irpp(2012, -36000, f3vg = 150000) test_irpp(2013, -1450, f3vg = 20000) test_irpp(2013, -9389, f3vg = 50000) test_irpp(2013, -48036, f3vg = 150000) print 'f3vz' # test_irpp(2010, 0, f3vz = 20000) # test_irpp(2010, 0, f3vz = 50000) # test_irpp(2010, 0, f3vz = 150000) test_irpp(2011, 0, f3vz = 20000) test_irpp(2011, 0, f3vz = 50000) test_irpp(2011, 0, f3vz = 150000) test_irpp(2012, 0, f3vz = 20000) test_irpp(2012, 0, f3vz = 50000) test_irpp(2012, 0, f3vz = 150000) test_irpp(2013, 0, f3vz = 20000) test_irpp(2013, 0, f3vz = 50000) test_irpp(2013, 0, f3vz = 150000) print 'f4ba' test_irpp(2010, -1461, f4ba = 20000) test_irpp(2010, -9434, f4ba = 50000) test_irpp(2010, -48142, f4ba = 150000) test_irpp(2011, -1461, f4ba = 20000) test_irpp(2011, -9434, f4ba = 50000) test_irpp(2011, -48142, f4ba = 150000) test_irpp(2012, -1461, f4ba = 20000) test_irpp(2012, -9434, f4ba = 50000) test_irpp(2012, -48142, f4ba = 150000) test_irpp(2013, -1450, f4ba = 20000) test_irpp(2013, -9389, f4ba = 50000) test_irpp(2013, -48036, f4ba = 150000) if __name__ == "__main__": sys.exit(main()) PKoz 1: # cette condition inclue les dates if i > len(choices): raise Exception('Il faut plus de choix pour remplir le formulaire') question.set_choice(choices[i]) i += 1 else: question.set_choice(question.possible_choices[0]) self.check_pages() def check_pages(self): for page in self.pages: page.check_page() def init(self): # premiere page request = urllib2.Request(self.url, headers = headers) response = url_opener.open(request) html_page = response.read() tree = etree.parse(StringIO(html_page), parser) form_element = tree.xpath('//form')[1] return response, form_element def get_a_tree(self): response, form_element = self.init() init = {'BCCommencer': 'Commencer', 'conditionsSimuLog': 'true'} response, form_element, html = go_to_next_page(init, response, form_element) while 'droit à une aide au logement' not in html: # on cherche la page, ou bien on la crée name_page = _get_page_name(form_element) if 'otre conjoint' in html.title(): print 'Votre conjoint' import pdb pdb.set_trace() if name_page not in self.pages_collections: page_question = _get_a_page(form_element) self.pages_collections[name_page] = page_question page_question.init_choices() else: page_question = self.pages_collections[name_page] print name_page page_question.set_next_choices() parameters = page_question.get_parameters() parameters["BCContinuer"] = "Continuer" response, form_element, html = go_to_next_page(parameters, response, form_element) # if 'droit à une aide au logement' in html: look = html[:(html.index('&euro') - 1)] montant = re.findall("\d+.\d+", look[-10:])[0] montant = montant.replace(',', '.') montant = float(montant) print montant print ('fin de boucle') import pdb pdb.set_trace() def get_parameters_serie(self): return [page.get_parameters() for page in self.pages] def fill_in(self): ''' remplir un formulaire avec les données de parameters''' response, form_element = self.init() parameters_serie = self.get_parameters_serie() for parameters in parameters_serie: print parameters response, form_element, html = go_to_next_page(parameters, response, form_element) if '&euro' in html and "loyer" not in html: look = html[:(html.index('&euro') - 1)] montant = re.findall("\d+.\d+", look[-10:])[0] montant = montant.replace(',', '.') montant = float(montant) return montant for input_element in form_element.xpath('.//input'): print etree.tostring(input_element) class Page(object): def __init__(self, questions, number=0): self.questions = questions self.number = number self.suite = {} def get_parameters(self): dico = {} for question in self.questions: if question.choice is None: raise Exception('Il faut donne une valeur à ' + question.name) else: dico[question.name] = question.choice return dico def check_page(self): pass def init_choices(self): for question in self.questions: question.choice = question.possible_choices[0] def set_next_choices(self): for question in self.questions[::-1]: if question.possible_choices is None: raise Exception('Il faut donner des valeurs à ' + question.name) if question.choice is not None: old_idx = question.possible_choices.index(question.choice) if old_idx < len(question.possible_choices) - 1: question.choice = question.possible_choices[old_idx + 1] break # si on est là c'est qu'on bien qu'on est au bout # des possibilité pour la question # a ce moment, là on remet au début et on décale la question d'après question.choice = question.possible_choices[0] def boucle_bouclee(self): ''' test si on a tout le monde à zéro ce qui arrive quand on initialise et quand on a fait le tour des possibilités sinon ''' return all([question.choice == question.possible_choices[0] for question in self.questions]) class Question(object): def __init__(self, name, possible_choices, type='radio'): self.name = name self.possible_choices = possible_choices self.choice = None self.type = type def set_choice(self, choice): if self.possible_choices not in ["date", 'int']: if choice not in self.possible_choices: raise Exception('le choix ' + choice + ' ne va pas pour ' + self.name) if self.possible_choices == "date": pass # TODO: check on form self.choice = choice url = "http://www.caf.fr/redirect/s/Redirect?page=aidesEtServicesSimuLogement" logement = Formulaire(url, [Page([])]) logement.get_a_tree() PKFDy y *openfisca_france/scripts/cnaf/simul_rsa.py# coding: utf-8 from formulaires_caf import Question, Page, Formulaire url = "http://www.caf.fr/redirect/s/Redirect?page=aidesEtServicesTestRsa" conditionsRsa = Question('conditionsRsa', ["true"]) BCCommencer = Question("BCCommencer", ["Commencer"]) BCContinuer = Question("BCContinuer", ["Continuer"]) page0 = Page([conditionsRsa, BCCommencer]) residez = Question("residez", ["FranceMetro", 'Autres']) # TODO: page1 = Page([residez, BCContinuer]) seulOuCouple = Question("seulOuCouple", ["SEUL", "COUPLE"]) DateIsole = Question("DateIsole", 'date') page2 = Page([seulOuCouple, DateIsole, BCContinuer]) typePers = Question("typePers", ['MME', 'MON']) NOM = Question("NOM", ['Martin']) PRENOM = Question("PRENOM", ['Alain']) dateNaissance = Question("dateNaissance", 'date') naissance = Question("naissance", ['', 'True']) enfantMoins3 = Question("enfantMoins3", 'int') enfantPlus3 = Question("enfantPlus3", 'int') enfantPlus14 = Question("enfantPlus14", 'int') page3 = Page([typePers, NOM, PRENOM, dateNaissance, naissance, enfantMoins3, enfantPlus3, enfantPlus14, BCContinuer]) rsaSitPro = Question("rsaSitPro", ["EtudiantEleve", "EtudiantSalarie", "Disponibilite", "Sabbatique", "Parental", "SansActivite", "Eti", "EnActivite"]) page4 = Page([rsaSitPro, BCContinuer]) revPercuSeul = Question('revenusPercusSeul', 'int') chomPercuSeul = Question('indemnitesChomagePercuesSeul', 'int') ressPercuSeul = Question('RessourcesPercuesSeul', 'int') pfPercuSeul = Question('pfPercusSeul', 'int') page_rev = Page([revPercuSeul, chomPercuSeul, ressPercuSeul, pfPercuSeul, BCContinuer]) rsa = Formulaire(url, [Page([]), page0, page1, page2, page3, page4, page_rev]) # TODO: a mettre def check_formulaire(formulaire): if formulaire["seulOuCouple"] == "COUPLE": assert formulaire["DateIsole"] == "" if __name__ == '__main__': exemple = ["FranceMetro", 'SEUL', "01/06/2003", 'MON', "01/06/1960", '', '0', '2', '0', "EnActivite", '0', '0', '0', '0'] rsa.set_choice(exemple) rsa.fill_in() #for sitPro in rsaSitPro.possible_choices: # exemple[-1] = sitPro # rsa.set_choice(exemple) # print('********* ' + sitPro) # rsa.fill_in() #continue = "EtudiantSalarie", #print html_page # #print etree.tostring(form_element) PKF*oc1openfisca_france/scripts/cnaf/exploitation_rsa.py# coding: utf-8 from simul_rsa import rsa exemple = ["FranceMetro", 'SEUL', "01/06/2003", 'MON', "01/06/1960", '', '0', '2', '0', "EnActivite", '0', '0', '0', '0'] #rsa.set_choice(exemple) #rsa.fill_in() #for sitPro in rsaSitPro.possible_choices: # exemple[-1] = sitPro # rsa.set_choice(exemple) # print('********* ' + sitPro) # rsa.fill_in() #continue = "EtudiantSalarie", #print html_page # #print etree.tostring(form_element) ## revenus #result_pf = {} #exemple_pf = list(exemple) #for revenu in range(10): # exemple[-1] = 100*revenu # rsa.set_choice(exemple) # result_pf[100*revenu] = rsa.fill_in() # print result_pf[100*revenu] ## => aucun intérêt car linéaire result_rev = {} exemple_rev = list(exemple) for revenu in range(10): exemple_rev[-4] = 100*revenu rsa.set_choice(exemple_rev) result_rev[100*revenu] = rsa.fill_in() print result_rev[100*revenu] PKFQ /openfisca_france/scripts/cnaf/simul_logement.py# coding: utf-8 from formulaires_caf import Question, Page, Formulaire url = "http://www.caf.fr/redirect/s/Redirect?page=aidesEtServicesSimuLogement" conditions = Question('conditionsSimuLog', ["true"]) BCCommencer = Question("BCCommencer", ["Commencer"]) BCContinuer = Question("BCContinuer", ["Continuer"]) page0 = Page([conditions, BCCommencer]) CODEPOS = Question("CODEPOS", 'int') # TODO: page1 = Page([CODEPOS, BCContinuer]) logOcc = Question("logOcc", ["loc", "etudiant", "foy", "accpart", "accpp", ]) doubleRes = Question("doubleRes", ['false', 'true']) page2 = Page([logOcc, doubleRes, BCContinuer]) logType = Question("logType", ["appartement", "chambre"]) logQui = Question('logQui', ['seul', 'conjoint', "autperson"]) logMeuble = Question('logMeuble', ['oui', 'non']) page3 = Page([logType, logQui, logMeuble, BCContinuer]) loyer = Question("MTLOY", 'int') page4 = Page([loyer, BCContinuer]) sitMatCpl = Question('sitMatCpl', ['oui', 'non']) dtNaissR = Question("dtNaissR", 'date') dtNaissC = Question("dtNaissC", 'date') topGross = Question('topGross', ['oui', 'non']) topGross4mois = Question('topGross4mois', ['oui', 'non']) tecNbrEnfant = Question("tecNbrEnfant", 'int') tecNbrAutre = Question("tecNbrAutre", 'int') page5 = Page([sitMatCpl, dtNaissR, dtNaissC, topGross, topGross4mois, tecNbrEnfant, tecNbrAutre, BCContinuer]) actPro = Question('actPro', ['oui', 'non']) beneRsa = Question('beneRsa', ['oui', 'non']) page6 = Page([actPro, beneRsa, BCContinuer]) sitActNon = Question('sitActNon', ['cho', 'ebo', 'etu', "parfoy", 'retre', 'arrtrav', 'han', 'inc' 'aut']) page7 = Page([sitActNon, BCContinuer]) sitChoDuree = Question('sitChoDuree', ["inf2m", "sup2m"]) sitChoAlloc = Question('sitChoAlloc', ['are', 'ass', 'ata', 'aca', 'asr', 'autind', 'attind', 'allnok']) page8 = Page([sitChoDuree, sitChoAlloc, BCContinuer]) revPercuSeul = Question('revenusPercusSeul', 'int') chomPercuSeul = Question('indemnitesChomagePercuesSeul', 'int') ressPercuSeul = Question('RessourcesPercuesSeul', 'int') pfPercuSeul = Question('pfPercusSeul', 'int') page_rev = Page([revPercuSeul, chomPercuSeul, ressPercuSeul, pfPercuSeul, BCContinuer]) logement = Formulaire(url, [Page([]), page0, page1, page2, page3, page4, page5, page6, page7, page8]) if __name__ == '__main__': exemple = ["FranceMetro", 'SEUL', "01/06/2003", 'MON', "01/06/1960", '', '0', '2', '0', "EnActivite", '0', '0', '0', '0'] exemple = ['75012', 'loc', 'false', "appartement", 'seul', 'non', '500', 'oui', '01/04/1980', '05/03/1975', 'non', 'non', '2', '0', 'oui', 'oui', 'cho', 'sup2m', 'ass'] logement.set_choice(exemple) logement.fill_in() #for sitPro in rsaSitPro.possible_choices: # exemple[-1] = sitPro # rsa.set_choice(exemple) # print('********* ' + sitPro) # rsa.fill_in() #continue = "EtudiantSalarie", #print html_page # #print etree.tostring(form_element) PKF )openfisca_france/scripts/cnaf/get_tree.py# -*- coding: utf-8 -*- """ Created on Wed Dec 24 15:44:05 2014 @author: AEidelman Pour avoir l'arbre des questions """ import pdb from selenium import webdriver from selenium.webdriver.common.keys import Keys from formulaires_caf import Question, Page, Formulaire url = "http://www.caf.fr/redirect/s/Redirect?page=aidesEtServicesSimuLogement" question_collection = {} page_collection = {} ## init browser = webdriver.Firefox() browser.get(url) condition = browser.find_element_by_name(u'conditionsSimuLog') condition.click() BCCommencer = browser.find_element_by_name("BCCommencer") BCCommencer.click() input_pas_interessant = ['you_search', '', 'form_id', 'BCContinuer'] def _get_inputs(browser): inputs = browser.find_elements_by_xpath("//input") inputs = [input for input in inputs if input.get_attribute('name') not in input_pas_interessant] for input in inputs: print input.get_attribute('name'), input.get_attribute('type') return inputs def continuer(browser): BCContinuer = browser.find_element_by_name("BCContinuer") BCContinuer.click() def create_page_from_inputs(browser): ''' determine la page sur laquelles on est - si la page existe (on a déjà vu les questions) on passe - sinon, on la créee''' global page_collection page_question = [] name_page = '' inputs = _get_inputs(browser) inputs_radio = [input for input in inputs if input.get_attribute('type') == 'radio'] inputs_not_radio = [input for input in inputs if input not in inputs_radio] ## regroupe les inputs radio: input_radio_names = [input.get_attribute('name') for input in inputs_radio] for radio_name in set(input_radio_names): name_page += radio_name choices = [input.get_attribute('value') for input in inputs_radio if input.get_attribute('name') == radio_name] page_question += [Question(radio_name, choices, 'radio')] for input in inputs_not_radio: name = input.get_attribute('name') name_page += name if input.get_attribute('type') == 'text': values = [] if name == 'CODEPOS': values = ['75012'] if name == 'MTLOY': # généraliser à MT dans le nom ? values = [str(100*x) for x in range(1, 10)] if 'dt' in name: # dtNaiss values = ['04/06/' + str(1920 + 10*x) for x in range(10)] if 'Nbr' in name: # Enfant values = [str(x) for x in range(4)] if name == 'MTMENEVAFOR': values = [str(1+100*x) for x in range(15)] if 'Ress' in name: if 'RessSal' in name or 'RessCho' in name: values = [str(1000*x) for x in range(20)] else: # if 'RessFR' in name or 'RessIJ' in name: values = ['0'] if values == []: print name pdb.set_trace() page_question += [Question(name, values, 'text')] elif input.get_attribute('type') == 'checkbox': page_question += [Question(name, ['false', 'true'], 'text')] else: print 'type non rencontré encore' print input.get_attribute('type') pdb.set_trace() if name_page not in page_collection.keys(): page_collection[name_page] = page_question print name_page return name_page def fill_page(browser, name_page): questions = page_collection[name_page] for question in questions: try: print 'question', question.name champs = browser.find_elements_by_name(question.name) if question.type == 'text': assert len(champs) == 1 champs[0].send_keys(question.possible_choices[0]) if question.type == 'radio': if champs[0].is_displayed(): champs[0].click() except: import pdb pdb.set_trace() while 'droit à une aide au logement' not in browser.page_source: name_page = create_page_from_inputs(browser) if name_page == '': break fill_page(browser, name_page) try: continuer(browser) except: pdb.set_trace() xxx conditions = Question('conditionsSimuLog', ["true"]) BCCommencer = Question("BCCommencer", ["Commencer"]) BCContinuer = Question("BCContinuer", ["Continuer"]) page0 = Page([conditions, BCCommencer]) CODEPOS = Question("CODEPOS", 'int', 'text') # TODO: page1 = Page([CODEPOS, BCContinuer]) logOcc = Question("logOcc", ["loc", "etudiant", "foy", "accpart", "accpp", ]) doubleRes = Question("doubleRes", ['false', 'true']) page2 = Page([logOcc, doubleRes, BCContinuer]) logType = Question("logType", ["appartement", "chambre"]) logQui = Question('logQui', ['seul', 'conjoint', "autperson"]) logMeuble = Question('logMeuble', ['oui', 'non']) page3 = Page([logType, logQui, logMeuble, BCContinuer]) loyer = Question("MTLOY", 'int') page4 = Page([loyer, BCContinuer]) sitMatCpl = Question('sitMatCpl', ['oui', 'non']) dtNaissR = Question("dtNaissR", 'date') dtNaissC = Question("dtNaissC", 'date') topGross = Question('topGross', ['oui', 'non']) topGross4mois = Question('topGross4mois', ['oui', 'non']) tecNbrEnfant = Question("tecNbrEnfant", 'int') tecNbrAutre = Question("tecNbrAutre", 'int') page5 = Page([sitMatCpl, dtNaissR, dtNaissC, topGross, topGross4mois, tecNbrEnfant, tecNbrAutre, BCContinuer]) actPro = Question('actPro', ['oui', 'non']) beneRsa = Question('beneRsa', ['oui', 'non']) page6 = Page([actPro, beneRsa, BCContinuer]) sitActNon = Question('sitActNon', ['cho', 'ebo', 'etu', "parfoy", 'retre', 'arrtrav', 'han', 'inc' 'aut']) page7 = Page([sitActNon, BCContinuer]) sitChoDuree = Question('sitChoDuree', ["inf2m", "sup2m"]) sitChoAlloc = Question('sitChoAlloc', ['are', 'ass', 'ata', 'aca', 'asr', 'autind', 'attind', 'allnok']) page8 = Page([sitChoDuree, sitChoAlloc, BCContinuer]) revPercuSeul = Question('revenusPercusSeul', 'int') chomPercuSeul = Question('indemnitesChomagePercuesSeul', 'int') ressPercuSeul = Question('RessourcesPercuesSeul', 'int') pfPercuSeul = Question('pfPercusSeul', 'int') page_rev = Page([revPercuSeul, chomPercuSeul, ressPercuSeul, pfPercuSeul, BCContinuer]) logement = Formulaire(url, [Page([]), page0, page1, page2, page3, page4, page5, page6, page7, page8]) if __name__ == '__main__': exemple = ['75012', 'loc', 'false', "appartement", 'seul', 'non', '500', 'oui', '01/04/1980', '05/03/1975', 'non', 'non', '2', '0', 'oui', 'oui', 'cho', 'sup2m', 'ass'] # logement.set_choice(exemple) logement.get_tree() #for sitPro in rsaSitPro.possible_choices: # exemple[-1] = sitPro # rsa.set_choice(exemple) # print('********* ' + sitPro) # rsa.fill_in() #continue = "EtudiantSalarie", #print html_page # #print etree.tostring(form_element) PKoz 7gy 7fy < 3 7jy, 7ly < 16, 7hy 7ky < 7jy 7my < 7ly 7eb + 7ed + 7eg, 7ea + 7ec + 7ef < nb_pac 7um < 2tr 7wn < 7wm 7ud < 521 7hy < 7iy 7ny < 7nx 7pd < 7pc 7ph < 7pg 7pl < 7pk 7pr < 7pq 7pw < 7pv 7ri < 7rh 7ro < 7rn 7rt < 7rs 7ry < 7rx 7qi < 7qh 7qr < 7qq hse < hsd hsj < hsi hso < hsn hst < hss htd < htc hsy < hsx Nécessite une autre case : 2ab, 2bg, 2ck, 4bf, 7uo, 7us, 8tb, 8tc, 8td, 8te, 8tg, 8ts, 8tz, 8uz, 8uy, 8wa, 8wb, 8wc, 8wd, 8we, 8wr, 8ws, 8wt, 8wu, 8wv, 8wx Une au maximum de ces variables est non nulle : 7HJ, 7HK PKoz single entity with codecs.open(os.path.join('json', h2 + '.json'), 'w', encoding = 'utf-8') as fichier: json.dump(add_official(scenario, h2, tested), fichier, encoding = 'utf-8', ensure_ascii = False, indent = 2, sort_keys = True) elif os.path.isfile(os.path.join('json', h + '.json')): compare(scenario, tested, h) else: compare(scenario, tested, h2) def main(): scenario = define_scenario() export_json(scenario) if __name__ == "__main__": sys.exit(main()) PKoz commune_depcom_by_subcommune_depcom.json ``` PKMME"openfisca_france/model/__init__.pyPKoz= 3 return period, (0 * (isol & _0_kid) + # Célibataire 1 * (not_(isol) & _0_kid) + # Couple sans enfants 2 * (not_(isol) & _1_kid) + # Couple un enfant 3 * (not_(isol) & _2_kid) + # Couple deux enfants 4 * (not_(isol) & _3_kid) + # Couple trois enfants et plus 5 * (isol & _1_kid) + # Famille monoparentale un enfant 6 * (isol & _2_kid) + # Famille monoparentale deux enfants 7 * (isol & _3_kid)) # Famille monoparentale trois enfants et plus @reference_formula class revdisp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"Revenu disponible du ménage" url = "http://fr.wikipedia.org/wiki/Revenu_disponible" def function(self, simulation, period): ''' Revenu disponible - ménage 'men' ''' period = period.start.period('year').offset('first-of') rev_trav_holder = simulation.compute('rev_trav', period) pen_holder = simulation.compute('pen', period) rev_cap_holder = simulation.compute('rev_cap', period) psoc_holder = simulation.compute('psoc', period) ppe_holder = simulation.compute('ppe', period) impo = simulation.calculate('impo', period) pen = self.sum_by_entity(pen_holder) ppe = self.cast_from_entity_to_role(ppe_holder, role = VOUS) ppe = self.sum_by_entity(ppe) psoc = self.cast_from_entity_to_role(psoc_holder, role = CHEF) psoc = self.sum_by_entity(psoc) rev_cap = self.sum_by_entity(rev_cap_holder) rev_trav = self.sum_by_entity(rev_trav_holder) return period, rev_trav + pen + rev_cap + psoc + ppe + impo @reference_formula class nivvie(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"Niveau de vie du ménage" def function(self, simulation, period): ''' Niveau de vie du ménage 'men' ''' period = period.start.offset('first-of', 'year').period('year') revdisp = simulation.calculate('revdisp', period) uc = simulation.calculate('uc', period) return period, revdisp / uc @reference_formula class revenu_net_individu(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Revenu net de l'individu" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') pen = simulation.calculate('pen', period) rev_cap = simulation.calculate('rev_cap', period) rev_trav = simulation.calculate('rev_trav', period) return period, pen + rev_cap + rev_trav @reference_formula class revnet(PersonToEntityColumn): entity_class = Menages label = u"Revenu net du ménage" operation = 'add' url = u"http://impotsurlerevenu.org/definitions/115-revenu-net-imposable.php", variable = revenu_net_individu @reference_formula class nivvie_net(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"Niveau de vie net du ménage" def function(self, simulation, period): ''' Niveau de vie net du ménage 'men' ''' period = period.start.offset('first-of', 'year').period('year') revnet = simulation.calculate('revnet', period) uc = simulation.calculate('uc', period) return period, revnet / uc @reference_formula class revenu_initial_individu(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Revenu initial de l'individu" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') cotisations_employeur_contributives = simulation.calculate('cotisations_employeur_contributives', period) cotisations_salariales_contributives = simulation.calculate('cotisations_salariales_contributives', period) pen = simulation.calculate('pen', period) rev_cap = simulation.calculate('rev_cap', period) rev_trav = simulation.calculate('rev_trav', period) return period, (rev_trav + pen + rev_cap - cotisations_employeur_contributives - cotisations_salariales_contributives) @reference_formula class revini(PersonToEntityColumn): entity_class = Menages label = u"Revenu initial du ménage" operation = 'add' variable = revenu_initial_individu @reference_formula class nivvie_ini(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"Niveau de vie initial du ménage" def function(self, simulation, period): ''' Niveau de vie initial du ménage 'men' ''' period = period.start.offset('first-of', 'year').period('year') revini = simulation.calculate('revini', period) uc = simulation.calculate('uc', period) return period, revini / uc def _revprim(rev_trav, cho, rev_cap, cotisations_employeur, cotisations_salariales): ''' Revenu primaire du ménage Ensemble des revenus d'activités superbruts avant tout prélèvement Il est égale à la valeur ajoutée produite par les résidents 'men' ''' return rev_trav + rev_cap - cotisations_employeur - cotisations_salariales - cho @reference_formula class rev_trav(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Revenus du travail (salariés et non salariés)" url = "http://fr.wikipedia.org/wiki/Revenu_du_travail" def function(self, simulation, period): ''' Revenu du travail ''' period = period.start.offset('first-of', 'year').period('year') rev_sal = simulation.calculate('rev_sal', period) rag = simulation.calculate('rag', period) ric = simulation.calculate('ric', period) rnc = simulation.calculate('rnc', period) return period, rev_sal + rag + ric + rnc @reference_formula class pen(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Total des pensions et revenus de remplacement" url = "http://fr.wikipedia.org/wiki/Rente" def function(self, simulation, period): ''' Pensions ''' period = period.start.period('year').offset('first-of') chonet = simulation.calculate('chonet', period) rstnet = simulation.calculate('rstnet', period) pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', period) pensions_alimentaires_versees_declarant1 = simulation.calculate( 'pensions_alimentaires_versees_declarant1', period ) rto_declarant1 = simulation.calculate_add('rto_declarant1', period) return period, (chonet + rstnet + pensions_alimentaires_percues + pensions_alimentaires_versees_declarant1 + rto_declarant1) @reference_formula class cotsoc_bar_declarant1(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Cotisations sociales sur les revenus du capital imposés au barème" def function(self, simulation, period): ''' Cotisations sociales sur les revenus du capital imposés au barème ''' period = period.start.period('year').offset('first-of') csg_cap_bar_declarant1 = simulation.calculate('csg_cap_bar_declarant1', period) prelsoc_cap_bar_declarant1 = simulation.calculate('prelsoc_cap_bar_declarant1', period) crds_cap_bar_declarant1 = simulation.calculate('crds_cap_bar_declarant1', period) return period, csg_cap_bar_declarant1 + prelsoc_cap_bar_declarant1 + crds_cap_bar_declarant1 @reference_formula class cotsoc_lib_declarant1(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Cotisations sociales sur les revenus du capital soumis au prélèvement libératoire" def function(self, simulation, period): ''' Cotisations sociales sur les revenus du capital soumis au prélèvement libératoire ''' period = period.start.offset('first-of', 'year').period('year') csg_cap_lib_declarant1 = simulation.calculate('csg_cap_lib_declarant1', period) prelsoc_cap_lib_declarant1 = simulation.calculate('prelsoc_cap_lib_declarant1', period) crds_cap_lib_declarant1 = simulation.calculate('crds_cap_lib_declarant1', period) return period, csg_cap_lib_declarant1 + prelsoc_cap_lib_declarant1 + crds_cap_lib_declarant1 @reference_formula class rev_cap(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Revenus du patrimoine" url = "http://fr.wikipedia.org/wiki/Revenu#Revenu_du_Capital" def function(self, simulation, period): ''' Revenus du patrimoine ''' period = period.start.offset('first-of', 'year').period('year') fon_holder = simulation.compute('fon', period) rev_cap_bar_holder = simulation.compute_add('rev_cap_bar', period) cotsoc_bar_declarant1 = simulation.calculate('cotsoc_bar_declarant1', period) rev_cap_lib_holder = simulation.compute_add('rev_cap_lib', period) cotsoc_lib_declarant1 = simulation.calculate('cotsoc_lib_declarant1', period) imp_lib_holder = simulation.compute('imp_lib', period) rac = simulation.calculate('rac', period) fon = self.cast_from_entity_to_role(fon_holder, role = VOUS) imp_lib = self.cast_from_entity_to_role(imp_lib_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) return period, fon + rev_cap_bar + cotsoc_bar_declarant1 + rev_cap_lib + cotsoc_lib_declarant1 + imp_lib + rac @reference_formula class psoc(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Total des prestations sociales" url = "http://fr.wikipedia.org/wiki/Prestation_sociale" def function(self, simulation, period): ''' Prestations sociales ''' period = period.start.offset('first-of', 'year').period('year') pfam = simulation.calculate('pfam', period) mini = simulation.calculate('mini', period) aides_logement = simulation.calculate('aides_logement', period) return period, pfam + mini + aides_logement @reference_formula class pfam(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Total des prestations familiales" url = "http://www.social-sante.gouv.fr/informations-pratiques,89/fiches-pratiques,91/prestations-familiales,1885/les-prestations-familiales,12626.html" def function(self, simulation, period): ''' Prestations familiales ''' period = period.start.offset('first-of', 'year').period('year') af = simulation.calculate_add('af', period) cf = simulation.calculate_add('cf', period) ars = simulation.calculate('ars', period) aeeh = simulation.calculate('aeeh', period) paje = simulation.calculate_add('paje', period) asf = simulation.calculate_add('asf', period) crds_pfam = simulation.calculate('crds_pfam', period) return period, af + cf + ars + aeeh + paje + asf + crds_pfam @reference_formula class mini(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Minima sociaux" url = "http://fr.wikipedia.org/wiki/Minima_sociaux" def function(self, simulation, period): ''' Minima sociaux ''' period = period.start.offset('first-of', 'year').period('year') aspa = simulation.calculate_add('aspa', period) aah_holder = simulation.compute_add('aah', period) caah_holder = simulation.compute_add('caah', period) asi = simulation.calculate_add('asi', period) rsa = simulation.calculate_add('rsa', period) aefa = simulation.calculate('aefa', period) api = simulation.calculate('api', period) ass = simulation.calculate_add('ass', period) psa = simulation.calculate_add('psa', period) aah = self.sum_by_entity(aah_holder) caah = self.sum_by_entity(caah_holder) return period, aspa + aah + caah + asi + rsa + aefa + api + ass + psa @reference_formula class aides_logement(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Allocations logements" url = "http://vosdroits.service-public.fr/particuliers/N20360.xhtml" def function(self, simulation, period): ''' Prestations logement ''' period = period.start.offset('first-of', 'year').period('year') apl = simulation.calculate_add('apl', period) als = simulation.calculate_add('als', period) alf = simulation.calculate_add('alf', period) crds_logement = simulation.calculate_add('crds_logement', period) return period, apl + als + alf + crds_logement @reference_formula class impo(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"Impôts sur le revenu" url = "http://fr.wikipedia.org/wiki/Imp%C3%B4t_direct" def function(self, simulation, period): ''' Impôts directs ''' period = period.start.offset('first-of', 'year').period('year') irpp_holder = simulation.compute('irpp', period) taxe_habitation = simulation.calculate('taxe_habitation', period) irpp = self.cast_from_entity_to_role(irpp_holder, role = VOUS) irpp = self.sum_by_entity(irpp) return period, irpp + taxe_habitation @reference_formula class crds(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Total des contributions au remboursement de la dette sociale" def function(self, simulation, period): """Contribution au remboursement de la dette sociale""" period = period.start.offset('first-of', 'year').period('year') crds_salaire = simulation.calculate_add('crds_salaire', period) crds_retraite = simulation.calculate_add('crds_retraite', period) crds_chomage = simulation.calculate_add('crds_chomage', period) crds_fon_holder = simulation.compute('crds_fon', period) crds_cap_bar_declarant1 = simulation.calculate('crds_cap_bar_declarant1', period) crds_cap_lib_declarant1 = simulation.calculate('crds_cap_lib_declarant1', period) crds_pfam_holder = simulation.compute('crds_pfam', period) crds_logement_holder = simulation.compute_add('crds_logement', period) crds_mini_holder = simulation.compute_add('crds_mini', period) crds_pv_mo_holder = simulation.compute('crds_pv_mo', period) crds_pv_immo_holder = simulation.compute('crds_pv_immo', period) crds_fon = self.cast_from_entity_to_role(crds_fon_holder, role = VOUS) crds_logement = self.cast_from_entity_to_role(crds_logement_holder, role = CHEF) crds_mini = self.cast_from_entity_to_role(crds_mini_holder, role = CHEF) crds_pfam = self.cast_from_entity_to_role(crds_pfam_holder, role = CHEF) crds_pv_immo = self.cast_from_entity_to_role(crds_pv_immo_holder, role = VOUS) crds_pv_mo = self.cast_from_entity_to_role(crds_pv_mo_holder, role = VOUS) return period, (crds_salaire + crds_retraite + crds_chomage + crds_fon + crds_cap_bar_declarant1 + crds_cap_lib_declarant1 + crds_pv_mo + crds_pv_immo + crds_pfam + crds_logement + crds_mini) @reference_formula class csg(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Total des contributions sociale généralisée" def function(self, simulation, period): """Contribution sociale généralisée""" period = period.start.offset('first-of', 'year').period('year') csg_imposable_salaire = simulation.calculate_add('csg_imposable_salaire', period) csg_deductible_salaire = simulation.calculate_add('csg_deductible_salaire', period) csg_imposable_chomage = simulation.calculate_add('csg_imposable_chomage', period) csg_deductible_chomage = simulation.calculate_add('csg_deductible_chomage', period) csg_imposable_retraite = simulation.calculate_add('csg_imposable_retraite', period) csg_deductible_retraite = simulation.calculate_add('csg_deductible_retraite', period) csg_fon_holder = simulation.compute('csg_fon', period) csg_cap_lib_declarant1 = simulation.calculate('csg_cap_lib_declarant1', period) csg_cap_bar_declarant1 = simulation.calculate('csg_cap_bar_declarant1', period) csg_pv_mo_holder = simulation.compute('csg_pv_mo', period) csg_pv_immo_holder = simulation.compute('csg_pv_immo', period) csg_fon = self.cast_from_entity_to_role(csg_fon_holder, role = VOUS) csg_pv_immo = self.cast_from_entity_to_role(csg_pv_immo_holder, role = VOUS) csg_pv_mo = self.cast_from_entity_to_role(csg_pv_mo_holder, role = VOUS) return period, (csg_imposable_salaire + csg_deductible_salaire + csg_imposable_chomage + csg_deductible_chomage + csg_imposable_retraite + csg_deductible_retraite + csg_fon + csg_cap_lib_declarant1 + csg_pv_mo + csg_pv_immo + csg_cap_bar_declarant1) @reference_formula class cotsoc_noncontrib(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Cotisations sociales non contributives" def function(self, simulation, period): ''' Cotisations sociales non contributives (hors prelsoc_cap_lib, prelsoc_cap_bar) ''' period = period.start.offset('first-of', 'year').period('year') cotisations_employeur_non_contributives = simulation.calculate('cotisations_employeur_non_contributives', period) cotisations_salariales_non_contributives = simulation.calculate('cotisations_salariales_non_contributives', period) return period, cotisations_employeur_non_contributives + cotisations_salariales_non_contributives @reference_formula class prelsoc_cap(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Prélèvements sociaux sur les revenus du capital" url = "http://www.impots.gouv.fr/portal/dgi/public/particuliers.impot?pageId=part_ctrb_soc&paf_dm=popup&paf_gm=content&typePage=cpr02&sfid=501&espId=1&impot=CS" def function(self, simulation, period): """ Prélèvements sociaux sur les revenus du capital """ period = period.start.offset('first-of', 'year').period('year') prelsoc_fon_holder = simulation.compute('prelsoc_fon', period) prelsoc_cap_lib_declarant1 = simulation.calculate('prelsoc_cap_lib_declarant1', period) prelsoc_cap_bar_declarant1 = simulation.calculate('prelsoc_cap_bar_declarant1', period) prelsoc_pv_mo_holder = simulation.compute('prelsoc_pv_mo', period) prelsoc_pv_immo_holder = simulation.compute('prelsoc_pv_immo', period) prelsoc_fon = self.cast_from_entity_to_role(prelsoc_fon_holder, role = VOUS) prelsoc_pv_immo = self.cast_from_entity_to_role(prelsoc_pv_immo_holder, role = VOUS) prelsoc_pv_mo = self.cast_from_entity_to_role(prelsoc_pv_mo_holder, role = VOUS) return period, (prelsoc_fon + prelsoc_cap_lib_declarant1 + prelsoc_cap_bar_declarant1 + prelsoc_pv_mo + prelsoc_pv_immo) @reference_formula class check_csk(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"check_csk" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') prelsoc_cap_bar_declarant1_holder = simulation.compute('prelsoc_cap_bar_declarant1', period) prelsoc_pv_mo_holder = simulation.compute('prelsoc_pv_mo', period) prelsoc_fon_holder = simulation.compute('prelsoc_fon', period) prelsoc_cap_bar = self.sum_by_entity(prelsoc_cap_bar_declarant1_holder) prelsoc_pv_mo = self.cast_from_entity_to_role(prelsoc_pv_mo_holder, role = CHEF) prelsoc_pv_mo = self.sum_by_entity(prelsoc_pv_mo) prelsoc_fon = self.cast_from_entity_to_role(prelsoc_fon_holder, role = CHEF) prelsoc_fon = self.sum_by_entity(prelsoc_fon) return period, prelsoc_cap_bar + prelsoc_pv_mo + prelsoc_fon @reference_formula class check_csg(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"check_csg" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') csg_cap_bar_declarant1_holder = simulation.compute('csg_cap_bar_declarant1', period) csg_pv_mo_holder = simulation.compute('csg_pv_mo', period) csg_fon_holder = simulation.compute('csg_fon', period) csg_cap_bar = self.sum_by_entity(csg_cap_bar_declarant1_holder) csg_pv_mo = self.cast_from_entity_to_role(csg_pv_mo_holder, role = CHEF) csg_pv_mo = self.sum_by_entity(csg_pv_mo) csg_fon = self.cast_from_entity_to_role(csg_fon_holder, role = CHEF) csg_fon = self.sum_by_entity(csg_fon) return period, csg_cap_bar + csg_pv_mo + csg_fon @reference_formula class check_crds(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"check_crds" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') crds_cap_bar_declarant1_holder = simulation.compute('crds_cap_bar_declarant1', period) crds_pv_mo_holder = simulation.compute('crds_pv_mo', period) crds_fon_holder = simulation.compute('crds_fon', period) crds_cap_bar = self.sum_by_entity(crds_cap_bar_declarant1_holder) crds_pv_mo = self.cast_from_entity_to_role(crds_pv_mo_holder, role = CHEF) crds_pv_mo = self.sum_by_entity(crds_pv_mo) crds_fon = self.cast_from_entity_to_role(crds_fon_holder, role = CHEF) crds_fon = self.sum_by_entity(crds_fon) return period, crds_cap_bar + crds_pv_mo + crds_fon PKoz= 60) + (statmarit == 4)) * (isf_tot <= 0) * (rfr < seuil_th) + (asi > 0) + (aspa > 0) + (aah > 0) return period, not_(elig) @reference_formula class taxe_habitation(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Menages label = u"Taxe d'habitation" url = "http://www.impots.gouv.fr/portal/dgi/public/particuliers.impot?espId=1&pageId=part_taxe_habitation&impot=TH&sfid=50" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('year') exonere_taxe_habitation = simulation.calculate('exonere_taxe_habitation', period) nombre_enfants_a_charge_menage = simulation.calculate('nombre_enfants_a_charge_menage', period) nombre_enfants_majeurs_celibataires_sans_enfant = simulation.calculate('nombre_enfants_majeurs_celibataires_sans_enfant', period) rfr_n_1_holder = simulation.compute('rfr_n_1', period) rfr_n_1 = self.cast_from_entity_to_role(rfr_n_1_holder, role = VOUS) rfr_n_1 = self.sum_by_entity(rfr_n_1) # Variables TODO: à inclure dans la fonction valeur_locative_brute = 0 valeur_locative_moyenne = 0 # déped de la collectivité) # Paramètres: à inclure dans param.xml taux_minimal_2_premiers = .1 # minimun depusi 2011 majoration_2_premiers = 0 taux_minimal_3_et_plus = .15 majoration_3_et_plus = 0 abattement_general_base_forfaitaire = 0 # si non nul le taux suivant est nul taux_abattement_general_base = .1 # entre 1% et 15% depuis 2011 taux_special_modeste = 0 seuil_elig_special_modeste = 1.3 # 130 % de la valeur locative moyenne seuil_elig_special_modeste_add = .1 # 10% par personne à charge en garde exclusive et 5% en garde altennée taux_special_invalide = .1 # 10% si l'abattement est voté est en vigueur taux_imposition = .10 # TODO: taux d'imposition voté par les colloc # abattements pour l'habitation principale # abattements obligatoires pour charges de famille # * les enfants du contribuable, de son conjoint ou les enfants recueillis qui sont pris en compte pour le # calcul de l’impôt sur le revenu (2). Ne sont pas concernés ceux pour lesquels le redevable déduit de ses # revenus imposables une pension alimentaire ; pac_enf = nombre_enfants_a_charge_menage + nombre_enfants_majeurs_celibataires_sans_enfant # TODO: inclure ceux du conjoint non présent sur la feuille d'impôt ? gestion des gardes alternées # * les ascendants du contribuable et ceux de son conjoint remplissant les 3 conditions suivantes : # – être âgés de plus de 70 ans ou infirmes (c’est-à-dire ne pouvant subvenir par leur travail aux nécessités # de l’existence), # – résider avec lui, # – et disposer d’un revenu fiscal de référence pour l’année précédente n’excédant pas la limite prévue à # l’article 1417-I du CGI (voir page 94). pac_asc = 0 # TODO taux_2_premiers = taux_minimal_2_premiers + majoration_2_premiers taux_3_et_plus = taux_minimal_3_et_plus + majoration_3_et_plus abattement_obligatoire = (min_(pac_enf + pac_asc, 2) * taux_2_premiers + max_(pac_enf + pac_asc - 2, 0) * taux_3_et_plus) * valeur_locative_moyenne # abattements facultatifs à la base : # abattement faculattif général abattement_general = abattement_general_base_forfaitaire + taux_abattement_general_base * valeur_locative_moyenne # abattement facultatif dit spécial en faveur des personnes dont le « revenu fiscal de référence » n’excède pas certaines limites # Il est institué à l’initiative des communes et EPCI à fiscalité propre ; il est indépendant de l’abattement géné- # ral à la base avec lequel il peut se cumuler. Il ne s’applique pas dans les départements d’outre-mer. # Son taux peut être fixé, selon la décision des communes et EPCI à fiscalité propre qui en décident # l’application, à une valeur entière comprise entre 1 et 15 % de la valeur locative moyenne des habitations # (pour rappel, jusqu’en 2011, les taux pouvaient être fixés à 5 %, 10 % ou 15 %) # # Pour bénéficier de cet abattement, les contribuables doivent remplir deux conditions : abattement_special_modeste = (valeur_locative_brute <= ((seuil_elig_special_modeste + seuil_elig_special_modeste_add * (pac_enf + pac_asc)) * valeur_locative_moyenne) # ) * (rfr_n_1 <= 100 # TODO ) * taux_special_modeste * valeur_locative_moyenne # abattement facultatif en faveur des personnes handicapées ou invalides. abattement_special_invalide = 0 * taux_special_invalide # Tous les habitants doivent êtres invalides base_nette = valeur_locative_brute - ( abattement_obligatoire + abattement_general + abattement_special_modeste + abattement_special_invalide) cotisation_brute = base_nette * taux_imposition # Frais de gestion # FRAIS DE GESTION DE LA # FISCALITÉ DIRECTE LOCALE (art. 1641 du CGI) # En contrepartie des frais de confection des # rôles et de dégrèvement qu’il prend à sa # charge, l’État perçoit une somme égale à : # - 3 % # (1) des cotisations perçues au profit # des communes et EPCI à fiscalité propre, # ramenée à 1 % pour les locaux meublés # affectés à l’habitation principale ; # - 8 % (2) des cotisations perçues au profit # des syndicats de communes ; # - 9 % (2) des cotisations perçues au profit # des établissements publics bénéficiaires de # taxes spéciales d’équipement (TSE). # (1) Dont frais de dégrèvement et de non-valeurs : 2 %. # (2) Dont frais de dégrèvement et de non-valeurs : 3,6 %. frais_gestion = 0 # Prélèvement pour base élevée et sur les résidences secondaires prelevement_residence_secondaire = 0 # TODO return period, - exonere_taxe_habitation * 0 PKoz= bareme.rates[1]) * ass_isf return period, bareme.calc(ass_isf) @reference_formula class isf_avant_reduction(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"isf_avant_reduction" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') isf_iai = simulation.calculate('isf_iai', period) decote_isf = simulation.calculate('decote_isf', period) return period, isf_iai - decote_isf @reference_formula class isf_reduc_pac(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"isf_reduc_pac" def function(self, simulation, period): ''' Réductions pour personnes à charges ''' period = period.start.offset('first-of', 'year').period('year') nb_pac = simulation.calculate('nb_pac', period) nbH = simulation.calculate('nbH', period) P = simulation.legislation_at(period.start).isf.reduc_pac return period, P.reduc_1 * nb_pac + P.reduc_2 * nbH @reference_formula class isf_inv_pme(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"isf_inv_pme" start_date = date(2008, 1, 1) def function(self, simulation, period): ''' Réductions pour investissements dans les PME à partir de 2008! ''' period = period.start.offset('first-of', 'year').period('year') b2mt = simulation.calculate('b2mt', period) b2ne = simulation.calculate('b2ne', period) b2mv = simulation.calculate('b2mv', period) b2nf = simulation.calculate('b2nf', period) b2mx = simulation.calculate('b2mx', period) b2na = simulation.calculate('b2na', period) P = simulation.legislation_at(period.start).isf.pme inv_dir_soc = b2mt * P.taux2 + b2ne * P.taux1 holdings = b2mv * P.taux2 + b2nf * P.taux1 fip = b2mx * P.taux1 fcpi = b2na * P.taux1 return period, holdings + fip + fcpi + inv_dir_soc @reference_formula class isf_org_int_gen(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"isf_org_int_gen" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') b2nc = simulation.calculate('b2nc', period) P = simulation.legislation_at(period.start).isf.pme return period, b2nc * P.taux2 @reference_formula class isf_avant_plaf(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"isf_avant_plaf" def function(self, simulation, period): ''' Montant de l'impôt avant plafonnement ''' period = period.start.offset('first-of', 'year').period('year') isf_avant_reduction = simulation.calculate('isf_avant_reduction', period) isf_inv_pme = simulation.calculate('isf_inv_pme', period) isf_org_int_gen = simulation.calculate('isf_org_int_gen', period) isf_reduc_pac = simulation.calculate('isf_reduc_pac', period) borne_max = simulation.legislation_at(period.start).isf.pme.max return period, max_(0, isf_avant_reduction - min_(isf_inv_pme + isf_org_int_gen, borne_max) - isf_reduc_pac) # # calcul du plafonnement ## @reference_formula class tot_impot(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"tot_impot" def function(self, simulation, period): ''' Total des impôts dus au titre des revenus et produits (irpp, cehr, pl, prélèvements sociaux) + ISF Utilisé pour calculer le montant du plafonnement de l'ISF ''' period = period.start.offset('first-of', 'year').period('year') irpp = simulation.calculate('irpp', period) isf_avant_plaf = simulation.calculate('isf_avant_plaf', period) crds_holder = simulation.compute('crds', period) csg_holder = simulation.compute('csg', period) prelsoc_cap_holder = simulation.compute('prelsoc_cap', period) crds = self.split_by_roles(crds_holder, roles = [VOUS, CONJ]) csg = self.split_by_roles(csg_holder, roles = [VOUS, CONJ]) prelsoc_cap = self.split_by_roles(prelsoc_cap_holder, roles = [VOUS, CONJ]) return period, (-irpp + isf_avant_plaf - (crds[VOUS] + crds[CONJ]) - (csg[VOUS] + csg[CONJ]) - (prelsoc_cap[VOUS] + prelsoc_cap[CONJ]) ) # TODO: irpp n'est pas suffisant : ajouter ir soumis à taux propor + impôt acquitté à l'étranger # + prélèvement libé de l'année passée + montant de la csg @reference_formula class revetproduits(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenus et produits perçus (avant abattement)" def function(self, simulation, period): ''' Utilisé pour calculer le montant du plafonnement de l'ISF Cf. http://www.impots.gouv.fr/portal/deploiement/p1/fichedescriptiveformulaire_8342/fichedescriptiveformulaire_8342.pdf ''' period = period.start.offset('first-of', 'year').period('year') salcho_imp_holder = simulation.compute('salcho_imp', period) pen_net_holder = simulation.compute('pen_net', period) rto_net = simulation.calculate('rto_net', period) rev_cap_bar = simulation.calculate('rev_cap_bar', period) fon = simulation.calculate('fon', period) ric_holder = simulation.compute('ric', period) rag_holder = simulation.compute('rag', period) rpns_exon_holder = simulation.compute('rpns_exon', period) rpns_pvct_holder = simulation.compute('rpns_pvct', period) rev_cap_lib = simulation.calculate('rev_cap_lib', period) imp_lib = simulation.calculate('imp_lib', period) P = simulation.legislation_at(period.start).isf.plafonnement pen_net = self.sum_by_entity(pen_net_holder) rag = self.sum_by_entity(rag_holder) ric = self.sum_by_entity(ric_holder) rpns_exon = self.sum_by_entity(rpns_exon_holder) rpns_pvct = self.sum_by_entity(rpns_pvct_holder) salcho_imp = self.sum_by_entity(salcho_imp_holder) # rev_cap et imp_lib pour produits soumis à prel libératoire- check TODO: # # def rev_exon et rev_etranger dans data? ## pt = max_( 0, salcho_imp + pen_net + rto_net + rev_cap_bar + rev_cap_lib + ric + rag + rpns_exon + rpns_pvct + imp_lib + fon ) return period, pt * P.taux @reference_formula class decote_isf(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Décote de l'ISF" start_date = date(2013, 1, 1) def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') ass_isf = simulation.calculate('ass_isf', period) P = simulation.legislation_at(period.start).isf.decote elig = (ass_isf >= P.min) & (ass_isf <= P.max) LB = P.base - P.taux * ass_isf return period, LB * elig @reference_formula class isf_apres_plaf(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Impôt sur la fortune après plafonnement" # Plafonnement supprimé pour l'année 2012 @dated_function(start = date(2002, 1, 1), stop = date(2011, 12, 31)) def function_20020101_20111231(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') tot_impot = simulation.calculate('tot_impot', period) revetproduits = simulation.calculate('revetproduits', period) isf_avant_plaf = simulation.calculate('isf_avant_plaf', period) P = simulation.legislation_at(period.start).isf.plaf # 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 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 period, max_(isf_avant_plaf - limitationplaf, 0) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') isf_avant_plaf = simulation.calculate('isf_avant_plaf', period) # 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 return period, isf_avant_plaf @dated_function(start = date(2013, 1, 1), stop = date(2015, 12, 31)) def function_20130101_20151231(self, simulation, period): """ Impôt sur la fortune après plafonnement """ period = period.start.offset('first-of', 'year').period('year') tot_impot = simulation.calculate('tot_impot', period) revetproduits = simulation.calculate('revetproduits', period) isf_avant_plaf = simulation.calculate('isf_avant_plaf', period) plafond = max_(0, tot_impot - revetproduits) # case PU sur la déclaration d'impôt return period, max_(isf_avant_plaf - plafond, 0) @reference_formula class isf_tot(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"isf_tot" url = "http://www.impots.gouv.fr/portal/dgi/public/particuliers.impot?pageId=part_isf&espId=1&impot=ISF&sfid=50" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') b4rs = simulation.calculate('b4rs', period) isf_avant_plaf = simulation.calculate('isf_avant_plaf', period) isf_apres_plaf = simulation.calculate('isf_apres_plaf', period) irpp = simulation.calculate('irpp', period) return period, min_(-((isf_apres_plaf - b4rs) * ((-irpp) > 0) + (isf_avant_plaf - b4rs) * ((-irpp) <= 0)), 0) # # BOUCLIER FISCAL ## # # calcul de l'ensemble des revenus du contribuable ## # TODO: à reintégrer dans irpp @reference_formula class rvcm_plus_abat(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"rvcm_plus_abat" def function(self, simulation, period): ''' Revenu catégoriel avec abattement de 40% réintégré. ''' period = period.start.offset('first-of', 'year').period('year') rev_cat_rvcm = simulation.calculate('rev_cat_rvcm', period) rfr_rvcm = simulation.calculate('rfr_rvcm', period) return period, rev_cat_rvcm + rfr_rvcm @reference_formula class maj_cga_i(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Majoration pour non adhésion à un centre de gestion agréé (pour chaque individu du foyer)" # TODO: à reintégrer dans irpp (et vérifier au passage que frag_impo est dans la majo_cga 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)) @reference_formula class maj_cga(PersonToEntityColumn): entity_class = FoyersFiscaux label = u"Majoration pour non adhésion à un centre de gestion agréé" operation = 'add' variable = maj_cga_i @reference_formula class bouclier_rev(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"bouclier_rev" start_date = date(2006, 1, 1) stop_date = date(2010, 12, 31) def function(self, simulation, period): ''' Total des revenus sur l'année 'n' net de charges ''' period = period.start.offset('first-of', 'year').period('year') rbg = simulation.calculate('rbg', period) maj_cga = simulation.calculate('maj_cga', period) csg_deduc = simulation.calculate('csg_deduc', period) rvcm_plus_abat = simulation.calculate('rvcm_plus_abat', period) rev_cap_lib = simulation.calculate('rev_cap_lib', period) rev_exo = simulation.calculate('rev_exo', period) rev_or = simulation.calculate('rev_or', period) cd_penali = simulation.calculate('cd_penali', period) cd_eparet = simulation.calculate('cd_eparet', period) # TODO: réintégrer les déficits antérieur # TODO: intégrer les revenus soumis au prélèvement libératoire null = 0 * rbg deficit_ante = null # # Revenus frac_rvcm_rfr = 0.7 * rvcm_plus_abat # TODO: UNUSED ? # # revenus distribués? # # A majorer de l'abatt de 40% - montant brut en cas de PFL # # pour le calcul de droit à restitution : prendre 0.7*montant_brut_rev_dist_soumis_au_barème rev_bar = rbg - maj_cga - csg_deduc - deficit_ante # # TODO: AJOUTER : indemnités de fonction percus par les élus- revenus soumis à régimes spéciaux # Revenu soumis à l'impôt sur le revenu forfaitaire rev_lib = rev_cap_lib # # AJOUTER plus-values immo et moins values? # #Revenus exonérés d'IR réalisés en France et à l'étranger## # rev_exo = primes_pel + primes_cel + rente_pea + int_livrets + plus_values_per rev_exo = null # # proposer à l'utilisateur des taux de réference- PER, PEA, PEL,...TODO # # sommes investis- calculer les plus_values annuelles et prendre en compte pour rev_exo? # revenus soumis à la taxe forfaitaire sur les métaux précieux : rev_or revenus = rev_bar + rev_lib + rev_exo + rev_or # # CHARGES # Pension alimentaires # Cotisations ou primes versées au titre de l'épargne retraite charges = cd_penali + cd_eparet return period, revenus - charges @reference_formula class bouclier_imp_gen(SimpleFormulaColumn): # # ajouter CSG- CRDS column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"bouclier_imp_gen" start_date = date(2006, 1, 1) stop_date = date(2010, 12, 31) def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') irpp = simulation.calculate('irpp', period) taxe_habitation_holder = simulation.compute('taxe_habitation', period) tax_fonc = simulation.calculate('tax_fonc', period) isf_tot = simulation.calculate('isf_tot', period) cotsoc_lib_declarant1_holder = simulation.compute('cotsoc_lib_declarant1', period) cotsoc_bar_declarant1_holder = simulation.compute('cotsoc_bar_declarant1', period) csg_deductible_salaire_holder = simulation.compute('csg_deductible_salaire', period) csg_imposable_salaire_holder = simulation.compute('csg_imposable_salaire', period) crds_salaire_holder = simulation.compute('crds_salaire', period) csg_imposable_chomage_holder = simulation.compute('csg_imposable_chomage', period) csg_deductible_chomage_holder = simulation.compute('csg_deductible_chomage', period) csg_deductible_retraite_holder = simulation.compute('csg_deductible_retraite', period) csg_imposable_retraite_holder = simulation.compute('csg_imposable_retraite', period) imp_lib = simulation.calculate('imp_lib', period) cotsoc_bar = self.sum_by_entity(cotsoc_bar_declarant1_holder) cotsoc_lib = self.sum_by_entity(cotsoc_lib_declarant1_holder) crds_salaire = self.sum_by_entity(crds_salaire_holder) csg_deductible_chomage = self.sum_by_entity(csg_deductible_chomage_holder) csg_imposable_chomage = self.sum_by_entity(csg_imposable_chomage_holder) csg_deductible_salaire = self.sum_by_entity(csg_deductible_salaire_holder) csg_imposable_salaire = self.sum_by_entity(csg_imposable_salaire_holder) csg_deductible_retraite = self.sum_by_entity(csg_deductible_retraite_holder) csg_imposable_retraite = self.sum_by_entity(csg_imposable_retraite_holder) taxe_habitation = self.cast_from_entity_to_role(taxe_habitation_holder, role = PREF) taxe_habitation = self.sum_by_entity(taxe_habitation) # # ajouter Prelèvements sources/ libé # # ajouter crds rstd # # impôt sur les plus-values immo et cession de fonds de commerce imp1 = cotsoc_lib + cotsoc_bar + csg_deductible_salaire + csg_deductible_chomage + crds_salaire + csg_deductible_retraite + imp_lib ''' Impôts payés en l'année 'n' au titre des revenus réalisés sur l'année 'n' ''' imp2 = irpp + isf_tot + taxe_habitation + tax_fonc + csg_imposable_salaire + csg_imposable_chomage + csg_imposable_retraite ''' Impôts payés en l'année 'n' au titre des revenus réalisés en 'n-1' ''' return period, imp1 + imp2 @reference_formula class restitutions(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"restitutions" start_date = date(2006, 1, 1) stop_date = date(2010, 12, 31) def function(self, simulation, period): ''' Restitutions d'impôt sur le revenu et degrèvements percus en l'année 'n' ''' period = period.start.offset('first-of', 'year').period('year') ppe = simulation.calculate('ppe', period) restit_imp = simulation.calculate('restit_imp', period) return period, ppe + restit_imp @reference_formula class bouclier_sumimp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"bouclier_sumimp" start_date = date(2006, 1, 1) stop_date = date(2010, 12, 31) def function(self, simulation, period): ''' Somme totale des impôts moins restitutions et degrèvements ''' period = period.start.offset('first-of', 'year').period('year') bouclier_imp_gen = simulation.calculate('bouclier_imp_gen', period) restitutions = simulation.calculate('restitutions', period) return period, -bouclier_imp_gen + restitutions @reference_formula class bouclier_fiscal(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"bouclier_fiscal" start_date = date(2006, 1, 1) stop_date = date(2010, 12, 31) url = "http://fr.wikipedia.org/wiki/Bouclier_fiscal" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') bouclier_sumimp = simulation.calculate('bouclier_sumimp', period) bouclier_rev = simulation.calculate('bouclier_rev', period) P = simulation.legislation_at(period.start).bouclier_fiscal return period, max_(0, bouclier_sumimp - (bouclier_rev * P.taux)) PKoz 2012: taux_contribution = redevable_taxe_apprentissage * ( (effectif_entreprise < 2000) * (ratio_alternants < .01) * taux.moins_2000_moins_1pc_alternants + (effectif_entreprise >= 2000) * (ratio_alternants < .01) * taux.plus_2000_moins_1pc_alternants + (.01 <= ratio_alternants) * (ratio_alternants < .02) * taux.entre_1_2_pc_alternants + (.02 <= ratio_alternants) * (ratio_alternants < .03) * taux.entre_2_3_pc_alternants + (.03 <= ratio_alternants) * (ratio_alternants < .04) * taux.entre_3_4_pc_alternants + (.04 <= ratio_alternants) * (ratio_alternants < .05) * taux.entre_4_5_pc_alternants ) else: taux_contribution = (effectif_entreprise >= 250) * taux.plus_de_250 * redevable_taxe_apprentissage # TODO: gestion de la place dans le XML pb avec l'arbre des paramètres / preprocessing return period, - taux_contribution * assiette_cotisations_sociales @reference_formula class cotisations_employeur_main_d_oeuvre(SimpleFormulaColumn): base_function = requested_period_added_value column = FloatCol entity_class = Individus label = u"Cotisation sociales employeur main d'oeuvre" def function(self, simulation, period): period = period conge_individuel_formation_cdd = simulation.calculate('conge_individuel_formation_cdd', period) contribution_developpement_apprentissage = simulation.calculate( 'contribution_developpement_apprentissage', period) contribution_supplementaire_apprentissage = simulation.calculate( 'contribution_supplementaire_apprentissage', period) financement_organisations_syndicales = simulation.calculate('financement_organisations_syndicales', period) fnal = simulation.calculate('fnal', period) formation_professionnelle = simulation.calculate('formation_professionnelle', period) participation_effort_construction = simulation.calculate_add('participation_effort_construction', period) prevoyance_obligatoire_cadre = simulation.calculate_add('prevoyance_obligatoire_cadre', period) taxe_apprentissage = simulation.calculate_add('taxe_apprentissage', period) versement_transport = simulation.calculate_add('versement_transport', period) cotisations_employeur_main_d_oeuvre = ( conge_individuel_formation_cdd + contribution_developpement_apprentissage + contribution_supplementaire_apprentissage + financement_organisations_syndicales + fnal + formation_professionnelle + participation_effort_construction + prevoyance_obligatoire_cadre + taxe_apprentissage + versement_transport ) return period, cotisations_employeur_main_d_oeuvre @reference_formula class fnal(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation fonds national action logement (FNAL)" def function(self, simulation, period): fnal_tranche_a = simulation.calculate('fnal_tranche_a', period) fnal_tranche_a_plus_20 = simulation.calculate('fnal_tranche_a_plus_20', period) return period, fnal_tranche_a + fnal_tranche_a_plus_20 @reference_formula class fnal_tranche_a(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation fonds national action logement (FNAL tout employeur)" def function(self, simulation, period): taille_entreprise = simulation.calculate('taille_entreprise', period) cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'fnal1', variable_name = self.__class__.__name__, ) return period, cotisation * (taille_entreprise <= 2) @reference_formula class fnal_tranche_a_plus_20(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Fonds national action logement (FNAL, employeur avec plus de 20 salariés)" def function(self, simulation, period): taille_entreprise = simulation.calculate('taille_entreprise', period) cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'fnal2', variable_name = self.__class__.__name__, ) return period, cotisation * (taille_entreprise > 2) @reference_formula class financement_organisations_syndicales(DatedFormulaColumn): column = FloatCol entity_class = Individus label = u"Contribution patronale au financement des organisations syndicales" @dated_function(date(2015, 1, 1)) def function(self, simulation, period): type_sal = simulation.calculate('type_sal', period) cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'financement_organisations_syndicales', variable_name = self.__class__.__name__, ) return period, cotisation * or_(type_sal <= 1, type_sal == 6) @reference_formula class formation_professionnelle(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Formation professionnelle" def function(self, simulation, period): taille_entreprise = simulation.calculate('taille_entreprise', period) cotisation_0_9 = (taille_entreprise == 1) * apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'formprof_09', variable_name = self.__class__.__name__, ) cotisation_10_19 = (taille_entreprise == 2) * apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'formprof_1019', variable_name = self.__class__.__name__, ) cotisation_20 = (taille_entreprise > 2) * apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'formprof_20', variable_name = self.__class__.__name__, ) return period, cotisation_0_9 + cotisation_10_19 + cotisation_20 @reference_formula class participation_effort_construction(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Participation à l'effort de construction" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'construction', variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class taxe_apprentissage(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Taxe d'apprentissage (employeur, entreprise redevable de la taxe d'apprentissage uniquement)" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') redevable_taxe_apprentissage = simulation.calculate('redevable_taxe_apprentissage', period) cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'apprentissage', variable_name = self.__class__.__name__, ) return period, redevable_taxe_apprentissage * cotisation @reference_formula class taxe_salaires(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Taxe sur les salaires" # Voir # http://www.impots.gouv.fr/portal/deploiement/p1/fichedescriptiveformulaire_8920/fichedescriptiveformulaire_8920.pdf def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') assujettie_taxe_salaires = simulation.calculate('assujettie_taxe_salaires', period) assiette_cotisations_sociales = simulation.calculate('assiette_cotisations_sociales', period) prevoyance_obligatoire_cadre = simulation.calculate('prevoyance_obligatoire_cadre', period) law = simulation.legislation_at(period.start) bareme = law.cotsoc.taxes_sal.taux_maj base = assiette_cotisations_sociales - prevoyance_obligatoire_cadre # TODO: exonérations apprentis # TODO: modify if DOM return period, - ( bareme.calc( base, factor = 1 / 12, round_base_decimals = 2 ) + round_(law.cotsoc.taxes_sal.taux.metro * base, 2) ) * assujettie_taxe_salaires @reference_formula class taux_versement_transport(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') depcom_entreprise = simulation.calculate('depcom_entreprise', period) effectif_entreprise = simulation.calculate('effectif_entreprise', period) type_sal = simulation.calculate('type_sal', period) preload_taux_versement_transport() public = (type_sal >= 2) default_value = 0.0 taux_aot = fromiter( ( taux_aot_by_depcom.get(depcom_cell, default_value) for depcom_cell in depcom_entreprise ), dtype = 'float', ) taux_smt = fromiter( ( taux_smt_by_depcom.get(depcom_cell, default_value) for depcom_cell in depcom_entreprise ), dtype = 'float', ) # "L'entreprise emploie-t-elle plus de 9 salariés dans le périmètre de l'Autorité organisatrice de transport # (AOT) suivante ou syndicat mixte de transport (SMT)" return period, (taux_aot + taux_smt) * or_(effectif_entreprise > 9, public) / 100 @reference_formula class versement_transport(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Versement transport" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') assiette_cotisations_sociales = simulation.calculate('assiette_cotisations_sociales', period) taux_versement_transport = simulation.calculate('taux_versement_transport', period) cotisation = - taux_versement_transport * assiette_cotisations_sociales return period, cotisation def preload_taux_versement_transport(): global taux_aot_by_depcom global taux_smt_by_depcom if taux_aot_by_depcom is None: with pkg_resources.resource_stream( openfisca_france.__name__, 'assets/versement_transport/taux.csv', ) as csv_file: csv_reader = csv.DictReader(csv_file) taux_aot_by_depcom = { row['code INSEE']: float(row['taux'] or 0) # autorité organisatrice des transports for row in csv_reader } if taux_smt_by_depcom is None: with pkg_resources.resource_stream( openfisca_france.__name__, 'assets/versement_transport/taux.csv', ) as csv_file: csv_reader = csv.DictReader(csv_file) taux_smt_by_depcom = { row['code INSEE']: float(row['taux additionnel'] or 0) # syndicat mixte de transport for row in csv_reader } PKFQopenfisca_france/model/prelevements_obligatoires/prelevements_sociaux/__init__.pyPKoz= 50) * taux @reference_formula class penalite_emploi_jeunes(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Pénalité visant à favoriser l'emploi des jeunes" start_date = "2010-01-01" end_date = "2013-09-30" def function(self, simulation, period): emploi_jeunes_accord = simulation.calculate('emploi_jeunes_accord', period) effectif_entreprise = simulation.calculate('effectif_entreprise', period) taux = 0 # TODO: comment coder taux ? nouvelle variable ? return period, not_(emploi_jeunes_accord) * (effectif_entreprise >= 300) * taux @reference_formula class penalite_emploi_seniors(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Pénalité visant à favoriser l'emploi des séniors" start_date = "2010-01-01" end_date = "2013-09-30" def function(self, simulation, period): emploi_senior_accord = simulation.calculate('emploi_senior_accord', period) effectif_entreprise = simulation.calculate('effectif_entreprise', period) taux = 0 # TODO: comment coder taux ? nouvelle variable ? 1% ? return period, not_(emploi_senior_accord) * (effectif_entreprise >= 50) * taux @reference_formula class penalite_penibilite(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Pénalité visant à favoriser la prévention de la pénibilité" # TODO start_date def function(self, simulation, period): penibilite_prevention_accord = simulation.calculate('penibilite_prevention_accord', period) effectif_entreprise = simulation.calculate('effectif_entreprise', period) taux = 0 # TODO: quel taux ? return period, not_(penibilite_prevention_accord) * (effectif_entreprise >= 50) * taux @reference_formula class penalite_handicapes(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Pénalité pour emploi insuffisant de personnes handicapées" # TODO start_date def function(self, simulation, period): # les entreprises sont soumises à une obligation d’emploi en faveur des travailleurs handicapés. # Toute entreprise (privée ou public) doit compter au moins 6% de # travailleurs ayant une reconnaissance administrative de handicap parmi ses # effectifs salariés. A défaut, l’employeur peut verser une contribution annuelle # proportionnelle au nombre de salariés handicapés qu’il aurait dû recruter pour # remplir son obligation d’emploi. effectif_entreprise = simulation.calculate('effectif_entreprise', period) return period, 0 * effectif_entreprise # TODO penibilite CDD évoquée page 11 du guide IPP est-elle la cotisation pour le CIF des CDD ? PKoz= 11) + exoneration_moins_11 * (effectif_entreprise < 11) ) * apprenti @reference_formula class exoneration_cotisations_salariales_apprenti(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Exonération de cotisations salariales pour l'emploi d'un apprenti" url = "http://www.apce.com/pid927/contrat-d-apprentissage.html?espace=1&tp=1&pagination=2" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') apprenti = simulation.calculate('apprenti', period) cotisations_salariales_contributives = simulation.calculate('cotisations_salariales_contributives', period) cotisations_salariales_non_contributives = simulation.calculate( 'cotisations_salariales_non_contributives', period) return period, - (cotisations_salariales_contributives + cotisations_salariales_non_contributives) * apprenti @reference_formula class prime_apprentissage(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Prime d'apprentissage pour les entreprise employant un apprenti" url = "http://www.apce.com/pid927/contrat-d-apprentissage.html?espace=1&tp=1&pagination=2" # L'employeur peut également recevoir de la région dans laquelle est situé l'établissement du lieu de travail, # une prime d'apprentissage. # # Les conditions d'attribution de cette aide sont fixées par chaque région (ou pour la Corse, par la collectivité # territoriale de Corse) après avis du comité de coordination régional de l'emploi et de la formation # professionnelle en tenant compte notamment de l'ensemble de l'effort de l'employeur dans le domaine de # l'apprentissage, de la durée de la formation et des objectifs de développement de la formation professionnelle # des jeunes sur le territoire de la région (ou de la collectivité territoriale de Corse). # # Son montant est au minimum de 1 000 euros par année de cycle de formation. # nouveau. Depuis le 1er janvier 2014 , cette aide n'est versée qu'aux entreprises de moins de 11 salariés. # # Son versement est subordonné à la condition que l'embauche de l'apprenti soit confirmée à l'issue des deux # premiers mois de l'apprentissage. # # Son versement cesse lorsque l'apprenti n'est plus salarié dans l'entreprise ou l'établissement qui l'a embauché. def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') apprenti = simulation.calculate('apprenti', period) return period, 1000 * apprenti # @reference_formula # class credit_impot_emploi_apprenti(SimpleFormulaColumn): # column = FloatCol # entity_class = Individus # label = u" Crédit d'impôt pour l'emploi d'apprentis" # url = "http://www.apce.com/pid927/contrat-d-apprentissage.html?espace=1&tp=1&pagination=2" # # def function(self, simulation, period): # pass # # Cet avantage fiscal est réservé aux entreprises imposées selon un régime d'imposition du réel. # # Précision : les entreprises exonérées d'impôt sur les bénéfices au titre des entreprises nouvelles, d'une # # implantation en zone franche urbaine, du statut de jeune entreprise innovante ou d'une implantation en Corse # # peuvent également en bénéficier. # # # # Le crédit d'impôt est égal au nombre moyen d'apprentis dont le contrat de travail a atteint une durée d'au moins # # 1 mois au cours de l'année civile multiplié par : # # - 1 600 €, # # - ou 2 200 € si l'apprenti est reconnu travailleur handicapé et qu'il bénéficie d'un accompagnement personnalisé, # # ou si l'apprenti est employé par une entreprise portant le label "Entreprise du patrimoine vivant", ou s'il est # # recruté dans le cadre d'une "formation apprentissage junior". # # # # L'avantage fiscal est plafonné au montant des dépenses de personnel afférentes aux apprentis minoré des # # subventions perçues en contrepartie de leur embauche. # @reference_formula # class credit_impot_emploi_apprenti(SimpleFormulaColumn): # column = FloatCol # entity_class = Individus # label = u"Déduction de la créance "bonus alternant" # Les entreprises de plus de 250 salariés, tous établissements confondus, redevables de la taxe d'apprentissage, qui emploient plus de 4 % de jeunes en apprentissage (5 % pour la taxe payable en 2016 au titre de 2015), dans la limite de 6 % d'alternants, peuvent bénéficier d'une créance à déduire du hors quota de la taxe d'apprentissage (TA). # Les entreprises concernées doivent calculer elles-mêmes le montant de la créance à déduire de leur TA. # Son montant est calculé selon la formule suivante : pourcentage d'alternants ouvrant droit à l'aide x effectif annuel moyen de l'entreprise au 31 décembre de l'année précédente x un montant forfaitaire de 400 € par alternant. # Par exemple, une entreprise de 300 salariés employant 6 % de salariés en alternance, ce qui porte le nombre d'alternants ouvrant droit à l'aide à 2 % (6 % - 4 %), peut bénéficier d'une prime de : 2 % x 300 x 400 = 2 400 €. PKFfopenfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/__init__.pyPKoz 0) @reference_formula class exoneration_cotisations_employeur_stagiaire(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Exonrérations de cotisations employeur pour un stagaire" url = "http://www.apce.com/pid2798/stages.html?espace=3" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') agirc_employeur = simulation.calculate('agirc_employeur', period) agirc_gmp_employeur = simulation.calculate('agirc_gmp_employeur', period) arrco_employeur = simulation.calculate('arrco_employeur', period) plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) stage_gratification_reintegration = simulation.calculate('stage_gratification_reintegration', period) stagiaire = simulation.calculate('stagiaire', period) type_sal = simulation.calculate('type_sal', period) bareme_by_type_sal_name = simulation.legislation_at(period.start).cotsoc.cotisations_employeur bareme_names = ['agffnc', 'agffc', 'chomfg', 'assedic'] exoneration = plafond_securite_sociale * 0.0 for bareme_name in bareme_names: exoneration += apply_bareme_for_relevant_type_sal( bareme_by_type_sal_name = bareme_by_type_sal_name, bareme_name = bareme_name, type_sal = type_sal, base = stage_gratification_reintegration, plafond_securite_sociale = plafond_securite_sociale, round_base_decimals = 2, ) exoneration = exoneration + agirc_employeur + agirc_gmp_employeur + arrco_employeur return period, - exoneration * stagiaire @reference_formula class exoneration_cotisations_salarie_stagiaire(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Exonrérations de cotisations salarié pour un stagiaire" url = "http://www.apce.com/pid2798/stages.html?espace=3" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') agirc_salarie = simulation.calculate('agirc_salarie', period) agirc_gmp_salarie = simulation.calculate('agirc_gmp_salarie', period) arrco_salarie = simulation.calculate('arrco_salarie', period) plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) stage_gratification_reintegration = simulation.calculate('stage_gratification_reintegration', period) stagiaire = simulation.calculate('stagiaire', period) type_sal = simulation.calculate('type_sal', period) bareme_by_type_sal_name = simulation.legislation_at(period.start).cotsoc.cotisations_salarie bareme_names = ['agff', 'assedic'] exoneration = plafond_securite_sociale * 0.0 for bareme_name in bareme_names: exoneration += apply_bareme_for_relevant_type_sal( bareme_by_type_sal_name = bareme_by_type_sal_name, bareme_name = bareme_name, type_sal = type_sal, base = stage_gratification_reintegration, plafond_securite_sociale = plafond_securite_sociale, round_base_decimals = 2, ) exoneration = exoneration + agirc_salarie + agirc_gmp_salarie + arrco_salarie return period, - exoneration * stagiaire PKoz debut_mois, contrat_de_travail_fin < fin_mois) jours_travailles = busday_count( max_(contrat_de_travail_debut, debut_mois), min_(contrat_de_travail_fin, fin_mois) ) duree_legale = 35 * 52 / 12 # mensuelle_temps_plein heures_temps_plein = ( (heures_duree_collective_entreprise == 0) * duree_legale + heures_duree_collective_entreprise ) # heures remunerees avant conges sans soldes/ijss heures_remunerees_volume = ( (contrat_de_travail == 0) * ( heures_temps_plein * not_(mois_incomplet) + # 151.67 jours_travailles * 7 * mois_incomplet # TODO: 7 = heures / jours ) + (contrat_de_travail == 1) * heures_remunerees_volume ) heures_realisees = heures_remunerees_volume - heures_non_remunerees_volume coefficient = ( # Salariés à temps plein (contrat_de_travail == 0) * heures_realisees / heures_temps_plein + # Salariés à temps partiel : plafond proratisé en fonction du ratio durée travaillée / durée du temps plein # Salariés sans convention de forfait à temps partiel (contrat_de_travail == 1) * heures_realisees / heures_temps_plein + # Salariés avec convention de forfait # Forfait en heures (contrat_de_travail >= 2) * (contrat_de_travail <= 3) * ( forfait_heures_remunerees_volume / 45.7 * 52 / 12 ) + # Forfait en jours (contrat_de_travail == 4) * forfait_jours_remuneres_volume / 218 ) return period, coefficient @reference_formula class credit_impot_competitivite_emploi(DatedFormulaColumn): column = FloatCol entity_class = Individus label = u"Crédit d'imôt pour la compétitivité et l'emploi" @dated_function(date(2013, 1, 1)) def function_2013_(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') assiette_allegement = simulation.calculate('assiette_allegement', period) jeune_entreprise_innovante = simulation.calculate('jeune_entreprise_innovante', period) smic_proratise = simulation.calculate('smic_proratise', period) stagiaire = simulation.calculate('stagiaire', period) cotsoc = simulation.legislation_at(period.start).cotsoc taux_cice = taux_exo_cice(assiette_allegement, smic_proratise, cotsoc) credit_impot_competitivite_emploi = ( taux_cice * assiette_allegement ) non_cumul = (jeune_entreprise_innovante == 0 + stagiaire) > 0 return period, credit_impot_competitivite_emploi * non_cumul @reference_formula class smic_proratise(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"SMIC proratisé" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') coefficient_proratisation = simulation.calculate('coefficient_proratisation', period) smic_horaire_brut = simulation.legislation_at(period.start).cotsoc.gen.smic_h_b smic_proratise = coefficient_proratisation * smic_horaire_brut * 35 * 52 / 12 return period, smic_proratise # Helper functions def compute_allegement_fillon_annuel(simulation, period): if period.start.month < 12: return 0 if period.start.month == 12: return compute_allegement_fillon(simulation, period.start.offset('first-of', 'year').period('year')) def compute_allegement_fillon_anticipe(simulation, period): if period.start.month < 12: return compute_allegement_fillon(simulation, period.start.offset('first-of', 'month').period('month')) if period.start.month == 12: cumul = simulation.calculate_add( 'allegement_fillon', period.start.offset('first-of', 'year').period('month', 11)) return compute_allegement_fillon( simulation, period.start.offset('first-of', 'year').period('year') ) - cumul def compute_allegement_fillon_progressif(simulation, period): if period.start.month == 1: return compute_allegement_fillon(simulation, period.start.offset('first-of', 'month').period('month')) if period.start.month > 1: up_to_this_month = period.start.offset('first-of', 'year').period('month', period.start.month) up_to_previous_month = period.start.offset('first-of', 'year').period('month', period.start.month - 1) cumul = simulation.calculate_add('allegement_fillon', up_to_previous_month) up_to_this_month = period.start.offset('first-of', 'year').period('month', period.start.month) return compute_allegement_fillon(simulation, up_to_this_month) - cumul def compute_allegement_fillon(simulation, period): ''' Exonération Fillon http://www.securite-sociale.fr/comprendre/dossiers/exocotisations/exoenvigueur/fillon.htm ''' assiette_allegement = simulation.calculate_add('assiette_allegement', period) smic_proratise = simulation.calculate_add('smic_proratise', period) taille_entreprise = simulation.calculate('taille_entreprise', period) majoration = (taille_entreprise <= 2) # majoration éventuelle pour les petites entreprises # Calcul du taux # Le montant maximum de l’allègement dépend de l’effectif de l’entreprise. # Le montant est calculé chaque année civile, pour chaque salarié ; # il est égal au produit de la totalité de la rémunération annuelle telle # que visée à l’article L. 242-1 du code de la Sécurité sociale par un # coefficient. # Ce montant est majoré de 10 % pour les entreprises de travail temporaire # au titre des salariés temporaires pour lesquels elle est tenue à # l’obligation d’indemnisation compensatrice de congés payés. Pf = simulation.legislation_at(period.start).cotsoc.exo_bas_sal.fillon seuil = Pf.seuil tx_max = (Pf.tx_max * not_(majoration) + Pf.tx_max2 * majoration) if seuil <= 1: return 0 ratio_smic_salaire = smic_proratise / (assiette_allegement + 1e-16) # règle d'arrondi: 4 décimales au dix-millième le plus proche taux_fillon = round_(tx_max * min_(1, max_(seuil * ratio_smic_salaire - 1, 0) / (seuil - 1)), 4) # Montant de l'allegment allegement_fillon = taux_fillon * assiette_allegement return allegement_fillon def taux_exo_cice(assiette_allegement, smic_proratise, P): Pc = P.exo_bas_sal.cice taux_cice = ((assiette_allegement / (smic_proratise + 1e-16)) <= Pc.max) * Pc.taux return taux_cice PKoz 0) @reference_formula class reintegration_titre_restaurant_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Prise en charge de l'employeur des dépenses de cantine et des titres restaurants non exonérés de charges sociales" # noqa def function(self, simulation, period): period = period # TODO valeur_unitaire = simulation.calculate("titre_restaurant_valeur_unitaire", period) volume = simulation.calculate("titre_restaurant_volume", period) taux_employeur = simulation.calculate('titre_restaurant_taux_employeur', period) cantines_titres_restaurants = simulation.legislation_at( period.start).cotsoc.assiette.cantines_titres_restaurants taux_minimum_exoneration = cantines_titres_restaurants.taux_minimum_exoneration taux_maximum_exoneration = cantines_titres_restaurants.taux_maximum_exoneration seuil_prix_titre = cantines_titres_restaurants.seuil_prix_titre condition_exoneration_taux = ( (taux_minimum_exoneration <= taux_employeur) * (taux_maximum_exoneration >= taux_employeur) ) montant_reintegration = volume * ( condition_exoneration_taux * max_(valeur_unitaire * taux_employeur - seuil_prix_titre, 0) + not_(condition_exoneration_taux) * valeur_unitaire * taux_employeur ) return period, montant_reintegration # Cotisations proprement dites @reference_formula class accident_du_travail(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisations employeur accident du travail et maladie professionelle" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') assiette_cotisations_sociales = simulation.calculate( 'assiette_cotisations_sociales', period) taux_accident_travail = simulation.calculate('taux_accident_travail', period) type_sal = simulation.calculate('type_sal', period) assujetti = type_sal <= 1 # TODO: ajouter contractuel du public salarié de moins d'un an ou à temps partiel return period, - assiette_cotisations_sociales * taux_accident_travail * assujetti @reference_formula class agff_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation retraite AGFF tranche A (salarié)" # AGFF: Association pour la gestion du fonds de financement (sous-entendu des départs entre 60 et 65 ans) def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "salarie", bareme_name = "agff", variable_name = self.__class__.__name__ ) return period, cotisation @reference_formula class agff_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation retraite AGFF tranche A (employeur)" # TODO: améliorer pour gérer mensuel/annuel def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') assiette_cotisations_sociales = simulation.calculate( 'assiette_cotisations_sociales', period) type_sal = simulation.calculate('type_sal', period) plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) law = simulation.legislation_at(period.start) cotisation_non_cadre = apply_bareme_for_relevant_type_sal( bareme_by_type_sal_name = law.cotsoc.cotisations_employeur, bareme_name = "agffnc", base = assiette_cotisations_sociales, plafond_securite_sociale = plafond_securite_sociale, type_sal = type_sal, ) cotisation_cadre = apply_bareme_for_relevant_type_sal( bareme_by_type_sal_name = law.cotsoc.cotisations_employeur, bareme_name = "agffc", base = assiette_cotisations_sociales, plafond_securite_sociale = plafond_securite_sociale, type_sal = type_sal, ) return period, cotisation_cadre + cotisation_non_cadre @reference_formula class agirc_gmp_assiette(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Assiette de la cotisation AGIRC pour la garantie minimale de points (GMP, salarié)" # TODO: gestion annuel/mensuel def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') assiette_cotisations_sociales = simulation.calculate('assiette_cotisations_sociales', period) salaire_charniere = simulation.legislation_at(period.start).cotsoc.agirc_gmp.salaire_charniere # annuel assiette = max_( (salaire_charniere / 12 - assiette_cotisations_sociales) * (assiette_cotisations_sociales > 0), 0, ) return period, assiette @reference_formula class agirc_gmp_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation AGIRC pour la garantie minimale de points (GMP, salarié)" # TODO: gestion annuel/mensuel def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') agirc_gmp_assiette = simulation.calculate('agirc_gmp_assiette', period) agirc_salarie = simulation.calculate('agirc_salarie', period) assiette_cotisations_sociales = simulation.calculate('assiette_cotisations_sociales', period) type_sal = simulation.calculate('type_sal', period) law = simulation.legislation_at(period.start).cotsoc.agirc_gmp cotisation_forfaitaire = law.cotisation_salarie taux = simulation.legislation_at(period.start).cotsoc.cotisations_salarie['prive_cadre']['agirc'].rates[1] sous_plafond_securite_sociale = ( (assiette_cotisations_sociales <= plafond_securite_sociale) & (assiette_cotisations_sociales > 0) ) cotisation = - ( sous_plafond_securite_sociale * cotisation_forfaitaire + not_(sous_plafond_securite_sociale) * agirc_gmp_assiette * taux ) return period, min_((cotisation - agirc_salarie) * (type_sal == 1), 0) # cotisation are negative @reference_formula class agirc_gmp_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation AGIRC pour la garantie minimale de points (GMP, employeur)" # TODO: gestion annuel/mensuel def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') agirc_employeur = simulation.calculate('agirc_employeur', period) agirc_gmp_assiette = simulation.calculate('agirc_gmp_assiette', period) assiette_cotisations_sociales = simulation.calculate('assiette_cotisations_sociales', period) type_sal = simulation.calculate('type_sal', period) law = simulation.legislation_at(period.start).cotsoc.agirc_gmp cotisation_forfaitaire = law.cotisation_employeur taux = simulation.legislation_at(period.start).cotsoc.cotisations_employeur['prive_cadre']['agirc'].rates[1] sous_plafond_securite_sociale = ( (assiette_cotisations_sociales <= plafond_securite_sociale) & (assiette_cotisations_sociales > 0) ) cotisation = - ( sous_plafond_securite_sociale * cotisation_forfaitaire + not_(sous_plafond_securite_sociale) * agirc_gmp_assiette * taux ) return period, min_((cotisation - agirc_employeur) * (type_sal == 1), 0) # cotisation are negative @reference_formula class agirc_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation AGIRC tranche B (salarié)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "salarie", bareme_name = "agirc", variable_name = self.__class__.__name__ ) type_sal = simulation.calculate('type_sal', period) return period, cotisation * (type_sal == 1) @reference_formula class agirc_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation AGIRC tranche B (employeur)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "employeur", bareme_name = "agirc", variable_name = self.__class__.__name__ ) type_sal = simulation.calculate('type_sal', period) return period, cotisation * (type_sal == 1) @reference_formula class ags(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Contribution à l'association pour la gestion du régime de garantie des créances des salariés (AGS, employeur)" # noqa analysis:ignore def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "employeur", bareme_name = "chomfg", variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class apec_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisations agence pour l'emploi des cadres (APEC, salarié)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "salarie", bareme_name = "apec", variable_name = self.__class__.__name__, ) return period, cotisation # TODO: check public notamment contractuel @reference_formula class apec_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisations Agenece pour l'emploi des cadres (APEC, employeur)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "employeur", bareme_name = "apec", variable_name = self.__class__.__name__, ) return period, cotisation # TODO: check public notamment contractuel @reference_formula class arrco_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation ARRCO tranche 1 (salarié)" # TODO: check gestion mensuel/annuel def function(self, simulation, period): cotisation_minimale = apply_bareme( simulation, period, cotisation_type = "salarie", bareme_name = "arrco", variable_name = self.__class__.__name__, ) arrco_tranche_a_taux_salarie = simulation.calculate('arrco_tranche_a_taux_salarie', period) assiette_cotisations_sociales = simulation.calculate_add('assiette_cotisations_sociales', period) plafond_securite_sociale = simulation.calculate_add('plafond_securite_sociale', period) type_sal = simulation.calculate('type_sal', period) cotisation_entreprise = - ( min_(max_(assiette_cotisations_sociales, 0), plafond_securite_sociale) * arrco_tranche_a_taux_salarie ) return period, ( cotisation_minimale * (arrco_tranche_a_taux_salarie == 0) + cotisation_entreprise ) * (type_sal <= 1) @reference_formula class arrco_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation ARRCO tranche 1 (employeur)" # TODO: check gestion mensuel/annuel def function(self, simulation, period): cotisation_minimale = apply_bareme( simulation, period, cotisation_type = "employeur", bareme_name = "arrco", variable_name = self.__class__.__name__, ) arrco_tranche_a_taux_employeur = simulation.calculate('arrco_tranche_a_taux_employeur', period) assiette_cotisations_sociales = simulation.calculate_add('assiette_cotisations_sociales', period) plafond_securite_sociale = simulation.calculate_add('plafond_securite_sociale', period) type_sal = simulation.calculate('type_sal', period) cotisation_entreprise = - ( min_(max_(assiette_cotisations_sociales, 0), plafond_securite_sociale) * arrco_tranche_a_taux_employeur ) return period, ( cotisation_minimale * (arrco_tranche_a_taux_employeur == 0) + cotisation_entreprise ) * (type_sal <= 1) @reference_formula class chomage_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation chômage tranche A (salarié)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "salarie", bareme_name = "assedic", variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class chomage_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation chômage tranche A (employeur)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "employeur", bareme_name = "assedic", variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class contribution_solidarite_autonomie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Contribution solidarité autonomie (employeur)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = "employeur", bareme_name = "csa", variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class cotisation_exceptionnelle_temporaire_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation_exceptionnelle_temporaire (employe)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = 'salarie', bareme_name = 'cet', variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class cotisation_exceptionnelle_temporaire_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation exceptionnelle temporaire (employeur)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'cet', variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class famille(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation famille (employeur)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'famille', variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class mmid_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation maladie (salarié)" def function(self, simulation, period): cotisation = apply_bareme( simulation, period, cotisation_type = 'salarie', bareme_name = 'maladie', variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class mmid_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation maladie (employeur)" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'maladie', variable_name = self.__class__.__name__, ) return period, cotisation # TODO: this formula is used only to check fiche_de_paie from memento @reference_formula class mmida_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation maladie (employeur)" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'maladie', variable_name = self.__class__.__name__, ) contribution_solidarite_autonomie = simulation.calculate('contribution_solidarite_autonomie', period) return period, cotisation + contribution_solidarite_autonomie @reference_formula class mhsup(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol entity_class = Individus label = u"Heures supplémentaires comptées négativement" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') hsup = simulation.calculate('hsup', period) return period, -hsup @reference_formula class plafond_securite_sociale(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Plafond de la securite sociale" # TODO gérer les plafonds mensuel, trimestriel, annuel def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') heures_non_remunerees_volume = simulation.calculate('heures_non_remunerees_volume') nombre_jours_calendaires = simulation.calculate('nombre_jours_calendaires', period) _P = simulation.legislation_at(period.start) plafond_temps_plein = _P.cotsoc.gen.plafond_securite_sociale jours_travailles = nombre_jours_calendaires - heures_non_remunerees_volume / 7 plafond_securite_sociale = min_(jours_travailles, 30) / 30 * plafond_temps_plein return period, plafond_securite_sociale @reference_formula class prevoyance_obligatoire_cadre(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation de prévoyance pour les cadres et assimilés" # TODO: gérer le mode de recouvrement et l'aspect mensuel/annuel def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') type_sal = simulation.calculate('type_sal', period) assiette_cotisations_sociales = simulation.calculate('assiette_cotisations_sociales', period) plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) prevoyance_obligatoire_cadre_taux_employeur = simulation.calculate( 'prevoyance_obligatoire_cadre_taux_employeur', period) cotisation = - ( (type_sal == CAT['prive_cadre']) * min_(assiette_cotisations_sociales, plafond_securite_sociale) * prevoyance_obligatoire_cadre_taux_employeur ) return period, cotisation @reference_formula class taille_entreprise(SimpleFormulaColumn): column = EnumCol( enum = Enum( [ u"Non pertinent", u"Moins de 10 salariés", u"De 10 à 19 salariés", u"De 20 à 249 salariés", u"Plus de 250 salariés", ], ), default = 0, ) entity_class = Individus label = u"Catégorie de taille d'entreprise" url = u"http://www.insee.fr/fr/themes/document.asp?ref_id=ip1321" def function(self, simulation, period): period = period effectif_entreprise = simulation.calculate('effectif_entreprise', period) taille_entreprise = ( (effectif_entreprise > 0).astype(int16) + (effectif_entreprise > 9).astype(int16) + (effectif_entreprise > 19).astype(int16) + (effectif_entreprise > 249).astype(int16) ) return period, taille_entreprise @reference_formula class taux_accident_travail(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Approximation du taux accident à partir de l'exposition au risque donnée" start_date = date(2012, 1, 1) def function(self, simulation, period): period_extract = period.start.period(u'month').offset('first-of') exposition_accident = simulation.calculate('exposition_accident', period_extract) accident = simulation.legislation_at(period_extract.start).cotsoc.accident return period, (exposition_accident == 0) * accident.faible + (exposition_accident == 1) * accident.moyen \ + (exposition_accident == 2) * accident.eleve + (exposition_accident == 3) * accident.treseleve @reference_formula class vieillesse_deplafonnee_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation vieillesse déplafonnée (salarié)" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') cotisation = apply_bareme( simulation, period, cotisation_type = 'salarie', bareme_name = 'vieillesse_deplafonnee', variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class vieillesse_plafonnee_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation vieillesse plafonnée (salarié)" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') cotisation = apply_bareme( simulation, period, cotisation_type = 'salarie', bareme_name = 'vieillesse', variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class vieillesse_deplafonnee_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation vieillesse déplafonnée" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'vieillesse_deplafonnee', variable_name = self.__class__.__name__, ) return period, cotisation @reference_formula class vieillesse_plafonnee_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation vieillesse plafonnée (employeur)" def function(self, simulation, period): period = period.start.period(u'month').offset('first-of') cotisation = apply_bareme( simulation, period, cotisation_type = 'employeur', bareme_name = 'vieillesse_plafonnee', variable_name = self.__class__.__name__, ) return period, cotisation PKoz= 2) # titulaire = (type_sal >= 2) * (type_sal <= 5) assiette = public * ( remuneration_principale # + not_(titulaire) * (indemnite_residence + primes_fonction_publique) ) return period, assiette # sft dans assiette csg et RAFP et Cotisation exceptionnelle de solidarité et taxe sur les salaires # primes dont indemnites de residences idem sft # avantages en nature contrib exceptionnelle de solidarite, RAFP, CSG, CRDS. @reference_formula class contribution_exceptionnelle_solidarite(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation exceptionnelle au fonds de solidarité (salarié)" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') traitement_indiciaire_brut = simulation.calculate('traitement_indiciaire_brut', period) hsup = simulation.calculate('hsup', period) type_sal = simulation.calculate('type_sal', period) indemnite_residence = simulation.calculate('indemnite_residence', period) primes_fonction_publique = simulation.calculate('primes_fonction_publique', period) rafp_salarie = simulation.calculate('rafp_salarie', period) pension_civile_salarie = simulation.calculate('pension_civile_salarie', period) cotisations_salariales_contributives = simulation.calculate('cotisations_salariales_contributives', period) plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) salaire_de_base = simulation.calculate('salaire_de_base', period) _P = simulation.legislation_at(period.start) seuil_assuj_fds = seuil_fds(_P) assujettis = ( (type_sal == CAT['public_titulaire_etat']) + (type_sal == CAT['public_titulaire_territoriale']) + (type_sal == CAT['public_titulaire_hospitaliere']) + (type_sal == CAT['public_non_titulaire']) ) * ( (traitement_indiciaire_brut + salaire_de_base - hsup) > seuil_assuj_fds ) # TODO: check assiette voir IPP cotisation = apply_bareme_for_relevant_type_sal( bareme_by_type_sal_name = _P.cotsoc.cotisations_salarie, bareme_name = "excep_solidarite", base = assujettis * min_( ( traitement_indiciaire_brut + salaire_de_base - hsup + indemnite_residence + rafp_salarie + pension_civile_salarie + primes_fonction_publique + (type_sal == CAT['public_non_titulaire']) * cotisations_salariales_contributives ), _P.cotsoc.sal.fonc.commun.plafond_base_solidarite, ), plafond_securite_sociale = plafond_securite_sociale, type_sal = type_sal, ) return period, cotisation @reference_formula class fonds_emploi_hospitalier(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Fonds pour l'emploi hospitalier (employeur)" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') assiette_cotisations_sociales_public = simulation.calculate('assiette_cotisations_sociales_public', period) plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) type_sal = simulation.calculate('type_sal', period) _P = simulation.legislation_at(period.start) cotisation = apply_bareme_for_relevant_type_sal( bareme_by_type_sal_name = _P.cotsoc.cotisations_employeur, bareme_name = "feh", base = assiette_cotisations_sociales_public, # TODO: check base plafond_securite_sociale = plafond_securite_sociale, type_sal = type_sal, ) return period, cotisation @reference_formula class ircantec_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Ircantec salarié" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') assiette_cotisations_sociales = simulation.calculate('assiette_cotisations_sociales', period) plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) type_sal = simulation.calculate('type_sal', period) _P = simulation.legislation_at(period.start) ircantec = apply_bareme_for_relevant_type_sal( bareme_by_type_sal_name = _P.cotsoc.cotisations_salarie, bareme_name = "ircantec", base = assiette_cotisations_sociales, plafond_securite_sociale = plafond_securite_sociale, type_sal = type_sal, ) return period, ircantec @reference_formula class ircantec_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Ircantec employeur" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') assiette_cotisations_sociales = simulation.calculate('assiette_cotisations_sociales', period) plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) type_sal = simulation.calculate('type_sal', period) _P = simulation.legislation_at(period.start) ircantec = apply_bareme_for_relevant_type_sal( bareme_by_type_sal_name = _P.cotsoc.cotisations_employeur, bareme_name = "ircantec", base = assiette_cotisations_sociales, plafond_securite_sociale = plafond_securite_sociale, type_sal = type_sal, ) return period, ircantec @reference_formula class pension_civile_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Pension civile salarié" url = u"http://www.ac-besancon.fr/spip.php?article2662", def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') traitement_indiciaire_brut = simulation.calculate('traitement_indiciaire_brut', period) # TODO: check nbi type_sal = simulation.calculate('type_sal', period) _P = simulation.legislation_at(period.start) sal = _P.cotsoc.cotisations_salarie terr_or_hosp = ( type_sal == CAT['public_titulaire_territoriale']) | (type_sal == CAT['public_titulaire_hospitaliere']) pension_civile_salarie = ( (type_sal == CAT['public_titulaire_etat']) * sal['public_titulaire_etat']['pension'].calc(traitement_indiciaire_brut) + terr_or_hosp * sal['public_titulaire_territoriale']['cnracl1'].calc(traitement_indiciaire_brut) ) return period, -pension_civile_salarie @reference_formula class pension_civile_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Cotisation patronale pension civile" url = u"http://www.ac-besancon.fr/spip.php?article2662" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') assiette_cotisations_sociales_public = simulation.calculate('assiette_cotisations_sociales_public', period) # plafond_securite_sociale = simulation.calculate('plafond_securite_sociale', period) type_sal = simulation.calculate('type_sal', period) _P = simulation.legislation_at(period.start) pat = _P.cotsoc.cotisations_employeur terr_or_hosp = ( (type_sal == CAT['public_titulaire_territoriale']) | (type_sal == CAT['public_titulaire_hospitaliere']) ) cot_pat_pension_civile = ( (type_sal == CAT['public_titulaire_etat']) * pat['public_titulaire_etat']['pension'].calc( assiette_cotisations_sociales_public) + terr_or_hosp * pat['public_titulaire_territoriale']['cnracl'].calc(assiette_cotisations_sociales_public) ) return period, -cot_pat_pension_civile @reference_formula class rafp_salarie(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Part salariale de la retraite additionelle de la fonction publique" # Part salariale de la retraite additionelle de la fonction publique # TODO: ajouter la gipa qui n'est pas affectée par le plafond d'assiette def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') traitement_indiciaire_brut = simulation.calculate('traitement_indiciaire_brut', period) type_sal = simulation.calculate('type_sal', period) primes_fonction_publique = simulation.calculate('primes_fonction_publique', period) supp_familial_traitement = simulation.calculate('supp_familial_traitement', period) indemnite_residence = simulation.calculate('indemnite_residence', period) _P = simulation.legislation_at(period.start) eligible = ((type_sal == CAT['public_titulaire_etat']) + (type_sal == CAT['public_titulaire_territoriale']) + (type_sal == CAT['public_titulaire_hospitaliere'])) plaf_ass = _P.cotsoc.sal.fonc.etat.rafp_plaf_assiette base_imposable = primes_fonction_publique + supp_familial_traitement + indemnite_residence assiette = min_(base_imposable, plaf_ass * traitement_indiciaire_brut * eligible) # Même régime pour les fonctions publiques d'Etat et des collectivité locales rafp_salarie = eligible * _P.cotsoc.cotisations_salarie.public_titulaire_etat['rafp'].calc(assiette) return period, -rafp_salarie @reference_formula class rafp_employeur(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Part patronale de la retraite additionnelle de la fonction publique" # TODO: ajouter la gipa qui n'est pas affectée par le plafond d'assiette def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') traitement_indiciaire_brut = simulation.calculate('traitement_indiciaire_brut', period) type_sal = simulation.calculate('type_sal', period) primes_fonction_publique = simulation.calculate('primes_fonction_publique', period) supp_familial_traitement = simulation.calculate('supp_familial_traitement', period) indemnite_residence = simulation.calculate('indemnite_residence', period) _P = simulation.legislation_at(period.start) eligible = ( (type_sal == CAT['public_titulaire_etat']) + (type_sal == CAT['public_titulaire_territoriale']) + (type_sal == CAT['public_titulaire_hospitaliere']) ) plaf_ass = _P.cotsoc.sal.fonc.etat.rafp_plaf_assiette base_imposable = primes_fonction_publique + supp_familial_traitement + indemnite_residence assiette = min_(base_imposable, plaf_ass * traitement_indiciaire_brut * eligible) bareme_rafp = _P.cotsoc.cotisations_employeur.public_titulaire_etat['rafp'] rafp_employeur = eligible * bareme_rafp.calc(assiette) return period, - rafp_employeur def seuil_fds(law): ''' Calcul du seuil mensuel d'assujetissement à la contribution au fond de solidarité ''' ind_maj_ref = law.cotsoc.sal.fonc.commun.ind_maj_ref pt_ind_mensuel = law.cotsoc.sal.fonc.commun.pt_ind / 12 seuil_mensuel = math.floor((pt_ind_mensuel * ind_maj_ref)) return seuil_mensuel PKoz 0 dummy_rmi = rsa > 0 dummy_aah = aah > 0 return period, (age_condition + dummy_ass + dummy_aah + dummy_rmi) > 0 @reference_formula class remuneration_professionnalisation(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Rémunération de l'apprenti" url = "http://www.apce.com/pid927/contrat-d-apprentissage.html?espace=1&tp=1&pagination=2" # La rémunération minimale varie en fonction de l'âge et du niveau de qualification des bénéficiaires des contrats # de professionnalisation : # # Pour les personnes de moins de 21 ans : # au minimum 55 % du Smic, # au minimum 65 % du Smic si le jeune est titulaire d'une qualification au moins égale au baccalauréat # professionnel ou d'un titre ou d'un diplôme à finalité professionnelle de même niveau. # # Pour les personnes ayant entre 21 et 25 ans : # au minimum 70 % du Smic, # au minimum 80 % du Smic si le bénéficiaire est titulaire d'une qualification au moins égale à celle d'un # baccalauréat professionnel ou d'un titre/diplôme à finalité professionnelle de même niveau. # # Pour les personnes âgées de plus de 26 ans : # au minimum le Smic, # au minimum 85 % du salaire minimum prévu par la convention ou l'accord de branche auquel est soumise # l'entreprise. def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age = simulation.calculate('age', period) smic = simulation.legislation_at(period.start).cotsoc.gen.smic_h_b * 52 * 35 / 12 professionnalisation = simulation.calculate('professionnalisation', period) qualifie = simulation.calculate('qualifie') salaire_en_smic = [ dict( part_de_smic_by_qualification = { 'non_qualifie': .55, 'qualifie': .65 }, age_min = 16, age_max = 21, ), dict( part_de_smic_by_qualification = { 1: .70, }, age_min = 21, age_max = 25, ), dict( part_de_smic_by_qualification = { 1: 1.0, }, age_min = 26, age_max = 99 ) ] taux_smic = age * 0.0 for age_interval in salaire_en_smic: age_condition = (age_interval['age_min'] <= age) * (age <= age_interval['age_max']) taux_smic[age_condition] = sum([ (qualifie[age_condition] == qualification) * part_de_smic for qualification, part_de_smic in age_interval['part_de_smic_by_qualification'].iteritems() ]) return period, taux_smic * smic * professionnalisation @reference_formula class exoneration_cotisations_employeur_apprenti(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Exonération de cotisations patronales pour l'emploi d'un apprenti" url = "http://www.apce.com/pid927/contrat-d-apprentissage.html?espace=1&tp=1&pagination=2" # Exonération de cotisations sociales patronales d'assurance maladie-maternité, de vieillesse de base, # d'invalidité-décès et d'allocations familiales au titre des rémunérations versées aux demandeurs d'emploi de # plus de 45 ans # # Les salariés en contrat de professionnalisation ne sont pas comptabilisés dans l'effectif de l'entreprise pendant # la durée du contrat s'il est à durée déterminée ou pendant l'action de professionnalisation si le contrat est à # durée indéterminée. # Remboursement de certaines dépenses par les organismes collecteurs paritaires agréés (OPCA) # Aide forfaitaire versée par Pôle emploi pour l'embauche d'un demandeur d'emploi de 26 ans et plus # En cas d'embauche d'un demandeur d'emploi de 26 ans et plus, l'employeur peut bénéficier d'une aide forfaitaire # (AFE) d'un montant maximum de 2 000 euros par bénéficiaire. Pour les salariés à temps partiel, le montant de # l'aide est proratisé en fonction du temps de travail effectif. # Aide spécifique de 686 euros par accompagnement et pour une année pleine est attribuée sous certaines conditions # aux groupements d'employeurs qui organisent dans le cadre des contrats de professionnalisation def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age = simulation.calculate('age', period) mmid_employeur = simulation.calculate('mmid_employeur', period) famille = simulation.calculate('famille', period) vieillesse_plafonnee_employeur = simulation.calculate('vieillesse_plafonnee_employeur', period) # correspond à # vieillesse de base? cotisations_exonerees = mmid_employeur + famille + vieillesse_plafonnee_employeur return period, cotisations_exonerees * (age > 45) # On est bien d'accord qu'il y a les exos uniquement pour les # plus de 45 ans? # O est d'accord aucun avantage pour l'employé ?? # @reference_formula # class exoneration_cotisations_salariales_apprenti(SimpleFormulaColumn): # column = FloatCol # entity_class = Individus # label = u"Exonération de cotisations salariales pour l'emploi d'un apprenti" # url = "http://www.apce.com/pid927/contrat-d-apprentissage.html?espace=1&tp=1&pagination=2" # # def function(self, simulation, period): # cotisations_salariales = simulation.calculate('cotisations_salariales', period) # return period, - cotisations_salariales PKoz contrat_de_travail_debut + timedelta64(365, 'D')) # TODO: move to legislation parameters file contrat_de_travail_eligible = (contrat_de_travail_debut <= datetime64("2014-12-31")) * ( (contrat_de_travail_duree == 0) + ( (contrat_de_travail_duree == 1) * (duree_cdd_eligible) ) ) # TODO: move to legislation parameters file eligible = ( contrat_de_travail_eligible * (effectif_entreprise <= 50) * zone_franche_urbaine * entreprise_eligible ) bareme_by_name = simulation.legislation_at(period.start).cotsoc.cotisations_employeur['prive_non_cadre'] taux_max = ( bareme_by_name['vieillesse_deplafonnee'].rates[0] + bareme_by_name['vieillesse_plafonnee'].rates[0] + bareme_by_name['maladie'].rates[0] + bareme_by_name['famille'].rates[0] + bareme_by_name['fnal1'].rates[0] + bareme_by_name['fnal2'].rates[0] * (effectif_entreprise >= 20) + taux_versement_transport ) # TODO: move to legislation parameters file : voir http://www.urssaf.fr/images/ref_lc2009-077.pdf seuil_max = 2 seuil_min = 1.4 taux_exoneration = compute_taux_exoneration(assiette_allegement, smic_proratise, taux_max, seuil_max, seuil_min) exoneration_relative_year_passed = exoneration_relative_year(period, contrat_de_travail_debut) large_rate_by_year_passed = { 0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: .60, 6: .40, 7: .20, } # TODO: move to legislation parameters file small_rate_by_year_passed = { 0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: .60, 6: .60, 7: .60, 8: .60, 9: .60, 10: .40, 11: .40, 12: .20, 13: .20, } # TODO: move to legislation parameters file large_taux_exoneration = eligible * 0.0 small_taux_exoneration = eligible * 0.0 for year_passed, rate in large_rate_by_year_passed.iteritems(): if (exoneration_relative_year_passed == year_passed).any(): large_taux_exoneration[exoneration_relative_year_passed == year_passed] = rate * taux_exoneration for year_passed, rate in small_rate_by_year_passed.iteritems(): if (exoneration_relative_year_passed == year_passed).any(): small_taux_exoneration[exoneration_relative_year_passed == year_passed] = rate * taux_exoneration exoneration_cotisations_zfu = eligible * assiette_allegement * ( small_taux_exoneration * (effectif_entreprise <= 5) + large_taux_exoneration * (effectif_entreprise > 5) ) return period, exoneration_cotisations_zfu # TODO: propager dans le temps @reference_formula class exoneration_cotisations_employeur_zrd(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Exonrérations de cotisations employeur pour l'embauche en zone de restructuration de la Défense (ZRD)" url = "http://www.apce.com/pid11668/exoneration-dans-les-zrd.html?espace=1&tp=1" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') assiette_allegement = simulation.calculate('assiette_allegement', period) entreprise_creation = simulation.calculate('entreprise_creation', period) smic_proratise = simulation.calculate('smic_proratise', period) zone_restructuration_defense = simulation.calculate('zone_restructuration_defense', period) eligible = zone_restructuration_defense taux_max = .281 # TODO: move to legislation parameters file seuil_max = 2.4 seuil_min = 1.4 taux_exoneration = compute_taux_exoneration(assiette_allegement, smic_proratise, taux_max, seuil_max, seuil_min) exoneration_relative_year_passed = exoneration_relative_year(period, entreprise_creation) rate_by_year_passed = { 0: 1, 1: 1, 2: 1, 3: 2 / 3, 4: 1 / 3, } # TODO: move to legislation parameters file ratio = eligible * 0.0 for year_passed, rate in rate_by_year_passed.iteritems(): if (exoneration_relative_year_passed == year_passed).any(): ratio[exoneration_relative_year_passed == year_passed] = rate exoneration_cotisations_zrd = ratio * taux_exoneration * assiette_allegement * eligible return period, exoneration_cotisations_zrd @reference_formula class exoneration_cotisations_employeur_zrr(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Exonrérations de cotisations employeur pour l'embauche en zone de revitalisation rurale (ZRR)" url = "http://www.apce.com/pid538/embauches-en-zru-et-zrr.html?espace=1&tp=1" # Les entreprises et groupements d'employeurs exerçant une activité industrielle, commerciale, artisanale, agricole # ou libérale et cotisant au régime d'assurance chômage. # Les entreprises concernées, y compris chacune de celles appartenant à un groupement d'employeurs, doivent avoir # au moins un établissement situé en zone de revitalisation rurale. # # A noter : les associations à but non lucratif sont exclues du dispositif. Par contre, quelle que soit leur forme # juridique, les entreprises d'insertion ou d'intérim d'insertion peuvent en bénéficier. Les régies de quartier # peuvent en bénéficier lorsque leur activité est susceptible d'entraîner l'assujettissement à la TVA à l'impôt sur # les sociétés ainsi qu'à la contribution économique territoriale qu'elles en soient effectivement redevables # ou non. # # L'employeur ne doit avoir procédé à aucun licenciement économique durant les 12 mois précédant l'embauche. def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') assiette_allegement = simulation.calculate('assiette_allegement', period) contrat_de_travail_duree = simulation.calculate('contrat_de_travail_duree', period) # 0: CDI, 1:CDD contrat_de_travail_debut = simulation.calculate('contrat_de_travail_debut', period) contrat_de_travail_fin = simulation.calculate('contrat_de_travail_fin', period) effectif_entreprise = simulation.calculate('effectif_entreprise', period) smic_proratise = simulation.calculate('smic_proratise', period) zone_revitalisation_rurale = simulation.calculate('zone_revitalisation_rurale', period) duree_cdd_eligible = contrat_de_travail_fin > contrat_de_travail_debut + timedelta64(365, 'D') # TODO: move to legislation parameters file contrat_de_travail_eligible = ( contrat_de_travail_duree == 0) + ( (contrat_de_travail_duree == 1) * (duree_cdd_eligible) ) duree_validite = ( datetime64(period.start) + timedelta64(1, 'D') - contrat_de_travail_debut).astype('timedelta64[Y]') < 1 eligible = ( contrat_de_travail_eligible * (effectif_entreprise <= 50) * zone_revitalisation_rurale * duree_validite ) taux_max = .281 if period.start.year < 2015 else .2655 # TODO: move to legislation parameters file seuil_max = 2.4 seuil_min = 1.5 taux_exoneration = compute_taux_exoneration(assiette_allegement, smic_proratise, taux_max, seuil_max, seuil_min) exoneration_cotisations_zrr = taux_exoneration * assiette_allegement * eligible return period, exoneration_cotisations_zrr # Aides à la création @reference_formula class exoneration_is_creation_zrr(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Exonrérations fiscales pour création d'une entreprise en zone de revitalisation rurale (ZRR)" url = 'http://www.apce.com/pid11690/exonerations-d-impots-zrr.html?espace=1&tp=1' def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') effectif_entreprise = simulation.calculate('effectif_entreprise', period) entreprise_benefice = simulation.calculate('entreprise_benefice', period) # TODO: MODIFIER avec création d'entreprise contrat_de_travail_duree = simulation.calculate('contrat_de_travail_duree', period) # 0: CDI, 1:CDD contrat_de_travail_debut = simulation.calculate('contrat_de_travail_debut', period) contrat_de_travail_fin = simulation.calculate('contrat_de_travail_fin', period) duree_eligible = contrat_de_travail_fin > contrat_de_travail_debut + timedelta64(365, 'D') # TODO: move to legislation parameters file contrat_de_travail_eligible = ( contrat_de_travail_duree == 0) + ( (contrat_de_travail_duree == 1) * (duree_eligible) ) zone_revitalisation_rurale = simulation.calculate('zone_revitalisation_rurale', period) eligible = ( contrat_de_travail_eligible * (effectif_entreprise <= 50) * zone_revitalisation_rurale ) exoneration_relative_year_passed = exoneration_relative_year(period, contrat_de_travail_debut) rate_by_year_passed = { 0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: .75, 6: .50, 7: .25, } # TODO: move to legislation parameters file taux_exoneraion = eligible * 0.0 for year_passed, rate in rate_by_year_passed.iteritems(): taux_exoneraion[exoneration_relative_year_passed == year_passed] = rate return period, taux_exoneraion * entreprise_benefice # TODO: mettre sur toutes les années # @reference_formula # class bassin_emploi_redynamiser(SimpleFormulaColumn): # column = BoolCol # entity_class = Individus # label = u"L'entreprise est située danns un bassin d'emploi à redynamiser(BER)" # # La liste des bassins d'emploi à redynamiser a été fixée par le décret n°2007-228 du 20 février 2007. # # Actuellement, deux régions sont concernées : Champagne-Ardenne (zone d'emploi de la Vallée de la Meuse) # # et Midi-Pyrénées (zone d'emploi de Lavelanet). # # def function(self, simulation, period): # effectif_entreprise = simulation.calculate('effectif_entreprise', period) # return period, (effectif_entreprise >= 1) * False @reference_formula class jeune_entreprise_innovante(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"L'entreprise est une jeune entreprise innovante" def function(self, simulation, period): # Toute entreprise existante au 1er janvier 2004 ou créée entre le 1er janvier 2004 et le 31 décembre 2016 à # condition de remplir les conditions suivantes : # # avoir moins de 8 ans d'existence au moment de la demande # # être réellement nouvelle, c'est-à-dire ne pas avoir été créée dans le cadre d'une concentration, # d'une restructuration, d'une extension d'activité préexistante ou d'une reprise # # employer moins de 250 personnes au cours de l'exercice au titre duquel elle demande à bénéficier de ce statut # # réaliser un chiffre d'affaires inférieur à 50 M€ et disposer d'un total de bilan inférieur à 43 M€ # # être indépendante, c'est-à-dire que son capital doit être détenu pour 50 % au minimum par : # # - des personnes physiques # # - une ou plusieurs autres JEI dont 50 % du capital au moins est détenu par des personnes physiques # # - des associations ou fondations reconnues d'utilité publique à caractère scientifique # # - des établissements de recherche et d'enseignement et leurs filiales # # - des structures d'investissement sous réserve qu'il n'y ait pas de lien de dépendance telles que des : # - fonds communs de placement dans l'innovation (FCPI) # - sociétés de capital-risque # - fonds d'investissement de proximité (FIP) # - sociétés de développement régional (SDR) # - sociétés financières d'innovation (SFI) # - sociétés unipersonnelles d'investissements à risques (SUIR). # # réaliser des dépenses de R§D représentant au moins 15 % des charges fiscalement déductibles au titre du même # exercice. effectif_entreprise = simulation.calculate('effectif_entreprise', period) entreprise_bilan = simulation.calculate('entreprise_bilan', period) entreprise_chiffre_affaire = simulation.calculate('entreprise_chiffre_affaire', period) entreprise_creation = simulation.calculate('entreprise_creation', period) # entreprise_depenses_rd = simulation.calculate('entreprise_depenses_rd', period) jei_date_demande = simulation.calculate('jei_date_demande', period) # TODO: move to legislation parameters file # entreprise_depenses_rd > .15 TODO independance = True jeune_entreprise_innovante = ( independance * (effectif_entreprise < 250) * (entreprise_creation <= datetime64("2016-12-31")) * ((jei_date_demande + timedelta64(1, 'D') - entreprise_creation).astype('timedelta64[Y]') < 8) * (entreprise_chiffre_affaire < 50e6) * (entreprise_bilan < 43e6) ) return period, jeune_entreprise_innovante @reference_formula class bassin_emploi_redynamiser(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"L'entreprise est située danns un bassin d'emploi à redynamiser (BER)" # La liste des bassins d'emploi à redynamiser a été fixée par le décret n°2007-228 du 20 février 2007. # Actuellement, deux régions sont concernées : Champagne-Ardenne (zone d'emploi de la Vallée de la Meuse) # et Midi-Pyrénées (zone d'emploi de Lavelanet). def function(self, simulation, period): effectif_entreprise = simulation.calculate('effectif_entreprise', period) return period, (effectif_entreprise >= 1) * False @reference_formula class zone_restructuration_defense(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"L'entreprise est située dans une zone de restructuration de la Défense (ZRD)" def function(self, simulation, period): effectif_entreprise = simulation.calculate('effectif_entreprise', period) return period, (effectif_entreprise >= 1) * False @reference_formula class zone_franche_urbaine(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"L'entreprise est située danns une zone franche urbaine (ZFU)" def function(self, simulation, period): effectif_entreprise = simulation.calculate('effectif_entreprise', period) return period, (effectif_entreprise >= 1) * False @reference_formula class zone_revitalisation_rurale(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"L'entreprise est située dans une zone de revitalisation rurale (ZRR)" def function(self, simulation, period): effectif_entreprise = simulation.calculate('effectif_entreprise', period) return period, (effectif_entreprise >= 1) * False # Helpers def compute_taux_exoneration(assiette_allegement, smic_proratise, taux_max, seuil_max, seuil_min = 1): ratio_smic_salaire = smic_proratise / (assiette_allegement + 1e-16) # règle d'arrondi: 4 décimales au dix-millième le plus proche ( # TODO: reprise de l'allègement Fillon unchecked) return round_( taux_max * min_(1, max_(seuil_max * seuil_min * ratio_smic_salaire - seuil_min, 0) / (seuil_max - seuil_min)), 4, ) def exoneration_relative_year(period, other_date): return (datetime64(period.start) + timedelta64(1, 'D') - other_date).astype('timedelta64[Y]') PKoz bareme.csg.capital.nonimp # # verse=1 # # CSG sur les revenus du patrimoine non imposés au barême (contributions sociales déjà prélevées) # # table.setIndiv('csgcap_bar', csgcap_bar*verse) # table.setIndiv('prelsoccap_bar', prelsoccap_bar*verse) # table.setIndiv('crdscap_bar', crdscap_bar*verse) PKFhopenfisca_france/model/prelevements_obligatoires/prelevements_sociaux/contributions_sociales/__init__.pyPKoz 13900) # TODO: insert in parameters file and deal with nombre de part fiscales return period, - casa @reference_formula class rst(SimpleFormulaColumn): base_function = requested_period_added_value column = FloatCol entity_class = Individus label = u"Pensions de retraite imposables" set_input = set_input_divide_by_period url = u"http://vosdroits.service-public.fr/particuliers/F415.xhtml" def function(self, simulation, period): period = period rstbrut = simulation.calculate_add('rstbrut', period) csg_deductible_retraite = simulation.calculate_add('csg_deductible_retraite', period) return period, rstbrut + csg_deductible_retraite @reference_formula class rstnet(SimpleFormulaColumn): base_function = requested_period_added_value column = FloatCol entity_class = Individus label = u"Pensions de retraite nettes" set_input = set_input_divide_by_period url = u"http://vosdroits.service-public.fr/particuliers/N20166.xhtml" # def function(self, rst, csg_imposable_retraite, crds_retraite, casa): # return rst + csg_imposable_retraite + crds_retraite + casa def function(self, simulation, period): period = period rst = simulation.calculate('rst', period) csg_imposable_retraite = simulation.calculate_add('csg_imposable_retraite', period) crds_retraite = simulation.calculate_add('crds_retraite', period) return period, rst + csg_imposable_retraite + crds_retraite @reference_formula class crds_pfam(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"CRDS sur les prestations familiales)" url = "http://www.cleiss.fr/docs/regimes/regime_francea1.html" def function(self, simulation, period): ''' Renvoie la CRDS des prestations familiales ''' period = period af = simulation.calculate_add('af', period) cf = simulation.calculate_add('cf', period) asf = simulation.calculate_add('asf', period) ars = simulation.calculate('ars', period) paje = simulation.calculate_add('paje', period) ape = simulation.calculate_add('ape', period) apje = simulation.calculate_add('apje', period) _P = simulation.legislation_at(period.start) return period, -(af + cf + asf + ars + paje + ape + apje) * _P.fam.af.crds PKFIopenfisca_france/model/prelevements_obligatoires/impot_revenu/__init__.pyPKuVGVePPCopenfisca_france/model/prelevements_obligatoires/impot_revenu/ir.py# -*- coding: utf-8 -*- from __future__ import division import logging from numpy import (datetime64, logical_and as and_, logical_not as not_, logical_or as or_, logical_xor as xor_, maximum as max_, minimum as min_, round) from ...base import * # noqa analysis:ignore log = logging.getLogger(__name__) # TODO: 8ti et 8tk (cerfa 2047) # TODO: CSG, CRDS et prélèvements sociaux sur revenu du patrimione, d'activité et de remplacement # TODO: finir RPNS (prise en compte des plafonds / cases non codées : codées pour certaines années mais pas pour # d'autres - car des cases sont réutilisées pour des variables différentes suivant les années) # zetrf = zeros(taille) # jveuf = zeros(taille, dtype = bool) # Reprise du crédit d'impôt en faveur des jeunes, des accomptes et des versements mensues de prime pour l'emploi # reprise = zeros(taille) # TODO : reprise=J80 # Pcredit = P.credits_impots # if hasattr(P.reductions_impots,'saldom'): Pcredit.saldom = P.reductions_impots.saldom # credits_impot = Credits(Pcredit, table) # Réduction d'impôt # reductions = Reductions(IPnet, P.reductions_impots) # def mcirra(): # # impôt sur le revenu # mcirra = -((IMP<=-8)*IMP) # mciria = max_(0,(IMP>=0)*IMP) # # mciria = max_(0,(IMP>=0)*IMP - credimp_etranger - cont_rev_loc - ( f8to + f8tb + f8tc )) # # # Dans l'ERFS, les prelevement libératoire sur les montants non déclarés # # sont intégrés. Pas possible de le recalculer. # # # impot sur le revenu du foyer (hors prélèvement libératoire, revenus au quotient) # irpp = -(mciria + ppetot - mcirra ) build_column('jour_xyz', IntCol(default = 360, entity = "foy", label = u"Jours décomptés au titre de cette déclaration")) build_column('rfr_n_1', IntCol(entity = 'foy', label = u"Revenu fiscal de référence année n - 1", val_type = "monetary")) build_column('rfr_n_2', IntCol(entity = 'foy', label = u"Revenu fiscal de référence année n - 2", val_type = "monetary")) build_column('nbptr_n_2', PeriodSizeIndependentIntCol(entity = 'foy', label = u"Nombre de parts année n - 2", val_type = "monetary")) ############################################################################### # # Initialisation de quelques variables utiles pour la suite ############################################################################### @reference_formula class age(SimpleFormulaColumn): base_function = missing_value column = AgeCol(val_type = "age") entity_class = Individus label = u"Âge (en années)" def function(self, simulation, period): has_birth = simulation.get_or_new_holder('birth')._array is not None if not has_birth: has_age_en_mois = bool(simulation.get_or_new_holder('age_en_mois')._array_by_period) if has_age_en_mois: return period, simulation.calculate('age_en_mois', period) // 12 # If age is known at the same day of another year, compute the new age from it. holder = self.holder start = period.start if holder._array_by_period is not None: for last_period, last_array in sorted(holder._array_by_period.iteritems(), reverse = True): last_start = last_period.start if last_start.day == start.day: return period, last_array + int((start.year - last_start.year) + (start.month - last_start.month) / 12) birth = simulation.calculate('birth', period) return period, (datetime64(period.start) - birth).astype('timedelta64[Y]') @reference_formula class age_en_mois(SimpleFormulaColumn): base_function = missing_value column = AgeCol(val_type = "months") entity_class = Individus label = u"Âge (en mois)" def function(self, simulation, period): # If age_en_mois is known at the same day of another month, compute the new age_en_mois from it. holder = self.holder start = period.start if holder._array_by_period is not None: for last_period, last_array in sorted(holder._array_by_period.iteritems(), reverse = True): last_start = last_period.start if last_start.day == start.day: return period, last_array + ((start.year - last_start.year) * 12 + (start.month - last_start.month)) has_birth = simulation.get_or_new_holder('birth')._array is not None if not has_birth: has_age = bool(simulation.get_or_new_holder('age')._array_by_period) if has_age: return period, simulation.calculate('age', period) * 12 birth = simulation.calculate('birth', period) return period, (datetime64(period.start) - birth).astype('timedelta64[M]') @reference_formula class nb_adult(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Nombre d'adulte(s) dans le foyer fiscal" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) celdiv = simulation.calculate('celdiv', period) veuf = simulation.calculate('veuf', period) return period, 2 * marpac + 1 * (celdiv | veuf) @reference_formula class nb_pac(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Nombre de personnes à charge dans le foyer fiscal" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') nbF = simulation.calculate('nbF', period) nbJ = simulation.calculate('nbJ', period) nbR = simulation.calculate('nbR', period) return period, nbF + nbJ + nbR @reference_formula class enfant_a_charge(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Enfant à charge non marié, de moins de 18 ans au 1er janvier de l'année de perception des" \ u" revenus, ou né durant la même année, ou handicapés quel que soit son âge" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') age = simulation.calculate('age', period) alt = simulation.calculate('alt', period) invalide = simulation.calculate('invalide', period) quifoy = simulation.calculate('quifoy', period) return period, and_(and_(quifoy >= 2, or_(age < 18, invalide)), not_(alt)) @reference_formula class nbF(PersonToEntityColumn): cerfa_field = u'F' entity_class = FoyersFiscaux label = u"Nombre d'enfants à charge non mariés, de moins de 18 ans au 1er janvier de l'année de perception des" \ u" revenus, ou nés durant la même année ou handicapés quel que soit leur âge" operation = 'add' variable = enfant_a_charge @reference_formula class nombre_enfants_a_charge_menage(PersonToEntityColumn): entity_class = Menages label = u"Nombre d'enfants à charge non mariés, de moins de 18 ans au 1er janvier de l'année de perception des" \ u" revenus, ou nés durant la même année ou handicapés quel que soit leur âge" operation = 'add' variable = enfant_a_charge @reference_formula class enfant_a_charge_invalide(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Enfant à charge titulaire de la carte d'invalidité" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') alt = simulation.calculate('alt', period) invalide = simulation.calculate('invalide', period) quifoy = simulation.calculate('quifoy', period) return period, and_(and_(quifoy >= 2, invalide), not_(alt)) @reference_formula class nbG(PersonToEntityColumn): cerfa_field = u'G' entity_class = FoyersFiscaux label = u"Nombre d'enfants à charge titulaires de la carte d'invalidité" operation = 'add' variable = enfant_a_charge_invalide @reference_formula class enfant_a_charge_garde_alternee(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Enfant à charge en résidence alternée, non marié, de moins de 18 ans au 1er janvier de l'année de" \ u" perception des revenus, ou né durant la même année ou handicapés quel que soit son âge" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') age = simulation.calculate('age', period) alt = simulation.calculate('alt', period) invalide = simulation.calculate('invalide', period) quifoy = simulation.calculate('quifoy', period) return period, and_(and_(quifoy >= 2, or_(age < 18, invalide)), alt) @reference_formula class nbH(PersonToEntityColumn): cerfa_field = u'H' entity_class = FoyersFiscaux label = u"Nombre d'enfants à charge en résidence alternée, non mariés de moins de 18 ans au 1er janvier de" \ u" l'année de perception des revenus, ou nés durant la même année ou handicapés quel que soit leur âge" operation = 'add' variable = enfant_a_charge_garde_alternee @reference_formula class enfant_a_charge_garde_alternee_invalide(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Enfant à charge en résidence alternée titulaire de la carte d'invalidité" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') alt = simulation.calculate('alt', period) invalide = simulation.calculate('invalide', period) quifoy = simulation.calculate('quifoy', period) return period, and_(and_(quifoy >= 2, invalide), alt) @reference_formula class nbI(PersonToEntityColumn): cerfa_field = u'I' entity_class = FoyersFiscaux label = u"Nombre d'enfants à charge en résidence alternée titulaires de la carte d'invalidité" operation = 'add' variable = enfant_a_charge_garde_alternee_invalide @reference_formula class enfant_majeur_celibataire_sans_enfant(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Enfant majeur célibataire sans enfant" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') age = simulation.calculate('age', period) invalide = simulation.calculate('invalide', period) quifoy = simulation.calculate('quifoy', period) return period, and_(and_(quifoy >= 2, age >= 18), not_(invalide)) @reference_formula class nbJ(PersonToEntityColumn): cerfa_field = u'J' entity_class = FoyersFiscaux label = u"Nombre d'enfants majeurs célibataires sans enfant" operation = 'add' variable = enfant_majeur_celibataire_sans_enfant @reference_formula class nombre_enfants_majeurs_celibataires_sans_enfant(PersonToEntityColumn): entity_class = Menages label = u"Nombre d'enfants majeurs célibataires sans enfant" operation = 'add' variable = enfant_majeur_celibataire_sans_enfant @reference_formula class marpac(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = FoyersFiscaux label = u"marpac" def function(self, simulation, period): ''' Marié (1) ou Pacsé (5) 'foy' ''' period = period.start.offset('first-of', 'year').period('year') statmarit_holder = simulation.compute('statmarit', period) statmarit = self.filter_role(statmarit_holder, role = VOUS) return period, (statmarit == 1) | (statmarit == 5) @reference_formula class celdiv(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = FoyersFiscaux label = u"celdiv" def function(self, simulation, period): ''' Célibataire (2) ou divorcé (3) 'foy' ''' period = period.start.offset('first-of', 'year').period('year') statmarit_holder = simulation.compute('statmarit', period) statmarit = self.filter_role(statmarit_holder, role = VOUS) return period, (statmarit == 2) | (statmarit == 3) @reference_formula class veuf(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = FoyersFiscaux label = u"veuf" def function(self, simulation, period): ''' Veuf (4) 'foy' ''' period = period.start.offset('first-of', 'year').period('year') statmarit_holder = simulation.compute('statmarit', period) statmarit = self.filter_role(statmarit_holder, role = VOUS) return period, statmarit == 4 @reference_formula class jveuf(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = FoyersFiscaux label = u"jveuf" def function(self, simulation, period): ''' Jeune Veuf 'foy' ''' period = period.start.offset('first-of', 'year').period('year') statmarit_holder = simulation.compute('statmarit', period) statmarit = self.filter_role(statmarit_holder, role = VOUS) return period, statmarit == 6 ############################################################################### # # Revenus catégoriels ############################################################################### @reference_formula class rev_sal(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Revenu imposé comme des salaires (salaires, mais aussi 3vj, 3vk)" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') salaire_imposable = simulation.calculate_add('salaire_imposable', period) cho = simulation.calculate('cho', period) return period, salaire_imposable + cho @reference_formula class salcho_imp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Salaires et chômage imposables après abattements" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') rev_sal = simulation.calculate('rev_sal', period) chomeur_longue_duree = simulation.calculate('chomeur_longue_duree', period) frais_reels = simulation.calculate('frais_reels', period) abatpro = simulation.legislation_at(period.start).ir.tspr.abatpro abattement_minimum = abatpro.min * not_(chomeur_longue_duree) + abatpro.min2 * chomeur_longue_duree abatfor = round(min_(max_(abatpro.taux * rev_sal, abattement_minimum), abatpro.max)) return period, (frais_reels > abatfor) * (rev_sal - frais_reels) + (frais_reels <= abatfor) * max_(0, rev_sal - abatfor) @reference_formula class rev_act_sal(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rev_act_sal" def function(self, simulation, period): ''' Revenus d'activités salariées''' period = period.start.offset('first-of', 'year').period('year') salaire_imposable = simulation.calculate_add('salaire_imposable', period) return period, salaire_imposable @reference_formula class rev_act_nonsal(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rev_act_nonsal" def function(self, simulation, period): ''' Revenus d'activités non salariées ''' period = period.start.offset('first-of', 'year').period('year') rpns_i = simulation.calculate('rpns_i', period) return period, rpns_i # TODO: vérifier cette définition @reference_formula class rev_act(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rev_act" def function(self, simulation, period): ''' Revenus d'activités ''' period = period.start.offset('first-of', 'year').period('year') rev_act_nonsal = simulation.calculate('rev_act_nonsal', period) rev_act_sal = simulation.calculate('rev_act_sal', period) return period, rev_act_nonsal + rev_act_sal @reference_formula class rev_pen(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Revenu imposé comme des pensions (retraites, pensions alimentaires, etc.)" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') pensions_alimentaires_percues = simulation.calculate('pensions_alimentaires_percues', period) pensions_alimentaires_percues_decl = simulation.calculate('pensions_alimentaires_percues_decl', period) rst = simulation.calculate('rst', period) return period, pensions_alimentaires_percues * pensions_alimentaires_percues_decl + rst @reference_formula class pen_net(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Pensions après abattements" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') rev_pen = simulation.calculate('rev_pen', period) abatpen = simulation.legislation_at(period.start).ir.tspr.abatpen # TODO: problème car les pensions sont majorées au niveau du foyer # d11 = ( AS + BS + CS + DS + ES + # AO + BO + CO + DO + EO ) # penv2 = (d11-f11> abatpen.max)*(penv + (d11-f11-abatpen.max)) + (d11-f11<= abatpen.max)*penv # Plus d'abatement de 20% en 2006 return period, max_(0, rev_pen - round(max_(abatpen.taux * rev_pen , abatpen.min))) # return max_(0, rev_pen - min_(round(max_(abatpen.taux*rev_pen , abatpen.min)), abatpen.max)) le max se met au niveau du foyer @reference_formula class indu_plaf_abat_pen(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"indu_plaf_abat_pen" def function(self, simulation, period): """ Plafonnement de l'abattement de 10% sur les pensions du foyer 'foy' """ period = period.start.offset('first-of', 'year').period('year') rev_pen_holder = simulation.compute('rev_pen', period) pen_net_holder = simulation.compute('pen_net', period) abatpen = simulation.legislation_at(period.start).ir.tspr.abatpen pen_net = self.sum_by_entity(pen_net_holder) rev_pen = self.sum_by_entity(rev_pen_holder) abat = rev_pen - pen_net return period, abat - min_(abat, abatpen.max) @reference_formula class abat_sal_pen(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Abattement de 20% sur les salaires" start_date = date(2002, 1, 1) stop_date = date(2005, 12, 31) def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') salcho_imp = simulation.calculate('salcho_imp', period) pen_net = simulation.calculate('pen_net', period) abatsalpen = simulation.legislation_at(period.start).ir.tspr.abatsalpen return period, min_(abatsalpen.taux * max_(salcho_imp + pen_net, 0), abatsalpen.max) @reference_formula class sal_pen_net(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Salaires et pensions après abattement de 20% sur les salaires" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') salcho_imp = simulation.calculate('salcho_imp', period) pen_net = simulation.calculate('pen_net', period) abat_sal_pen = simulation.calculate('abat_sal_pen', period) return period, salcho_imp + pen_net - abat_sal_pen @reference_formula class rto(SimpleFormulaColumn): """Rentes viagères à titre onéreux (avant abattements) Annuel pour les impôts mais mensuel pour la base ressource des minimas sociaux donc mensuel. """ calculate_output = calculate_output_add column = FloatCol entity_class = FoyersFiscaux label = u"Rentes viagères (rentes à titre onéreux)" set_input = set_input_divide_by_period url = u"http://fr.wikipedia.org/wiki/Rente_viagère" def function(self, simulation, period): year = period.start.period(u'year').offset('first-of') period = period.start.offset('first-of', 'month').period('month') f1aw = simulation.calculate('f1aw', year) f1bw = simulation.calculate('f1bw', year) f1cw = simulation.calculate('f1cw', year) f1dw = simulation.calculate('f1dw', year) return period, (f1aw + f1bw + f1cw + f1dw) / 12 @reference_formula class rto_declarant1(EntityToPersonColumn): entity_class = Individus label = u"Rentes viagères (rentes à titre onéreux) (pour le premier déclarant du foyer fiscal)" role = VOUS variable = rto @reference_formula class rto_net(SimpleFormulaColumn): column = FloatCol entity_class = FoyersFiscaux label = u"Rentes viagères après abattements" url = u"http://www.lafinancepourtous.fr/Vie-professionnelle-et-retraite/Retraite/Epargne-retraite/La-rente-viagere/La-fiscalite-de-la-rente-viagere" # noqa def function(self, simulation, period): period = period.start.period(u'year').offset('first-of') f1aw = simulation.calculate('f1aw', period) f1bw = simulation.calculate('f1bw', period) f1cw = simulation.calculate('f1cw', period) f1dw = simulation.calculate('f1dw', period) abatviag = simulation.legislation_at(period.start).ir.tspr.abatviag return period, round(abatviag.taux1 * f1aw + abatviag.taux2 * f1bw + abatviag.taux3 * f1cw + abatviag.taux4 * f1dw) @reference_formula class rto_net_declarant1(EntityToPersonColumn): entity_class = Individus label = u"Rentes viagères après abattements (pour le premier déclarant du foyer fiscal)" role = VOUS variable = rto_net @reference_formula class tspr(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Traitements salaires pensions et rentes individuelles" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') sal_pen_net = simulation.calculate('sal_pen_net', period) # Quand tspr est calculé sur une année glissante, rto_net_declarant1 est calculé sur l'année légale # correspondante. rto_net_declarant1 = simulation.calculate('rto_net_declarant1', period.offset('first-of')) return period, sal_pen_net + rto_net_declarant1 @reference_formula class rev_cat_pv(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu catégoriel - Plus-values" start_date = date(2013, 1, 1) url = "http://www.insee.fr/fr/methodes/default.asp?page=definitions/revenus-categoriesl.htm" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') f3vg = simulation.calculate('f3vg', period) f3vh = simulation.calculate('f3vh', period) return period, f3vg - f3vh @reference_formula class rev_cat_tspr(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu catégoriel - Traitements, salaires, pensions et rentes" url = "http://www.insee.fr/fr/methodes/default.asp?page=definitions/revenus-categoriesl.htm" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') tspr_holder = simulation.compute('tspr', period) indu_plaf_abat_pen = simulation.calculate('indu_plaf_abat_pen', period) tspr = self.sum_by_entity(tspr_holder) return period, tspr + indu_plaf_abat_pen @reference_formula class deficit_rcm(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Deficit capitaux mobiliers" start_date = date(2009, 1, 1) url = "http://www.lefigaro.fr/impots/2008/04/25/05003-20080425ARTFIG00254-les-subtilites-des-revenus-de-capitaux-mobiliers-.php" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') f2aa = simulation.calculate('f2aa', period) f2al = simulation.calculate('f2al', period) f2am = simulation.calculate('f2am', period) f2an = simulation.calculate('f2an', period) f2aq = simulation.calculate('f2aq', period) f2ar = simulation.calculate('f2ar', period) _P = simulation.legislation_at(period.start) return period, f2aa + f2al + f2am + f2an + f2aq + f2ar @reference_formula class rev_cat_rvcm(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu catégoriel - Capitaux" url = "http://www.insee.fr/fr/methodes/default.asp?page=definitions/revenus-categoriesl.htm" @dated_function(start = date(2002, 1, 1), stop = date(2004, 12, 31)) def function_20020101_20041231(self, simulation, period): """ Revenus des valeurs et capitaux mobiliers """ period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) deficit_rcm = simulation.calculate('deficit_rcm', period) f2ch = simulation.calculate('f2ch', period) f2dc = simulation.calculate('f2dc', period) f2ts = simulation.calculate('f2ts', period) f2ca = simulation.calculate('f2ca', period) f2fu = simulation.calculate('f2fu', period) f2go = simulation.calculate('f2go', period) f2gr = simulation.calculate('f2gr', period) f2tr = simulation.calculate('f2tr', period) _P = simulation.legislation_at(period.start) finpfl = simulation.legislation_at(period.start).ir.autre.finpfl rvcm = simulation.legislation_at(period.start).ir.rvcm f2dc_bis = f2dc f2tr_bis = f2tr # # Calcul du revenu catégoriel # 1.2 Revenus des valeurs et capitaux mobiliers b12 = min_(f2ch, rvcm.abat_assvie * (1 + marpac)) TOT1 = f2ch - b12 # c12 # Part des frais s'imputant sur les revenus déclarés case DC den = ((f2dc_bis + f2ts) != 0) * (f2dc_bis + f2ts) + ((f2dc_bis + f2ts) == 0) F1 = f2ca / den * f2dc_bis # f12 # 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_bis * (1 - rvcm.abatmob_taux) - F1, 0) # partie positive g12b = max_(f2dc_bis * (1 - rvcm.abatmob_taux) - F1, 0) rev = g12b + f2gr + f2fu * (1 - rvcm.abatmob_taux) # Abattements, limité au revenu h12 = rvcm.abatmob * (1 + marpac) TOT2 = max_(0, rev - h12) # i121= -min_(0,rev - h12) # Part des frais s'imputant sur les revenus déclarés ligne TS F2 = f2ca - F1 TOT3 = (f2ts - F2) + f2go * rvcm.majGO + f2tr_bis - g12a DEF = deficit_rcm return period, max_(TOT1 + TOT2 + TOT3 - DEF, 0) @dated_function(start = date(2005, 1, 1), stop = date(2012, 12, 31)) def function_20050101_20121231(self, simulation, period): """ Revenus des valeurs et capitaux mobiliers """ period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) deficit_rcm = simulation.calculate('deficit_rcm', period) f2ch = simulation.calculate('f2ch', period) f2dc = simulation.calculate('f2dc', period) f2ts = simulation.calculate('f2ts', period) f2ca = simulation.calculate('f2ca', period) f2fu = simulation.calculate('f2fu', period) f2go = simulation.calculate('f2go', period) f2gr = simulation.calculate('f2gr', period) f2tr = simulation.calculate('f2tr', period) finpfl = simulation.legislation_at(period.start).ir.autre.finpfl rvcm = simulation.legislation_at(period.start).ir.rvcm # Add f2da to f2dc and f2ee to f2tr when no PFL f2dc_bis = f2dc f2tr_bis = f2tr # # Calcul du revenu catégoriel # 1.2 Revenus des valeurs et capitaux mobiliers b12 = min_(f2ch, rvcm.abat_assvie * (1 + marpac)) TOT1 = f2ch - b12 # c12 # Part des frais s'imputant sur les revenus déclarés case DC den = ((f2dc_bis + f2ts) != 0) * (f2dc_bis + f2ts) + ((f2dc_bis + f2ts) == 0) F1 = f2ca / den * f2dc_bis # f12 # 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_bis * (1 - rvcm.abatmob_taux) - F1, 0) # partie positive g12b = max_(f2dc_bis * (1 - rvcm.abatmob_taux) - F1, 0) rev = g12b + f2gr + f2fu * (1 - rvcm.abatmob_taux) # Abattements, limité au revenu h12 = rvcm.abatmob * (1 + marpac) TOT2 = max_(0, rev - h12) # i121= -min_(0,rev - h12) # Part des frais s'imputant sur les revenus déclarés ligne TS F2 = f2ca - F1 TOT3 = (f2ts - F2) + f2go * rvcm.majGO + f2tr_bis - g12a DEF = deficit_rcm return period, max_(TOT1 + TOT2 + TOT3 - DEF, 0) @dated_function(start = date(2013, 1, 1), stop = date(2015, 12, 31)) def function_20130101_20151231(self, simulation, period): """ Revenus des valeurs et capitaux mobiliers """ period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) deficit_rcm = simulation.calculate('deficit_rcm', period) f2ch = simulation.calculate('f2ch', period) f2dc = simulation.calculate('f2dc', period) f2ts = simulation.calculate('f2ts', period) f2ca = simulation.calculate('f2ca', period) f2fu = simulation.calculate('f2fu', period) f2go = simulation.calculate('f2go', period) f2tr = simulation.calculate('f2tr', period) f2da = simulation.calculate('f2da', period) f2ee = simulation.calculate('f2ee', period) finpfl = simulation.legislation_at(period.start).ir.autre.finpfl rvcm = simulation.legislation_at(period.start).ir.rvcm # Add f2da to f2dc and f2ee to f2tr when no PFL f2dc_bis = f2dc + f2da # TODO: l'abattement de 40% est déduit uniquement en l'absence de revenus déclarés case 2DA f2tr_bis = f2tr + f2ee # # Calcul du revenu catégoriel # 1.2 Revenus des valeurs et capitaux mobiliers b12 = min_(f2ch, rvcm.abat_assvie * (1 + marpac)) TOT1 = f2ch - b12 # c12 # Part des frais s'imputant sur les revenus déclarés case DC den = ((f2dc_bis + f2ts) != 0) * (f2dc_bis + f2ts) + ((f2dc_bis + f2ts) == 0) F1 = f2ca / den * f2dc_bis # f12 # 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_bis * (1 - rvcm.abatmob_taux) - F1, 0) # partie positive g12b = max_(f2dc_bis * (1 - rvcm.abatmob_taux) - F1, 0) rev = g12b + f2fu * (1 - rvcm.abatmob_taux) # Abattements, limité au revenu h12 = rvcm.abatmob * (1 + marpac) TOT2 = max_(0, rev - h12) # i121= -min_(0,rev - h12) # Part des frais s'imputant sur les revenus déclarés ligne TS F2 = f2ca - F1 TOT3 = (f2ts - F2) + f2go * rvcm.majGO + f2tr_bis - g12a DEF = deficit_rcm return period, max_(TOT1 + TOT2 + TOT3 - DEF, 0) @reference_formula class rfr_rvcm(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"rfr_rvcm" def function(self, simulation, period): ''' Abattements sur rvcm à réintégrer dans le revenu fiscal de référence ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f2dc = simulation.calculate('f2dc', period) f2ts = simulation.calculate('f2ts', period) f2ca = simulation.calculate('f2ca', period) f2gr = simulation.calculate('f2gr', period) f2fu = simulation.calculate('f2fu', period) f2da = simulation.calculate('f2da', period) finpfl = simulation.legislation_at(period.start).ir.autre.finpfl rvcm = simulation.legislation_at(period.start).ir.rvcm if finpfl: f2dc_bis = f2dc + f2da else: f2dc_bis = f2dc # Calcul de i121 # Part des frais s'imputant sur les revenus déclarés case DC den = ((f2dc_bis + f2ts) != 0) * (f2dc_bis + f2ts) + ((f2dc_bis + f2ts) == 0) F1 = f2ca / den * f2dc_bis # f12 # Revenus de capitaux mobiliers nets de frais, ouvrant droit à abattement # partie positive g12b = max_(f2dc_bis * (1 - rvcm.abatmob_taux) - F1, 0) rev = g12b + f2gr + f2fu * (1 - rvcm.abatmob_taux) # Abattements, limité au revenu h12 = rvcm.abatmob * (1 + marpac) i121 = - min_(0, rev - h12) return period, max_((rvcm.abatmob_taux) * (f2dc_bis + f2fu) - i121, 0) @reference_formula class rev_cat_rfon(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu catégoriel - Foncier" url = "http://www.insee.fr/fr/methodes/default.asp?page=definitions/revenus-categoriesl.htm" def function(self, simulation, period): """ Revenus fonciers TODO: add assert in validator """ period = period.start.offset('first-of', 'year').period('year') f4ba = simulation.calculate('f4ba', period) f4bb = simulation.calculate('f4bb', period) f4bc = simulation.calculate('f4bc', period) f4bd = simulation.calculate('f4bd', period) f4be = simulation.calculate('f4be', period) microfoncier = simulation.legislation_at(period.start).ir.microfoncier # # Calcul du revenu catégoriel if ((f4be != 0) & ((f4ba != 0) | (f4bb != 0) | (f4bc != 0))).any(): log.error(("Problème de déclarations des revenus : incompatibilité de la déclaration des revenus fonciers (f4ba, f4bb, f4bc) et microfonciers (f4be)")) a13 = f4ba + f4be - microfoncier.taux * f4be * (f4be <= microfoncier.max) b13 = f4bb c13 = a13 - b13 d13 = f4bc e13 = c13 - d13 * (c13 >= 0) f13 = f4bd * (e13 >= 0) g13 = max_(0, e13 - f13) rev_cat_rfon = (c13 >= 0) * (g13 + e13 * (e13 < 0)) - (c13 < 0) * d13 return period, rev_cat_rfon @reference_formula class rev_cat_rpns(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu catégoriel - Rpns" url = "http://www.insee.fr/fr/methodes/default.asp?page=definitions/revenus-categoriesl.htm" def function(self, simulation, period): ''' Revenus personnels non salariés 'foy' ''' period = period.start.offset('first-of', 'year').period('year') nbnc_pvce_holder = simulation.compute('nbnc_pvce', period) mbic_mvct = simulation.calculate('mbic_mvct', period) rpns_i_holder = simulation.compute('rpns_i', period) defrag = simulation.calculate('defrag', period) defacc = simulation.calculate('defacc', period) defncn = simulation.calculate('defncn', period) defmeu = simulation.calculate('defmeu', period) return period, ( self.sum_by_entity(rpns_i_holder) - self.sum_by_entity(nbnc_pvce_holder) - defrag - defncn - defacc - defmeu - mbic_mvct ) @reference_formula class rev_cat(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenus catégoriels" url = "http://www.insee.fr/fr/methodes/default.asp?page=definitions/revenus-categoriesl.htm" def function(self, simulation, period): ''' Revenus Categoriels ''' period = period.start.offset('first-of', 'year').period('year') rev_cat_tspr = simulation.calculate('rev_cat_tspr', period) rev_cat_rvcm = simulation.calculate('rev_cat_rvcm', period) rev_cat_rfon = simulation.calculate('rev_cat_rfon', period) rev_cat_rpns = simulation.calculate('rev_cat_rpns', period) rev_cat_pv = simulation.calculate('rev_cat_pv', period) return period, rev_cat_tspr + rev_cat_rvcm + rev_cat_rfon + rev_cat_rpns + rev_cat_pv ############################################################################### # # Déroulé du calcul de l'irpp ############################################################################### @reference_formula class deficit_ante(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Déficit global antérieur" url = "http://impotsurlerevenu.org/declaration-de-revenus-fonciers-2044/796-deficits-anterieurs-restant-a-imputer-cadre-450.php" def function(self, simulation, period): ''' Déficits antérieurs ''' period = period.start.offset('first-of', 'year').period('year') f6fa = simulation.calculate('f6fa', period) f6fb = simulation.calculate('f6fb', period) f6fc = simulation.calculate('f6fc', period) f6fd = simulation.calculate('f6fd', period) f6fe = simulation.calculate('f6fe', period) f6fl = simulation.calculate('f6fl', period) return period, f6fa + f6fb + f6fc + f6fd + f6fe + f6fl @reference_formula class rbg(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu brut global" url = "http://www.documentissime.fr/dossiers-droit-pratique/dossier-19-l-impot-sur-le-revenu-les-modalites-generales-d-imposition/la-determination-du-revenu-imposable/le-revenu-brut-global.html" def function(self, simulation, period): '''Revenu brut global ''' period = period.start.offset('first-of', 'year').period('year') rev_cat = simulation.calculate('rev_cat', period) deficit_ante = simulation.calculate('deficit_ante', period) f6gh = simulation.calculate('f6gh', period) nbic_impm_holder = simulation.compute('nbic_impm', period) nacc_pvce_holder = simulation.compute('nacc_pvce', period) cga = simulation.legislation_at(period.start).ir.rpns.cga_taux2 # (Total 17) # sans les revenus au quotient nacc_pvce = self.sum_by_entity(nacc_pvce_holder) return period, max_(0, rev_cat + f6gh + (self.sum_by_entity(nbic_impm_holder) + nacc_pvce) * (1 + cga) - deficit_ante) @reference_formula class csg_deduc_patrimoine(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Csg déductible sur le patrimoine" url = "http://www.impots.gouv.fr/portal/dgi/public/particuliers.impot?pageId=part_ctrb_soc&typePage=cpr02&sfid=503&espId=1&communaute=1&impot=CS" def function(self, simulation, period): ''' CSG déductible sur les revenus du patrimoine http://bofip.impots.gouv.fr/bofip/887-PGP ''' period = period.start.offset('first-of', 'year').period('year') f6de = simulation.calculate('f6de', period) return period, max_(f6de, 0) @reference_formula class csg_deduc_patrimoine_simulated(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Csg déductible sur le patrimoine simulée" url = "http://www.impots.gouv.fr/portal/dgi/public/particuliers.impot?pageId=part_ctrb_soc&typePage=cpr02&sfid=503&espId=1&communaute=1&impot=CS" def function(self, simulation, period): ''' Cette fonction simule le montant mentionné dans la case f6de de la déclaration 2042 http://bofip.impots.gouv.fr/bofip/887-PGP ''' period = period.start.offset('first-of', 'year').period('year') rev_cat_rfon = simulation.calculate('rev_cat_rfon', period) rev_cap_bar = simulation.calculate('rev_cap_bar', period) rto = simulation.calculate('rto', period) taux = simulation.legislation_at(period.start).csg.capital.deduc patrimoine_deduc = rev_cat_rfon + rev_cap_bar + rto return period, taux * patrimoine_deduc @reference_formula class csg_deduc(SimpleFormulaColumn): # f6de column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Csg déductible sur le patrimoine" url = "http://www.impots.gouv.fr/portal/dgi/public/particuliers.impot?pageId=part_ctrb_soc&typePage=cpr02&sfid=503&espId=1&communaute=1&impot=CS" def function(self, simulation, period): ''' CSG déductible ''' period = period.start.offset('first-of', 'year').period('year') rbg = simulation.calculate('rbg', period) csg_deduc_patrimoine = simulation.calculate('csg_deduc_patrimoine', period) # min_(f6de, max_(rbg, 0)) return period, min_(csg_deduc_patrimoine, max_(rbg, 0)) @reference_formula class rng(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu net global" url = "http://impotsurlerevenu.org/definitions/114-revenu-net-global.php" def function(self, simulation, period): ''' Revenu net global (total 20) ''' period = period.start.offset('first-of', 'year').period('year') rbg = simulation.calculate('rbg', period) csg_deduc = simulation.calculate('csg_deduc', period) charges_deduc = simulation.calculate('charges_deduc', period) return period, max_(0, rbg - csg_deduc - charges_deduc) @reference_formula class rni(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu net imposable" url = "http://impotsurlerevenu.org/definitions/115-revenu-net-imposable.php" def function(self, simulation, period): ''' Revenu net imposable ou déficit à reporter''' period = period.start.offset('first-of', 'year').period('year') rng = simulation.calculate('rng', period) abat_spe = simulation.calculate('abat_spe', period) return period, rng - abat_spe @reference_formula class ir_brut(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Impot sur le revenu brut avant non imposabilité et plafonnement du quotient" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('year') nbptr = simulation.calculate('nbptr', period) taux_effectif = simulation.calculate('taux_effectif', period) rni = simulation.calculate('rni', period) bareme = simulation.legislation_at(period.start).ir.bareme return period, (taux_effectif == 0) * nbptr * bareme.calc(rni / nbptr) + taux_effectif * rni @reference_formula class ir_ss_qf(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"ir_ss_qf" def function(self, simulation, period): ''' Impôt sans quotient familial ''' period = period.start.offset('first-of', 'year').period('year') ir_brut = simulation.calculate('ir_brut', period) rni = simulation.calculate('rni', period) nb_adult = simulation.calculate('nb_adult', period) bareme = simulation.legislation_at(period.start).ir.bareme A = bareme.calc(rni / nb_adult) return period, nb_adult * A @reference_formula class ir_plaf_qf(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"ir_plaf_qf" def function(self, simulation, period): ''' Impôt après plafonnement du quotient familial et réduction complémentaire ''' period = period.start.offset('first-of', 'year').period('year') ir_brut = simulation.calculate('ir_brut', period) ir_ss_qf = simulation.calculate('ir_ss_qf', period) nb_adult = simulation.calculate('nb_adult', period) nb_pac = simulation.calculate('nb_pac', period) nbptr = simulation.calculate('nbptr', period) marpac = simulation.calculate('marpac', period) veuf = simulation.calculate('veuf', period) jveuf = simulation.calculate('jveuf', period) celdiv = simulation.calculate('celdiv', period) caseE = simulation.calculate('caseE', period) caseF = simulation.calculate('caseF', period) caseG = simulation.calculate('caseG', period) caseH = simulation.calculate('caseH', period) caseK = simulation.calculate('caseK', period) caseN = simulation.calculate('caseN', period) caseP = simulation.calculate('caseP', period) caseS = simulation.calculate('caseS', period) caseT = simulation.calculate('caseT', period) caseW = simulation.calculate('caseW', period) nbF = simulation.calculate('nbF', period) nbG = simulation.calculate('nbG', period) nbH = simulation.calculate('nbH', period) nbI = simulation.calculate('nbI', period) nbR = simulation.calculate('nbR', period) plafond_qf = simulation.legislation_at(period.start).ir.plafond_qf A = ir_ss_qf I = ir_brut aa0 = (nbptr - nb_adult) * 2 # nombre de demi part excédant nbadult # on dirait que les impôts font une erreur sur aa1 (je suis obligé de # diviser par 2) aa1 = min_((nbptr - 1) * 2, 2) / 2 # deux première demi part excédants une part aa2 = max_((nbptr - 2) * 2, 0) # nombre de demi part restantes # celdiv parents isolés condition61 = celdiv & caseT B1 = plafond_qf.celib_enf * aa1 + plafond_qf.marpac * aa2 # tous les autres B2 = plafond_qf.marpac * aa0 # si autre # celdiv, veufs (non jveuf) vivants seuls et autres conditions # TODO: année en dur... pour caseH condition63 = (celdiv | (veuf & not_(jveuf))) & not_(caseN) & (nb_pac == 0) & (caseK | caseE) & (caseH < 1981) B3 = plafond_qf.celib B = B1 * condition61 + \ B2 * (not_(condition61 | condition63)) + \ B3 * (condition63 & not_(condition61)) C = max_(0, A - B) # Impôt après plafonnement IP0 = max_(I, C) # 6.2 réduction d'impôt pratiquée sur l'impot après plafonnement et le cas particulier des DOM # pas de réduction complémentaire condition62a = (I >= C) # réduction complémentaire condition62b = (I < C) # celdiv veuf condition62caa0 = (celdiv | (veuf & not_(jveuf))) condition62caa1 = (nb_pac == 0) & (caseP | caseG | caseF | caseW) condition62caa2 = caseP & ((nbF - nbG > 0) | (nbH - nbI > 0)) condition62caa3 = not_(caseN) & (caseE | caseK) & (caseH >= 1981) condition62caa = condition62caa0 & (condition62caa1 | condition62caa2 | condition62caa3) # marié pacs condition62cab = (marpac | jveuf) & caseS & not_(caseP | caseF) condition62ca = (condition62caa | condition62cab) # plus de 590 euros si on a des plus de condition62cb = ((nbG + nbR + nbI) > 0) | caseP | caseF D = plafond_qf.reduc_postplafond * (condition62ca + ~condition62ca * condition62cb * ( 1 * caseP + 1 * caseF + nbG + nbR + nbI / 2)) E = max_(0, A - I - B) Fo = D * (D <= E) + E * (E < D) IP1 = IP0 - Fo # TODO: 6.3 Cas particulier: Contribuables domiciliés dans les DOM. # conditionGuadMarReu = # conditionGuyane= # conitionDOM = conditionGuadMarReu | conditionGuyane # postplafGuadMarReu = 5100 # postplafGuyane = 6700 # IP2 = IP1 - conditionGuadMarReu*min( postplafGuadMarReu,.3*IP1) - conditionGuyane*min(postplafGuyane,.4*IP1) # Récapitulatif return period, condition62a * IP0 + condition62b * IP1 # IP2 si DOM @reference_formula class avantage_qf(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"avantage_qf" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') ir_ss_qf = simulation.calculate('ir_ss_qf', period) ir_plaf_qf = simulation.calculate('ir_plaf_qf', period) return period, ir_ss_qf - ir_plaf_qf @reference_formula class decote(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"décote" @dated_function(start = date(2001, 1, 1), stop = date(2013, 12, 31)) def function_2001_2013(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') ir_plaf_qf = simulation.calculate('ir_plaf_qf', period) decote = simulation.legislation_at(period.start).ir.decote return period, (ir_plaf_qf < decote.seuil) * (decote.seuil - ir_plaf_qf) * 0.5 @dated_function(start = date(2014, 1, 1)) def function_2014__(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') ir_plaf_qf = simulation.calculate('ir_plaf_qf', period) nb_adult = simulation.calculate('nb_adult', period) decote_seuil_celib = simulation.legislation_at(period.start).ir.decote.seuil_celib decote_seuil_couple = simulation.legislation_at(period.start).ir.decote.seuil_couple decote_celib = (ir_plaf_qf < decote_seuil_celib) * (decote_seuil_celib - ir_plaf_qf) decote_couple = (ir_plaf_qf < decote_seuil_couple) * (decote_seuil_couple - ir_plaf_qf) return period, (nb_adult == 1) * decote_celib + (nb_adult == 2) * decote_couple @reference_formula class decote_gain_fiscal(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Gain fiscal de la décote/Décote au sens Dgfip tel que sur la feuille d'impôt" start_date = date(1982, 1, 1) def function(self, simulation, period): ''' Renvoie le gain fiscal du à la décote ''' period = period.start.offset('first-of', 'year').period('year') decote = simulation.calculate('decote', period) ir_plaf_qf = simulation.calculate('ir_plaf_qf', period) return period, min_(decote, ir_plaf_qf) @reference_formula class nat_imp(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = FoyersFiscaux label = u"nat_imp" def function(self, simulation, period): ''' Renvoie True si le foyer est imposable, False sinon ''' period = period.start.offset('first-of', 'year').period('year') iai = simulation.calculate('iai', period) credits_impot = simulation.calculate('credits_impot', period) cehr = simulation.calculate('cehr', period) # def _nat_imp(rni, nbptr, non_imposable = law.ir.non_imposable): # seuil = non_imposable.seuil + (nbptr - 1)*non_imposable.supp return period, (iai - credits_impot + cehr) > 0 @reference_formula class ip_net(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"ip_net" def function(self, simulation, period): ''' irpp après décote ''' period = period.start.offset('first-of', 'year').period('year') ir_plaf_qf = simulation.calculate('ir_plaf_qf', period) cncn_info_holder = simulation.compute('cncn_info', period) decote = simulation.calculate('decote', period) taux = simulation.legislation_at(period.start).ir.rpns.taux16 return period, max_(0, ir_plaf_qf + self.sum_by_entity(cncn_info_holder) * taux - decote) @reference_formula class iaidrdi(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"iaidrdi" def function(self, simulation, period): ''' Impôt après imputation des réductions d'impôt ''' period = period.start.offset('first-of', 'year').period('year') ip_net = simulation.calculate('ip_net', period) reductions = simulation.calculate('reductions', period) return period, ip_net - reductions @reference_formula class cont_rev_loc(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"cont_rev_loc" start_date = date(2001, 1, 1) def function(self, simulation, period): ''' Contribution sur les revenus locatifs ''' period = period.start.offset('first-of', 'year').period('year') f4bl = simulation.calculate('f4bl', period) crl = simulation.legislation_at(period.start).ir.crl return period, round(crl.taux * (f4bl >= crl.seuil) * f4bl) @reference_formula class teicaa(SimpleFormulaColumn): # f5rm column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"teicaa" def function(self, simulation, period): """ Taxe exceptionelle sur l'indemnité compensatrice des agents d'assurance """ period = period.start.offset('first-of', 'year').period('year') f5qm_holder = simulation.compute('f5qm', period) bareme = simulation.legislation_at(period.start).ir.teicaa f5qm = self.filter_role(f5qm_holder, role = VOUS) f5rm = self.filter_role(f5qm_holder, role = CONJ) return period, bareme.calc(f5qm) + bareme.calc(f5rm) @reference_formula class assiette_vente(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"assiette_vente" start_date = date(2009, 1, 1) def function(self, simulation, period): ''' Assiette régime microsociale pour les ventes ''' period = period.start.offset('first-of', 'year').period('year') ebic_impv_holder = simulation.compute('ebic_impv', period) return period, self.sum_by_entity(ebic_impv_holder) @reference_formula class assiette_service(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"assiette_service" start_date = date(2009, 1, 1) def function(self, simulation, period): ''' Assiette régime microsociale pour les prestations et services ''' period = period.start.offset('first-of', 'year').period('year') ebic_imps_holder = simulation.compute('ebic_imps', period) return period, self.sum_by_entity(ebic_imps_holder) # P = _P.ir.rpns.microentreprise # assert (ebic_imps <= P.servi.max) @reference_formula class assiette_proflib(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"assiette_proflib" start_date = date(2009, 1, 1) def function(self, simulation, period): ''' Assiette régime microsociale pour les professions libérales ''' period = period.start.offset('first-of', 'year').period('year') ebnc_impo_holder = simulation.compute('ebnc_impo', period) P = simulation.legislation_at(period.start).ir.rpns.microentreprise # TODO: distinction RSI/CIPAV (pour les cotisations sociales) # http://vosdroits.service-public.fr/professionnels-entreprises/F23267.xhtml return period, self.sum_by_entity(ebnc_impo_holder) # assert (ebnc_impo <= P.specialbnc.max) @reference_formula class microsocial(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"microsocial" start_date = date(2009, 1, 1) url = "http://fr.wikipedia.org/wiki/R%C3%A9gime_micro-social" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') assiette_service = simulation.calculate('assiette_service', period) assiette_vente = simulation.calculate('assiette_vente', period) assiette_proflib = simulation.calculate('assiette_proflib', period) microsocial = simulation.legislation_at(period.start).ir.rpns.microsocial return period, ( assiette_service * microsocial.servi + assiette_vente * microsocial.vente + assiette_proflib * microsocial.bnc ) @reference_formula class microentreprise(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"microentreprise" start_date = date(2009, 1, 1) def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') ebnc_impo_holder = simulation.compute('ebnc_impo', period) ebic_imps_holder = simulation.compute('ebic_imps', period) ebic_impv_holder = simulation.compute('ebic_impv', period) me = simulation.legislation_at(period.start).ir.rpns.microentreprise ebnc_impo = self.sum_by_entity(ebnc_impo_holder) ebic_imps = self.sum_by_entity(ebic_imps_holder) ebic_impv = self.sum_by_entity(ebic_impv_holder) return period, ( ebnc_impo * (1 - me.specialbnc.taux) + ebic_imps * (1 - me.servi.taux) + ebic_impv * (1 - me.vente.taux) ) @reference_formula class plus_values(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"plus_values" @dated_function(start = date(2007, 1, 1), stop = date(2007, 12, 31)) def function_20070101_20071231(self, simulation, period): # f3sd is in f3vd holder """ Taxation des plus value TODO: f3vt, 2013 f3Vg au barème / tout refaire """ period = period.start.offset('first-of', 'year').period('year') f3vg = simulation.calculate('f3vg', period) f3vh = simulation.calculate('f3vh', period) f3vl = simulation.calculate('f3vl', period) f3vm = simulation.calculate('f3vm', period) f3vi_holder = simulation.compute('f3vi', period) f3vf_holder = simulation.compute('f3vf', period) f3vd_holder = simulation.compute('f3vd', period) rpns_pvce_holder = simulation.compute('rpns_pvce', period) _P = simulation.legislation_at(period.start) plus_values = simulation.legislation_at(period.start).ir.plus_values rpns_pvce = self.sum_by_entity(rpns_pvce_holder) f3vd = self.filter_role(f3vd_holder, role = VOUS) f3sd = self.filter_role(f3vd_holder, role = CONJ) f3vi = self.filter_role(f3vi_holder, role = VOUS) f3si = self.filter_role(f3vi_holder, role = CONJ) f3vf = self.filter_role(f3vf_holder, role = VOUS) f3sf = self.filter_role(f3vf_holder, role = CONJ) # TODO: remove this todo use sum for all fields after checking # revenus taxés à un taux proportionnel rdp = max_(0, f3vg - f3vh) + f3vl + rpns_pvce + f3vm + f3vi + f3vf out = (plus_values.pvce * rpns_pvce + plus_values.taux1 * max_(0, f3vg - f3vh) + plus_values.caprisque * f3vl + plus_values.pea * f3vm + plus_values.taux3 * f3vi + plus_values.taux4 * f3vf) return period, round(out) @dated_function(start = date(2008, 1, 1), stop = date(2011, 12, 31)) def function_20080101_20111231(self, simulation, period): # f3sd is in f3vd holder """ Taxation des plus value TODO: f3vt, 2013 f3Vg au barème / tout refaire """ period = period.start.offset('first-of', 'year').period('year') f3vg = simulation.calculate('f3vg', period) f3vh = simulation.calculate('f3vh', period) f3vl = simulation.calculate('f3vl', period) f3vm = simulation.calculate('f3vm', period) f3vi_holder = simulation.compute('f3vi', period) f3vf_holder = simulation.compute('f3vf', period) f3vd_holder = simulation.compute('f3vd', period) rpns_pvce_holder = simulation.compute('rpns_pvce', period) plus_values = simulation.legislation_at(period.start).ir.plus_values rpns_pvce = self.sum_by_entity(rpns_pvce_holder) f3vd = self.filter_role(f3vd_holder, role = VOUS) f3sd = self.filter_role(f3vd_holder, role = CONJ) f3vi = self.filter_role(f3vi_holder, role = VOUS) f3si = self.filter_role(f3vi_holder, role = CONJ) f3vf = self.filter_role(f3vf_holder, role = VOUS) f3sf = self.filter_role(f3vf_holder, role = CONJ) # TODO: remove this todo use sum for all fields after checking # revenus taxés à un taux proportionnel rdp = max_(0, f3vg - f3vh) + f3vl + rpns_pvce + f3vm + f3vi + f3vf out = (plus_values.pvce * rpns_pvce + plus_values.taux1 * max_(0, f3vg - f3vh) + plus_values.caprisque * f3vl + plus_values.pea * f3vm + plus_values.taux3 * f3vi + plus_values.taux4 * f3vf) # revenus taxés à un taux proportionnel rdp += f3vd out += plus_values.taux1 * f3vd return period, round(out) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): # f3sd is in f3vd holder """ Taxation des plus value TODO: f3vt, 2013 f3Vg au barème / tout refaire """ period = period.start.offset('first-of', 'year').period('year') f3vg = simulation.calculate('f3vg', period) f3vh = simulation.calculate('f3vh', period) f3vl = simulation.calculate('f3vl', period) f3vm = simulation.calculate('f3vm', period) f3vi_holder = simulation.compute('f3vi', period) f3vf_holder = simulation.compute('f3vf', period) f3vd_holder = simulation.compute('f3vd', period) rpns_pvce_holder = simulation.compute('rpns_pvce', period) plus_values = simulation.legislation_at(period.start).ir.plus_values rpns_pvce = self.sum_by_entity(rpns_pvce_holder) f3vd = self.filter_role(f3vd_holder, role = VOUS) f3sd = self.filter_role(f3vd_holder, role = CONJ) f3vi = self.filter_role(f3vi_holder, role = VOUS) f3si = self.filter_role(f3vi_holder, role = CONJ) f3vf = self.filter_role(f3vf_holder, role = VOUS) f3sf = self.filter_role(f3vf_holder, role = CONJ) # TODO: remove this todo use sum for all fields after checking # revenus taxés à un taux proportionnel rdp = max_(0, f3vg - f3vh) + f3vl + rpns_pvce + f3vm + f3vi + f3vf out = (plus_values.pvce * rpns_pvce + plus_values.taux1 * max_(0, f3vg - f3vh) + plus_values.caprisque * f3vl + plus_values.pea * f3vm + plus_values.taux3 * f3vi + plus_values.taux4 * f3vf) # revenus taxés à un taux proportionnel rdp += f3vd out += plus_values.taux1 * f3vd # out = plus_values.taux2 * f3vd + plus_values.taux3 * f3vi + plus_values.taux4 * f3vf + plus_values.taux1 *max_( # 0, f3vg - f3vh) out = (plus_values.taux2 * (f3vd + f3sd) + plus_values.taux3 * (f3vi + f3si) + plus_values.taux4 * (f3vf + f3sf) + plus_values.taux1 * max_(0, f3vg - f3vh) + plus_values.pvce * rpns_pvce) # TODO: chek this rpns missing ? return period, round(out) @dated_function(start = date(2013, 1, 1), stop = date(2015, 12, 31)) def function_20130101_20151231(self, simulation, period): # f3sd is in f3vd holder """ Taxation des plus value TODO: f3vt, 2013 f3Vg au barème / tout refaire """ period = period.start.offset('first-of', 'year').period('year') f3vg = simulation.calculate('f3vg', period) f3vh = simulation.calculate('f3vh', period) f3vl = simulation.calculate('f3vl', period) f3vm = simulation.calculate('f3vm', period) f3vi_holder = simulation.compute('f3vi', period) f3vf_holder = simulation.compute('f3vf', period) f3vd_holder = simulation.compute('f3vd', period) f3sa = simulation.calculate('f3sa', period) rpns_pvce_holder = simulation.compute('rpns_pvce', period) _P = simulation.legislation_at(period.start) plus_values = simulation.legislation_at(period.start).ir.plus_values rpns_pvce = self.sum_by_entity(rpns_pvce_holder) f3vd = self.filter_role(f3vd_holder, role = VOUS) f3sd = self.filter_role(f3vd_holder, role = CONJ) f3vi = self.filter_role(f3vi_holder, role = VOUS) f3si = self.filter_role(f3vi_holder, role = CONJ) f3vf = self.filter_role(f3vf_holder, role = VOUS) f3sf = self.filter_role(f3vf_holder, role = CONJ) # TODO: remove this todo use sum for all fields after checking # revenus taxés à un taux proportionnel rdp = max_(0, f3vg - f3vh) + f3vl + rpns_pvce + f3vm + f3vi + f3vf out = (plus_values.pvce * rpns_pvce + plus_values.taux1 * max_(0, f3vg - f3vh) + plus_values.caprisque * f3vl + plus_values.pea * f3vm + plus_values.taux3 * f3vi + plus_values.taux4 * f3vf) # revenus taxés à un taux proportionnel rdp += f3vd out += plus_values.taux1 * f3vd # out = plus_values.taux2 * f3vd + plus_values.taux3 * f3vi + plus_values.taux4 * f3vf + plus_values.taux1 * max_( # 0, f3vg - f3vh) out = (plus_values.taux2 * (f3vd + f3sd) + plus_values.taux3 * (f3vi + f3si) + plus_values.taux4 * (f3vf + f3sf) + plus_values.taux1 * max_(0, - f3vh) + plus_values.pvce * (rpns_pvce + f3sa)) # TODO: chek this 3VG return period, round(out) @reference_formula class iai(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Impôt avant imputations" url = "http://forum-juridique.net-iris.fr/finances-fiscalite-assurance/43963-declaration-impots.html" def function(self, simulation, period): ''' impôt avant imputation de l'irpp ''' period = period.start.offset('first-of', 'year').period('year') iaidrdi = simulation.calculate('iaidrdi', period) plus_values = simulation.calculate('plus_values', period) cont_rev_loc = simulation.calculate('cont_rev_loc', period) teicaa = simulation.calculate('teicaa', period) return period, iaidrdi + plus_values + cont_rev_loc + teicaa @reference_formula class cehr(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Contribution exceptionnelle sur les hauts revenus" url = "http://www.legifrance.gouv.fr/affichCode.do?cidTexte=LEGITEXT000006069577&idSectionTA=LEGISCTA000025049019" def function(self, simulation, period): ''' Contribution exceptionnelle sur les hauts revenus 'foy' ''' period = period.start.offset('first-of', 'year').period('year') rfr = simulation.calculate('rfr', period) nb_adult = simulation.calculate('nb_adult', period) bareme = simulation.legislation_at(period.start).ir.cehr return period, bareme.calc(rfr / nb_adult) * nb_adult @reference_formula class irpp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Impôt sur le revenu des personnes physiques" url = "http://www.impots.gouv.fr/portal/dgi/public/particuliers.impot?pageId=part_impot_revenu&espId=1&impot=IR&sfid=50" def function(self, simulation, period): ''' Montant après seuil de recouvrement (hors ppe) ''' period = period.start.offset('first-of', 'year').period('year') iai = simulation.calculate('iai', period) credits_impot = simulation.calculate('credits_impot', period) cehr = simulation.calculate('cehr', period) P = simulation.legislation_at(period.start).ir.recouvrement # TODO: crade ? pre_result = iai - credits_impot + cehr return period, ((iai > P.seuil) * ((pre_result < P.min) * (pre_result > 0) * iai * 0 + ((pre_result <= 0) + (pre_result >= P.min)) * (- pre_result)) + (iai <= P.seuil) * ((pre_result < 0) * (-pre_result) + (pre_result >= 0) * 0 * iai)) ############################################################################### # # Autres totaux utiles pour la suite ############################################################################### @reference_formula class pensions_alimentaires_versees(SimpleFormulaColumn): column = FloatCol entity_class = FoyersFiscaux label = u"Pensions alimentaires versées" url = u"http://vosdroits.service-public.fr/particuliers/F2.xhtml" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') f6gi = simulation.calculate('f6gi', period) f6gj = simulation.calculate('f6gj', period) f6el = simulation.calculate('f6el', period) f6em = simulation.calculate('f6em', period) f6gp = simulation.calculate('f6gp', period) f6gu = simulation.calculate('f6gu', period) return period, -(f6gi + f6gj + f6el + f6em + f6gp + f6gu) @reference_formula class pensions_alimentaires_versees_declarant1(EntityToPersonColumn): entity_class = Individus label = u"Pensions alimentaires versées (pour le premier déclarant du foyer fiscal)" role = VOUS variable = pensions_alimentaires_versees @reference_formula class rfr(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Revenu fiscal de référence" def function(self, simulation, period): ''' Revenu fiscal de référence f3vg -> rev_cat_pv -> ... -> rni ''' period = period.start.offset('first-of', 'year').period('year') rni = simulation.calculate('rni', period) f3va_holder = simulation.compute('f3va', period) f3vi_holder = simulation.compute('f3vi', period) rfr_cd = simulation.calculate('rfr_cd', period) rfr_rvcm = simulation.calculate('rfr_rvcm', period) rpns_exon_holder = simulation.compute('rpns_exon', period) rpns_pvce_holder = simulation.compute('rpns_pvce', period) rev_cap_lib = simulation.calculate_add('rev_cap_lib', period) f3vz = simulation.calculate('f3vz', period) microentreprise = simulation.calculate('microentreprise', period) f3va = self.sum_by_entity(f3va_holder) f3vi = self.sum_by_entity(f3vi_holder) rpns_exon = self.sum_by_entity(rpns_exon_holder) rpns_pvce = self.sum_by_entity(rpns_pvce_holder) return period, (max_(0, rni) + rfr_cd + rfr_rvcm + rev_cap_lib + f3vi + rpns_exon + rpns_pvce + f3va + f3vz + microentreprise) @reference_formula class glo(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Gain de levée d'options" url = "http://www.officeo.fr/imposition-au-bareme-progressif-de-l-impot-sur-le-revenu-des-gains-de-levee-d-options-sur-actions-et-attributions-d-actions-gratuites" def function(self, simulation, period): ''' Gains de levée d'option ''' period = period.start.offset('first-of', 'year').period('year') f1tv = simulation.calculate('f1tv', period) f1tw = simulation.calculate('f1tw', period) f1tx = simulation.calculate('f1tx', period) f3vf = simulation.calculate('f3vf', period) f3vi = simulation.calculate('f3vi', period) f3vj = simulation.calculate('f3vj', period) return period, f1tv + f1tw + f1tx + f3vf + f3vi + f3vj @reference_formula class rev_cap_bar(SimpleFormulaColumn): """Revenus du capital imposés au barème Annuel pour les impôts mais mensuel pour la base ressource des minimas sociaux donc mensuel. """ calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"rev_cap_bar" set_input = set_input_divide_by_period url = "http://fr.wikipedia.org/wiki/Revenu#Revenu_du_Capital" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') year = period.start.offset('first-of', 'year').period('year') f2dc = simulation.calculate('f2dc', year) f2gr = simulation.calculate('f2gr', year) f2ch = simulation.calculate('f2ch', year) f2ts = simulation.calculate('f2ts', year) f2go = simulation.calculate('f2go', year) f2tr = simulation.calculate('f2tr', year) f2fu = simulation.calculate('f2fu', year) avf = simulation.calculate('avf', year) f2da = simulation.calculate('f2da', year) f2ee = simulation.calculate('f2ee', year) finpfl = simulation.legislation_at(period.start).ir.autre.finpfl # TODO remove ad check case majGO = simulation.legislation_at(period.start).ir.rvcm.majGO # year = period.start.year # if year <= 2011: # return f2dc + f2gr + f2ch + f2ts + f2go + f2tr + f2fu - avf # elif year > 2011: # return f2dc + f2gr + f2ch + f2ts + f2go + f2tr + f2fu - avf + (f2da + f2ee) return period, (f2dc + f2gr + f2ch + f2ts + f2go * majGO + f2tr + f2fu - avf + (f2da + f2ee) * finpfl) / 12 # We add f2da an f2ee to allow for comparaison between years @reference_formula class rev_cap_lib(DatedFormulaColumn): '''Revenu du capital imposé au prélèvement libératoire Annuel pour les impôts mais mensuel pour la base ressource des minimas sociaux donc mensuel. ''' calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"rev_cap_lib" set_input = set_input_divide_by_period url = "http://fr.wikipedia.org/wiki/Revenu#Revenu_du_Capital" @dated_function(start = date(2002, 1, 1), stop = date(2007, 12, 31)) def function_20020101_20071231(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') year = period.start.offset('first-of', 'year').period('year') f2dh = simulation.calculate('f2dh', year) f2ee = simulation.calculate('f2ee', year) _P = simulation.legislation_at(period.start) finpfl = simulation.legislation_at(period.start).ir.autre.finpfl out = f2dh + f2ee return period, out * not_(finpfl) / 12 @dated_function(start = date(2008, 1, 1), stop = date(2015, 12, 31)) def function_20080101_20151231(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') year = period.start.offset('first-of', 'year').period('year') f2da = simulation.calculate('f2da', year) f2dh = simulation.calculate('f2dh', year) f2ee = simulation.calculate('f2ee', year) _P = simulation.legislation_at(period.start) finpfl = simulation.legislation_at(period.start).ir.autre.finpfl out = f2da + f2dh + f2ee return period, out * not_(finpfl) / 12 @reference_formula class avf(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"avf" def function(self, simulation, period): ''' Avoir fiscal et crédits d'impôt (zavff) ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) return period, f2ab @reference_formula class imp_lib(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"imp_lib" url = "http://www.impots.gouv.fr/portal/dgi/public/particuliers.impot?pageId=part_ctrb_soc&paf_dm=popup&paf_gm=content&typePage=cpr02&sfid=501&espId=1&impot=CS" @dated_function(start = date(2002, 1, 1), stop = date(2007, 12, 31)) def function_20020101_20071231(self, simulation, period): ''' Prelèvement libératoire sur les revenus du capital ''' period = period.start.offset('first-of', 'year').period('year') f2dh = simulation.calculate('f2dh', period) f2ee = simulation.calculate('f2ee', period) _P = simulation.legislation_at(period.start) prelevement_liberatoire = simulation.legislation_at(period.start).ir.rvcm.prelevement_liberatoire out = -(prelevement_liberatoire.assvie * f2dh + prelevement_liberatoire.autre * f2ee) return period, out @dated_function(start = date(2008, 1, 1), stop = date(2012, 12, 31)) def function_20080101_20121231(self, simulation, period): ''' Prelèvement libératoire sur les revenus du capital ''' period = period.start.offset('first-of', 'year').period('year') f2da = simulation.calculate('f2da', period) f2dh = simulation.calculate('f2dh', period) f2ee = simulation.calculate('f2ee', period) _P = simulation.legislation_at(period.start) finpfl = simulation.legislation_at(period.start).ir.autre.finpfl prelevement_liberatoire = simulation.legislation_at(period.start).ir.rvcm.prelevement_liberatoire out = -(prelevement_liberatoire.action * f2da + prelevement_liberatoire.autre * f2ee) * not_(finpfl) \ - prelevement_liberatoire.assvie * f2dh return period, out @reference_formula class fon(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"fon" url = "http://impotsurlerevenu.org/definitions/220-revenu-foncier.php" def function(self, simulation, period): ''' Revenus fonciers ''' period = period.start.offset('first-of', 'year').period('year') f4ba = simulation.calculate('f4ba', period) f4bb = simulation.calculate('f4bb', period) f4bc = simulation.calculate('f4bc', period) f4bd = simulation.calculate('f4bd', period) f4be = simulation.calculate('f4be', period) microfoncier = simulation.legislation_at(period.start).ir.microfoncier return period, f4ba - f4bb - f4bc + round(f4be * (1 - microfoncier.taux)) @reference_formula class rpns_pvce(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rpns_pvce" def function(self, simulation, period): ''' Plus values de cession 'ind' frag_pvce (f5hx, f5ix, f5jx) arag_pvce (f5he, f5ie, f5je) mbic_pvce (f5kq, f5lq, f5mq) abic_pvce (f5ke, f5le, f5me) macc_pvce (f5nq, f5oq, f5pq) aacc_pvce (f5ne, f5oe, f5pe) mncn_pvce (f5kv, f5lv, f5mv) cncn_pvce (f5so, f5nt, f5ot) mbnc_pvce (f5hr, f5ir, f5jr) abnc_pvce (f5qd, f5rd, f5sd) ''' period = period.start.offset('first-of', 'year').period('year') frag_pvce = simulation.calculate('frag_pvce', period) arag_pvce = simulation.calculate('arag_pvce', period) mbic_pvce = simulation.calculate('mbic_pvce', period) abic_pvce = simulation.calculate('abic_pvce', period) macc_pvce = simulation.calculate('macc_pvce', period) aacc_pvce = simulation.calculate('aacc_pvce', period) mbnc_pvce = simulation.calculate('mbnc_pvce', period) abnc_pvce = simulation.calculate('abnc_pvce', period) mncn_pvce = simulation.calculate('mncn_pvce', period) cncn_pvce = simulation.calculate('cncn_pvce', period) return period, (frag_pvce + arag_pvce + mbic_pvce + abic_pvce + macc_pvce + aacc_pvce + mbnc_pvce + abnc_pvce + mncn_pvce + cncn_pvce) @reference_formula class rpns_exon(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rpns_exon" def function(self, simulation, period): ''' Plus values de cession 'ind' frag_exon (f5hn, f5in, f5jn) arag_exon (f5hb, f5ib, f5jb) nrag_exon (f5hh, f5ih, f5jh) mbic_exon (f5kn, f5ln, f5mn) abic_exon (f5kb, f5lb, f5mb) nbic_exon (f5kh, f5lh, f5mh) macc_exon (f5nn, f5on, f5pn) aacc_exon (f5nb, f5ob, f5pb) nacc_exon (f5nh, f5oh, f5ph) mbnc_exon (f5hp, f5ip, f5jp) abnc_exon (f5qb, f5rb, f5sb) nbnc_exon (f5qh, f5rh, f5sh) nbnc_pvce (f5qj, f5rj, f5sj) ''' period = period.start.offset('first-of', 'year').period('year') frag_exon = simulation.calculate('frag_exon', period) arag_exon = simulation.calculate('arag_exon', period) nrag_exon = simulation.calculate('nrag_exon', period) mbic_exon = simulation.calculate('mbic_exon', period) abic_exon = simulation.calculate('abic_exon', period) nbnc_proc = simulation.calculate('nbnc_proc', period) nbic_exon = simulation.calculate('nbic_exon', period) macc_exon = simulation.calculate('macc_exon', period) aacc_exon = simulation.calculate('aacc_exon', period) nacc_exon = simulation.calculate('nacc_exon', period) mbnc_exon = simulation.calculate('mbnc_exon', period) abnc_proc = simulation.calculate('abnc_proc', period) nrag_pvce = simulation.calculate('nrag_pvce', period) abnc_exon = simulation.calculate('abnc_exon', period) nbnc_exon = simulation.calculate('nbnc_exon', period) mncn_exon = simulation.calculate('mncn_exon', period) cncn_exon = simulation.calculate('cncn_exon', period) cncn_jcre = simulation.calculate('cncn_jcre', period) cncn_info = simulation.calculate('cncn_info', period) nbic_pvce = simulation.calculate('nbic_pvce', period) cga = simulation.legislation_at(period.start).ir.rpns.cga_taux2 return period, (frag_exon + arag_exon + nrag_exon + mbic_exon + abic_exon + nbnc_proc * (1 + cga) + nbic_exon + macc_exon + aacc_exon + nacc_exon + mbnc_exon + abnc_proc + abnc_exon + nbnc_exon + mncn_exon + cncn_exon + cncn_jcre + cncn_info + nbic_pvce + nrag_pvce) @reference_formula class defrag(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Déficit agricole des années antérieures" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') f5qf = simulation.calculate('f5qf', period) f5qg = simulation.calculate('f5qg', period) f5qn = simulation.calculate('f5qn', period) f5qo = simulation.calculate('f5qo', period) f5qp = simulation.calculate('f5qp', period) f5qq = simulation.calculate('f5qq', period) frag_impo_holder = simulation.compute('frag_impo', period) nrag_impg_holder = simulation.compute('nrag_impg', period) frag_fore_holder = simulation.compute('frag_fore', period) frag_pvct_holder = simulation.compute('frag_pvct', period) arag_impg_holder = simulation.compute('arag_impg', period) cga = simulation.legislation_at(period.start).ir.rpns.cga_taux2 frag_fore = self.sum_by_entity(frag_fore_holder) frag_impo = self.sum_by_entity(frag_impo_holder) arag_impg = self.sum_by_entity(arag_impg_holder) nrag_impg = self.sum_by_entity(nrag_impg_holder) frag_pvct = self.sum_by_entity(frag_pvct_holder) return period, min_(f5qf + f5qg + f5qn + f5qo + f5qp + f5qq, (1 + cga) * (frag_impo + nrag_impg + frag_pvct) + arag_impg + frag_fore) @reference_formula class defacc(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Déficit industriels et commerciaux non professionnels des années antérieures" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') f5rn = simulation.calculate('f5rn', period) f5ro = simulation.calculate('f5ro', period) f5rp = simulation.calculate('f5rp', period) f5rq = simulation.calculate('f5rq', period) f5rr = simulation.calculate('f5rr', period) f5rw = simulation.calculate('f5rw', period) macc_impv_holder = simulation.compute('macc_impv', period) macc_imps_holder = simulation.compute('macc_imps', period) nacc_impn_holder = simulation.compute('nacc_impn', period) macc_pvct_holder = simulation.compute('macc_pvct', period) aacc_impn_holder = simulation.compute('aacc_impn', period) cga = simulation.legislation_at(period.start).ir.rpns.cga_taux2 microentreprise = simulation.legislation_at(period.start).ir.rpns.microentreprise def abat_rpns(rev, P): return max_(0, rev - min_(rev, max_(P.taux * min_(P.max, rev), P.min))) nacc_impn = self.sum_by_entity(nacc_impn_holder) macc_pvct = self.sum_by_entity(macc_pvct_holder) macc_impv = self.sum_by_entity(macc_impv_holder) macc_imps = self.sum_by_entity(macc_imps_holder) aacc_impn = self.sum_by_entity(aacc_impn_holder) macc_timp = abat_rpns(macc_impv, microentreprise.vente) + abat_rpns(macc_imps, microentreprise.servi) return period, ( min_(f5rn + f5ro + f5rp + f5rq + f5rr + f5rw, aacc_impn + macc_pvct + macc_timp + (1 + cga) * nacc_impn) ) @reference_formula class defncn(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Déficit non commerciaux non professionnels des années antérieures" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') f5ht = simulation.calculate('f5ht', period) f5it = simulation.calculate('f5it', period) f5jt = simulation.calculate('f5jt', period) f5kt = simulation.calculate('f5kt', period) f5lt = simulation.calculate('f5lt', period) f5mt = simulation.calculate('f5mt', period) mncn_impo_holder = simulation.compute('mncn_impo', period) mncn_pvct_holder = simulation.compute('mncn_pvct', period) cncn_aimp_holder = simulation.compute('cncn_aimp', period) cncn_bene_holder = simulation.compute('cncn_bene', period) cga = simulation.legislation_at(period.start).ir.rpns.cga_taux2 spbnc = simulation.legislation_at(period.start).ir.rpns.microentreprise.specialbnc def abat_rpns(rev, P): return max_(0, rev - min_(rev, max_(P.taux * min_(P.max, rev), P.min))) cncn_bene = self.sum_by_entity(cncn_bene_holder) mncn_impo = self.sum_by_entity(mncn_impo_holder) mncn_pvct = self.sum_by_entity(mncn_pvct_holder) cncn_aimp = self.sum_by_entity(cncn_aimp_holder) return period, min_(f5ht + f5it + f5jt + f5kt + f5lt + f5mt, abat_rpns(mncn_impo, spbnc) + mncn_pvct + cncn_aimp + (1 + cga) * cncn_bene) @reference_formula class defmeu(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Déficit des locations meublées non professionnelles des années antérieures" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') f5ga = simulation.calculate('f5ga', period) f5gb = simulation.calculate('f5gb', period) f5gc = simulation.calculate('f5gc', period) f5gd = simulation.calculate('f5gd', period) f5ge = simulation.calculate('f5ge', period) f5gf = simulation.calculate('f5gf', period) f5gg = simulation.calculate('f5gg', period) f5gh = simulation.calculate('f5gh', period) f5gi = simulation.calculate('f5gi', period) f5gj = simulation.calculate('f5gj', period) alnp_imps_holder = simulation.compute('alnp_imps', period) nacc_defs_holder = simulation.compute('nacc_defs', period) nacc_defs = self.sum_by_entity(nacc_defs_holder) alnp_imps = self.sum_by_entity(alnp_imps_holder) return period, min_(f5ga + f5gb + f5gc + f5gd + f5ge + f5gf + f5gg + f5gh + f5gi + f5gj, alnp_imps + nacc_defs) @reference_formula class rag(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rag" url = "http://www.impots.gouv.fr/portal/dgi/public/professionnels.impot?espId=2&impot=BA&pageId=prof_ba&sfid=50" def function(self, simulation, period): ''' Revenus agricoles 'ind' frag_exon (f5hn, f5in, f5jn) frag_impo (f5ho, f5io, f5jo) arag_exon (f5hb, f5ib, f5jb) arag_impg (f5hc, f5ic, f5jc) arag_defi (f5hf, f5if, f5jf) nrag_exon (f5hh, f5ih, f5jh) nrag_impg (f5hi, f5ii, f5ji) nrag_defi (f5hl, f5il, f5jl) nrag_ajag (f5hm, f5im, f5jm) ''' period = period.start.offset('first-of', 'year').period('year') frag_exon = simulation.calculate('frag_exon', period) frag_impo = simulation.calculate('frag_impo', period) arag_exon = simulation.calculate('arag_exon', period) arag_impg = simulation.calculate('arag_impg', period) arag_defi = simulation.calculate('arag_defi', period) nrag_exon = simulation.calculate('nrag_exon', period) nrag_impg = simulation.calculate('nrag_impg', period) nrag_defi = simulation.calculate('nrag_defi', period) nrag_ajag = simulation.calculate('nrag_ajag', period) return period, (frag_exon + frag_impo + arag_exon + arag_impg - arag_defi + nrag_exon + nrag_impg - nrag_defi + nrag_ajag) @reference_formula class ric(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"ric" url = "http://www.impots.gouv.fr/portal/dgi/public/professionnels.impot?pageId=prof_bic&espId=2&impot=BIC&sfid=50" def function(self, simulation, period): ''' Bénéfices industriels et commerciaux 'ind' mbic_exon (f5kn, f5ln, f5mn) abic_exon (f5kb, f5lb, f5mb) nbic_exon (f5kh, f5lh, f5mh) mbic_impv (f5ko, f5lo, f5mo) mbic_imps (f5kp, f5lp, f5mp) abic_impn (f5kc, f5lc, f5mc) abic_imps (f5kd, f5ld, f5md) nbic_impn (f5ki, f5li, f5mi) nbic_imps (f5kj, f5lj, f5mj) abic_defn (f5kf, f5lf, f5mf) abic_defs (f5kg, f5lg, f5mg) nbic_defn (f5kl, f5ll, f5ml) nbic_defs (f5km, f5lm, f5mm) nbic_apch (f5ks, f5ls, f5ms) ''' period = period.start.offset('first-of', 'year').period('year') mbic_exon = simulation.calculate('mbic_exon', period) mbic_impv = simulation.calculate('mbic_impv', period) mbic_imps = simulation.calculate('mbic_imps', period) abic_exon = simulation.calculate('abic_exon', period) nbic_exon = simulation.calculate('nbic_exon', period) abic_impn = simulation.calculate('abic_impn', period) nbic_impn = simulation.calculate('nbic_impn', period) abic_imps = simulation.calculate('abic_imps', period) nbic_imps = simulation.calculate('nbic_imps', period) abic_defn = simulation.calculate('abic_defn', period) nbic_defn = simulation.calculate('nbic_defn', period) abic_defs = simulation.calculate('abic_defs', period) nbic_defs = simulation.calculate('nbic_defs', period) nbic_apch = simulation.calculate('nbic_apch', period) microentreprise = simulation.legislation_at(period.start).ir.rpns.microentreprise zbic = (mbic_exon + mbic_impv + mbic_imps + abic_exon + nbic_exon + abic_impn + nbic_impn + abic_imps + nbic_imps - abic_defn - nbic_defn - abic_defs - nbic_defs + nbic_apch) cond = (mbic_impv > 0) & (mbic_imps == 0) taux = microentreprise.vente.taux * cond + microentreprise.servi.taux * not_(cond) cbic = min_( mbic_impv + mbic_imps + mbic_exon, max_( microentreprise.vente.min, round( mbic_impv * microentreprise.vente.taux + mbic_imps * microentreprise.servi.taux + mbic_exon * taux ) ) ) return period, zbic - cbic @reference_formula class rac(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rac" url = "http://vosdroits.service-public.fr/particuliers/F1225.xhtml" def function(self, simulation, period): ''' Revenus accessoires individuels 'ind' macc_exon (f5nn, f5on, f5pn) aacc_exon (f5nb, f5ob, f5pb) nacc_exon (f5nh, f5oh, f5ph) macc_impv (f5no, f5oo, f5po) macc_imps (f5np, f5op, f5pp) aacc_impn (f5nc, f5oc, f5pc) aacc_imps (f5nd, f5od, f5pd) aacc_defn (f5nf, f5of, f5pf) aacc_defs (f5ng, f5og, f5pg) nacc_impn (f5ni, f5oi, f5pi) nacc_defn (f5nl, f5ol, f5pl) nacc_defs (f5nm, f5om, f5pm) mncn_impo (f5ku, f5lu, f5mu) cncn_bene (f5sn, f5ns, f5os) cncn_defi (f5sp, f5nu, f5ou, f5sr) f5sv???? ''' period = period.start.offset('first-of', 'year').period('year') macc_exon = simulation.calculate('macc_exon', period) macc_impv = simulation.calculate('macc_impv', period) macc_imps = simulation.calculate('macc_imps', period) aacc_exon = simulation.calculate('aacc_exon', period) aacc_impn = simulation.calculate('aacc_impn', period) aacc_imps = simulation.calculate('aacc_imps', period) aacc_defn = simulation.calculate('aacc_defn', period) aacc_defs = simulation.calculate('aacc_defs', period) nacc_exon = simulation.calculate('nacc_exon', period) nacc_impn = simulation.calculate('nacc_impn', period) nacc_defn = simulation.calculate('nacc_defn', period) nacc_defs = simulation.calculate('nacc_defs', period) mncn_impo = simulation.calculate('mncn_impo', period) cncn_bene = simulation.calculate('cncn_bene', period) cncn_defi = simulation.calculate('cncn_defi', period) microentreprise = simulation.legislation_at(period.start).ir.rpns.microentreprise zacc = (macc_exon + macc_impv + macc_imps + aacc_exon + aacc_impn + aacc_imps - aacc_defn - aacc_defs + nacc_exon + nacc_impn - nacc_defn - nacc_defs + mncn_impo + cncn_bene - cncn_defi) #TODO: aacc_imps aacc_defs cond = (macc_impv > 0) & (macc_imps == 0) taux = microentreprise.vente.taux * cond + microentreprise.servi.taux * not_(cond) cacc = min_(macc_impv + macc_imps + macc_exon + mncn_impo, max_(microentreprise.vente.min, round( macc_impv * microentreprise.vente.taux + macc_imps * microentreprise.servi.taux + macc_exon * taux + mncn_impo * microentreprise.specialbnc.taux))) return period, zacc - cacc @reference_formula class rnc(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rnc" url = "http://www.impots.gouv.fr/portal/dgi/public/professionnels.impot?espId=2&pageId=prof_bnc&impot=BNC&sfid=50" def function(self, simulation, period): ''' Revenus non commerciaux individuels 'ind' mbnc_exon (f5hp, f5ip, f5jp) abnc_exon (f5qb, f5rb, f5sb) nbnc_exon (f5qh, f5rh, f5sh) mbnc_impo (f5hq, f5iq, f5jq) abnc_impo (f5qc, f5rc, f5sc) abnc_defi (f5qe, f5re, f5se) nbnc_impo (f5qi, f5ri, f5si) nbnc_defi (f5qk, f5rk, f5sk) f5ql, f5qm???? ''' period = period.start.offset('first-of', 'year').period('year') mbnc_exon = simulation.calculate('mbnc_exon', period) mbnc_impo = simulation.calculate('mbnc_impo', period) abnc_exon = simulation.calculate('abnc_exon', period) nbnc_exon = simulation.calculate('nbnc_exon', period) abnc_impo = simulation.calculate('abnc_impo', period) nbnc_impo = simulation.calculate('nbnc_impo', period) abnc_defi = simulation.calculate('abnc_defi', period) nbnc_defi = simulation.calculate('nbnc_defi', period) specialbnc = simulation.legislation_at(period.start).ir.rpns.microentreprise.specialbnc zbnc = (mbnc_exon + mbnc_impo + abnc_exon + nbnc_exon + abnc_impo + nbnc_impo - abnc_defi - nbnc_defi) cbnc = min_(mbnc_exon + mbnc_impo, max_(specialbnc.min, round((mbnc_exon + mbnc_impo) * specialbnc.taux))) return period, zbnc - cbnc @reference_formula class rpns(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Revenus individuels des professions non salariées" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') rag = simulation.calculate('rag', period) ric = simulation.calculate('ric', period) rac = simulation.calculate('rac', period) rnc = simulation.calculate('rnc', period) return period, rag + ric + rac + rnc @reference_formula class rpns_pvct(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rpns_pvct" def function(self, simulation, period): ''' Plus values de court terme 'ind' frag_pvct (f5hw, f5iw, f5jw) mbic_pvct (f5kx, f5lx, f5mx) macc_pvct (f5nx, f5ox, f5px) mbnc_pvct (f5hv, f5iv, f5jv) mncn_pvct (f5ky, f5ly, f5my) ''' period = period.start.offset('first-of', 'year').period('year') frag_pvct = simulation.calculate('frag_pvct', period) mbic_pvct = simulation.calculate('mbic_pvct', period) macc_pvct = simulation.calculate('macc_pvct', period) mbnc_pvct = simulation.calculate('mbnc_pvct', period) mncn_pvct = simulation.calculate('mncn_pvct', period) return period, frag_pvct + macc_pvct + mbic_pvct + mbnc_pvct + mncn_pvct @reference_formula class rpns_mvct(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rpns_mvct" def function(self, simulation, period): """Moins values de court terme 'ind' macc_mvct (f5iu) mncn_mvct (f5ju) mbnc_mvct (f5kz) """ period = period.start.offset('first-of', 'year').period('year') macc_mvct_holder = simulation.compute('macc_mvct', period) mbnc_mvct = simulation.calculate('mbnc_mvct', period) mncn_mvct_holder = simulation.compute('mncn_mvct', period) macc_mvct = self.cast_from_entity_to_role(macc_mvct_holder, role = VOUS) mncn_mvct = self.cast_from_entity_to_role(mncn_mvct_holder, role = VOUS) return period, mbnc_mvct + macc_mvct # mncn_mvct ? @reference_formula class rpns_mvlt(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rpns_mvlt" def function(self, simulation, period): ''' Moins values de long terme 'ind' mbic_mvlt (f5kr, f5lr, f5mr) macc_mvlt (f5nr, f5or, f5pr) mncn_mvlt (f5kw, f5lw, f5mw) mbnc_mvlt (f5hs, f5is, f5js) ''' period = period.start.offset('first-of', 'year').period('year') mbic_mvlt = simulation.calculate('mbic_mvlt', period) macc_mvlt = simulation.calculate('macc_mvlt', period) mbnc_mvlt = simulation.calculate('mbnc_mvlt', period) mncn_mvlt = simulation.calculate('mncn_mvlt', period) return period, mbic_mvlt + macc_mvlt + mbnc_mvlt + mncn_mvlt @reference_formula class rpns_i(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"rpns_i" def function(self, simulation, period): ''' Revenus des professions non salariées individuels ''' period = period.start.offset('first-of', 'year').period('year') frag_impo = simulation.calculate('frag_impo', period) arag_impg = simulation.calculate('arag_impg', period) nrag_impg = simulation.calculate('nrag_impg', period) arag_defi = simulation.calculate('arag_defi', period) nrag_defi = simulation.calculate('nrag_defi', period) mbic_impv = simulation.calculate('mbic_impv', period) mbic_imps = simulation.calculate('mbic_imps', period) abic_impn = simulation.calculate('abic_impn', period) abic_imps = simulation.calculate('abic_imps', period) abic_defn = simulation.calculate('abic_defn', period) abic_defs = simulation.calculate('abic_defs', 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) macc_impv = simulation.calculate('macc_impv', period) macc_imps = simulation.calculate('macc_imps', period) nbic_mvct = simulation.calculate('nbic_mvct', period) aacc_impn = simulation.calculate('aacc_impn', period) aacc_defn = simulation.calculate('aacc_defn', period) aacc_gits = simulation.calculate('aacc_gits', period) nacc_impn = simulation.calculate('nacc_impn', period) nacc_defn = simulation.calculate('nacc_defn', period) nacc_defs = simulation.calculate('nacc_defs', period) aacc_imps = simulation.calculate('aacc_imps', period) mbnc_impo = simulation.calculate('mbnc_impo', period) nacc_meup = simulation.calculate('nacc_meup', period) abic_impm = simulation.calculate('abic_impm', period) abic_defm = simulation.calculate('abic_defm', period) abnc_impo = simulation.calculate('abnc_impo', period) abnc_defi = simulation.calculate('abnc_defi', period) nbic_impm = simulation.calculate('nbic_impm', period) alnp_imps = simulation.calculate('alnp_imps', period) nbnc_impo = simulation.calculate('nbnc_impo', period) nbnc_defi = simulation.calculate('nbnc_defi', period) alnp_defs = simulation.calculate('alnp_defs', period) cbnc_assc = simulation.calculate('cbnc_assc', period) mncn_impo = simulation.calculate('mncn_impo', period) cncn_bene = simulation.calculate('cncn_bene', period) cncn_defi = simulation.calculate('cncn_defi', period) abnc_proc = simulation.calculate('abnc_proc', period) rpns_pvct = simulation.calculate('rpns_pvct', period) rpns_mvct = simulation.calculate('rpns_mvct', period) nbnc_proc = simulation.calculate('nbnc_proc', period) frag_fore = simulation.calculate('frag_fore', period) f5sq = simulation.calculate('f5sq', period) mncn_exon = simulation.calculate('mncn_exon', period) cncn_exon = simulation.calculate('cncn_exon', period) cncn_aimp = simulation.calculate('cncn_aimp', period) cncn_adef = simulation.calculate('cncn_adef', period) cncn_info = simulation.calculate('cncn_info', period) cncn_jcre = simulation.calculate('cncn_jcre', period) revimpres = simulation.calculate('revimpres', period) pveximpres = simulation.calculate('pveximpres', period) pvtaimpres = simulation.calculate('pvtaimpres', period) cga_taux2 = simulation.legislation_at(period.start).ir.rpns.cga_taux2 microentreprise = simulation.legislation_at(period.start).ir.rpns.microentreprise def abat_rpns(rev, P): return max_(0, rev - min_(rev, max_(P.taux * min_(P.max, rev), P.min))) # Jeunes agriculteurs montant de l'abattement de 50% ou 100% # nrag_ajag = f5hm + f5im + f5jm # # déficits agricole des années antérieurs (imputables uniquement # # sur des revenus agricoles) # rag_timp = frag_impo + frag_pvct + arag_impg + nrag_impg # cond = (AUTRE <= microentreprise.def_agri_seuil) # def_agri = cond*(arag_defi + nrag_defi) + not_(cond)*min_(rag_timp, arag_defi + nrag_defi) # # TODO : check 2006 cf art 156 du CGI pour 2006 # def_agri_ant = min_(max_(0,rag_timp - def_agri), f5sq) def_agri = f5sq + arag_defi + nrag_defi # # B revenus industriels et commerciaux professionnels # regime micro entreprise mbic_timp = abat_rpns(mbic_impv, microentreprise.vente) + abat_rpns(mbic_imps, microentreprise.servi) # Régime du bénéfice réel bénéficiant de l'abattement CGA abic_timp = abic_impn + abic_imps - (abic_defn + abic_defs) # Régime du bénéfice réel ne bénéficiant pas de l'abattement CGA nbic_timp = (nbic_impn + nbic_imps) - (nbic_defn + nbic_defs) # Abatemment artisant pécheur # nbic_apch = f5ks + f5ls + f5ms # TODO : à intégrer qqpart # # C revenus industriels et commerciaux non professionnels # (revenus accesoires du foyers en nomenclature INSEE) # regime micro entreprise macc_timp = abat_rpns(macc_impv, microentreprise.vente) + abat_rpns(macc_imps, microentreprise.servi) # Régime du bénéfice réel bénéficiant de l'abattement CGA aacc_timp = (max_(0, (aacc_impn + (aacc_gits > 0) * max_(microentreprise.servi.min, aacc_gits * (1 - microentreprise.vente.taux)) + (aacc_imps > 0) * max_(microentreprise.servi.min, aacc_imps * (1 - microentreprise.servi.taux)) + (nacc_meup > 0) * max_(microentreprise.servi.min, nacc_meup * (1 - microentreprise.vente.taux)) + nacc_defs - aacc_defn))) # Régime du bénéfice réel ne bénéficiant pas de l'abattement CGA nacc_timp = max_(0, nacc_impn - nacc_defn) # # E revenus non commerciaux non professionnels # regime déclaratif special ou micro-bnc mncn_timp = abat_rpns(mncn_impo, microentreprise.specialbnc) # régime de la déclaration controlée # total 11 cncn_timp = max_(0, cncn_bene - cncn_defi) # Abatement jeunes créateurs # # D revenus non commerciaux professionnels # regime déclaratif special ou micro-bnc mbnc_timp = abat_rpns(mbnc_impo, microentreprise.specialbnc) # regime de la déclaration contrôlée bénéficiant de l'abattement association agréée abnc_timp = abnc_impo - abnc_defi # regime 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 atimp = arag_impg + abic_timp + aacc_timp + abnc_timp ntimp = nrag_impg + nbic_timp + nacc_timp + nbnc_timp + cncn_timp majo_cga = max_(0, cga_taux2 * (ntimp + frag_impo)) # Pour ne pas avoir à majorer les déficits # total 6 rev_NS = frag_impo + frag_fore + atimp + ntimp + majo_cga - def_agri # revenu net après abatement # total 7 rev_NS_mi = mbic_timp + max_(0, macc_timp) + mbnc_timp + mncn_timp exon = max_(0, macc_timp + nacc_timp - rpns_mvct) - macc_timp - nacc_timp # ajout artificiel RPNS = (rev_NS + rev_NS_mi + rpns_pvct + exon + abic_impm - abic_defm + alnp_imps + cncn_aimp - nbic_mvct) return period, RPNS @reference_formula class abat_spe(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Abattements spéciaux" url = "http://bofip.impots.gouv.fr/bofip/2036-PGP" def function(self, simulation, period): """ Abattements spéciaux - pour personnes âges ou invalides : âgé(e) de plus de 65 ans ou invalide (titulaire d’une pension d’invalidité militaire ou d’accident du travail d’au moins 40 % ou titulaire de la carte d’invalidité), abattement de 2 172 € si rng du foyer fiscal inférieur à 13 370 € 1 086 € si rng compris entre 13 370 € et 21 570 €. Abattement doublé si conjoint remplit également ces conditions d’âge ou d’invalidité. - pour enfants à charge ayant fondé un foyer distinct : Si rattachement enfants mariés ou pacsés ou enfants célibataires, veufs, divorcés, séparés, chargés de famille, abattement 5 495 € par personne ainsi rattachée. Si l’enfant de la personne rattachée est réputé à charge de l’un et l’autre de ses parents (garde alternée), cet abattement est divisé par deux soit 2 748€. Exemple : 10 990 € pour un jeune ménage et 8 243 € pour un célibataire avec un jeune enfant en résidence alternée. """ period = period.start.offset('first-of', 'year').period('year') age_holder = simulation.compute('age', period) caseP = simulation.calculate('caseP', period) caseF = simulation.calculate('caseF', period) rng = simulation.calculate('rng', period) nbN = simulation.calculate('nbN', period) abattements_speciaux = simulation.legislation_at(period.start).ir.abattements_speciaux age = self.split_by_roles(age_holder, roles = [VOUS, CONJ]) ageV, ageC = age[VOUS], age[CONJ] invV, invC = caseP, caseF nb_elig_as = (1 * (((ageV >= 65) | invV) & (ageV > 0)) + 1 * (((ageC >= 65) | invC) & (ageC > 0)) ) as_inv = (nb_elig_as * abattements_speciaux.inv_montant * ((rng <= abattements_speciaux.inv_max1) + ((rng > abattements_speciaux.inv_max1) & (rng <= abattements_speciaux.inv_max2)) * 0.5)) as_enf = nbN * abattements_speciaux.enf_montant return period, min_(rng, as_inv + as_enf) @reference_formula class taux_effectif(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"taux_effectif" start_date = date(2009, 1, 1) def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') rni = simulation.calculate('rni', period) nbptr = simulation.calculate('nbptr', period) microentreprise = simulation.calculate('microentreprise', period) abnc_proc_holder = simulation.compute('abnc_proc', period) nbnc_proc_holder = simulation.compute('nbnc_proc', period) bareme = simulation.legislation_at(period.start).ir.bareme cga = simulation.legislation_at(period.start).ir.rpns.cga_taux2 abnc_proc = self.sum_by_entity(abnc_proc_holder) nbnc_proc = self.sum_by_entity(nbnc_proc_holder) base_fictive = rni + microentreprise + abnc_proc + nbnc_proc * (1 + cga) trigger = (microentreprise != 0) | (abnc_proc != 0) | (nbnc_proc != 0) return period, trigger * nbptr * bareme.calc(base_fictive / nbptr) / max_(1, base_fictive) ############################################################################### # # Calcul du nombre de parts ############################################################################### @reference_formula class nbptr(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Nombre de parts" url = "http://vosdroits.service-public.fr/particuliers/F2705.xhtml" def function(self, simulation, period): ''' Nombre de parts du foyer 'foy' note 1 enfants et résidence alternée (formulaire 2041 GV page 10) quotient_familial.conj : nb part associées au conjoint d'un couple marié ou pacsé quotient_familial.enf1 : nb part 2 premiers enfants quotient_familial.enf2 : nb part enfants de rang 3 ou plus quotient_familial.inv1 : nb part supp enfants invalides (I, G) quotient_familial.inv2 : nb part supp adultes invalides (R) quotient_familial.not31 : nb part supp note 3 : cases W ou G pour veuf, celib ou div quotient_familial.not32 : nb part supp note 3 : personne seule ayant élevé des enfants quotient_familial.not41 : nb part supp adultes invalides (vous et/ou conjoint) note 4 quotient_familial.not42 : nb part supp adultes anciens combattants (vous et/ou conjoint) note 4 quotient_familial.not6 : nb part supp note 6 quotient_familial.isol : demi-part parent isolé (T) quotient_familial.edcd : enfant issu du mariage avec conjoint décédé; ''' period = period.start.offset('first-of', 'year').period('year') nb_pac = simulation.calculate('nb_pac', period) marpac = simulation.calculate('marpac', period) celdiv = simulation.calculate('celdiv', period) veuf = simulation.calculate('veuf', period) jveuf = simulation.calculate('jveuf', period) nbF = simulation.calculate('nbF', period) nbG = simulation.calculate('nbG', period) nbH = simulation.calculate('nbH', period) nbI = simulation.calculate('nbI', period) nbR = simulation.calculate('nbR', period) nbJ = simulation.calculate('nbJ', period) caseP = simulation.calculate('caseP', period) caseW = simulation.calculate('caseW', period) caseG = simulation.calculate('caseG', period) caseE = simulation.calculate('caseE', period) caseK = simulation.calculate('caseK', period) caseN = simulation.calculate('caseN', period) caseF = simulation.calculate('caseF', period) caseS = simulation.calculate('caseS', period) caseL = simulation.calculate('caseL', period) caseT = simulation.calculate('caseT', period) quotient_familial = simulation.legislation_at(period.start).ir.quotient_familial no_pac = nb_pac == 0 # Aucune personne à charge en garde exclusive has_pac = not_(no_pac) no_alt = nbH == 0 # Aucun enfant à charge en garde alternée has_alt = not_(no_alt) # # nombre de parts liées aux enfants à charge # que des enfants en résidence alternée enf1 = (no_pac & has_alt) * (quotient_familial.enf1 * min_(nbH, 2) * 0.5 + quotient_familial.enf2 * max_(nbH - 2, 0) * 0.5) # pas que des enfants en résidence alternée enf2 = (has_pac & has_alt) * ((nb_pac == 1) * (quotient_familial.enf1 * min_(nbH, 1) * 0.5 + quotient_familial.enf2 * max_(nbH - 1, 0) * 0.5) + (nb_pac > 1) * (quotient_familial.enf2 * nbH * 0.5)) # pas d'enfant en résidence alternée enf3 = quotient_familial.enf1 * min_(nb_pac, 2) + quotient_familial.enf2 * max_((nb_pac - 2), 0) enf = enf1 + enf2 + enf3 # # note 2 : nombre de parts liées aux invalides (enfant + adulte) n2 = quotient_familial.inv1 * (nbG + nbI / 2) + quotient_familial.inv2 * nbR # # note 3 : Pas de personne à charge # - invalide n31a = quotient_familial.not31a * (no_pac & no_alt & caseP) # - ancien combatant n31b = quotient_familial.not31b * (no_pac & no_alt & (caseW | caseG)) n31 = max_(n31a, n31b) # - personne seule ayant élevé des enfants n32 = quotient_familial.not32 * (no_pac & no_alt & ((caseE | caseK) & not_(caseN))) n3 = max_(n31, n32) # # note 4 Invalidité de la personne ou du conjoint pour les mariés ou # # jeunes veuf(ve)s n4 = max_(quotient_familial.not41 * (1 * caseP + 1 * caseF), quotient_familial.not42 * (caseW | caseS)) # # note 5 # - enfant du conjoint décédé n51 = quotient_familial.cdcd * (caseL & ((nbF + nbJ) > 0)) # - enfant autre et parent isolé n52 = quotient_familial.isol * caseT * (((no_pac & has_alt) * ((nbH == 1) * 0.5 + (nbH >= 2))) + 1 * has_pac) n5 = max_(n51, n52) # # note 6 invalide avec personne à charge n6 = quotient_familial.not6 * (caseP & (has_pac | has_alt)) # # note 7 Parent isolé n7 = quotient_familial.isol * caseT * ((no_pac & has_alt) * ((nbH == 1) * 0.5 + (nbH >= 2)) + 1 * has_pac) # # Régime des mariés ou pacsés m = 1 + quotient_familial.conj + enf + n2 + n4 # # veufs hors jveuf v = 1 + enf + n2 + n3 + n5 + n6 # # celib div c = 1 + enf + n2 + n3 + n6 + n7 return period, (marpac | jveuf) * m + (veuf & not_(jveuf)) * v + celdiv * c ############################################################################### # # Calcul de la prime pour l'emploi ############################################################################### @reference_formula class ppe_coef(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"ppe_coef" def function(self, simulation, period): ''' PPE: coefficient de conversion en cas de changement en cours d'année ''' period = period.start.offset('first-of', 'year').period('year') jour_xyz = simulation.calculate('jour_xyz', period) nb_jour = (jour_xyz == 0) + jour_xyz return period, 360 / nb_jour @reference_formula class ppe_elig(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = FoyersFiscaux label = u"ppe_elig" def function(self, simulation, period): ''' 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 ''' period = period.start.offset('first-of', 'year').period('year') rfr = simulation.calculate('rfr', period) ppe_coef = simulation.calculate('ppe_coef', period) marpac = simulation.calculate('marpac', period) veuf = simulation.calculate('veuf', period) celdiv = simulation.calculate('celdiv', period) nbptr = simulation.calculate('nbptr', period) ppe = simulation.legislation_at(period.start).ir.credits_impot.ppe seuil = (veuf | celdiv) * (ppe.eligi1 + 2 * max_(nbptr - 1, 0) * ppe.eligi3) \ + marpac * (ppe.eligi2 + 2 * max_(nbptr - 2, 0) * ppe.eligi3) return period, (rfr * ppe_coef) <= seuil @reference_formula class ppe_rev(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"ppe_rev" def function(self, simulation, period): ''' base ressource de la ppe 'ind' ''' period = period.start.offset('first-of', 'year').period('year') salaire_imposable = simulation.calculate_add('salaire_imposable', period) hsup = simulation.calculate('hsup', period) rpns = simulation.calculate('rpns', period) ppe = simulation.legislation_at(period.start).ir.credits_impot.ppe # Revenu d'activité salarié rev_sa = salaire_imposable + hsup # TODO: + TV + TW + TX + AQ + LZ + VJ # Revenu d'activité non salarié rev_ns = min_(0, rpns) / ppe.abatns + max_(0, rpns) * ppe.abatns #TODO: très bizarre la partie min(0,rpns) - après vérification c'est dans la loi return period, rev_sa + rev_ns @reference_formula class ppe_coef_tp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"ppe_coef_tp" def function(self, simulation, period): ''' PPE: coefficient de conversion temps partiel 'ind' ''' period = period.start.offset('first-of', 'year').period('year') ppe_du_sa = simulation.calculate('ppe_du_sa', period) ppe_du_ns = simulation.calculate('ppe_du_ns', period) ppe_tp_sa = simulation.calculate('ppe_tp_sa', period) ppe_tp_ns = simulation.calculate('ppe_tp_ns', period) ppe = simulation.legislation_at(period.start).ir.credits_impot.ppe frac_sa = ppe_du_sa / ppe.TP_nbh frac_ns = ppe_du_ns / ppe.TP_nbj tp = ppe_tp_sa | ppe_tp_ns | (frac_sa + frac_ns >= 1) return period, tp + not_(tp) * (frac_sa + frac_ns) @reference_formula class ppe_base(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"ppe_base" def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') ppe_rev = simulation.calculate('ppe_rev', period) ppe_coef_tp = simulation.calculate('ppe_coef_tp', period) ppe_coef_holder = simulation.compute('ppe_coef', period) ppe_coef = self.cast_from_entity_to_roles(ppe_coef_holder) return period, ppe_rev / (ppe_coef_tp + (ppe_coef_tp == 0)) * ppe_coef @reference_formula class ppe_elig_i(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = Individus label = u"ppe_elig_i" def function(self, simulation, period): ''' Eligibilité individuelle à la ppe Attention : condition de plafonnement introduite dans ppe brute 'ind' ''' period = period.start.offset('first-of', 'year').period('year') ppe_rev = simulation.calculate('ppe_rev', period) ppe_coef_tp = simulation.calculate('ppe_coef_tp', period) ppe = simulation.legislation_at(period.start).ir.credits_impot.ppe return period, (ppe_rev >= ppe.seuil1) & (ppe_coef_tp != 0) @reference_formula class ppe_brute(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Prime pour l'emploi brute" def function(self, simulation, period): ''' Prime pour l'emploi (avant éventuel dispositif de cumul avec le RSA) 'foy' Cf. http://travail-emploi.gouv.fr/informations-pratiques,89/fiches-pratiques,91/remuneration,113/la-prime-pour-l-emploi-ppe,1034.html ''' period = period.start.offset('first-of', 'year').period('year') ppe_elig = simulation.calculate('ppe_elig', period) ppe_elig_i_holder = simulation.compute('ppe_elig_i', period) ppe_rev_holder = simulation.compute('ppe_rev', period) ppe_base_holder = simulation.compute('ppe_base', period) ppe_coef = simulation.calculate('ppe_coef', period) ppe_coef_tp_holder = simulation.compute('ppe_coef_tp', period) nb_pac = simulation.calculate('nb_pac', period) marpac = simulation.calculate('marpac', period) celdiv = simulation.calculate('celdiv', period) veuf = simulation.calculate('veuf', period) caseT = simulation.calculate('caseT', period) caseL = simulation.calculate('caseL', period) nbH = simulation.calculate('nbH', period) ppe = simulation.legislation_at(period.start).ir.credits_impot.ppe ppe_base = self.split_by_roles(ppe_base_holder) ppe_coef_tp = self.split_by_roles(ppe_coef_tp_holder) ppe_elig_i = self.split_by_roles(ppe_elig_i_holder) ppe_rev = self.split_by_roles(ppe_rev_holder) eliv, elic, eli1, eli2, eli3 = ppe_elig_i[VOUS], ppe_elig_i[CONJ], ppe_elig_i[PAC1], \ ppe_elig_i[PAC2], ppe_elig_i[PAC3] basevi, baseci = ppe_rev[VOUS], ppe_rev[CONJ] basev, basec, base1, base2, base3 = ppe_base[VOUS], ppe_base[CONJ], ppe_base[PAC1], ppe_base[PAC2], ppe_base[PAC1] coef_tpv, coef_tpc, coef_tp1, coef_tp2, coef_tp3 = ppe_coef_tp[VOUS], ppe_coef_tp[CONJ], \ ppe_coef_tp[PAC1], ppe_coef_tp[PAC2], ppe_coef_tp[PAC1] nb_pac_ppe = max_(0, nb_pac - eli1 - eli2 - eli3) ligne2 = marpac & xor_(basevi >= ppe.seuil1, baseci >= ppe.seuil1) ligne3 = (celdiv | veuf) & caseT & not_(veuf & caseT & caseL) ligne1 = not_(ligne2) & not_(ligne3) base_monact = ligne2 * (eliv * basev + elic * basec) base_monacti = ligne2 * (eliv * basevi + elic * baseci) def ppe_bar1(base): # cond1 = ligne1 | ligne3 # cond2 = ligne2 # return 1 / ppe_coef * ((cond1 & (base <= ppe.seuil2)) * (base) * ppe.taux1 + # (cond1 & (base > ppe.seuil2) & (base <= ppe.seuil3)) * (ppe.seuil3 - base) * ppe.taux2 + # (cond2 & (base <= ppe.seuil2)) * (base * ppe.taux1) + # (cond2 & (base > ppe.seuil2) & (base <= ppe.seuil3)) * ((ppe.seuil3 - base) * ppe.taux2) + # (cond2 & (base > ppe.seuil4) & (base <= ppe.seuil5)) * (ppe.seuil5 - base) * ppe.taux3) return (1 / ppe_coef) * ( ((base <= ppe.seuil2)) * (base) * ppe.taux1 + ((base > ppe.seuil2) & (base <= ppe.seuil3)) * (ppe.seuil3 - base) * ppe.taux2 + ligne2 * ((base > ppe.seuil4) & (base <= ppe.seuil5)) * (ppe.seuil5 - base) * ppe.taux3) def ppe_bar2(base): return (1 / ppe_coef) * ( (base <= ppe.seuil2) * (base) * ppe.taux1 + ((base > ppe.seuil2) & (base <= ppe.seuil3)) * (ppe.seuil3 - base1) * ppe.taux2) # calcul des primes individuelles. ppev = eliv * ppe_bar1(basev) ppec = elic * ppe_bar1(basec) ppe1 = eli1 * ppe_bar2(base1) ppe2 = eli2 * ppe_bar2(base2) ppe3 = eli3 * ppe_bar2(base3) # Primes de monoactivité ppe_monact_vous = (eliv & ligne2 & (basevi >= ppe.seuil1) & (basev <= ppe.seuil4)) * ppe.monact ppe_monact_conj = (elic & ligne2 & (baseci >= ppe.seuil1) & (basec <= ppe.seuil4)) * ppe.monact # Primes pour enfants à charge maj_pac = ppe_elig * (eliv | elic) * ( (ligne1 & marpac & ((ppev + ppec) != 0) & (min_(basev, basec) <= ppe.seuil3)) * ppe.pac * (nb_pac_ppe + nbH * 0.5) + (ligne1 & (celdiv | veuf) & eliv & (basev <= ppe.seuil3)) * ppe.pac * (nb_pac_ppe + nbH * 0.5) + (ligne2 & (base_monacti >= ppe.seuil1) & (base_monact <= ppe.seuil3)) * ppe.pac * (nb_pac_ppe + nbH * 0.5) + (ligne2 & (base_monact > ppe.seuil3) & (base_monact <= ppe.seuil5)) * ppe.pac * ((nb_pac_ppe != 0) + 0.5 * ((nb_pac_ppe == 0) & (nbH != 0))) + (ligne3 & (basevi >= ppe.seuil1) & (basev <= ppe.seuil3)) * ( (min_(nb_pac_ppe, 1) * 2 * ppe.pac + max_(nb_pac_ppe - 1, 0) * ppe.pac) + (nb_pac_ppe == 0) * (min_(nbH, 2) * ppe.pac + max_(nbH - 2, 0) * ppe.pac * 0.5)) + (ligne3 & (basev > ppe.seuil3) & (basev <= ppe.seuil5)) * ppe.pac * ((nb_pac_ppe != 0) * 2 + ((nb_pac_ppe == 0) & (nbH != 0)))) def coef(coef_tp): return (coef_tp <= 0.5) * coef_tp * 1.45 + (coef_tp > 0.5) * (0.55 * coef_tp + 0.45) ppe_vous = ppe_elig * (ppev * coef(coef_tpv) + ppe_monact_vous) ppe_conj = ppe_elig * (ppec * coef(coef_tpc) + ppe_monact_conj) ppe_pac1 = ppe_elig * (ppe1 * coef(coef_tp1)) ppe_pac2 = ppe_elig * (ppe2 * coef(coef_tp2)) ppe_pac3 = ppe_elig * (ppe3 * coef(coef_tp3)) ppe_tot = ppe_vous + ppe_conj + ppe_pac1 + ppe_pac2 + ppe_pac3 + maj_pac ppe_tot = (ppe_tot != 0) * max_(ppe.versmin, ppe_tot) # from pandas import DataFrame # decompo = {0: ppev, 1 :ppe_vous, 2: ppec,3: ppe_conj, 4: maj_pac, 5 : ppe_monact_vous, 6: ppe_monact_conj, #8: basev, 81 : basevi, 9: basec, 91 : baseci, 10:ppe_tot} # ppe DataFrame(decompo).to_string() return period, ppe_tot @reference_formula class ppe(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Prime pour l'emploi" url = "http://vosdroits.service-public.fr/particuliers/F2882.xhtml" def function(self, simulation, period): """ PPE effectivement versée 'foy' """ period = period.start.offset('first-of', 'year').period('year') ppe_brute = simulation.calculate('ppe_brute', period) rsa_act_i_holder = simulation.compute('rsa_act_i', period) # TODO: les foyers qui paient l'ISF n'ont pas le droit à la PPE rsa_act_i = self.split_by_roles(rsa_act_i_holder, roles = [VOUS, CONJ]) # On retranche le RSA activité de la PPE # Dans les agrégats officiels de la DGFP, c'est la PPE brute qu'il faut comparer ppe = max_(ppe_brute - rsa_act_i[VOUS] - rsa_act_i[CONJ], 0) return period, ppe PKoz>Yopenfisca_france/model/prelevements_obligatoires/impot_revenu/plus_values_immobilieres.py# -*- coding: utf-8 -*- from numpy import maximum as max_, minimum as min_ from ...base import * # noqa analysis:ignore ######################################################################## # Calcul de l'impôt sur les plus-values immobilières # Impôt sur le revenu afférent à la plus-value immobilière (CGI, art. 150 U, 150 UC-I et 150 UD) # Prélèvement dû par les non-résidents assujettis ou non à l’impôt sur le revenu (CGI, art. 244 bis A) # Taxe forfaitaire sur la cession de terrains nus devenus constructibles (CGI, art. 1529) # Taxe sur la cession à titre onéreux de terrains nus rendus constructibles (CGI, art.1605 nonies) # 2048-IMM-SD ######################################################################## #TODO: create new function for f3VV (new legislation : non-resident_45%) # def _plus_value_brute(prix_pv_immo, charges_pv_immo, frais_pv_immo, prix_acqu_immo, # charges_aqu_immo, frais_acqu_immo, const_acqu_immo, voirie_acqu_immo): # """ # Calcul de la plus-value immobilière brute # """ # # CESSION # prix_cess_immo = 0 # 10; PRIX DE CESSION OU INDEMNITE D’EXPROPRIATION = € # charges_cess_immo = 0 # 11. CHARGES ET INDEMNITES SUPPORTEES PAR L’ACQUEREUR + € # frais_cess_immo =0 # 12. FRAIS ET TAXES SUPPORTES PAR LE VENDEUR (NOTAMMENT FRAIS DE REPRESENTATION FISCALE) - € # # # 13. PRIX DE CESSION CORRIGE (LIGNE 10 + LIGNE 11 – LIGNE 12) = = € # prix_cess_corr = prix_cess_immo + charges_cess_immo - frais_cess_immo # # # ACQISISTION # prix_acqu_immo = 0 # 20. PRIX D’ACQUISITION OU VALEUR VENALE = € # charges_aqu_immo = 0 # 21. CHARGES ET INDEMNITES (MONTANT REEL) + € # frais_acqu_immo = 0 # 22. FRAIS D’ACQUISITION : # # * A TITRE GRATUIT (MONTANT REEL) + € # # * A TITRE ONEREUX (MONTANT REEL OU FIXE A 7,5% DU PRIX D’ACQUISITION) + € # const_acqu_immo = 0 # 23. DEPENSES DE CONSTRUCTION, RECONSTRUCTION, AGRANDISSEMENT OU AMELIORATION + € # # (MONTANT REEL OU FIXE A 15% DU PRIX D’ACQUISITION SI IMMEUBLE BATI DETENU DEPUIS PLUS DE 5 ANS). # voirie_acqu_immo = 0 # 24. FRAIS DE VOIRIE, RESEAUX ET DISTRIBUTION + € # valeur_venale = prix_acqu_immo + charges_aqu_immo + frais_acqu_immo + const_acqu_immo + voirie_acqu_immo # 25. PRIX D’ACQUISITION OU VALEUR VENALE CORRIGE (LIGNE 20 + LIGNE 21 + LIGNE 22 + LIGNE 23 + LIGNE 24) = - € # return prix_cess_corr-valeur_venale # # # 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 @reference_formula class ir_pv_immo(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Impôt sur le revenu afférent à la plus-value immobilière" url = "http://www.impots.gouv.fr/portal/dgi/public/popup?espId=1&typePage=cpr02&docOid=documentstandard_2157" def function(self, simulation, period): """ Impôt sur le revenu afférent à la plus-value immobilière (CGI, art. 150 U, 150 UC-I et 150 UD) """ period = period.start.offset('first-of', 'year').period('year') f3vz = simulation.calculate('f3vz', period) pv_immo = simulation.legislation_at(period.start).ir.pv_immo # 61. MONTANT DU PAR LES PERSONNES PHYSIQUES RESIDENTES DE FRANCE OU D’UN AUTRE ETAT MEMBRE DE L’EEE(1) # (VOIR TABLEAU PAGE 3). # if resident impo = pv_immo.taux*f3vz # 62. MONTANT DU PAR LES AUTRES NON-RESIDENTS (VOIR TABLEAU PAGE 3 ET REMPLIR PAGE 4 SI NECESSAIRE) # IMPOSITION A 33,1/3% DES PERSONNES PHYSIQUES [(LIGNE 50 OU LIGNE 53) X 33,1/3%] = = € # IMPOSITION A 15% OU 19% OU 33,1/3% DES PERSONNES MORALES NON ASSUJETTIES A L’IR, ETABLIES DANS UN ETAT # MEMBRE DE L’EEE(1) (LIGNE 300 X 15% OU 19% OU 33,1/3%) = = € #IMPOSITION A 50% DES PERSONNES PHYSIQUES OU MORALES RESIDENTES D’UN ETNC(2) #[(LIGNE 50 OU (LIGNE 54 + LIGNE 300)) X 50%] = = € #63. ABATTEMENT REPRESENTATIF DU FORFAIT FORESTIER (SI LE CEDANT EST UNE PERSONNE PHYSIQUE RESIDENTE) - € #64. MONTANT DE L’IMPOT DU APRES ABATTEMENT [(LIGNE 61 + LIGNE 62) – LIGNE 63] = = € #(POUR L’APPLICATION DES PRELEVEMENTS SOCIAUX CI-DESSOUS, CF. TABLEAU « RAPPEL DES TAUX D’IMPOSITION » PAGE 5) : return period, -impo PKoz 0) + P.seuil * (marpac + 1) * (f7cu <= 0) return period, P.taux * min_(base, seuil) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Souscriptions au capital des PME 2011 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7cf = simulation.calculate('f7cf', period) f7cl = simulation.calculate('f7cl', period) f7cm = simulation.calculate('f7cm', period) f7cn = simulation.calculate('f7cn', period) f7cq = simulation.calculate('f7cq', period) f7cu = simulation.calculate('f7cu', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.cappme base = f7cl + f7cm + f7cn + f7cq seuil = P.seuil_tpe * (marpac + 1) * (f7cu > 0) + P.seuil * (marpac + 1) * (f7cu <= 0) max0 = max_(seuil - base, 0) return period, max_(P.taux25 * min_(base, seuil), P.taux * min_(max0, f7cf + f7cu)) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Souscriptions au capital des PME 2012 cf. 2041 GR ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7cf = simulation.calculate('f7cf', period) f7cl = simulation.calculate('f7cl', period) f7cm = simulation.calculate('f7cm', period) f7cn = simulation.calculate('f7cn', period) f7cq = simulation.calculate('f7cq', period) f7cu = simulation.calculate('f7cu', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.cappme #TODO: gérer les changements de situation familiale base = f7cl + f7cm + f7cn seuil1 = P.seuil * (marpac + 1) seuil2 = max_(0, P.seuil_tpe * (marpac + 1) - min_(base, seuil1) - min_(f7cq, seuil1) - min_(f7cu, seuil1)) seuil3 = min_(P.seuil_tpe * (marpac + 1) - min_(base, seuil1) - min_(f7cq, seuil1), seuil1) return period, P.taux25 * min_(base, seuil1) + P.taux * min_(f7cq, seuil1) + P.taux18 * (min_(f7cf, seuil3) + mini(f7cu, seuil2, seuil1)) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Souscriptions au capital des PME 2013 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7cc = simulation.calculate('f7cc', period) f7cf = simulation.calculate('f7cf', period) f7cl = simulation.calculate('f7cl', period) f7cm = simulation.calculate('f7cm', period) f7cn = simulation.calculate('f7cn', period) f7cq = simulation.calculate('f7cq', period) f7cu = simulation.calculate('f7cu', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.cappme base = f7cl + f7cm seuil1 = P.seuil * (marpac + 1) seuil2 = max_(0, P.seuil_tpe * (marpac + 1) - min_(base, seuil1) - min_(f7cn, seuil1) - min_(f7cu, seuil1)) seuil3 = min_(P.seuil_tpe * (marpac + 1) - min_(base, seuil1) - min_(f7cq, seuil1), seuil1) return period, P.taux25 * min_(base, seuil1) + P.taux22 * min_(f7cn, seuil1) + P.taux18 * (min_(f7cf + f7cc, seuil3) + min_(f7cu + f7cq, seuil2)) #TODO: vérifier l'existence du "max_" @reference_formula class cotsyn(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"cotsyn" def function(self, simulation, period): ''' Cotisations syndicales (2002-20131 ''' period = period.start.offset('first-of', 'year').period('year') f7ac_holder = simulation.compute('f7ac', period) salaire_imposable_holder = simulation.compute_add('salaire_imposable', period) cho_holder = simulation.compute('cho', period) rst_holder = simulation.compute('rst', period) P = simulation.legislation_at(period.start).ir.reductions_impots.cotsyn f7ac = self.filter_role(f7ac_holder, role = VOUS) f7ae = self.filter_role(f7ac_holder, role = CONJ) f7ag = self.filter_role(f7ac_holder, role = PAC1) cho = self.split_by_roles(cho_holder) rst = self.split_by_roles(rst_holder) salaire_imposable = self.split_by_roles(salaire_imposable_holder) tx = P.seuil salv, salc, salp = salaire_imposable[VOUS], salaire_imposable[CONJ], salaire_imposable[PAC1] chov, choc, chop = cho[VOUS], cho[CONJ], cho[PAC1] rstv, rstc, rstp = rst[VOUS], rst[CONJ], rst[PAC1] maxv = (salv + chov + rstv) * tx maxc = (salc + choc + rstc) * tx maxp = (salp + chop + rstp) * tx return period, P.taux * (min_(f7ac, maxv) + min_(f7ae, maxc) + min_(f7ag, maxp)) @reference_formula class creaen(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"creaen" @dated_function(start = date(2006, 1, 1), stop = date(2008, 12, 31)) def function_20060101_20081231(self, simulation, period): ''' Aide aux créateurs et repreneurs d'entreprises 2006-2008 ''' period = period.start.offset('first-of', 'year').period('year') f7fy = simulation.calculate('f7fy', period) f7gy = simulation.calculate('f7gy', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.creaen return period, (P.base * f7fy + P.hand * f7gy) @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): ''' Aide aux créateurs et repreneurs d'entreprises 2009 ''' period = period.start.offset('first-of', 'year').period('year') f7fy = simulation.calculate('f7fy', period) f7gy = simulation.calculate('f7gy', period) f7jy = simulation.calculate('f7jy', period) f7hy = simulation.calculate('f7hy', period) f7ky = simulation.calculate('f7ky', period) f7iy = simulation.calculate('f7iy', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.creaen return period, (P.base * ((f7jy + f7fy) + f7hy / 2) + P.hand * ((f7ky + f7gy) + f7iy / 2)) @dated_function(start = date(2010, 1, 1), stop = date(2011, 12, 31)) def function_20100101_20111231(self, simulation, period): ''' Aide aux créateurs et repreneurs d'entreprises 2010-2011 ''' period = period.start.offset('first-of', 'year').period('year') f7fy = simulation.calculate('f7fy', period) f7gy = simulation.calculate('f7gy', period) f7jy = simulation.calculate('f7jy', period) f7hy = simulation.calculate('f7hy', period) f7ky = simulation.calculate('f7ky', period) f7iy = simulation.calculate('f7iy', period) f7ly = simulation.calculate('f7ly', period) f7my = simulation.calculate('f7my', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.creaen return period, (P.base * ((f7jy + f7fy) + (f7hy + f7ly) / 2) + P.hand * ((f7ky + f7gy) + (f7iy + f7my) / 2)) @dated_function(start = date(2012, 1, 1), stop = date(2014, 12, 31)) def function_20120101_20141231(self, simulation, period): ''' Aide aux créateurs et repreneurs d'entreprises 2012- ''' period = period.start.offset('first-of', 'year').period('year') f7ly = simulation.calculate('f7ly', period) f7my = simulation.calculate('f7my', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.creaen return period, (P.base * (f7ly / 2) + P.hand * (f7my / 2)) @reference_formula class deffor(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"deffor" start_date = date(2006, 1, 1) def function(self, simulation, period): ''' Défense des forêts contre l'incendie 2006- ''' period = period.start.offset('first-of', 'year').period('year') f7uc = simulation.calculate('f7uc', period) P = simulation.legislation_at(period.start).ir.reductions_impots.deffor return period, P.taux * min_(f7uc, P.max) @reference_formula class daepad(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"daepad" def function(self, simulation, period): ''' Dépenses d'accueil dans un établissement pour personnes âgées dépendantes ?- ''' period = period.start.offset('first-of', 'year').period('year') f7cd = simulation.calculate('f7cd', period) f7ce = simulation.calculate('f7ce', period) P = simulation.legislation_at(period.start).ir.reductions_impots.daepad return period, P.taux * (min_(f7cd, P.max) + min_(f7ce, P.max)) @reference_formula class dfppce(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"dfppce" @dated_function(start = date(2002, 1, 1), stop = date(2003, 12, 31)) def function_20020101_20031231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = f7uf max1 = P.max * rbg_int return period, P.taux * min_(base, max1) @dated_function(start = date(2004, 1, 1), stop = date(2004, 12, 31)) def function_20040101_20041231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) f7xs = simulation.calculate('f7xs', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = f7uf + f7xs max1 = P.max * rbg_int return period, P.taux * min_(base, max1) @dated_function(start = date(2005, 1, 1), stop = date(2005, 12, 31)) def function_20050101_20051231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) f7xs = simulation.calculate('f7xs', period) f7xt = simulation.calculate('f7xt', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = f7uf + f7xs + f7xt max1 = P.max * rbg_int return period, P.taux * min_(base, max1) @dated_function(start = date(2006, 1, 1), stop = date(2006, 12, 31)) def function_20060101_20061231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) f7xs = simulation.calculate('f7xs', period) f7xt = simulation.calculate('f7xt', period) f7xu = simulation.calculate('f7xu', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = f7uf + f7xs + f7xt + f7xu max1 = P.max * rbg_int return period, P.taux * min_(base, max1) @dated_function(start = date(2007, 1, 1), stop = date(2007, 12, 31)) def function_20070101_20071231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) f7xs = simulation.calculate('f7xs', period) f7xt = simulation.calculate('f7xt', period) f7xu = simulation.calculate('f7xu', period) f7xw = simulation.calculate('f7xw', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = f7uf + f7xs + f7xt + f7xu + f7xw max1 = P.max * rbg_int return period, P.taux * min_(base, max1) @dated_function(start = date(2008, 1, 1), stop = date(2010, 12, 31)) def function_20080101_20101231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) f7xs = simulation.calculate('f7xs', period) f7xt = simulation.calculate('f7xt', period) f7xu = simulation.calculate('f7xu', period) f7xw = simulation.calculate('f7xw', period) f7xy = simulation.calculate('f7xy', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = f7uf + f7xs + f7xt + f7xu + f7xw + f7xy max1 = P.max * rbg_int return period, P.taux * min_(base, max1) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales (2011-2013) ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) f7xs = simulation.calculate('f7xs', period) f7xt = simulation.calculate('f7xt', period) f7xu = simulation.calculate('f7xu', period) f7xw = simulation.calculate('f7xw', period) f7xy = simulation.calculate('f7xy', period) f7vc = simulation.calculate('f7vc', period) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = f7uf + f7vc + f7xs + f7xt + f7xu + f7xw + f7xy max1 = P.max * rbg_int return period, P.taux * min_(base, max1) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales (2011-2013) ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) f7xs = simulation.calculate('f7xs', period) f7xt = simulation.calculate('f7xt', period) f7xu = simulation.calculate('f7xu', period) f7xw = simulation.calculate('f7xw', period) f7xy = simulation.calculate('f7xy', period) f7vc = simulation.calculate('f7vc', period) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = min_(P.max_niv, f7uf) + f7vc + f7xs + f7xt + f7xu + f7xw + f7xy max1 = P.max * rbg_int return period, P.taux * min_(base, max1) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Dons aux autres oeuvres et dons effectués pour le financement des partis politiques et des campagnes électorales (2011-2013) ''' period = period.start.offset('first-of', 'year').period('year') rbg_int = simulation.calculate('rbg_int', period) f7uf = simulation.calculate('f7uf', period) f7uh = simulation.calculate('f7uh', period) f7xs = simulation.calculate('f7xs', period) f7xt = simulation.calculate('f7xt', period) f7xu = simulation.calculate('f7xu', period) f7xw = simulation.calculate('f7xw', period) f7xy = simulation.calculate('f7xy', period) f7vc = simulation.calculate('f7vc', period) P = simulation.legislation_at(period.start).ir.reductions_impots.dfppce base = min_(P.max_niv, f7uf + f7uh) + f7vc + f7xs + f7xt + f7xu + f7xw + f7xy max1 = P.max * rbg_int return period, P.taux * min_(base, max1) # TODO: note de bas de page # Introduire plus de détails dans la déclaration pour séparer les dons aux partis poitiques # et aux candidats des autres dons # Outre-mer : TODO: plafonnement, cf. 2041-GE 2042-IOM @reference_formula class doment(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"doment" @dated_function(start = date(2005, 1, 1), stop = date(2005, 12, 31)) def function_20050101_20051231(self, simulation, period): ''' Investissements dans les DOM-TOM dans le cadre d'une entrepise. ''' period = period.start.offset('first-of', 'year').period('year') f7ur = simulation.calculate('f7ur', period) f7oz = simulation.calculate('f7oz', period) f7pz = simulation.calculate('f7pz', period) f7qz = simulation.calculate('f7qz', period) f7rz = simulation.calculate('f7rz', period) return period, f7ur + f7oz + f7pz + f7qz + f7rz @dated_function(start = date(2006, 1, 1), stop = date(2008, 12, 31)) def function_20060101_20081231(self, simulation, period): ''' Investissements dans les DOM-TOM dans le cadre d'une entrepise. ''' period = period.start.offset('first-of', 'year').period('year') f7ur = simulation.calculate('f7ur', period) f7oz = simulation.calculate('f7oz', period) f7pz = simulation.calculate('f7pz', period) f7qz = simulation.calculate('f7qz', period) f7rz = simulation.calculate('f7rz', period) f7sz = simulation.calculate('f7sz', period) return period, f7ur + f7oz + f7pz + f7qz + f7rz + f7sz @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): ''' Investissements dans les DOM-TOM dans le cadre d'une entrepise. ''' period = period.start.offset('first-of', 'year').period('year') f7oz = simulation.calculate('f7oz', period) f7pz = simulation.calculate('f7pz', period) f7qz = simulation.calculate('f7qz', period) f7rz = simulation.calculate('f7rz', period) f7sz = simulation.calculate('f7sz', period) f7qe = simulation.calculate('f7qe', period) f7qf = simulation.calculate('f7qf', period) f7qg = simulation.calculate('f7qg', period) f7qh = simulation.calculate('f7qh', period) f7qi = simulation.calculate('f7qi', period) f7qj = simulation.calculate('f7qj', period) return period, f7oz + f7pz + f7qz + f7rz + f7sz + f7qe + f7qf + f7qg + f7qh + f7qi + f7qj @dated_function(start = date(2010, 1, 1), stop = date(2010, 12, 31)) def function_20100101_20101231(self, simulation, period): ''' Investissements dans les DOM-TOM dans le cadre d'une entrepise. ''' period = period.start.offset('first-of', 'year').period('year') f7oz = simulation.calculate('f7oz', period) f7pz = simulation.calculate('f7pz', period) f7qz = simulation.calculate('f7qz', period) f7rz = simulation.calculate('f7rz', period) f7qe = simulation.calculate('f7qe', period) f7qf = simulation.calculate('f7qf', period) f7qg = simulation.calculate('f7qg', period) f7qh = simulation.calculate('f7qh', period) f7qi = simulation.calculate('f7qi', period) f7qj = simulation.calculate('f7qj', period) f7qo = simulation.calculate('f7qo', period) f7qp = simulation.calculate('f7qp', period) f7qq = simulation.calculate('f7qq', period) f7qr = simulation.calculate('f7qr', period) f7qs = simulation.calculate('f7qs', period) f7mm = simulation.calculate('f7mm', period) f7ma = simulation.calculate('f7ma', period) f7lg = simulation.calculate('f7lg', period) f7ks = simulation.calculate('f7ks', period) f7ls = simulation.calculate('f7ls', period) return period, (f7oz + f7pz + f7qz + f7rz + f7qe + f7qf + f7qg + f7qh + f7qi + f7qj + f7qo + f7qp + f7qq + f7qr + f7qs + f7mm + f7ma + f7lg + f7ks + f7ls) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Investissements dans les DOM-TOM dans le cadre d'une entrepise. ''' period = period.start.offset('first-of', 'year').period('year') f7ks = simulation.calculate('f7ks', period) f7kt = simulation.calculate('f7kt', period) f7ku = simulation.calculate('f7ku', period) f7lg = simulation.calculate('f7lg', period) f7lh = simulation.calculate('f7lh', period) f7li = simulation.calculate('f7li', period) f7mm = simulation.calculate('f7mm', period) f7ma = simulation.calculate('f7ma', period) f7mb = simulation.calculate('f7mb', period) f7mc = simulation.calculate('f7mc', period) f7mn = simulation.calculate('f7mn', period) f7oz = simulation.calculate('f7oz', period) f7pa = simulation.calculate('f7pa', period) f7pb = simulation.calculate('f7pb', period) f7pd = simulation.calculate('f7pd', period) f7pe = simulation.calculate('f7pe', period) f7pf = simulation.calculate('f7pf', period) f7ph = simulation.calculate('f7ph', period) f7pi = simulation.calculate('f7pi', period) f7pj = simulation.calculate('f7pj', period) f7pl = simulation.calculate('f7pl', period) f7pz = simulation.calculate('f7pz', period) f7qz = simulation.calculate('f7qz', period) f7qe = simulation.calculate('f7qe', period) f7qf = simulation.calculate('f7qf', period) f7qg = simulation.calculate('f7qg', period) f7qh = simulation.calculate('f7qh', period) f7qi = simulation.calculate('f7qi', period) f7qo = simulation.calculate('f7qo', period) f7qp = simulation.calculate('f7qp', period) f7qq = simulation.calculate('f7qq', period) f7qr = simulation.calculate('f7qr', period) f7qv = simulation.calculate('f7qv', period) return period, (f7ks + f7kt + f7ku + f7lg + f7lh + f7li + f7mb + f7mn + f7mc + f7mm + f7ma + f7oz + f7pa + f7pb + f7pd + f7pe + f7pf + f7ph + f7pi + f7pj + f7pl + f7pz + f7qz + f7qf + f7qg + f7qh + f7qi + f7qo + f7qp + f7qq + f7qr + f7qe + f7qv) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Investissements dans les DOM-TOM dans le cadre d'une entrepise. ''' period = period.start.offset('first-of', 'year').period('year') f7ks = simulation.calculate('f7ks', period) f7kt = simulation.calculate('f7kt', period) f7ku = simulation.calculate('f7ku', period) f7lg = simulation.calculate('f7lg', period) f7lh = simulation.calculate('f7lh', period) f7li = simulation.calculate('f7li', period) f7ma = simulation.calculate('f7ma', period) f7mb = simulation.calculate('f7mb', period) f7mc = simulation.calculate('f7mc', period) f7mm = simulation.calculate('f7mm', period) f7mn = simulation.calculate('f7mn', period) f7nu = simulation.calculate('f7nu', period) f7nv = simulation.calculate('f7nv', period) f7nw = simulation.calculate('f7nw', period) f7ny = simulation.calculate('f7ny', period) f7pa = simulation.calculate('f7pa', period) f7pb = simulation.calculate('f7pb', period) f7pd = simulation.calculate('f7pd', period) f7pe = simulation.calculate('f7pe', period) f7pf = simulation.calculate('f7pf', period) f7ph = simulation.calculate('f7ph', period) f7pi = simulation.calculate('f7pi', period) f7pj = simulation.calculate('f7pj', period) f7pl = simulation.calculate('f7pl', period) f7pm = simulation.calculate('f7pm', period) f7pn = simulation.calculate('f7pn', period) f7po = simulation.calculate('f7po', period) f7pp = simulation.calculate('f7pp', period) f7pr = simulation.calculate('f7pr', period) f7ps = simulation.calculate('f7ps', period) f7pt = simulation.calculate('f7pt', period) f7pu = simulation.calculate('f7pu', period) f7pw = simulation.calculate('f7pw', period) f7px = simulation.calculate('f7px', period) f7py = simulation.calculate('f7py', period) f7pz = simulation.calculate('f7pz', period) f7qe = simulation.calculate('f7qe', period) f7qf = simulation.calculate('f7qf', period) f7qg = simulation.calculate('f7qg', period) f7qi = simulation.calculate('f7qi', period) f7qo = simulation.calculate('f7qo', period) f7qp = simulation.calculate('f7qp', period) f7qr = simulation.calculate('f7qr', period) f7qv = simulation.calculate('f7qv', period) f7qz = simulation.calculate('f7qz', period) f7rg = simulation.calculate('f7rg', period) f7ri = simulation.calculate('f7ri', period) f7rj = simulation.calculate('f7rj', period) f7rk = simulation.calculate('f7rk', period) f7rl = simulation.calculate('f7rl', period) f7rm = simulation.calculate('f7rm', period) f7ro = simulation.calculate('f7ro', period) f7rp = simulation.calculate('f7rp', period) f7rq = simulation.calculate('f7rq', period) f7rr = simulation.calculate('f7rr', period) f7rt = simulation.calculate('f7rt', period) f7ru = simulation.calculate('f7ru', period) f7rv = simulation.calculate('f7rv', period) f7rw = simulation.calculate('f7rw', period) f7rx = simulation.calculate('f7rx', period) f7ry = simulation.calculate('f7ry', period) return period, (f7ks + f7kt + f7ku + f7lg + f7lh + f7li + f7ma + f7mb + f7mc + f7mm + f7mn + f7pz + f7nu + f7nv + f7nw + f7ny + f7pa + f7pb + f7pd + f7pe + f7pf + f7ph + f7pi + f7pj + f7pl + f7pm + f7pn + f7po + f7pp + f7pr + f7ps + f7pt + f7pu + f7pw + f7px + f7py + f7qe + f7qf + f7qg + f7qi + f7qo + f7qp + f7qr + f7qv + f7qz + f7rg + f7ri + f7rj + f7rk + f7rl + f7rm + f7ro + f7rp + f7rq + f7rr + f7rt + f7ru + f7rv + f7rw) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Investissements dans les DOM-TOM dans le cadre d'une entrepise. ''' period = period.start.offset('first-of', 'year').period('year') fhsa = simulation.calculate('fhsa', period) fhsb = simulation.calculate('fhsb', period) fhsf = simulation.calculate('fhsf', period) fhsg = simulation.calculate('fhsg', period) fhsc = simulation.calculate('fhsc', period) fhsh = simulation.calculate('fhsh', period) fhse = simulation.calculate('fhse', period) fhsj = simulation.calculate('fhsj', period) fhsk = simulation.calculate('fhsk', period) fhsl = simulation.calculate('fhsl', period) fhsp = simulation.calculate('fhsp', period) fhsq = simulation.calculate('fhsq', period) fhsm = simulation.calculate('fhsm', period) fhsr = simulation.calculate('fhsr', period) fhso = simulation.calculate('fhso', period) fhst = simulation.calculate('fhst', period) fhsu = simulation.calculate('fhsu', period) fhsv = simulation.calculate('fhsv', period) fhsw = simulation.calculate('fhsw', period) fhsz = simulation.calculate('fhsz', period) fhta = simulation.calculate('fhta', period) fhtb = simulation.calculate('fhtb', period) fhtd = simulation.calculate('fhtd', period) f7ks = simulation.calculate('f7ks', period) f7kt = simulation.calculate('f7kt', period) f7ku = simulation.calculate('f7ku', period) f7lg = simulation.calculate('f7lg', period) f7lh = simulation.calculate('f7lh', period) f7li = simulation.calculate('f7li', period) f7ma = simulation.calculate('f7ma', period) f7mb = simulation.calculate('f7mb', period) f7mc = simulation.calculate('f7mc', period) f7mm = simulation.calculate('f7mm', period) f7mn = simulation.calculate('f7mn', period) f7nu = simulation.calculate('f7nu', period) f7nv = simulation.calculate('f7nv', period) f7nw = simulation.calculate('f7nw', period) f7ny = simulation.calculate('f7ny', period) f7pa = simulation.calculate('f7pa', period) f7pb = simulation.calculate('f7pb', period) f7pd = simulation.calculate('f7pd', period) f7pe = simulation.calculate('f7pe', period) f7pf = simulation.calculate('f7pf', period) f7ph = simulation.calculate('f7ph', period) f7pi = simulation.calculate('f7pi', period) f7pj = simulation.calculate('f7pj', period) f7pl = simulation.calculate('f7pl', period) f7pm = simulation.calculate('f7pm', period) f7pn = simulation.calculate('f7pn', period) f7po = simulation.calculate('f7po', period) f7pp = simulation.calculate('f7pp', period) f7pr = simulation.calculate('f7pr', period) f7ps = simulation.calculate('f7ps', period) f7pt = simulation.calculate('f7pt', period) f7pu = simulation.calculate('f7pu', period) f7pw = simulation.calculate('f7pw', period) f7px = simulation.calculate('f7px', period) f7py = simulation.calculate('f7py', period) f7qe = simulation.calculate('f7qe', period) f7qf = simulation.calculate('f7qf', period) f7qg = simulation.calculate('f7qg', period) f7qi = simulation.calculate('f7qi', period) f7qo = simulation.calculate('f7qo', period) f7qp = simulation.calculate('f7qp', period) f7qr = simulation.calculate('f7qr', period) f7qv = simulation.calculate('f7qv', period) f7qz = simulation.calculate('f7qz', period) f7rg = simulation.calculate('f7rg', period) f7ri = simulation.calculate('f7ri', period) f7rj = simulation.calculate('f7rj', period) f7rk = simulation.calculate('f7rk', period) f7rl = simulation.calculate('f7rl', period) f7rm = simulation.calculate('f7rm', period) f7ro = simulation.calculate('f7ro', period) f7rp = simulation.calculate('f7rp', period) f7rq = simulation.calculate('f7rq', period) f7rr = simulation.calculate('f7rr', period) f7rt = simulation.calculate('f7rt', period) f7ru = simulation.calculate('f7ru', period) f7rv = simulation.calculate('f7rv', period) f7rw = simulation.calculate('f7rw', period) f7ry = simulation.calculate('f7ry', period) return period, (fhsa + fhsb + fhsf + fhsg + fhsc + fhsh + fhse + fhsj + fhsk + fhsl + fhsp + fhsq + fhsm + fhsr + fhso + fhst + fhsu + fhsv + fhsw + fhsz + fhta + fhtb + fhtd + f7ks + f7kt + f7ku + f7lg + f7lh + f7li + f7ma + f7mb + f7mc + f7mm + f7mn + f7nu + f7nv + f7nw + f7ny + f7pa + f7pb + f7pd + f7pe + f7pf + f7ph + f7pi + f7pj + f7pl + f7pm + f7pn + f7po + f7pp + f7pr + f7ps + f7pt + f7pu + f7pw + f7px + f7py + f7qe + f7qf + f7qg + f7qi + f7qo + f7qp + f7qr + f7qv + f7qz + f7rg + f7ri + f7rj + f7rk + f7rl + f7rm + f7ro + f7rp + f7rq + f7rr + f7rt + f7ru + f7rv + f7rw) #TODO: vérifier pour 2002 #TODO: pb 7ul 2005-2009 (ITRED = 0 au lieu de 20€ (forfaitaire), dû à ça : Cochez [7UL] si vous déclarez en ligne pour #la première fois vos revenus 2008 et si vous utilisez un moyen automatique de paiement (prélèvement mensuel ou à #l'échéance ou paiement par voie électronique)) #TODO: vérifier les dates des variables de doment et domsoc (y sont-elles encore en 2013 par ex ?) @reference_formula class domlog(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"domlog" @dated_function(start = date(2002, 1, 1), stop = date(2002, 12, 31)) def function_20020101_20021231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2002 ''' period = period.start.offset('first-of', 'year').period('year') f7ua = simulation.calculate('f7ua', period) f7ub = simulation.calculate('f7ub', period) f7uc = simulation.calculate('f7uc', period) f7uj = simulation.calculate('f7uj', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.domlog return period, P.taux1 * f7uj + P.taux2 * (f7ua + f7ub + f7uc) @dated_function(start = date(2003, 1, 1), stop = date(2004, 12, 31)) def function_20030101_20041231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2003-2004 ''' period = period.start.offset('first-of', 'year').period('year') f7ua = simulation.calculate('f7ua', period) f7ub = simulation.calculate('f7ub', period) f7uc = simulation.calculate('f7uc', period) f7ui = simulation.calculate('f7ui', period) f7uj = simulation.calculate('f7uj', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.domlog return period, P.taux1 * f7uj + P.taux2 * (f7ua + f7ub + f7uc) + f7ui @dated_function(start = date(2005, 1, 1), stop = date(2007, 12, 31)) def function_20050101_20071231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2005-2007 ''' period = period.start.offset('first-of', 'year').period('year') f7ua = simulation.calculate('f7ua', period) f7ub = simulation.calculate('f7ub', period) f7uc = simulation.calculate('f7uc', period) f7ui = simulation.calculate('f7ui', period) f7uj = simulation.calculate('f7uj', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.domlog return period, P.taux1 * f7uj + P.taux2 * (f7ua + f7ub) + f7ui @dated_function(start = date(2008, 1, 1), stop = date(2008, 12, 31)) def function_20080101_20081231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2008 ''' period = period.start.offset('first-of', 'year').period('year') f7ui = simulation.calculate('f7ui', period) return period, f7ui @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2009 ''' period = period.start.offset('first-of', 'year').period('year') f7qb = simulation.calculate('f7qb', period) f7qc = simulation.calculate('f7qc', period) f7qd = simulation.calculate('f7qd', period) f7qk = simulation.calculate('f7qk', period) return period, f7qb + f7qc + f7qd + f7qk / 2 @dated_function(start = date(2010, 1, 1), stop = date(2010, 12, 31)) def function_20100101_20101231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2010 TODO: Plafonnement sur la notice ''' period = period.start.offset('first-of', 'year').period('year') f7qb = simulation.calculate('f7qb', period) f7qc = simulation.calculate('f7qc', period) f7qd = simulation.calculate('f7qd', period) f7ql = simulation.calculate('f7ql', period) f7qt = simulation.calculate('f7qt', period) f7qm = simulation.calculate('f7qm', period) return period, f7qb + f7qc + f7qd + f7ql + f7qt + f7qm @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2011 TODO: Plafonnement sur la notice ''' period = period.start.offset('first-of', 'year').period('year') f7qb = simulation.calculate('f7qb', period) f7qc = simulation.calculate('f7qc', period) f7qd = simulation.calculate('f7qd', period) f7ql = simulation.calculate('f7ql', period) f7qm = simulation.calculate('f7qm', period) f7qt = simulation.calculate('f7qt', period) f7oa = simulation.calculate('f7oa', period) f7ob = simulation.calculate('f7ob', period) f7oc = simulation.calculate('f7oc', period) f7oh = simulation.calculate('f7oh', period) f7oi = simulation.calculate('f7oi', period) f7oj = simulation.calculate('f7oj', period) f7ok = simulation.calculate('f7ok', period) return period, f7qb + f7qc + f7qd + f7ql + f7qm + f7qt + f7oa + f7ob + f7oc + f7oh + f7oi + f7oj + f7ok @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2012 TODO: Plafonnement sur la notice ''' period = period.start.offset('first-of', 'year').period('year') f7qb = simulation.calculate('f7qb', period) f7qc = simulation.calculate('f7qc', period) f7qd = simulation.calculate('f7qd', period) f7ql = simulation.calculate('f7ql', period) f7qm = simulation.calculate('f7qm', period) f7qt = simulation.calculate('f7qt', period) f7oa = simulation.calculate('f7oa', period) f7ob = simulation.calculate('f7ob', period) f7oc = simulation.calculate('f7oc', period) f7oh = simulation.calculate('f7oh', period) f7oi = simulation.calculate('f7oi', period) f7oj = simulation.calculate('f7oj', period) f7ok = simulation.calculate('f7ok', period) f7ol = simulation.calculate('f7ol', period) f7om = simulation.calculate('f7om', period) f7on = simulation.calculate('f7on', period) f7oo = simulation.calculate('f7oo', period) f7op = simulation.calculate('f7op', period) f7oq = simulation.calculate('f7oq', period) f7or = simulation.calculate('f7or', period) f7os = simulation.calculate('f7os', period) f7ot = simulation.calculate('f7ot', period) f7ou = simulation.calculate('f7ou', period) f7ov = simulation.calculate('f7ov', period) f7ow = simulation.calculate('f7ow', period) return period, (f7qb + f7qc + f7qd + f7ql + f7qm + f7qt + f7oa + f7ob + f7oc + f7oh + f7oi + f7oj + f7ok + f7ol + f7om + f7on + f7oo + f7op + f7oq + f7or + f7os + f7ot + f7ou + f7ov + f7ow) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Investissements OUTRE-MER dans le secteur du logement et autres secteurs d’activité 2013 TODO: Plafonnement sur la notice ''' period = period.start.offset('first-of', 'year').period('year') fhod = simulation.calculate('fhod', period) fhoe = simulation.calculate('fhoe', period) fhof = simulation.calculate('fhof', period) fhog = simulation.calculate('fhog', period) fhox = simulation.calculate('fhox', period) fhoy = simulation.calculate('fhoy', period) fhoz = simulation.calculate('fhoz', period) f7qb = simulation.calculate('f7qb', period) f7qc = simulation.calculate('f7qc', period) f7qd = simulation.calculate('f7qd', period) f7ql = simulation.calculate('f7ql', period) f7qm = simulation.calculate('f7qm', period) f7qt = simulation.calculate('f7qt', period) f7oa = simulation.calculate('f7oa', period) f7ob = simulation.calculate('f7ob', period) f7oc = simulation.calculate('f7oc', period) f7oh = simulation.calculate('f7oh', period) f7oi = simulation.calculate('f7oi', period) f7oj = simulation.calculate('f7oj', period) f7ok = simulation.calculate('f7ok', period) f7ol = simulation.calculate('f7ol', period) f7om = simulation.calculate('f7om', period) f7on = simulation.calculate('f7on', period) f7oo = simulation.calculate('f7oo', period) f7op = simulation.calculate('f7op', period) f7oq = simulation.calculate('f7oq', period) f7or = simulation.calculate('f7or', period) f7os = simulation.calculate('f7os', period) f7ot = simulation.calculate('f7ot', period) f7ou = simulation.calculate('f7ou', period) f7ov = simulation.calculate('f7ov', period) f7ow = simulation.calculate('f7ow', period) return period, (f7qb + f7qc + f7qd + f7ql + f7qm + f7qt + f7oa + f7ob + f7oc + f7oh + f7oi + f7oj + f7ok + f7ol + f7om + f7on + f7oo + f7op + f7oq + f7or + f7os + f7ot + f7ou + f7ov + f7ow + fhod + fhoe + fhof + fhog + fhox + fhoy + fhoz) #En accord avec la DGFiP mais pas de 7ub et 7uj dans la notice @reference_formula class domsoc(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"domsoc" @dated_function(start = date(2010, 1, 1), stop = date(2012, 12, 31)) def function_20100101_20121231(self, simulation, period): ''' Investissements outre-mer dans le logement social (déclaration n°2042 IOM) 2010- TODO plafonnement à 15% f7qa / liens avec autres investissments ? ''' period = period.start.offset('first-of', 'year').period('year') f7qn = simulation.calculate('f7qn', period) f7qk = simulation.calculate('f7qk', period) f7qu = simulation.calculate('f7qu', period) f7kg = simulation.calculate('f7kg', period) f7kh = simulation.calculate('f7kh', period) f7ki = simulation.calculate('f7ki', period) f7qj = simulation.calculate('f7qj', period) f7qs = simulation.calculate('f7qs', period) f7qw = simulation.calculate('f7qw', period) f7qx = simulation.calculate('f7qx', period) return period, f7qn + f7qk + f7qu + f7kg + f7kh + f7ki + f7qj + f7qs + f7qw + f7qx @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Investissements outre-mer dans le logement social (déclaration n°2042 IOM) 2013 TODO plafonnement à 15% f7qa / liens avec autres investissments ? ''' period = period.start.offset('first-of', 'year').period('year') fhra = simulation.calculate('fhra', period) fhrb = simulation.calculate('fhrb', period) fhrc = simulation.calculate('fhrc', period) fhrd = simulation.calculate('fhrd', period) f7qn = simulation.calculate('f7qn', period) f7qk = simulation.calculate('f7qk', period) f7qu = simulation.calculate('f7qu', period) f7kg = simulation.calculate('f7kg', period) f7kh = simulation.calculate('f7kh', period) f7ki = simulation.calculate('f7ki', period) f7qj = simulation.calculate('f7qj', period) f7qs = simulation.calculate('f7qs', period) f7qw = simulation.calculate('f7qw', period) f7qx = simulation.calculate('f7qx', period) return period, fhra + fhrb + fhrc + fhrd + f7qn + f7qk + f7qu + f7kg + f7kh + f7ki + f7qj + f7qs + f7qw + f7qx @reference_formula class donapd(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"donapd" @dated_function(start = date(2002, 1, 1), stop = date(2010, 12, 31)) def function_20020101_20101231(self, simulation, period): ''' Dons effectués à des organises d'aide aux personnes en difficulté (2002-2010) ''' period = period.start.offset('first-of', 'year').period('year') f7ud = simulation.calculate('f7ud', period) P = simulation.legislation_at(period.start).ir.reductions_impots.donapd return period, P.taux * min_(f7ud, P.max) @dated_function(start = date(2011, 1, 1), stop = date(2013, 12, 31)) def function_20110101_20131231(self, simulation, period): ''' Dons effectués à des organises d'aide aux personnes en difficulté (2011-2013) ''' period = period.start.offset('first-of', 'year').period('year') f7ud = simulation.calculate('f7ud', period) f7va = simulation.calculate('f7va', period) P = simulation.legislation_at(period.start).ir.reductions_impots.donapd return period, P.taux * min_(f7ud + f7va, P.max) @reference_formula class duflot(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"duflot" start_date = date(2013, 1, 1) def function(self, simulation, period): ''' Investissements locatifs interméiaires (loi Duflot) 2013- ''' period = period.start.offset('first-of', 'year').period('year') f7gh = simulation.calculate('f7gh', period) f7gi = simulation.calculate('f7gi', period) P = simulation.legislation_at(period.start).ir.reductions_impots.duflot return period, min_(P.plafond, P.taux_m * f7gh + P.taux_om * f7gi) / 9 #TODO: / 5 dans trois TOM @reference_formula class ecodev(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"ecodev" start_date = date(2009, 1, 1) stop_date = date(2009, 12, 31) def function(self, simulation, period): ''' Sommes versées sur un compte épargne codéveloppement (case 7UH) 2009 ''' period = period.start.offset('first-of', 'year').period('year') f7uh = simulation.calculate('f7uh', period) rbg_int = simulation.calculate('rbg_int', period) P = simulation.legislation_at(period.start).ir.reductions_impots.ecodev return period, min_(f7uh * P.taux, min_(P.base * rbg_int, P.max)) # page3 ligne 18 @reference_formula class ecpess(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"ecpess" def function(self, simulation, period): ''' Réduction d'impôt au titre des enfants à charge poursuivant leurs études secondaires ou supérieures ''' period = period.start.offset('first-of', 'year').period('year') f7ea = simulation.calculate('f7ea', period) f7eb = simulation.calculate('f7eb', period) f7ec = simulation.calculate('f7ec', period) f7ed = simulation.calculate('f7ed', period) f7ef = simulation.calculate('f7ef', period) f7eg = simulation.calculate('f7eg', period) P = simulation.legislation_at(period.start).ir.reductions_impots.ecpess return period, (P.col * (f7ea + f7eb / 2) + P.lyc * (f7ec + f7ed / 2) + P.sup * (f7ef + f7eg / 2)) @reference_formula class garext(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"garext" @dated_function(start = date(2002, 1, 1), stop = date(2002, 12, 31)) def function_20020101_20021231(self, simulation, period): ''' Frais de garde des enfants à l’extérieur du domicile (cases GA, GB, GC de la 2042) et GE, GF, GG 2002 ''' period = period.start.offset('first-of', 'year').period('year') f7ga = simulation.calculate('f7ga', period) f7gb = simulation.calculate('f7gb', period) f7gc = simulation.calculate('f7gc', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.garext max1 = P.max return period, P.taux * (min_(f7ga, max1) + min_(f7gb, max1) + min_(f7gc, max1)) @dated_function(start = date(2003, 1, 1), stop = date(2005, 12, 31)) def function_20030101_20051231(self, simulation, period): ''' Frais de garde des enfants à l’extérieur du domicile (cases GA, GB, GC de la 2042) et GE, GF, GG 2003-2005 ''' period = period.start.offset('first-of', 'year').period('year') f7ga = simulation.calculate('f7ga', period) f7gb = simulation.calculate('f7gb', period) f7gc = simulation.calculate('f7gc', period) f7ge = simulation.calculate('f7ge', period) f7gf = simulation.calculate('f7gf', period) f7gg = simulation.calculate('f7gg', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.garext max1 = P.max max2 = P.max / 2 return period, P.taux * (min_(f7ga, max1) + min_(f7gb, max1) + min_(f7gc, max1) + min_(f7ge, max2) + min_(f7gf, max2) + min_(f7gg, max2)) @reference_formula class intagr(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"intagr" start_date = date(2005, 1, 1) def function(self, simulation, period): ''' Intérêts pour paiement différé accordé aux agriculteurs 2005- ''' period = period.start.offset('first-of', 'year').period('year') f7um = simulation.calculate('f7um', period) marpac = simulation.calculate('marpac', period) P = simulation.legislation_at(period.start).ir.reductions_impots.intagr max1 = P.max * (1 + marpac) return period, P.taux * min_(f7um, max1) @reference_formula class intcon(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"intcon" start_date = date(2004, 1, 1) stop_date = date(2005, 12, 31) def function(self, simulation, period): ''' Intérêts des prêts à la consommation (case UH) 2004-2005 ''' period = period.start.offset('first-of', 'year').period('year') f7uh = simulation.calculate('f7uh', period) P = simulation.legislation_at(period.start).ir.reductions_impots.intcon max1 = P.max return period, P.taux * min_(f7uh, max1) @reference_formula class intemp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"intemp" start_date = date(2002, 1, 1) stop_date = date(2003, 12, 31) def function(self, simulation, period): ''' Intérêts d'emprunts 2002-2003 ''' period = period.start.offset('first-of', 'year').period('year') nb_pac = simulation.calculate('nb_pac', period) f7wg = simulation.calculate('f7wg', period) P = simulation.legislation_at(period.start).ir.reductions_impots.intemp max1 = P.max + P.pac * nb_pac return period, P.taux * min_(f7wg, max1) @reference_formula class invfor(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"invfor" @dated_function(start = date(2002, 1, 1), stop = date(2005, 12, 31)) def function_20020101_20051231(self, simulation, period): ''' Investissements forestiers pour 2002-2005 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7un = simulation.calculate('f7un', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invfor seuil = P.seuil * (marpac + 1) return period, P.taux * min_(f7un, seuil) @dated_function(start = date(2006, 1, 1), stop = date(2008, 12, 31)) def function_20060101_20081231(self, simulation, period): ''' Investissements forestiers pour 2006-2008 ''' period = period.start.offset('first-of', 'year').period('year') f7un = simulation.calculate('f7un', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invfor return period, P.taux * f7un @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): ''' Investissements forestiers pour 2009 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7un = simulation.calculate('f7un', period) f7up = simulation.calculate('f7up', period) f7uq = simulation.calculate('f7uq', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invfor return period, P.taux * (min_(f7un, P.seuil * (marpac + 1)) + min_(f7up, P.ifortra_seuil * (marpac + 1)) + min_(f7uq, P.iforges_seuil * (marpac + 1))) @dated_function(start = date(2010, 1, 1), stop = date(2010, 12, 31)) def function_20100101_20101231(self, simulation, period): ''' Investissements forestiers pour 2010 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7te = simulation.calculate('f7te', period) f7un = simulation.calculate('f7un', period) f7up = simulation.calculate('f7up', period) f7uq = simulation.calculate('f7uq', period) f7uu = simulation.calculate('f7uu', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invfor return period, (P.taux * ( min_(f7un, P.seuil * (marpac + 1)) + min_(f7up + f7uu + f7te, P.ifortra_seuil * (marpac + 1)) + min_(f7uq, P.iforges_seuil * (marpac + 1)))) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Investissements forestiers pour 2011 cf. 2041 GK ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7te = simulation.calculate('f7te', period) f7tf = simulation.calculate('f7tf', period) f7ul = simulation.calculate('f7ul', period) f7un = simulation.calculate('f7un', period) f7up = simulation.calculate('f7up', period) f7uq = simulation.calculate('f7uq', period) f7uu = simulation.calculate('f7uu', period) f7uv = simulation.calculate('f7uv', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invfor max0 = max_(0, P.ifortra_seuil * (marpac + 1) - f7ul) max1 = max_(0, max0 - f7uu + f7te + f7uv + f7tf) return period, (P.taux * ( min_(f7un, P.seuil * (marpac + 1)) + min_(f7up, max1) + min_(f7uq, P.iforges_seuil * (marpac + 1))) + P.report10 * min_(f7uu + f7te + f7uv + f7tf, max0) + P.taux_ass * min_(f7ul, P.ifortra_seuil * (marpac + 1))) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Investissements forestiers pour 2012 cf. 2041 GK ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7te = simulation.calculate('f7te', period) f7tf = simulation.calculate('f7tf', period) f7tg = simulation.calculate('f7tg', period) f7ul = simulation.calculate('f7ul', period) f7un = simulation.calculate('f7un', period) f7up = simulation.calculate('f7up', period) f7uq = simulation.calculate('f7uq', period) f7uu = simulation.calculate('f7uu', period) f7uv = simulation.calculate('f7uv', period) f7uw = simulation.calculate('f7uw', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invfor max0 = max_(0, P.ifortra_seuil * (marpac + 1) - f7ul) max1 = max_(0, max0 - f7uu + f7te + f7uv + f7tf) max2 = max_(0, max1 - f7tg - f7uw) return period, (P.taux * ( min_(f7un, P.seuil * (marpac + 1)) + min_(f7up, max2) + min_(f7uq, P.iforges_seuil * (marpac + 1))) + P.report10 * min_(f7uu + f7te + f7uv + f7tf, max0) + P.report11 * min_(f7tg + f7uw, max1) + P.taux_ass * min_(f7ul, P.ifortra_seuil * (marpac + 1))) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Investissements forestiers pour 2013 cf. 2041 GK ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7te = simulation.calculate('f7te', period) f7tf = simulation.calculate('f7tf', period) f7tg = simulation.calculate('f7tg', period) f7th = simulation.calculate('f7th', period) f7ul = simulation.calculate('f7ul', period) f7un = simulation.calculate('f7un', period) f7up = simulation.calculate('f7up', period) f7uq = simulation.calculate('f7uq', period) f7uu = simulation.calculate('f7uu', period) f7uv = simulation.calculate('f7uv', period) f7uw = simulation.calculate('f7uw', period) f7ux = simulation.calculate('f7ux', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invfor max0 = max_(0, P.ifortra_seuil * (marpac + 1) - f7ul) max1 = max_(0, max0 - f7uu + f7te + f7uv + f7tf) max2 = max_(0, max1 - f7tg - f7uw) max3 = max_(0, max2 - f7th - f7ux) return period, (P.taux * ( min_(f7un, P.seuil * (marpac + 1)) + min_(f7up, max3) + min_(f7uq, P.iforges_seuil * (marpac + 1))) + P.report10 * min_(f7uu + f7te + f7uv + f7tf, max0) + P.report11 * min_(f7tg + f7uw, max1) + P.report12 * min_(f7th + f7ux, max2) + P.taux_ass * min_(f7ul, P.ifortra_seuil * (marpac + 1))) @reference_formula class invlst(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"invlst" @dated_function(start = date(2004, 1, 1), stop = date(2004, 12, 31)) def function_20040101_20041231(self, simulation, period): ''' Investissements locatifs dans le secteur touristique 2004 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7xc = simulation.calculate('f7xc', period) f7xd = simulation.calculate('f7xd', period) f7xe = simulation.calculate('f7xe', period) f7xf = simulation.calculate('f7xf', period) f7xg = simulation.calculate('f7xg', period) f7xh = simulation.calculate('f7xh', period) f7xi = simulation.calculate('f7xi', period) f7xj = simulation.calculate('f7xj', period) f7xk = simulation.calculate('f7xk', period) f7xl = simulation.calculate('f7xl', period) f7xm = simulation.calculate('f7xm', period) f7xn = simulation.calculate('f7xn', period) f7xo = simulation.calculate('f7xo', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invlst seuil1 = P.seuil1 * (1 + marpac) seuil2 = P.seuil2 * (1 + marpac) seuil3 = P.seuil3 * (1 + marpac) xc = P.taux_xc * min_(f7xc, seuil1 / 4) xd = P.taux_xd * f7xd xe = P.taux_xe * min_(f7xe, seuil1 / 6) xf = P.taux_xf * f7xf xg = P.taux_xg * min_(f7xg, seuil2) xh = P.taux_xh * min_(f7xh, seuil3) xi = P.taux_xi * min_(f7xi, seuil1 / 4) xj = P.taux_xj * f7xj xk = P.taux_xk * f7xk xl = P.taux_xl * min_(f7xl, seuil1 / 6) xm = P.taux_xm * f7xm xn = P.taux_xn * min_(f7xn, seuil1 / 6) xo = P.taux_xo * f7xo return period, around(xc + xd + xe + xf + xg + xh + xi + xj + xk + xl + xm + xn + xo) @dated_function(start = date(2005, 1, 1), stop = date(2010, 12, 31)) def function_20050101_20101231(self, simulation, period): ''' Investissements locatifs dans le secteur touristique 2005-2010 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7xc = simulation.calculate('f7xc', period) f7xd = simulation.calculate('f7xd', period) f7xe = simulation.calculate('f7xe', period) f7xf = simulation.calculate('f7xf', period) f7xg = simulation.calculate('f7xg', period) f7xh = simulation.calculate('f7xh', period) f7xi = simulation.calculate('f7xi', period) f7xj = simulation.calculate('f7xj', period) f7xk = simulation.calculate('f7xk', period) f7xl = simulation.calculate('f7xl', period) f7xm = simulation.calculate('f7xm', period) f7xn = simulation.calculate('f7xn', period) f7xo = simulation.calculate('f7xo', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invlst seuil1 = P.seuil1 * (1 + marpac) seuil2 = P.seuil2 * (1 + marpac) seuil3 = P.seuil3 * (1 + marpac) xc = P.taux_xc * min_(f7xc, seuil1 / 6) xd = P.taux_xd * f7xd xe = P.taux_xe * min_(f7xe, seuil1 / 6) xf = P.taux_xf * f7xf xg = P.taux_xg * min_(f7xg, seuil2) xh = P.taux_xh * min_(f7xh, seuil2 - f7xg) xi = P.taux_xi * f7xi xj = P.taux_xj * f7xj xk = P.taux_xk * f7xk xl = P.taux_xl * min_(f7xl, seuil1 / 6) xm = P.taux_xm * f7xm xn = P.taux_xn * min_(f7xn, seuil1 / 6) xo = P.taux_xo * f7xo return period, around(xc + xd + xe + xf + xg + xh + xi + xj + xk + xl + xm + xn + xo) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Investissements locatifs dans le secteur touristique 2011 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7xa = simulation.calculate('f7xa', period) f7xb = simulation.calculate('f7xb', period) f7xc = simulation.calculate('f7xc', period) f7xd = simulation.calculate('f7xd', period) f7xe = simulation.calculate('f7xe', period) f7xf = simulation.calculate('f7xf', period) f7xg = simulation.calculate('f7xg', period) f7xh = simulation.calculate('f7xh', period) f7xi = simulation.calculate('f7xi', period) f7xj = simulation.calculate('f7xj', period) f7xk = simulation.calculate('f7xk', period) f7xl = simulation.calculate('f7xl', period) f7xm = simulation.calculate('f7xm', period) f7xn = simulation.calculate('f7xn', period) f7xo = simulation.calculate('f7xo', period) f7xp = simulation.calculate('f7xp', period) f7xq = simulation.calculate('f7xq', period) f7xr = simulation.calculate('f7xr', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invlst seuil1 = P.seuil1 * (1 + marpac) seuil2 = P.seuil2 * (1 + marpac) seuil3 = P.seuil3 * (1 + marpac) xc = P.taux_xc * min_(f7xc, seuil1 / 6) xa = P.taux_xa * min_(f7xa, seuil2) xg = P.taux_xg * min_(f7xg, seuil2 - f7xa) xb = P.taux_xb * min_(f7xb, seuil2 - f7xa - f7xg) xh = P.taux_xh * min_(f7xh, seuil2 - f7xa - f7xg - f7xb) xi = P.taux_xi * (f7xf + f7xi + f7xp) xj = P.taux_xj * (f7xm + f7xj + f7xq) xl = P.taux_xl * min_(f7xl, seuil1 / 6) xo = P.taux_xo * (f7xk + f7xo + f7xr) return period, around(xc + xa + xg + xb + xh + xi + xj + xl + xo) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Investissements locatifs dans le secteur touristique 2012 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7xa = simulation.calculate('f7xa', period) f7xb = simulation.calculate('f7xb', period) f7xc = simulation.calculate('f7xc', period) f7xd = simulation.calculate('f7xd', period) f7xe = simulation.calculate('f7xe', period) f7xf = simulation.calculate('f7xf', period) f7xg = simulation.calculate('f7xg', period) f7xh = simulation.calculate('f7xh', period) f7xi = simulation.calculate('f7xi', period) f7xj = simulation.calculate('f7xj', period) f7xk = simulation.calculate('f7xk', period) f7xl = simulation.calculate('f7xl', period) f7xm = simulation.calculate('f7xm', period) f7xn = simulation.calculate('f7xn', period) f7xo = simulation.calculate('f7xo', period) f7xp = simulation.calculate('f7xp', period) f7xq = simulation.calculate('f7xq', period) f7xr = simulation.calculate('f7xr', period) f7xv = simulation.calculate('f7xv', period) f7xx = simulation.calculate('f7xx', period) f7xz = simulation.calculate('f7xz', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invlst seuil1 = P.seuil1 * (1 + marpac) seuil2 = P.seuil2 * (1 + marpac) seuil3 = P.seuil3 * (1 + marpac) xc = P.taux_xc * min_(f7xc, seuil1 / 6) xa = P.taux_xa * min_(f7xa, seuil2) xg = P.taux_xg * min_(f7xg, seuil2 - f7xa) xx = P.taux_xx * min_(f7xx, seuil2 - f7xa - f7xg) xb = P.taux_xb * min_(f7xb, seuil2 - f7xa - f7xg - f7xx) xh = P.taux_xh * min_(f7xh, seuil2 - f7xa - f7xg - f7xb - f7xx) xz = P.taux_xz * min_(f7xz, seuil2 - f7xa - f7xg - f7xb - f7xx - f7xh) xi = P.taux_xi * (f7xf + f7xi + f7xp + f7xn) xj = P.taux_xj * (f7xm + f7xj + f7xq + f7xv) xl = P.taux_xl * min_(f7xl, seuil1 / 6) xo = P.taux_xo * (f7xk + f7xo + f7xr) return period, around(xc + xa + xg + xx + xb + xz + xh + xi + xj + xl + xo) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Investissements locatifs dans le secteur touristique 2013 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7uy = simulation.calculate('f7uy', period) f7uz = simulation.calculate('f7uz', period) f7xf = simulation.calculate('f7xf', period) f7xi = simulation.calculate('f7xi', period) f7xj = simulation.calculate('f7xj', period) f7xk = simulation.calculate('f7xk', period) f7xm = simulation.calculate('f7xm', period) f7xn = simulation.calculate('f7xn', period) f7xo = simulation.calculate('f7xo', period) f7xp = simulation.calculate('f7xp', period) f7xq = simulation.calculate('f7xq', period) f7xr = simulation.calculate('f7xr', period) f7xv = simulation.calculate('f7xv', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.invlst xi = P.taux_xi * (f7xf + f7xi + f7xp + f7xn + f7uy) xj = P.taux_xj * (f7xm + f7xj + f7xq + f7xv + f7uz) xo = P.taux_xo * (f7xk + f7xo + f7xr) return period, around(xi + xj + xo) @reference_formula class invrev(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"invrev" start_date = date(2002, 1, 1) stop_date = date(2003, 12, 31) def function(self, simulation, period): ''' Investissements locatifs dans les résidences de tourisme situées dans une zone de revitalisation rurale (cases GS, GT, XG, GU et GV) 2002-2003 TODO 1/4 codé en dur ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7gs = simulation.calculate('f7gs', period) f7gt = simulation.calculate('f7gt', period) f7xg = simulation.calculate('f7xg', period) f7gu = simulation.calculate('f7gu', period) f7gv = simulation.calculate('f7gv', period) P = simulation.legislation_at(period.start).ir.reductions_impots.invrev return period, (P.taux_gs * min_(f7gs, P.seuil_gs * (1 + marpac)) / 4 + P.taux_gu * min_(f7gu, P.seuil_gu * (1 + marpac)) / 4 + P.taux_xg * min_(f7xg, P.seuil_xg * (1 + marpac)) / 4 + P.taux_gt * f7gt + P.taux_gt * f7gv) @reference_formula class locmeu(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"locmeu" @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): ''' Investissement en vue de la location meublée non professionnelle dans certains établissements ou résidences 2009 ''' period = period.start.offset('first-of', 'year').period('year') f7ij = simulation.calculate('f7ij', period) P = simulation.legislation_at(period.start).ir.reductions_impots.locmeu return period, P.taux * min_(P.max, f7ij) / 9 @dated_function(start = date(2010, 1, 1), stop = date(2010, 12, 31)) def function_20100101_20101231(self, simulation, period): ''' Investissement en vue de la location meublée non professionnelle dans certains établissements ou résidences 2010 ''' period = period.start.offset('first-of', 'year').period('year') f7ij = simulation.calculate('f7ij', period) f7ik = simulation.calculate('f7ik', period) f7il = simulation.calculate('f7il', period) f7im = simulation.calculate('f7im', period) f7is = simulation.calculate('f7is', period) P = simulation.legislation_at(period.start).ir.reductions_impots.locmeu return period, ((min_(P.max, max_(f7ij, f7il)) + min_(P.max, f7im)) / 9 + f7ik) * P.taux + f7is @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Investissement en vue de la location meublée non professionnelle dans certains établissements ou résidences 2011 ''' period = period.start.offset('first-of', 'year').period('year') f7ij = simulation.calculate('f7ij', period) f7ik = simulation.calculate('f7ik', period) f7il = simulation.calculate('f7il', period) f7im = simulation.calculate('f7im', period) f7in = simulation.calculate('f7in', period) f7io = simulation.calculate('f7io', period) f7ip = simulation.calculate('f7ip', period) f7iq = simulation.calculate('f7iq', period) f7ir = simulation.calculate('f7ir', period) f7is = simulation.calculate('f7is', period) f7it = simulation.calculate('f7it', period) f7iu = simulation.calculate('f7iu', period) f7iv = simulation.calculate('f7iv', period) f7iw = simulation.calculate('f7iw', period) P = simulation.legislation_at(period.start).ir.reductions_impots.locmeu m20 = (maxi(f7ij, f7il, f7in, f7iv) == max_(f7il, f7in)) return period, ((min_(P.max, maxi(f7ij, f7il, f7in, f7iv)) * (P.taux20 * m20 + P.taux18 * not_(m20)) + P.taux * (min_(P.max, max_(f7im, f7iw)) + min_(P.max, f7io))) / 9 + P.taux * max_(f7ik, f7ip + f7ir + f7iq) + f7is + f7iu + f7it) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Investissement en vue de la location meublée non professionnelle dans certains établissements ou résidences 2012 ''' period = period.start.offset('first-of', 'year').period('year') f7ia = simulation.calculate('f7ia', period) f7ib = simulation.calculate('f7ib', period) f7ic = simulation.calculate('f7ic', period) f7id = simulation.calculate('f7id', period) f7ie = simulation.calculate('f7ie', period) f7if = simulation.calculate('f7if', period) f7ig = simulation.calculate('f7ig', period) f7ih = simulation.calculate('f7ih', period) f7ij = simulation.calculate('f7ij', period) f7ik = simulation.calculate('f7ik', period) f7il = simulation.calculate('f7il', period) f7im = simulation.calculate('f7im', period) f7in = simulation.calculate('f7in', period) f7io = simulation.calculate('f7io', period) f7ip = simulation.calculate('f7ip', period) f7iq = simulation.calculate('f7iq', period) f7ir = simulation.calculate('f7ir', period) f7is = simulation.calculate('f7is', period) f7it = simulation.calculate('f7it', period) f7iu = simulation.calculate('f7iu', period) f7iv = simulation.calculate('f7iv', period) f7iw = simulation.calculate('f7iw', period) f7ix = simulation.calculate('f7ix', period) f7iz = simulation.calculate('f7iz', period) P = simulation.legislation_at(period.start).ir.reductions_impots.locmeu m18 = (maxi(f7id, f7ie, f7if, f7ig) == max_(f7ie, f7if)) m20 = (maxi(f7ij, f7il, f7in, f7iv) == max_(f7il, f7in)) return period, ((min_(P.max, maxi(f7ij, f7il, f7in, f7iv)) * (P.taux20 * m20 + P.taux18 * not_(m20)) + min_(P.max, maxi(f7id, f7ie, f7if, f7ig)) * (P.taux18 * m18 + P.taux11 * not_(m18)) + P.taux * (min_(P.max, max_(f7im, f7iw)) + min_(P.max, f7io))) / 9 + P.taux * max_(f7ik + f7ip, f7ir + f7iq) + f7ia + f7ib + f7ic + f7ih + f7is + f7iu + f7it + f7ix + f7iz) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Investissement en vue de la location meublée non professionnelle dans certains établissements ou résidences 2013 ''' period = period.start.offset('first-of', 'year').period('year') f7ia = simulation.calculate('f7ia', period) f7ib = simulation.calculate('f7ib', period) f7ic = simulation.calculate('f7ic', period) f7id = simulation.calculate('f7id', period) f7ie = simulation.calculate('f7ie', period) f7if = simulation.calculate('f7if', period) f7ig = simulation.calculate('f7ig', period) f7ih = simulation.calculate('f7ih', period) f7ij = simulation.calculate('f7ij', period) f7ik = simulation.calculate('f7ik', period) f7il = simulation.calculate('f7il', period) f7im = simulation.calculate('f7im', period) f7in = simulation.calculate('f7in', period) f7io = simulation.calculate('f7io', period) f7ip = simulation.calculate('f7ip', period) f7iq = simulation.calculate('f7iq', period) f7ir = simulation.calculate('f7ir', period) f7is = simulation.calculate('f7is', period) f7it = simulation.calculate('f7it', period) f7iu = simulation.calculate('f7iu', period) f7iv = simulation.calculate('f7iv', period) f7iw = simulation.calculate('f7iw', period) f7ix = simulation.calculate('f7ix', period) f7iy = simulation.calculate('f7iy', period) f7iz = simulation.calculate('f7iz', period) f7jc = simulation.calculate('f7jc', period) f7ji = simulation.calculate('f7ji', period) f7js = simulation.calculate('f7js', period) f7jt = simulation.calculate('f7jt', period) f7ju = simulation.calculate('f7ju', period) f7jv = simulation.calculate('f7jv', period) f7jw = simulation.calculate('f7jw', period) f7jx = simulation.calculate('f7jx', period) f7jy = simulation.calculate('f7jy', period) P = simulation.legislation_at(period.start).ir.reductions_impots.locmeu m18 = (maxi(f7id, f7ie, f7if, f7ig) == max_(f7ie, f7if)) m20 = (maxi(f7ij, f7il, f7in, f7iv) == max_(f7il, f7in)) return period, ((min_(P.max, maxi(f7ij, f7il, f7in, f7iv)) * (P.taux20 * m20 + P.taux18 * not_(m20)) + min_(P.max, maxi(f7id, f7ie, f7if, f7ig)) * (P.taux18 * m18 + P.taux11 * not_(m18)) + P.taux11 * min_(P.max, f7jt + f7ju) + P.taux * (min_(P.max, max_(f7im, f7iw)) + min_(P.max, f7io))) / 9 + P.taux * max_(f7ik + f7ip, f7ir + f7iq) + f7ia + f7ib + f7ic + f7ih + f7is + f7iu + f7it + f7ix + f7iy + f7iz + f7jv + f7jw + f7jx + f7jy + f7jc + f7ji + f7js) @reference_formula class mohist(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"mohist" start_date = date(2008, 1, 1) def function(self, simulation, period): ''' Travaux de conservation et de restauration d’objets classés monuments historiques (case NZ) 2008- ''' period = period.start.offset('first-of', 'year').period('year') f7nz = simulation.calculate('f7nz', period) P = simulation.legislation_at(period.start).ir.reductions_impots.mohist return period, P.taux * min_(f7nz, P.max) @reference_formula class patnat(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"patnat" @dated_function(start = date(2010, 1, 1), stop = date(2010, 12, 31)) def function_20100101_20101231(self, simulation, period): ''' Dépenses de protections du patrimoine naturel (case 7KA) 2010 ''' period = period.start.offset('first-of', 'year').period('year') f7ka = simulation.calculate('f7ka', period) P = simulation.legislation_at(period.start).ir.reductions_impots.patnat max1 = P.max return period, P.taux * min_(f7ka, max1) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Dépenses de protections du patrimoine naturel (case 7KA, 7KB) 2011 ''' period = period.start.offset('first-of', 'year').period('year') f7ka = simulation.calculate('f7ka', period) f7kb = simulation.calculate('f7kb', period) P = simulation.legislation_at(period.start).ir.reductions_impots.patnat max1 = P.max return period, P.taux * min_(f7ka, max1) + f7kb @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Dépenses de protections du patrimoine naturel (case 7KA, 7KB, 7KC) 2012 ''' period = period.start.offset('first-of', 'year').period('year') f7ka = simulation.calculate('f7ka', period) f7kb = simulation.calculate('f7kb', period) f7kc = simulation.calculate('f7kc', period) P = simulation.legislation_at(period.start).ir.reductions_impots.patnat max1 = P.max return period, P.taux * min_(f7ka, max1) + f7kb + f7kc @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Dépenses de protections du patrimoine naturel (case 7KA, 7KB, 7KC) 2013 ''' period = period.start.offset('first-of', 'year').period('year') f7ka = simulation.calculate('f7ka', period) f7kb = simulation.calculate('f7kb', period) f7kc = simulation.calculate('f7kc', period) f7kd = simulation.calculate('f7kd', period) P = simulation.legislation_at(period.start).ir.reductions_impots.patnat max1 = P.max return period, P.taux * min_(f7ka, max1) + f7kb + f7kc + f7kd @reference_formula class prcomp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"prcomp" def function(self, simulation, period): ''' Prestations compensatoires 2002- ''' period = period.start.offset('first-of', 'year').period('year') f7wm = simulation.calculate('f7wm', period) f7wn = simulation.calculate('f7wn', period) f7wo = simulation.calculate('f7wo', period) f7wp = simulation.calculate('f7wp', period) P = simulation.legislation_at(period.start).ir.reductions_impots.prcomp div = (f7wo == 0) * 1 + f7wo # Pour éviter les divisions par zéro return period, ((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)) + (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) @reference_formula class repsoc(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"repsoc" start_date = date(2003, 1, 1) def function(self, simulation, period): ''' Intérèts d'emprunts pour reprises de société 2003- ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7fh = simulation.calculate('f7fh', period) P = simulation.legislation_at(period.start).ir.reductions_impots.repsoc seuil = P.seuil * (marpac + 1) return period, P.taux * min_(f7fh, seuil) @reference_formula class resimm(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"resimm" @dated_function(start = date(2009, 1, 1), stop = date(2010, 12, 31)) def function_20090101_20101231(self, simulation, period): ''' Travaux de restauration immobilière (cases 7RA et 7RB) 2009-2010 ''' period = period.start.offset('first-of', 'year').period('year') f7ra = simulation.calculate('f7ra', period) f7rb = simulation.calculate('f7rb', period) P = simulation.legislation_at(period.start).ir.reductions_impots.resimm max1 = P.max max2 = max_(max1 - f7rb, 0) return period, P.taux_rb * min_(f7rb, max1) + P.taux_ra * min_(f7ra, max2) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Travaux de restauration immobilière (cases 7RA, 7RB, 7RC, 7RD) 2011 ''' period = period.start.offset('first-of', 'year').period('year') f7ra = simulation.calculate('f7ra', period) f7rb = simulation.calculate('f7rb', period) f7rc = simulation.calculate('f7rc', period) f7rd = simulation.calculate('f7rd', period) P = simulation.legislation_at(period.start).ir.reductions_impots.resimm max1 = P.max max2 = max_(max1 - f7rd, 0) max3 = max_(max2 - f7rb, 0) max4 = max_(max3 - f7rc, 0) return period, (P.taux_rd * min_(f7rd, max1) + P.taux_rb * min_(f7rb, max2) + P.taux_rc * min_(f7rc, max3) + P.taux_ra * min_(f7ra, max4)) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Travaux de restauration immobilière (cases 7RA, 7RB, 7RC, 7RD, 7RE, 7RF) 2012 ''' period = period.start.offset('first-of', 'year').period('year') f7ra = simulation.calculate('f7ra', period) f7rb = simulation.calculate('f7rb', period) f7rc = simulation.calculate('f7rc', period) f7rd = simulation.calculate('f7rd', period) f7re = simulation.calculate('f7re', period) f7rf = simulation.calculate('f7rf', period) P = simulation.legislation_at(period.start).ir.reductions_impots.resimm max1 = P.max max2 = max_(max1 - f7rd, 0) max3 = max_(max2 - f7rb, 0) max4 = max_(max3 - f7rc - f7rf, 0) max5 = max_(max4 - f7ra, 0) return period, (P.taux_rd * min_(f7rd, max1) + P.taux_rb * min_(f7rb, max2) + P.taux_rc * min_(f7rc + f7rf, max3) + P.taux_ra * min_(f7ra, max4) + P.taux_re * min_(f7re, max5)) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Travaux de restauration immobilière (cases 7RA, 7RB, 7RC, 7RD, 7RE, 7RF, 7SX, 7SY) 2012 ''' period = period.start.offset('first-of', 'year').period('year') f7ra = simulation.calculate('f7ra', period) f7rb = simulation.calculate('f7rb', period) f7rc = simulation.calculate('f7rc', period) f7rd = simulation.calculate('f7rd', period) f7re = simulation.calculate('f7re', period) f7rf = simulation.calculate('f7rf', period) f7sx = simulation.calculate('f7sx', period) f7sy = simulation.calculate('f7sy', period) P = simulation.legislation_at(period.start).ir.reductions_impots.resimm max1 = P.max max2 = max_(max1 - f7rd, 0) max3 = max_(max2 - f7rb, 0) max4 = max_(max3 - f7rc - f7sy - f7rf, 0) max5 = max_(max4 - f7ra, 0) return period, (P.taux_rd * min_(f7rd, max1) + P.taux_rb * min_(f7rb, max2) + P.taux_rc * min_(f7sy + f7rf + f7rc, max3) + P.taux_ra * min_(f7ra, max4) + P.taux_re * min_(f7re + f7sx, max5)) @reference_formula class rsceha(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"rsceha" def function(self, simulation, period): ''' Rentes de survie et contrats d'épargne handicap 2002- ''' period = period.start.offset('first-of', 'year').period('year') nb_pac2 = simulation.calculate('nb_pac2', period) nbR = simulation.calculate('nbR', period) f7gz = simulation.calculate('f7gz', period) P = simulation.legislation_at(period.start).ir.reductions_impots.rsceha max1 = P.seuil1 + (nb_pac2 - nbR) * P.seuil2 return period, P.taux * min_(f7gz, max1) @reference_formula class saldom(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"saldom" @dated_function(start = date(2002, 1, 1), stop = date(2004, 12, 31)) def function_20020101_20041231(self, simulation, period): ''' Sommes versées pour l'emploi d'un salariés à domicile 2002-2004 ''' period = period.start.offset('first-of', 'year').period('year') f7df = simulation.calculate('f7df', period) f7dg = simulation.calculate('f7dg', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.saldom isinvalid = f7dg max1 = P.max1 * not_(isinvalid) + P.max3 * isinvalid return period, P.taux * min_(f7df, max1) @dated_function(start = date(2005, 1, 1), stop = date(2006, 12, 31)) def function_20050101_20061231(self, simulation, period): ''' Sommes versées pour l'emploi d'un salariés à domicile 2005-2006 ''' period = period.start.offset('first-of', 'year').period('year') nb_pac2 = simulation.calculate('nb_pac2', period) f7df = simulation.calculate('f7df', period) f7dl = simulation.calculate('f7dl', period) f7dg = simulation.calculate('f7dg', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.saldom isinvalid = f7dg nbpacmin = nb_pac2 + f7dl maxBase = P.max1 maxDuMaxNonInv = P.max2 maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv) max1 = maxNonInv * not_(isinvalid) + P.max3 * isinvalid return period, P.taux * min_(f7df, max1) @dated_function(start = date(2007, 1, 1), stop = date(2008, 12, 31)) def function_20070101_20081231(self, simulation, period): ''' Sommes versées pour l'emploi d'un salariés à domicile 2007-2008 ''' period = period.start.offset('first-of', 'year').period('year') nb_pac2 = simulation.calculate('nb_pac2', period) f7db = simulation.calculate('f7db', period) f7df = simulation.calculate('f7df', period) f7dl = simulation.calculate('f7dl', period) f7dg = simulation.calculate('f7dg', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.saldom isinvalid = f7dg nbpacmin = nb_pac2 + f7dl maxBase = P.max1 maxDuMaxNonInv = P.max2 maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv) maxEffectif = maxNonInv * not_(isinvalid) + P.max3 * isinvalid max1 = maxEffectif - min_(f7db, maxEffectif) return period, P.taux * min_(f7df, max1) @dated_function(start = date(2009, 1, 1), stop = date(2013, 12, 31)) def function_20090101_20131231(self, simulation, period): ''' Sommes versées pour l'emploi d'un salariés à domicile 2009-2013 ''' period = period.start.offset('first-of', 'year').period('year') nb_pac2 = simulation.calculate('nb_pac2', period) f7db = simulation.calculate('f7db', period) f7df = simulation.calculate('f7df', period) f7dl = simulation.calculate('f7dl', period) f7dq = simulation.calculate('f7dq', period) f7dg = simulation.calculate('f7dg', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.saldom isinvalid = f7dg annee1 = f7dq nbpacmin = nb_pac2 + f7dl maxBase = P.max1 * not_(annee1) + P.max1_1ereAnnee * annee1 maxDuMaxNonInv = P.max2 * not_(annee1) + P.max2_1ereAnnee * annee1 maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv) maxEffectif = maxNonInv * not_(isinvalid) + P.max3 * isinvalid max1 = maxEffectif - min_(f7db, maxEffectif) return period, P.taux * min_(f7df, max1) @reference_formula class scelli(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"scelli" @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): ''' Investissements locatif neufs : Dispositif Scellier (cases 7HJ et 7HK) 2009 ''' period = period.start.offset('first-of', 'year').period('year') f7hj = simulation.calculate('f7hj', period) f7hk = simulation.calculate('f7hk', period) P = simulation.legislation_at(period.start).ir.reductions_impots.scelli return period, max_(P.taux1 * min_(P.max, f7hj), P.taux2 * min_(P.max, f7hk)) / 9 @dated_function(start = date(2010, 1, 1), stop = date(2010, 12, 31)) def function_20100101_20101231(self, simulation, period): ''' Investissements locatif neufs : Dispositif Scellier 2010 ''' period = period.start.offset('first-of', 'year').period('year') f7hj = simulation.calculate('f7hj', period) f7hk = simulation.calculate('f7hk', period) f7hn = simulation.calculate('f7hn', period) f7ho = simulation.calculate('f7ho', period) f7hl = simulation.calculate('f7hl', period) f7hm = simulation.calculate('f7hm', period) f7hr = simulation.calculate('f7hr', period) f7hs = simulation.calculate('f7hs', period) f7la = simulation.calculate('f7la', period) P = simulation.legislation_at(period.start).ir.reductions_impots.scelli return period, (max_( max_(P.taux1 * min_(P.max, f7hj), P.taux2 * min_(P.max, f7hk)), max_(P.taux1 * min_(P.max, f7hn), P.taux2 * min_(P.max, f7ho))) / 9 + max_( P.taux1 * min_(P.max, f7hl), P.taux2 * min_(P.max, f7hm)) / 9 + max_(P.taux1 * f7hr, P.taux2 * f7hs) + f7la) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Investissements locatif neufs : Dispositif Scellier 2011 ''' period = period.start.offset('first-of', 'year').period('year') f7hj = simulation.calculate('f7hj', period) f7hk = simulation.calculate('f7hk', period) f7hl = simulation.calculate('f7hl', period) f7hm = simulation.calculate('f7hm', period) f7hn = simulation.calculate('f7hn', period) f7ho = simulation.calculate('f7ho', period) f7hr = simulation.calculate('f7hr', period) f7hs = simulation.calculate('f7hs', period) f7ht = simulation.calculate('f7ht', period) f7hu = simulation.calculate('f7hu', period) f7hv = simulation.calculate('f7hv', period) f7hw = simulation.calculate('f7hw', period) f7hx = simulation.calculate('f7hx', period) f7hz = simulation.calculate('f7hz', period) f7la = simulation.calculate('f7la', period) f7lb = simulation.calculate('f7lb', period) f7lc = simulation.calculate('f7lc', period) f7na = simulation.calculate('f7na', period) f7nb = simulation.calculate('f7nb', period) f7nc = simulation.calculate('f7nc', period) f7nd = simulation.calculate('f7nd', period) f7ne = simulation.calculate('f7ne', period) f7nf = simulation.calculate('f7nf', period) f7ng = simulation.calculate('f7ng', period) f7nh = simulation.calculate('f7nh', period) f7ni = simulation.calculate('f7ni', period) f7nj = simulation.calculate('f7nj', period) f7nk = simulation.calculate('f7nk', period) f7nl = simulation.calculate('f7nl', period) f7nm = simulation.calculate('f7nm', period) f7nn = simulation.calculate('f7nn', period) f7no = simulation.calculate('f7no', period) f7np = simulation.calculate('f7np', period) f7nq = simulation.calculate('f7nq', period) f7nr = simulation.calculate('f7nr', period) f7ns = simulation.calculate('f7ns', period) f7nt = simulation.calculate('f7nt', period) P = simulation.legislation_at(period.start).ir.reductions_impots.scelli return period, (min_(P.max, maxi( P.taux13 * max_(f7nf, f7nj) / 9, P.taux15 * max_(f7ng, f7ni) / 9, P.taux22 * max_(f7na, f7ne) / 9, P.taux1 * maxi(f7nb, f7nc, f7nd, f7nh) / 9, P.taux36 * maxi(f7nk / 9, f7no / 9, f7np / 5, f7nt / 5), P.taux2 * maxi(f7nl / 9, f7nm / 9, f7nn / 9, f7nq / 5, f7nr / 5, f7ns / 5))) + min_(P.max, maxi( P.taux1 * max_(f7hj, f7hn), P.taux2 * max_(f7hk, f7ho))) / 9 + min_(P.max, max_(P.taux1 * f7hl, P.taux2 * f7hm)) / 9 + min_(P.max, maxi(P.taux1 * f7hv, P.taux1 * f7hx, P.taux2 * f7hw, P.taux2 * f7hz)) + min_(P.max, max_(P.taux1 * f7ht, P.taux2 * f7hu)) + min_(P.max, max_(P.taux1 * f7hr, P.taux2 * f7hs)) + f7la + f7lb + f7lc ) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Investissements locatif neufs : Dispositif Scellier 2012 ''' period = period.start.offset('first-of', 'year').period('year') f7ha = simulation.calculate('f7ha', period) f7hb = simulation.calculate('f7hb', period) f7hg = simulation.calculate('f7hg', period) f7hh = simulation.calculate('f7hh', period) f7hd = simulation.calculate('f7hd', period) f7he = simulation.calculate('f7he', period) f7hf = simulation.calculate('f7hf', period) f7hj = simulation.calculate('f7hj', period) f7hk = simulation.calculate('f7hk', period) f7hl = simulation.calculate('f7hl', period) f7hm = simulation.calculate('f7hm', period) f7hn = simulation.calculate('f7hn', period) f7ho = simulation.calculate('f7ho', period) f7hr = simulation.calculate('f7hr', period) f7hs = simulation.calculate('f7hs', period) f7ht = simulation.calculate('f7ht', period) f7hu = simulation.calculate('f7hu', period) f7hv = simulation.calculate('f7hv', period) f7hw = simulation.calculate('f7hw', period) f7hx = simulation.calculate('f7hx', period) f7hz = simulation.calculate('f7hz', period) f7ja = simulation.calculate('f7ja', period) f7jb = simulation.calculate('f7jb', period) f7jd = simulation.calculate('f7jd', period) f7je = simulation.calculate('f7je', period) f7jf = simulation.calculate('f7jf', period) f7jg = simulation.calculate('f7jg', period) f7jh = simulation.calculate('f7jh', period) f7jj = simulation.calculate('f7jj', period) f7jk = simulation.calculate('f7jk', period) f7jl = simulation.calculate('f7jl', period) f7jm = simulation.calculate('f7jm', period) f7jn = simulation.calculate('f7jn', period) f7jo = simulation.calculate('f7jo', period) f7jp = simulation.calculate('f7jp', period) f7jq = simulation.calculate('f7jq', period) f7jr = simulation.calculate('f7jr', period) f7la = simulation.calculate('f7la', period) f7lb = simulation.calculate('f7lb', period) f7lc = simulation.calculate('f7lc', period) f7ld = simulation.calculate('f7ld', period) f7le = simulation.calculate('f7le', period) f7lf = simulation.calculate('f7lf', period) f7na = simulation.calculate('f7na', period) f7nb = simulation.calculate('f7nb', period) f7nc = simulation.calculate('f7nc', period) f7nd = simulation.calculate('f7nd', period) f7ne = simulation.calculate('f7ne', period) f7nf = simulation.calculate('f7nf', period) f7ng = simulation.calculate('f7ng', period) f7nh = simulation.calculate('f7nh', period) f7ni = simulation.calculate('f7ni', period) f7nj = simulation.calculate('f7nj', period) f7nk = simulation.calculate('f7nk', period) f7nl = simulation.calculate('f7nl', period) f7nm = simulation.calculate('f7nm', period) f7nn = simulation.calculate('f7nn', period) f7no = simulation.calculate('f7no', period) f7np = simulation.calculate('f7np', period) f7nq = simulation.calculate('f7nq', period) f7nr = simulation.calculate('f7nr', period) f7ns = simulation.calculate('f7ns', period) f7nt = simulation.calculate('f7nt', period) P = simulation.legislation_at(period.start).ir.reductions_impots.scelli return period, (min_(P.max, maxi( P.taux13 * max_(f7nf, f7nj) / 9, P.taux15 * max_(f7ng, f7ni) / 9, P.taux22 * max_(f7na, f7ne) / 9, P.taux1 * maxi(f7nb, f7nc, f7nd, f7nh) / 9, P.taux36 * maxi(f7nk / 9, f7no / 9, f7np / 5, f7nt / 5), P.taux2 * maxi(f7nl / 9, f7nm / 9, f7nn / 9, f7nq / 5, f7nr / 5, f7ns / 5))) + min_(P.max, maxi( P.taux1 * max_(f7hj, f7hn), P.taux2 * max_(f7hk, f7ho))) / 9 + min_(P.max, max_(P.taux1 * f7hl, P.taux2 * f7hm)) / 9 + min_(P.max, maxi(P.taux1 * f7hv, P.taux1 * f7hx, P.taux2 * f7hw, P.taux2 * f7hz)) + min_(P.max, max_(P.taux1 * f7ht, P.taux2 * f7hu)) + min_(P.max, max_(P.taux1 * f7hr, P.taux2 * f7hs)) + f7la + f7lb + f7lc + f7ld + f7le + f7lf + f7ha + f7hb + f7hg + f7hh + f7hd + f7he + f7hf + min_(P.max, maxi( P.taux6 * max_(f7jf, f7jj) / 9, P.taux13 * maxi(f7ja, f7je, f7jg, f7jh) / 9, P.taux22 * maxi(f7jb, f7jd) / 9, P.taux24 * maxi(f7jk / 9, f7jn / 9, f7jo / 5, f7jr / 5), P.taux36 * maxi(f7jl / 9, f7jm / 9, f7jp / 5, f7jq / 5))) ) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Investissements locatif neufs : Dispositif Scellier 2013 ''' period = period.start.offset('first-of', 'year').period('year') f7fa = simulation.calculate('f7fa', period) f7fb = simulation.calculate('f7fb', period) f7fc = simulation.calculate('f7fc', period) f7fd = simulation.calculate('f7fd', period) f7gj = simulation.calculate('f7gj', period) f7gk = simulation.calculate('f7gk', period) f7gl = simulation.calculate('f7gl', period) f7gp = simulation.calculate('f7gp', period) f7gs = simulation.calculate('f7gs', period) f7gt = simulation.calculate('f7gt', period) f7gu = simulation.calculate('f7gu', period) f7gv = simulation.calculate('f7gv', period) f7gw = simulation.calculate('f7gw', period) f7gx = simulation.calculate('f7gx', period) f7ha = simulation.calculate('f7ha', period) f7hb = simulation.calculate('f7hb', period) f7hg = simulation.calculate('f7hg', period) f7hh = simulation.calculate('f7hh', period) f7hd = simulation.calculate('f7hd', period) f7he = simulation.calculate('f7he', period) f7hf = simulation.calculate('f7hf', period) f7hj = simulation.calculate('f7hj', period) f7hk = simulation.calculate('f7hk', period) f7hl = simulation.calculate('f7hl', period) f7hm = simulation.calculate('f7hm', period) f7hn = simulation.calculate('f7hn', period) f7ho = simulation.calculate('f7ho', period) f7hr = simulation.calculate('f7hr', period) f7hs = simulation.calculate('f7hs', period) f7ht = simulation.calculate('f7ht', period) f7hu = simulation.calculate('f7hu', period) f7hv = simulation.calculate('f7hv', period) f7hw = simulation.calculate('f7hw', period) f7hx = simulation.calculate('f7hx', period) f7hz = simulation.calculate('f7hz', period) f7ja = simulation.calculate('f7ja', period) f7jb = simulation.calculate('f7jb', period) f7jd = simulation.calculate('f7jd', period) f7je = simulation.calculate('f7je', period) f7jf = simulation.calculate('f7jf', period) f7jg = simulation.calculate('f7jg', period) f7jh = simulation.calculate('f7jh', period) f7jj = simulation.calculate('f7jj', period) f7jk = simulation.calculate('f7jk', period) f7jl = simulation.calculate('f7jl', period) f7jm = simulation.calculate('f7jm', period) f7jn = simulation.calculate('f7jn', period) f7jo = simulation.calculate('f7jo', period) f7jp = simulation.calculate('f7jp', period) f7jq = simulation.calculate('f7jq', period) f7jr = simulation.calculate('f7jr', period) f7la = simulation.calculate('f7la', period) f7lb = simulation.calculate('f7lb', period) f7lc = simulation.calculate('f7lc', period) f7ld = simulation.calculate('f7ld', period) f7le = simulation.calculate('f7le', period) f7lf = simulation.calculate('f7lf', period) f7lm = simulation.calculate('f7lm', period) f7ls = simulation.calculate('f7ls', period) f7lz = simulation.calculate('f7lz', period) f7mg = simulation.calculate('f7mg', period) f7na = simulation.calculate('f7na', period) f7nb = simulation.calculate('f7nb', period) f7nc = simulation.calculate('f7nc', period) f7nd = simulation.calculate('f7nd', period) f7ne = simulation.calculate('f7ne', period) f7nf = simulation.calculate('f7nf', period) f7ng = simulation.calculate('f7ng', period) f7nh = simulation.calculate('f7nh', period) f7ni = simulation.calculate('f7ni', period) f7nj = simulation.calculate('f7nj', period) f7nk = simulation.calculate('f7nk', period) f7nl = simulation.calculate('f7nl', period) f7nm = simulation.calculate('f7nm', period) f7nn = simulation.calculate('f7nn', period) f7no = simulation.calculate('f7no', period) f7np = simulation.calculate('f7np', period) f7nq = simulation.calculate('f7nq', period) f7nr = simulation.calculate('f7nr', period) f7ns = simulation.calculate('f7ns', period) f7nt = simulation.calculate('f7nt', period) P = simulation.legislation_at(period.start).ir.reductions_impots.scelli return period, (min_(P.max, maxi( P.taux13 * max_(f7nf, f7nj) / 9, P.taux15 * max_(f7ng, f7ni) / 9, P.taux22 * max_(f7na, f7ne) / 9, P.taux1 * maxi(f7nb, f7nc, f7nd, f7nh) / 9, P.taux36 * maxi(f7nk / 9, f7no / 9, f7np / 5, f7nt / 5), P.taux2 * maxi(f7nl / 9, f7nm / 9, f7nn / 9, f7nq / 5, f7nr / 5, f7ns / 5))) + min_(P.max, maxi( P.taux1 * max_(f7hj, f7hn), P.taux2 * max_(f7hk, f7ho))) / 9 + min_(P.max, max_(P.taux1 * f7hl, P.taux2 * f7hm)) / 9 + min_(P.max, maxi(P.taux1 * f7hv, P.taux1 * f7hx, P.taux2 * f7hw, P.taux2 * f7hz)) + min_(P.max, max_(P.taux1 * f7ht, P.taux2 * f7hu)) + min_(P.max, max_(P.taux1 * f7hr, P.taux2 * f7hs)) + min_(P.max, maxi( P.taux6 * maxi(f7jf, f7jj, f7fb) / 9, P.taux13 * maxi(f7ja, f7je, f7jg, f7jh, f7fa) / 9, P.taux22 * maxi(f7jb, f7jd) / 9, P.taux24 * maxi(f7jk / 9, f7jn / 9, f7jo / 5, f7jr / 5, f7fc / 9, f7fd / 5), P.taux36 * maxi(f7jl / 9, f7jm / 9, f7jp / 5, f7jq / 5))) + f7la + f7lb + f7lc + f7ld + f7le + f7lf + f7lm + f7ls + f7lz + f7mg + f7ha + f7hb + f7hg + f7hh + f7hd + f7he + f7hf + f7gj + f7gk + f7gl + f7gp + f7gs + f7gt + f7gu + f7gv + f7gx + f7gw ) @reference_formula class sofica(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"sofica" start_date = date(2006, 1, 1) def function(self, simulation, period): ''' Souscriptions au capital de SOFICA 2006- ''' period = period.start.offset('first-of', 'year').period('year') f7gn = simulation.calculate('f7gn', period) f7fn = simulation.calculate('f7fn', period) rng = simulation.calculate('rng', period) P = simulation.legislation_at(period.start).ir.reductions_impots.sofica max0 = min_(P.taux1 * max_(rng, 0), P.max) max1 = max_(0, max0 - f7gn) return period, P.taux2 * min_(f7gn, max0) + P.taux3 * min_(f7fn, max1) @reference_formula class sofipe(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"sofipe" start_date = date(2009, 1, 1) stop_date = date(2011, 1, 1) def function(self, simulation, period): """ Souscription au capital d’une SOFIPECHE (case 7GS) 2009-2011 """ period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) rbg_int = simulation.calculate('rbg_int', period) f7gs = simulation.calculate('f7gs', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.sofipe max1 = min_(P.max * (marpac + 1), P.base * rbg_int) # page3 ligne 18 return period, P.taux * min_(f7gs, max1) @reference_formula class spfcpi(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"spfcpi" @dated_function(start = date(2002, 1, 1), stop = date(2002, 12, 31)) def function_20020101_20021231(self, simulation, period): ''' Souscription de parts de fonds communs de placement dans l'innovation, de fonds d'investissement de proximité 2002 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7gq = simulation.calculate('f7gq', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.spfcpi max1 = P.max * (marpac + 1) return period, P.taux1 * min_(f7gq, max1) @dated_function(start = date(2003, 1, 1), stop = date(2006, 12, 31)) def function_20030101_20061231(self, simulation, period): ''' Souscription de parts de fonds communs de placement dans l'innovation, de fonds d'investissement de proximité 2003-2006 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7gq = simulation.calculate('f7gq', period) f7fq = simulation.calculate('f7fq', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.spfcpi max1 = P.max * (marpac + 1) return period, (P.taux1 * min_(f7gq, max1) + P.taux1 * min_(f7fq, max1)) @dated_function(start = date(2007, 1, 1), stop = date(2010, 12, 31)) def function_20070101_20101231(self, simulation, period): ''' Souscription de parts de fonds communs de placement dans l'innovation, de fonds d'investissement de proximité 2007-2010 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7gq = simulation.calculate('f7gq', period) f7fq = simulation.calculate('f7fq', period) f7fm = simulation.calculate('f7fm', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.spfcpi max1 = P.max * (marpac + 1) return period, (P.taux1 * min_(f7gq, max1) + P.taux1 * min_(f7fq, max1) + P.taux2 * min_(f7fm, max1)) @dated_function(start = date(2011, 1, 1), stop = date(2013, 12, 31)) def function_20110101_20131231(self, simulation, period): ''' Souscription de parts de fonds communs de placement dans l'innovation, de fonds d'investissement de proximité 2011-2013 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f7gq = simulation.calculate('f7gq', period) f7fq = simulation.calculate('f7fq', period) f7fm = simulation.calculate('f7fm', period) f7fl = simulation.calculate('f7fl', period) _P = simulation.legislation_at(period.start) P = simulation.legislation_at(period.start).ir.reductions_impots.spfcpi max1 = P.max * (marpac + 1) return period, (P.taux1 * min_(f7gq, max1) + P.taux1 * min_(f7fq, max1) + P.taux2 * min_(f7fm, max1) + P.taux3 * min_(f7fl, max1)) @dated_function(start = date(2014, 1, 1), stop = date(2014, 12, 31)) def function_20140101_20141231(self, simulation, period): ''' Souscription de parts de fonds communs de placement dans l'innovation, de fonds d'investissement de proximité 2014 ''' period = period.start.offset('first-of', 'year').period('year') f7gq = simulation.calculate('f7gq', period) return period, f7gq * 0 def mini(a, b, *args): if not args: return min_(a, b) else: return min_(a, mini(b, *args)) def maxi(a, b, *args): if not args: return max_(a, b) else: return max_(a, maxi(b, *args)) PKoz= 1) + P.pac2 * (n >= 2) + P.pac3 * (max_(n - 2, 0)) + ((n >= 2) * P.pac3 * nbH + (n == 1) * (P.pac2 + (nbH > 1) * P.pac3 * (nbH - 1) ) * (nbH >= 1) + (n == 0) * (P.pac1 + (nbH > 1) * P.pac2 * (nbH - 1) + (nbH > 2) * P.pac3 * (nbH - 2)) * (nbH >= 1)) / 2) return period, P.taux_wi * min_(f7wi, max0) @dated_function(start = date(2004, 1, 1), stop = date(2005, 12, 31)) def function_20040101_20051231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de l’aide aux personnes (cases 7WI, 7WJ). 2004-2005 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) nbH = simulation.calculate('nbH', period) f7wi = simulation.calculate('f7wi', period) f7wj = simulation.calculate('f7wj', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.aidper n = nb_pac2 - nbH/2 max0 = (P.max * (1 + marpac) + P.pac1 * (n >= 1) + P.pac2 * (n >= 2) + P.pac3 * (max_(n - 2, 0)) + ((n >= 2) * P.pac3 * nbH + (n == 1) * (P.pac2 + (nbH > 1) * P.pac3 * (nbH - 1) ) * (nbH >= 1) + (n == 0) * (P.pac1 + (nbH > 1) * P.pac2 * (nbH - 1) + (nbH > 2) * P.pac3 * (nbH - 2)) * (nbH >= 1)) / 2) max1 = max_(0, max0 - f7wj) return period, (P.taux_wj * min_(f7wj, max0) + P.taux_wi * min_(f7wi, max1)) @dated_function(start = date(2006, 1, 1), stop = date(2009, 12, 31)) def function_20060101_20091231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de l’aide aux personnes (cases 7WI, 7WJ). 2006-2009 cf. cerfa 50796 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) f7wi = simulation.calculate('f7wi', period) f7wj = simulation.calculate('f7wj', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.aidper max0 = P.max * (1 + marpac) + P.pac1 * nb_pac2 max1 = max_(0, max0 - f7wj) return period, (P.taux_wj * min_(f7wj, max0) + P.taux_wi * min_(f7wi, max1)) @dated_function(start = date(2010, 1, 1), stop = date(2011, 12, 31)) def function_20100101_20111231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de l’aide aux personnes (cases 7SF, 7WI, 7WJ, 7WL). 2010-2011 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) f7sf = simulation.calculate('f7sf', period) f7wi = simulation.calculate('f7wi', period) f7wj = simulation.calculate('f7wj', period) f7wl = simulation.calculate('f7wl', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.aidper max0 = P.max * (1 + marpac) + P.pac1 * nb_pac2 max1 = max_(0, max0 - f7wl - f7sf) max2 = max_(0, max1 - f7wj) return period, P.taux_wl * min_(f7wl+f7sf, max0) + P.taux_wj * min_(f7wj, max1) + P.taux_wi * min_(f7wi, max2) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de l’aide aux personnes (cases 7WI, 7WJ, 7WL, 7WR). 2012 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) f7wi = simulation.calculate('f7wi', period) f7wj = simulation.calculate('f7wj', period) f7wl = simulation.calculate('f7wl', period) f7wr = simulation.calculate('f7wr', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.aidper # On ne contrôle pas que 7WR ne dépasse pas le plafond (ça dépend du nombre de logements (7sa) et de la nature des #travaux, c'est un peu le bordel) max00 = P.max * (1 + marpac) max0 = max00 + P.pac1 * nb_pac2 max1 = max_(0, max0 - max_(0,f7wl-max00)) max2 = max_(0, max1 - f7wj) return period, (P.taux_wr * f7wr + P.taux_wl * min_(f7wl, max00) + P.taux_wl * max_(f7wl - max00, 0) + P.taux_wj * min_(f7wj, max1) + P.taux_wi * min_(f7wi, max2)) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de l’aide aux personnes (cases 7WI, 7WJ, 7WL). 2013 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) f7wj = simulation.calculate('f7wj', period) f7wl = simulation.calculate('f7wl', period) f7wr = simulation.calculate('f7wr', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.aidper # On ne contrôle pas que 7WR ne dépasse pas le plafond (ça dépend du nombre de logements et de la nature des #travaux, c'est un peu le bordel) max00 = P.max * (1 + marpac) max0 = max00 + P.pac1 * nb_pac2 max1 = max_(0, max0 - max_(0,f7wl-max00)) return period, (P.taux_wr * f7wr + P.taux_wl * min_(f7wl, max00) + P.taux_wl * max_(f7wl - max00, 0) + P.taux_wj * min_(f7wj, max1)) @reference_formula class assloy(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"assloy" start_date = date(2005, 1, 1) def function(self, simulation, period): ''' Crédit d’impôt primes d’assurance pour loyers impayés (case 4BF) 2005- ''' period = period.start.offset('first-of', 'year').period('year') f4bf = simulation.calculate('f4bf', period) _P = simulation.legislation_at(period.start) return period, _P.ir.credits_impot.assloy.taux * f4bf @reference_formula class autent(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"autent" start_date = date(2009, 1, 1) def function(self, simulation, period): ''' Auto-entrepreneur : versements d’impôt sur le revenu (case 8UY) 2009- ''' period = period.start.offset('first-of', 'year').period('year') f8uy = simulation.calculate('f8uy', period) return period, f8uy @reference_formula class ci_garext(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"ci_garext" start_date = date(2005, 1, 1) def function(self, simulation, period): ''' Frais de garde des enfants à l’extérieur du domicile (cases 7GA à 7GC et 7GE à 7GG) 2005- ''' period = period.start.offset('first-of', 'year').period('year') f7ga = simulation.calculate('f7ga', period) f7gb = simulation.calculate('f7gb', period) f7gc = simulation.calculate('f7gc', period) f7ge = simulation.calculate('f7ge', period) f7gf = simulation.calculate('f7gf', period) f7gg = simulation.calculate('f7gg', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.garext max1 = P.max return period, P.taux * (min_(f7ga, max1) + min_(f7gb, max1) + min_(f7gc, max1) + min_(f7ge, max1 / 2) + min_(f7gf, max1 / 2) + min_(f7gg, max1 / 2)) @reference_formula class creimp_exc_2008(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"creimp_exc_2008" def function(self, simulation, period): ''' Crédit d'impôt exceptionnel sur les revenus 2008 http://www11.minefi.gouv.fr/boi/boi2009/5fppub/textes/5b2509/5b2509.pdf ''' period = period.start.offset('first-of', 'year').period('year') rni = simulation.calculate('rni', period) nbptr = simulation.calculate('nbptr', period) iai = simulation.calculate('iai', period) mohist = simulation.calculate('mohist', period) elig_creimp_exc_2008 = simulation.calculate('elig_creimp_exc_2008', period) #TODO: gérer les DOM-TOM, corriger les formules, inclure 7KA rpp = rni / nbptr return period, (elig_creimp_exc_2008 * (mohist < 10700) * (rpp <= 12475) * around((2/3) * min_(12475, iai) * (rpp < 11674) + (rpp > 11673) * max_(0, 8317 * (12475 - rpp) / 802))) @reference_formula class creimp(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"creimp" @dated_function(start = date(2002, 1, 1), stop = date(2002, 12, 31)) def function_20020101_20021231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2002 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8td_2002_2005 = simulation.calculate('f8td_2002_2005', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) return period, (f2ab + f8ta + f8tb + f8tc + f8td_2002_2005 + f8te - f8tf + f8tg + f8th) @dated_function(start = date(2003, 1, 1), stop = date(2003, 12, 31)) def function_20030101_20031231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2003 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8td_2002_2005 = simulation.calculate('f8td_2002_2005', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) return period, (f2ab + f8ta + f8tb + f8tc + f8td_2002_2005 + f8te - f8tf + f8tg + f8th + f8to - f8tp) @dated_function(start = date(2004, 1, 1), stop = date(2004, 12, 31)) def function_20040101_20041231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2004 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8td_2002_2005 = simulation.calculate('f8td_2002_2005', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8tz = simulation.calculate('f8tz', period) f8uz = simulation.calculate('f8uz', period) return period, (f2ab + f8ta + f8tb + f8tc + f8td_2002_2005 + f8te - f8tf + f8tg + f8th + f8to - f8tp + f8tz + f8uz) @dated_function(start = date(2005, 1, 1), stop = date(2005, 12, 31)) def function_20050101_20051231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2005 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8td_2002_2005 = simulation.calculate('f8td_2002_2005', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8tz = simulation.calculate('f8tz', period) f8uz = simulation.calculate('f8uz', period) f8wa = simulation.calculate('f8wa', period) f8wb = simulation.calculate('f8wb', period) f8wc = simulation.calculate('f8wc', period) f8we = simulation.calculate('f8we', period) return period, (f2ab + f8ta + f8tb + f8tc + f8td_2002_2005 + f8te - f8tf + f8tg + f8th + f8to - f8tp + f8tz + f8uz + f8wa + f8wb + f8wc + f8we) @dated_function(start = date(2006, 1, 1), stop = date(2006, 12, 31)) def function_20060101_20061231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2006 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8tz = simulation.calculate('f8tz', period) f8uz = simulation.calculate('f8uz', period) f8wa = simulation.calculate('f8wa', period) f8wb = simulation.calculate('f8wb', period) f8wc = simulation.calculate('f8wc', period) f8wd = simulation.calculate('f8wd', period) f8we = simulation.calculate('f8we', period) f8wr = simulation.calculate('f8wr', period) f8ws = simulation.calculate('f8ws', period) f8wt = simulation.calculate('f8wt', period) f8wu = simulation.calculate('f8wu', period) return period, (f2ab + f8ta + f8tb + f8tc + f8te - f8tf + f8tg + f8th + f8to - f8tp + f8tz + f8uz + f8wa + f8wb + f8wc + f8wd + f8we + f8wr + f8ws + f8wt + f8wu) @dated_function(start = date(2007, 1, 1), stop = date(2007, 12, 31)) def function_20070101_20071231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2007 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8tz = simulation.calculate('f8tz', period) f8uz = simulation.calculate('f8uz', period) f8wa = simulation.calculate('f8wa', period) f8wb = simulation.calculate('f8wb', period) f8wc = simulation.calculate('f8wc', period) f8wd = simulation.calculate('f8wd', period) f8wr = simulation.calculate('f8wr', period) f8ws = simulation.calculate('f8ws', period) f8wt = simulation.calculate('f8wt', period) f8wu = simulation.calculate('f8wu', period) f8wv = simulation.calculate('f8wv', period) f8wx = simulation.calculate('f8wx', period) return period, (f2ab + f8ta + f8tb + f8tc + f8te - f8tf + f8tg + f8th + f8to - f8tp + f8tz + f8uz + f8wa + f8wb + f8wc + f8wd + f8wr + f8ws + f8wt + f8wu + f8wv + f8wx) @dated_function(start = date(2008, 1, 1), stop = date(2008, 12, 31)) def function_20080101_20081231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2008''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8tz = simulation.calculate('f8tz', period) f8uz = simulation.calculate('f8uz', period) f8wa = simulation.calculate('f8wa', period) f8wb = simulation.calculate('f8wb', period) f8wc = simulation.calculate('f8wc', period) f8wd = simulation.calculate('f8wd', period) f8we = simulation.calculate('f8we', period) f8wr = simulation.calculate('f8wr', period) f8ws = simulation.calculate('f8ws', period) f8wt = simulation.calculate('f8wt', period) f8wu = simulation.calculate('f8wu', period) f8wv = simulation.calculate('f8wv', period) f8wx = simulation.calculate('f8wx', period) return period, (f2ab + f8ta + f8tb + f8tc + f8te - f8tf + f8tg + f8th + f8to - f8tp + f8tz + f8uz + f8wa + f8wb + f8wc + f8wd + f8wr + f8ws + f8wt + f8wu + f8wv + f8wx) @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2009''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8tz = simulation.calculate('f8tz', period) f8uz = simulation.calculate('f8uz', period) f8wa = simulation.calculate('f8wa', period) f8wb = simulation.calculate('f8wb', period) f8wd = simulation.calculate('f8wd', period) f8we = simulation.calculate('f8we', period) f8wr = simulation.calculate('f8wr', period) f8ws = simulation.calculate('f8ws', period) f8wt = simulation.calculate('f8wt', period) f8wu = simulation.calculate('f8wu', period) f8wv = simulation.calculate('f8wv', period) f8wx = simulation.calculate('f8wx', period) return period, (f2ab + f8ta + f8tb + f8te - f8tf + f8tg + f8th + f8to - f8tp + f8tz + f8uz + f8wa + f8wb + f8wd + f8we + f8wr + f8ws + f8wt + f8wu + f8wv + f8wx) @dated_function(start = date(2010, 1, 1), stop = date(2011, 12, 31)) def function_20100101_20111231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2010 et 2011 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8tz = simulation.calculate('f8tz', period) f8uz = simulation.calculate('f8uz', period) f8wa = simulation.calculate('f8wa', period) f8wb = simulation.calculate('f8wb', period) f8wd = simulation.calculate('f8wd', period) f8we = simulation.calculate('f8we', period) f8wr = simulation.calculate('f8wr', period) f8wt = simulation.calculate('f8wt', period) f8wu = simulation.calculate('f8wu', period) f8wv = simulation.calculate('f8wv', period) return period, (f2ab + f8ta + f8tb + f8tc + f8te - f8tf + f8tg + f8th + f8to - f8tp + f8tz + f8uz + f8wa + f8wb + f8wd + f8we + f8wr + f8wt + f8wu + f8wv) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2012 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8ts = simulation.calculate('f8ts', period) f8tz = simulation.calculate('f8tz', period) f8uz = simulation.calculate('f8uz', period) f8wa = simulation.calculate('f8wa', period) f8wb = simulation.calculate('f8wb', period) f8wd = simulation.calculate('f8wd', period) f8we = simulation.calculate('f8we', period) f8wr = simulation.calculate('f8wr', period) f8wt = simulation.calculate('f8wt', period) f8wu = simulation.calculate('f8wu', period) f8wv = simulation.calculate('f8wv', period) return period, (f2ab + f8ta + f8tb + f8tc +f8te - f8tf + f8tg + f8th + f8to - f8tp + f8ts + f8tz + f8uz + f8wa + f8wb + f8wd + f8we + f8wr + f8wt + f8wu + f8wv) @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): '''Avoir fiscaux et crédits d'impôt 2013 ''' period = period.start.offset('first-of', 'year').period('year') f2ab = simulation.calculate('f2ab', period) f2ck = simulation.calculate('f2ck', period) f8ta = simulation.calculate('f8ta', period) f8tb = simulation.calculate('f8tb', period) f8tc = simulation.calculate('f8tc', period) f8te = simulation.calculate('f8te', period) f8tf = simulation.calculate('f8tf', period) f8tg = simulation.calculate('f8tg', period) f8th = simulation.calculate('f8th', period) f8tl = simulation.calculate('f8tl', period) f8to = simulation.calculate('f8to', period) f8tp = simulation.calculate('f8tp', period) f8ts = simulation.calculate('f8ts', period) f8tz = simulation.calculate('f8tz', period) f8uw = simulation.calculate('f8uw', period) f8uz = simulation.calculate('f8uz', period) f8wa = simulation.calculate('f8wa', period) f8wb = simulation.calculate('f8wb', period) f8wc = simulation.calculate('f8wc', period) f8wd = simulation.calculate('f8wd', period) f8we = simulation.calculate('f8we', period) f8wr = simulation.calculate('f8wr', period) f8wt = simulation.calculate('f8wt', period) f8wu = simulation.calculate('f8wu', period) return period, (f2ab + f2ck + f8ta + f8tb + f8tc + f8te - f8tf + f8tg + f8th + f8to - f8tp + f8tl + f8ts + f8tz + f8uw + f8uz + f8wa + f8wb + f8wc + f8wd + f8we + f8wr + f8wt + f8wu) @reference_formula class direpa(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"direpa" def function(self, simulation, period): ''' Crédit d’impôt directive « épargne » (case 2BG) 2006- ''' period = period.start.offset('first-of', 'year').period('year') f2bg = simulation.calculate('f2bg', period) return period, f2bg @reference_formula class divide(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"divide" start_date = date(2005, 1, 1) stop_date = date(2009, 12, 31) def function(self, simulation, period): ''' Crédit d'impôt dividendes 2005-2009 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) f2dc = simulation.calculate('f2dc', period) f2gr = simulation.calculate('f2gr', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.divide max1 = P.max * (marpac + 1) return period, min_(P.taux * (f2dc + f2gr), max1) @reference_formula class drbail(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"drbail" def function(self, simulation, period): ''' Crédit d’impôt représentatif de la taxe additionnelle au droit de bail (case 4TQ) 2002- ''' period = period.start.offset('first-of', 'year').period('year') f4tq = simulation.calculate('f4tq', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.drbail return period, P.taux * f4tq @reference_formula class inthab(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"inthab" @dated_function(start = date(2007, 1, 1), stop = date(2007, 12, 31)) def function_20070101_20071231(self, simulation, period): ''' Crédit d’impôt intérêts des emprunts pour l’habitation principale (cases 7UH) 2007 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) caseP = simulation.calculate('caseP', period) caseF = simulation.calculate('caseF', period) nbG = simulation.calculate('nbG', period) nbR = simulation.calculate('nbR', period) f7uh = simulation.calculate('f7uh', period) P = simulation.legislation_at(period.start).ir.credits_impot.inthab invalide = caseP | caseF | (nbG != 0) | (nbR != 0) max0 = P.max * (marpac + 1) * (1 + invalide) + nb_pac2 * P.add return period, P.taux1 * min_(max0, f7uh) @dated_function(start = date(2008, 1, 1), stop = date(2008, 12, 31)) def function_20080101_20081231(self, simulation, period): ''' Crédit d’impôt intérêts des emprunts pour l’habitation principale (cases 7VX, 7VY et 7VZ) 2008 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) caseP = simulation.calculate('caseP', period) caseF = simulation.calculate('caseF', period) nbG = simulation.calculate('nbG', period) nbR = simulation.calculate('nbR', period) f7vy = simulation.calculate('f7vy', period) f7vz = simulation.calculate('f7vz', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.inthab invalide = caseP | caseF | (nbG != 0) | (nbR != 0) max0 = P.max * (marpac + 1) * (1 + invalide) + nb_pac2 * P.add max1 = max_(max0 - f7vy, 0) return period, (P.taux1 * min_(f7vy, max0) + P.taux3 * min_(f7vz, max1)) @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): ''' Crédit d’impôt intérêts des emprunts pour l’habitation principale (cases 7VX, 7VY et 7VZ) 2009 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) caseP = simulation.calculate('caseP', period) caseF = simulation.calculate('caseF', period) nbG = simulation.calculate('nbG', period) nbR = simulation.calculate('nbR', period) f7vx = simulation.calculate('f7vx', period) f7vy = simulation.calculate('f7vy', period) f7vz = simulation.calculate('f7vz', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.inthab invalide = caseP | caseF | (nbG != 0) | (nbR != 0) max0 = P.max * (marpac + 1) * (1 + invalide) + nb_pac2 * P.add max1 = max_(max0 - f7vx, 0) max2 = max_(max1 - f7vy, 0) return period, (P.taux1 * min_(f7vx, max0) + P.taux1 * min_(f7vy, max1) + P.taux3 * min_(f7vz, max2)) @dated_function(start = date(2010, 1, 1), stop = date(2010, 12, 31)) def function_20100101_20101231(self, simulation, period): ''' Crédit d’impôt intérêts des emprunts pour l’habitation principale (cases 7VW, 7VX, 7VY et 7VZ) 2010 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) caseP = simulation.calculate('caseP', period) caseF = simulation.calculate('caseF', period) nbG = simulation.calculate('nbG', period) nbR = simulation.calculate('nbR', period) f7vw = simulation.calculate('f7vw', period) f7vx = simulation.calculate('f7vx', period) f7vy = simulation.calculate('f7vy', period) f7vz = simulation.calculate('f7vz', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.inthab invalide = caseP | caseF | (nbG != 0) | (nbR != 0) max0 = P.max * (marpac + 1) * (1 + invalide) + nb_pac2 * P.add max1 = max_(max0 - f7vx, 0) max2 = max_(max1 - f7vy, 0) max3 = max_(max2 - f7vw, 0) return period, (P.taux1 * min_(f7vx, max0) + P.taux1 * min_(f7vy, max1) + P.taux2 * min_(f7vw, max2) + P.taux3 * min_(f7vz, max3)) @dated_function(start = date(2011, 1, 1), stop = date(2011, 12, 31)) def function_20110101_20111231(self, simulation, period): ''' Crédit d’impôt intérêts des emprunts pour l’habitation principale (cases 7VW, 7VX, 7VY et 7VZ) 2011 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) caseP = simulation.calculate('caseP', period) caseF = simulation.calculate('caseF', period) nbG = simulation.calculate('nbG', period) nbR = simulation.calculate('nbR', period) f7vu = simulation.calculate('f7vu', period) f7vw = simulation.calculate('f7vw', period) f7vv = simulation.calculate('f7vv', period) f7vx = simulation.calculate('f7vx', period) f7vy = simulation.calculate('f7vy', period) f7vz = simulation.calculate('f7vz', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.inthab invalide = caseP | caseF | (nbG != 0) | (nbR != 0) max0 = P.max * (marpac + 1) * (1 + invalide) + nb_pac2 * P.add max1 = max_(max0 - f7vx, 0) max2 = max_(max1 - f7vy, 0) max3 = max_(max2 - f7vw, 0) max4 = max_(max3 - f7vu, 0) max5 = max_(max4 - f7vz, 0) return period, (P.taux1 * min_(f7vx, max0) + P.taux1 * min_(f7vy, max1) + P.taux2 * min_(f7vw, max2) + P.taux3 * min_(f7vu, max3) + P.taux4 * min_(f7vz, max4) + P.taux5 * min_(f7vv, max5)) @dated_function(start = date(2012, 1, 1), stop = date(2013, 12, 31)) def function_20120101_20131231(self, simulation, period): ''' Crédit d’impôt intérêts des emprunts pour l’habitation principale (cases 7VW, 7VX, 7VY et 7VZ) 2011 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) caseP = simulation.calculate('caseP', period) caseF = simulation.calculate('caseF', period) nbG = simulation.calculate('nbG', period) nbR = simulation.calculate('nbR', period) f7vt = simulation.calculate('f7vt', period) f7vu = simulation.calculate('f7vu', period) f7vv = simulation.calculate('f7vv', period) f7vw = simulation.calculate('f7vw', period) f7vx = simulation.calculate('f7vx', period) f7vy = simulation.calculate('f7vy', period) f7vz = simulation.calculate('f7vz', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.inthab invalide = caseP | caseF | (nbG != 0) | (nbR != 0) max0 = P.max * (marpac + 1) * (1 + invalide) + nb_pac2 * P.add max1 = max_(max0 - f7vx, 0) max2 = max_(max1 - f7vy, 0) max3 = max_(max2 - f7vw, 0) max4 = max_(max3 - f7vu, 0) max5 = max_(max4 - f7vz, 0) max6 = max_(max5 - f7vv, 0) return period, (P.taux1 * min_(f7vx, max0) + P.taux1 * min_(f7vy, max1) + P.taux2 * min_(f7vw, max2) + P.taux3 * min_(f7vu, max3) + P.taux4 * min_(f7vz, max4) + P.taux5 * min_(f7vv, max5) + P.taux6 * min_(f7vt, max6)) @reference_formula class jeunes(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"jeunes" start_date = date(2005, 1, 1) stop_date = date(2008, 12, 31) def function(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') jeunes_ind_holder = simulation.compute('jeunes_ind', period) return period, self.sum_by_entity(jeunes_ind_holder) @reference_formula class jeunes_ind(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"jeunes_ind" start_date = date(2005, 1, 1) stop_date = date(2008, 12, 31) def function(self, simulation, period): ''' Crédit d'impôt en faveur des jeunes 2005-2008 rfr de l'année où jeune de moins de 26 à travaillé six mois cf. http://www3.finances.gouv.fr/calcul_impot/2009/pdf/form-2041-GY.pdf Attention seuls certains ''' period = period.start.offset('first-of', 'year').period('year') age = simulation.calculate('age', period) nbptr_holder = simulation.compute('nbptr', period) rfr_holder = simulation.compute('rfr', period) salaire_imposable = simulation.calculate_add('salaire_imposable', period) marpac_holder = simulation.compute('marpac', period) elig_creimp_jeunes = simulation.calculate('elig_creimp_jeunes', period) _P = simulation.legislation_at(period.start) #TODO: vérifier si les jeunes sous le foyer fiscal de leurs parents sont éligibles P = _P.ir.credits_impot.jeunes rfr = self.cast_from_entity_to_roles(rfr_holder) nbptr = self.cast_from_entity_to_roles(nbptr_holder) marpac = self.cast_from_entity_to_roles(marpac_holder) elig = (age < P.age) * (rfr < P.rfr_plaf * (marpac * P.rfr_mult + not_(marpac)) + max_(0, nbptr - 2) * .5 * P.rfr_maj + (nbptr == 1.5) * P.rfr_maj) montant = ( (P.min <= salaire_imposable) * (salaire_imposable < P.int) * P.montant + (P.int <= salaire_imposable) * (salaire_imposable <= P.max) * (P.max - salaire_imposable) * P.taux ) return period, elig_creimp_jeunes * elig * max_(25, montant) # D'après le document num. 2041 GY # somme calculée sur formulaire 2041 @reference_formula class mecena(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"mecena" start_date = date(2003, 1, 1) def function(self, simulation, period): ''' Mécénat d'entreprise (case 7US) 2003- ''' period = period.start.offset('first-of', 'year').period('year') f7us = simulation.calculate('f7us', period) return period, f7us @reference_formula class percvm(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"percvm" start_date = date(2010, 1, 1) stop_date = date(2010, 12, 31) def function(self, simulation, period): ''' Crédit d’impôt pertes sur cessions de valeurs mobilières (3VV) -2010 ''' period = period.start.offset('first-of', 'year').period('year') f3vv_end_2010 = simulation.calculate('f3vv_end_2010', period) _P = simulation.legislation_at(period.start) return period, _P.ir.credits_impot.percvm.taux * f3vv_end_2010 @reference_formula class preetu(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"preetu" @dated_function(start = date(2005, 1, 1), stop = date(2005, 12, 31)) def function_20050101_20051231(self, simulation, period): ''' Crédit d’impôt pour souscription de prêts étudiants (cases 7UK, 7VO et 7TD) 2005 ''' period = period.start.offset('first-of', 'year').period('year') f7uk = simulation.calculate('f7uk', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.preetu return period, P.taux * min_(f7uk, P.max) @dated_function(start = date(2006, 1, 1), stop = date(2007, 12, 31)) def function_20060101_20071231(self, simulation, period): ''' Crédit d’impôt pour souscription de prêts étudiants (cases 7UK, 7VO et 7TD) 2006-2007 ''' period = period.start.offset('first-of', 'year').period('year') f7uk = simulation.calculate('f7uk', period) f7vo = simulation.calculate('f7vo', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.preetu max1 = P.max * (1 + f7vo) return period, P.taux * min_(f7uk, max1) @dated_function(start = date(2008, 1, 1), stop = date(2015, 12, 31)) def function_20080101_20151231(self, simulation, period): ''' Crédit d’impôt pour souscription de prêts étudiants (cases 7UK, 7VO et 7TD) 2008- ''' period = period.start.offset('first-of', 'year').period('year') f7uk = simulation.calculate('f7uk', period) f7vo = simulation.calculate('f7vo', period) f7td = simulation.calculate('f7td', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.preetu max1 = P.max * f7vo return period, P.taux * min_(f7uk, P.max) + P.taux * min_(f7td, max1) @reference_formula class prlire(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"Prélèvement libératoire à restituer (case 2DH)" stop_date = date(2013, 12, 31) def function(self, simulation, period): ''' Prélèvement libératoire à restituer (case 2DH) 2002- http://www2.impots.gouv.fr/documentation/2013/brochure_ir/index.html#122/z ''' period = period.start.offset('first-of', 'year').period('year') f2dh = simulation.calculate('f2dh', period) f2ch = simulation.calculate('f2ch', period) marpac = simulation.calculate('marpac', period) _P = simulation.legislation_at(period.start) plaf_resid = max_(_P.ir.rvcm.abat_assvie * (1 + marpac) - f2ch, 0) return period, _P.ir.credits_impot.prlire.taux * min_(f2dh, plaf_resid) @reference_formula class quaenv(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"quaenv" @dated_function(start = date(2005, 1, 1), stop = date(2005, 12, 31)) def function_20050101_20051231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de la qualité environnementale (cases 7WF, 7WG, 7WH) 2005 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) f7wf = simulation.calculate('f7wf', period) f7wg = simulation.calculate('f7wg', period) f7wh = simulation.calculate('f7wh', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.quaenv n = nb_pac2 max0 = P.max * (1 + marpac) + P.pac1 * (n >= 1) + P.pac2 * (n >= 2) + P.pac2 * (max_(n - 2, 0)) max1 = max_(0, max0 - f7wf) max2 = max_(0, max1 - f7wg) return period, (P.taux_wf * min_(f7wf, max0) + P.taux_wg * min_(f7wg, max1) + P.taux_wh * min_(f7wh, max2)) @dated_function(start = date(2006, 1, 1), stop = date(2008, 12, 31)) def function_20060101_20081231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de la qualité environnementale (cases 7WF, 7WG, 7WH, 7WQ) 2006-2008 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) f7wf = simulation.calculate('f7wf', period) f7wg = simulation.calculate('f7wg', period) f7wh = simulation.calculate('f7wh', period) f7wq = simulation.calculate('f7wq', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.quaenv max0 = P.max * (1 + marpac) + P.pac1 * nb_pac2 max1 = max_(0, max0 - f7wf) max2 = max_(0, max1 - f7wg) max3 = max_(0, max2 - f7wh) return period, (P.taux_wf * min_(f7wf, max0) + P.taux_wg * min_(f7wg, max1) + P.taux_wh * min_(f7wh, max2) + P.taux_wq * min_(f7wq, max3)) @dated_function(start = date(2009, 1, 1), stop = date(2009, 12, 31)) def function_20090101_20091231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de la qualité environnementale (cases 7WF, 7WG, 7WH, 7WK, 7WQ, 7SB, 7SC, 7SD, 7SE) 2009 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) f7we = simulation.calculate('f7we', period) f7wf = simulation.calculate('f7wf', period) f7wg = simulation.calculate('f7wg', period) f7wh = simulation.calculate('f7wh', period) f7wk = simulation.calculate('f7wk', period) f7wq = simulation.calculate('f7wq', period) f7sb = simulation.calculate('f7sb', period) f7sc = simulation.calculate('f7sc', period) f7sd = simulation.calculate('f7sd', period) f7se = simulation.calculate('f7se', period) rfr = simulation.calculate('rfr', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.quaenv max0 = P.max * (1 + marpac) + P.pac1 * nb_pac2 max1 = max_(0, max0 - f7wf) max2 = max_(0, max1 - f7se) max3 = max_(0, max2 - f7wk) max4 = max_(0, max3 - f7sd) max5 = max_(0, max4 - f7wg) max6 = max_(0, max5 - f7sc) max7 = max_(0, max6 - f7wh) max8 = max_(0, max7 - f7sb) return period, or_(not_(f7we), rfr < 45000) * (P.taux_wf * min_(f7wf, max0) + P.taux_se * min_(f7se, max1) + P.taux_wk * min_(f7wk, max2) + P.taux_sd * min_(f7sd, max3) + P.taux_wg * min_(f7wg, max4) + P.taux_sc * min_(f7sc, max5) + P.taux_wh * min_(f7wh, max6) + P.taux_sb * min_(f7sb, max7) + P.taux_wq * min_(f7wq, max8)) @dated_function(start = date(2010, 1, 1), stop = date(2011, 12, 31)) def function_20100101_20111231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de la qualité environnementale (cases 7WF, 7WH, 7WK, 7WQ, 7SB, 7SD, 7SE et 7SH) 2010-2011 ''' period = period.start.offset('first-of', 'year').period('year') marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) f7we = simulation.calculate('f7we', period) f7wf = simulation.calculate('f7wf', period) f7wg = simulation.calculate('f7wg', period) f7wh = simulation.calculate('f7wh', period) f7wk = simulation.calculate('f7wk', period) f7wq = simulation.calculate('f7wq', period) f7sb = simulation.calculate('f7sb', period) f7sd = simulation.calculate('f7sd', period) f7se = simulation.calculate('f7se', period) f7sh = simulation.calculate('f7sh', period) rfr = simulation.calculate('rfr', period) _P = simulation.legislation_at(period.start) P = _P.ir.credits_impot.quaenv max0 = P.max * (1 + marpac) + P.pac1 * nb_pac2 max1 = max_(0, max0 - f7wf) max2 = max_(0, max1 - f7se) max3 = max_(0, max2 - f7wk) max4 = max_(0, max3 - f7sd) max5 = max_(0, max4 - f7wh) max6 = max_(0, max5 - f7sb) max7 = max_(0, max6 - f7wq) return period, not_(f7wg) * or_(not_(f7we), (rfr < 45000)) * ( P.taux_wf * min_(f7wf, max0) + P.taux_se * min_(f7se, max1) + P.taux_wk * min_(f7wk, max2) + P.taux_sd * min_(f7sd, max3) + P.taux_wh * min_(f7wh, max4) + P.taux_sb * min_(f7sb, max5) + P.taux_wq * min_(f7wq, max6) + P.taux_sh * min_(f7sh, max7)) @dated_function(start = date(2012, 1, 1), stop = date(2012, 12, 31)) def function_20120101_20121231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de la qualité environnementale 2012 ''' period = period.start.offset('first-of', 'year').period('year') f7sd = simulation.calculate('f7sd', period) f7se = simulation.calculate('f7se', period) f7sf = simulation.calculate('f7sf', period) f7sg = simulation.calculate('f7sg', period) f7sh = simulation.calculate('f7sh', period) f7si = simulation.calculate('f7si', period) f7sj = simulation.calculate('f7sj', period) f7sk = simulation.calculate('f7sk', period) f7sl = simulation.calculate('f7sl', period) f7sm = simulation.calculate('f7sm', period) f7sn = simulation.calculate('f7sn', period) f7so = simulation.calculate('f7so', period) f7sp = simulation.calculate('f7sp', period) f7sq = simulation.calculate('f7sq', period) f7sr = simulation.calculate('f7sr', period) f7ss = simulation.calculate('f7ss', period) f7tt = simulation.calculate('f7tt', period) f7tu = simulation.calculate('f7tu', period) f7tv = simulation.calculate('f7tv', period) f7tw = simulation.calculate('f7tw', period) f7tx = simulation.calculate('f7tx', period) f7ty = simulation.calculate('f7ty', period) f7st = simulation.calculate('f7st', period) f7su = simulation.calculate('f7su', period) f7sv = simulation.calculate('f7sv', period) f7sw = simulation.calculate('f7sw', period) f7sz = simulation.calculate('f7sz', period) f7wc = simulation.calculate('f7wc', period) f7we = simulation.calculate('f7we', period) f7wg = simulation.calculate('f7wg', period) f7wh = simulation.calculate('f7wh', period) f7wk = simulation.calculate('f7wk', period) marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) quaenv_bouquet = simulation.calculate('quaenv_bouquet', period) rfr = simulation.calculate('rfr', period) P = simulation.legislation_at(period.start).ir.credits_impot.quaenv max0 = P.max * (1 + marpac) + P.pac1 * nb_pac2 maxi1 = max_(0, max0 - f7ty) maxi2 = max_(0, maxi1 - f7tx) maxi3 = max_(0, maxi2 - f7tw) maxi4 = max_(0, maxi3 - f7tv) maxi5 = max_(0, maxi4 - f7tu) collectif = (P.taux_ty * min_(f7ty, max0) + P.taux_tx * min_(f7tx, maxi1) + P.taux_tw * min_(f7tw, maxi2) + P.taux_tv * min_(f7tv, maxi3) + P.taux_tu * min_(f7tu, maxi4) + P.taux_tt * min_(f7tt, maxi5)) max1 = max_(0, max0 - quaenv_bouquet * (f7ss + f7st) - not_(quaenv_bouquet) * (f7ss + f7st + f7sv)) max2 = max_(0, max1 - quaenv_bouquet * (f7sn + f7sr + f7sq) - not_(quaenv_bouquet) * (f7sn + f7sq + f7sr)) max3 = max_(0, max2 - quaenv_bouquet * (f7sv) - not_(quaenv_bouquet) * (f7se)) max4 = (max_(0, max3 - quaenv_bouquet * (f7se) - not_(quaenv_bouquet) * (f7sf + f7sg + f7sh + f7si + f7so + f7su + f7sw + f7sp))) max5 = max_(0, max4 - quaenv_bouquet * (f7sg + f7sh + f7so + f7sp) - not_(quaenv_bouquet) * (f7sm)) max6 = max_(0, max5 - quaenv_bouquet * (f7sd + f7sj)) max7 = max_(0, max6 - quaenv_bouquet * (f7sf + f7si + f7su + f7sw)) max8 = max_(0, max7 - quaenv_bouquet * (f7sm)) montant = (quaenv_bouquet * ( min_(max8, P.taux10 * (f7sk + f7sl)) + min_(max7, P.taux11 * f7sm) + min_(max6, P.taux15 * (f7sf + f7si + f7su + f7sw)) + min_(max5, P.taux18 * (f7sd + f7sj)) + min_(max4, P.taux23 * (f7sg + f7sh + f7so + f7sp)) + min_(max3, P.taux26 * f7se) + min_(max2, P.taux32 * f7sv) + min_(max1, P.taux34 * (f7sn + f7sr + f7sq)) + min_(max0, P.taux40 * (f7ss + f7st))) + (not_(quaenv_bouquet) * ( min_(max0, P.taux32 * (f7ss + f7st + f7sv)) + min_(max1, P.taux26 * (f7sn + f7sq + f7sr)) + min_(max2, P.taux17 * f7se) + min_(max3, P.taux15 * (f7sf + f7sg + f7sh + f7si + f7so + f7su + f7sw + f7sp)) + min_(max4, P.taux11 * f7sm) + min_(max5, P.taux10 * (f7sd + f7wk * (f7sj + f7sk + f7sl)))) )) return period, not_(f7wg) * or_(not_(f7we), (rfr < 30000)) * (montant + collectif) + f7sz @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_20130101_20131231(self, simulation, period): ''' Crédits d’impôt pour dépenses en faveur de la qualité environnementale 2013 ''' period = period.start.offset('first-of', 'year').period('year') f7sd = simulation.calculate('f7sd', period) f7se = simulation.calculate('f7se', period) f7sf = simulation.calculate('f7sf', period) f7sg = simulation.calculate('f7sg', period) f7sh = simulation.calculate('f7sh', period) f7si = simulation.calculate('f7si', period) f7sj = simulation.calculate('f7sj', period) f7sk = simulation.calculate('f7sk', period) f7sl = simulation.calculate('f7sl', period) f7sm = simulation.calculate('f7sm', period) f7sn = simulation.calculate('f7sn', period) f7so = simulation.calculate('f7so', period) f7sp = simulation.calculate('f7sp', period) f7sq = simulation.calculate('f7sq', period) f7sr = simulation.calculate('f7sr', period) f7ss = simulation.calculate('f7ss', period) f7st = simulation.calculate('f7st', period) f7su = simulation.calculate('f7su', period) f7sv = simulation.calculate('f7sv', period) f7sw = simulation.calculate('f7sw', period) f7sz = simulation.calculate('f7sz', period) f7wc = simulation.calculate('f7wc', period) f7we = simulation.calculate('f7we', period) f7wg = simulation.calculate('f7wg', period) f7wh = simulation.calculate('f7wh', period) f7wk = simulation.calculate('f7wk', period) marpac = simulation.calculate('marpac', period) nb_pac2 = simulation.calculate('nb_pac2', period) quaenv_bouquet = simulation.calculate('quaenv_bouquet', period) rfr = simulation.calculate('rfr', period) P = simulation.legislation_at(period.start).ir.credits_impot.quaenv max0 = P.max * (1 + marpac) + P.pac1 * nb_pac2 max1 = max_(0, max0 - quaenv_bouquet * (f7ss + f7st) - not_(quaenv_bouquet) * (f7ss + f7st + f7sv)) max2 = max_(0, max1 - quaenv_bouquet * (f7sn + f7sr + f7sq) - not_(quaenv_bouquet) * (f7sn + f7sq + f7sr)) max3 = max_(0, max2 - quaenv_bouquet * (f7sv) - not_(quaenv_bouquet) * (f7se)) max4 = (max_(0, max3 - quaenv_bouquet * (f7se) - not_(quaenv_bouquet) * (f7sf + f7sg + f7sh + f7si + f7so + f7su + f7sw + f7sp))) max5 = max_(0, max4 - quaenv_bouquet * (f7sg + f7sh + f7so + f7sp) - not_(quaenv_bouquet) * (f7sm)) max6 = max_(0, max5 - quaenv_bouquet * (f7sd + f7sj)) max7 = max_(0, max6 - quaenv_bouquet * (f7sf + f7si + f7su + f7sw)) max8 = max_(0, max7 - quaenv_bouquet * (f7sm)) montant = (quaenv_bouquet * ( min_(max8, P.taux10 * (f7sk + f7sl)) + min_(max7, P.taux11 * f7sm) + min_(max6, P.taux15 * (f7sf + f7si + f7su + f7sw)) + min_(max5, P.taux18 * (f7sd + f7sj)) + min_(max4, P.taux23 * (f7sg + f7sh + f7so + f7sp)) + min_(max3, P.taux26 * f7se) + min_(max2, P.taux32 * f7sv) + min_(max1, P.taux34 * (f7sn + f7sr + f7sq)) + min_(max0, P.taux40 * (f7ss + f7st))) + (not_(quaenv_bouquet) * ( min_(max0, P.taux32 * (f7ss + f7st + f7sv)) + min_(max1, P.taux26 * (f7sn + f7sq + f7sr)) + min_(max2, P.taux17 * f7se) + min_(max3, P.taux15 * (f7sf + f7sg + f7sh + f7si + f7so + f7su + f7sw + f7sp)) + min_(max4, P.taux11 * f7sm) + min_(max5, P.taux10 * (f7sd + f7wk * (f7sj + f7sk + f7sl)))) )) return period, or_(not_(or_(f7we, f7wg)), (rfr < 30000)) * montant + f7sz @reference_formula class quaenv_bouquet(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = FoyersFiscaux label = u"quaenv_bouquet" start_date = date(2013, 1, 1) def function(self, simulation, period): ''' Les dépenses de travaux dépendent d'un bouquet de travaux 2013 ''' period = period.start.offset('first-of', 'year').period('year') f7sd = simulation.calculate('f7sd', period) f7se = simulation.calculate('f7se', period) f7sn = simulation.calculate('f7sn', period) f7so = simulation.calculate('f7so', period) f7sp = simulation.calculate('f7sp', period) f7sq = simulation.calculate('f7sq', period) f7sr = simulation.calculate('f7sr', period) f7ss = simulation.calculate('f7ss', period) f7st = simulation.calculate('f7st', period) f7ve = simulation.calculate('f7ve', period) f7vf = simulation.calculate('f7vf', period) f7vg = simulation.calculate('f7vg', period) f7wa = simulation.calculate('f7wa', period) f7wb = simulation.calculate('f7wb', period) f7wc = simulation.calculate('f7wc', period) f7wf = simulation.calculate('f7wf', period) f7wh = simulation.calculate('f7wh', period) f7wq = simulation.calculate('f7wq', period) f7ws = simulation.calculate('f7ws', period) f7wt = simulation.calculate('f7wt', period) t1 = or_(or_(f7wt * f7ws, f7wq), f7wf) t2 = or_(f7wc * f7wb, f7wa) t3 = or_(f7vg * f7vf, f7ve) t4 = or_(f7sn > 0, f7so > 0) t5 = or_(f7sr > 0, f7ss > 0) t6 = or_(or_(or_(f7st > 0, f7sp > 0), or_(f7sq > 0, f7sd > 0)), f7se > 0) bouquet = (t1 + t2 + t3 + t4 + t5 + t6 > 1) return period, or_(bouquet, f7wh) @reference_formula class saldom2(DatedFormulaColumn): column = FloatCol(default = 0) entity_class = FoyersFiscaux label = u"saldom2" @dated_function(start = date(2007, 1, 1), stop = date(2008, 12, 31)) def function_20070101_20081231(self, simulation, period): ''' Crédit d’impôt emploi d’un salarié à domicile (cases 7DB, 7DG) 2007-2008 ''' period = period.start.offset('first-of', 'year').period('year') nb_pac2 = simulation.calculate('nb_pac2', period) f7db = simulation.calculate('f7db', period) f7dg = simulation.calculate('f7dg', period) f7dl = simulation.calculate('f7dl', period) _P = simulation.legislation_at(period.start) P = _P.ir.reductions_impots.saldom isinvalid = f7dg nbpacmin = nb_pac2 + f7dl maxBase = P.max1 maxDuMaxNonInv = P.max2 maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv) maxEffectif = maxNonInv * not_(isinvalid) + P.max3 * isinvalid return period, P.taux * min_(f7db, maxEffectif) @dated_function(start = date(2009, 1, 1), stop = date(2013, 12, 31)) def function_20090101_20131231(self, simulation, period): ''' Crédit d’impôt emploi d’un salarié à domicile (cases 7DB, 7DG) 2009-2010 ''' period = period.start.offset('first-of', 'year').period('year') nb_pac2 = simulation.calculate('nb_pac2', period) f7db = simulation.calculate('f7db', period) f7dg = simulation.calculate('f7dg', period) f7dl = simulation.calculate('f7dl', period) f7dq = simulation.calculate('f7dq', period) _P = simulation.legislation_at(period.start) P = _P.ir.reductions_impots.saldom isinvalid = f7dg annee1 = f7dq nbpacmin = nb_pac2 + f7dl maxBase = P.max1 * not_(annee1) + P.max1_1ereAnnee * annee1 maxDuMaxNonInv = P.max2 * not_(annee1) + P.max2_1ereAnnee * annee1 maxNonInv = min_(maxBase + P.pac * nbpacmin, maxDuMaxNonInv) maxEffectif = maxNonInv * not_(isinvalid) + P.max3 * isinvalid return period, P.taux * min_(f7db, maxEffectif) PKF/openfisca_france/model/consommation/__init__.pyPKF-openfisca_france/model/patrimoine/__init__.pyPKFHopenfisca_france/model/caracteristiques_socio_demographiques/__init__.pyPKoz PART @reference_formula class etu(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = Individus label = u"Indicatrice individuelle étudiant" def function(self, simulation, period): # Note : Cette variable est "instantanée" : quelque soit la période demandée, elle retourne la valeur au premier # jour, sans changer la période. activite = simulation.calculate('activite', period) return period, activite == 2 reference_input_variable( name = "rempli_obligation_scolaire", column = BoolCol(default = True), entity_class = Individus, label = u"Rempli l'obligation scolaire", ) reference_input_variable( name ="ressortissant_eee", column = BoolCol(default = True), entity_class = Individus, label = u"Ressortissant de l'EEE ou de la Suisse." ) reference_input_variable( name ="duree_possession_titre_sejour", column = IntCol, entity_class = Individus, label = u"Durée depuis laquelle l'individu possède un titre de séjour (en années)" ) PKF.openfisca_france/model/prestations/__init__.pyPKvTG/openfisca_france/model/prestations/education.py# -*- coding: utf-8 -*- from __future__ import division from numpy import zeros, logical_not as not_, logical_or as or_, round as round_ from ..base import * # noqa analysis:ignore SCOLARITE_INCONNUE = 0 SCOLARITE_COLLEGE = 1 SCOLARITE_LYCEE = 2 @reference_formula class bourse_college(SimpleFormulaColumn): column = FloatCol label = u"Montant mensuel de la bourse de collège" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') rfr = simulation.calculate('rfr', period.start.offset('first-of', 'year').period('year').offset(-2)) age_holder = simulation.compute('age', period) scolarite_holder = simulation.compute('scolarite', period) P = simulation.legislation_at(period.start).bourses_education.bourse_college ages = self.split_by_roles(age_holder, roles = ENFS) nb_enfants = zeros(len(rfr)) for age in ages.itervalues(): nb_enfants += age >= 0 plafond_taux_1 = round_(P.plafond_taux_1 + P.plafond_taux_1 * nb_enfants * P.coeff_enfant_supplementaire) plafond_taux_2 = round_(P.plafond_taux_2 + P.plafond_taux_2 * nb_enfants * P.coeff_enfant_supplementaire) plafond_taux_3 = round_(P.plafond_taux_3 + P.plafond_taux_3 * nb_enfants * P.coeff_enfant_supplementaire) eligible_taux_3 = rfr <= plafond_taux_3 eligible_taux_2 = not_(eligible_taux_3) * (rfr <= plafond_taux_2) eligible_taux_1 = not_(or_(eligible_taux_2, eligible_taux_3)) * (rfr <= plafond_taux_1) scolarites = self.split_by_roles(scolarite_holder, roles = ENFS) nb_enfants_college = zeros(len(rfr)) for scolarite in scolarites.itervalues(): nb_enfants_college += scolarite == SCOLARITE_COLLEGE montant = nb_enfants_college * ( eligible_taux_3 * P.montant_taux_3 + eligible_taux_2 * P.montant_taux_2 + eligible_taux_1 * P.montant_taux_1 ) return period, montant / 12 @reference_formula class bourse_lycee_points_de_charge(SimpleFormulaColumn): column = FloatCol label = u"Nombre de points de charge pour la bourse de lycée" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age_holder = simulation.compute('age', period) isol = simulation.calculate('isol', period) # compte le nombre d'enfants ages = self.split_by_roles(age_holder, roles = ENFS) nb_enfants = zeros(len(isol)) for age in ages.itervalues(): nb_enfants += age >= 0 points_de_charge = 11 * (nb_enfants >= 1) points_de_charge += 1 * (nb_enfants >= 2) # 1 point de charge pour le 2ème enfant points_de_charge += 2 * (nb_enfants >= 3) + 2 * (nb_enfants >= 4) # 2 points de charge pour les 3ème et 4ème enfants points_de_charge += 3 * (nb_enfants >= 5) * (nb_enfants - 4) # 3 points de charge pour chaque enfant au-dessus de 4 enfants points_de_charge += 3 * isol # 3 points de charge en plus si parent isolé return period, points_de_charge @reference_formula class bourse_lycee_nombre_parts(SimpleFormulaColumn): column = FloatCol label = u"Nombre de parts pour le calcul du montant de la bourse de lycée" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') points_de_charge = simulation.calculate('bourse_lycee_points_de_charge', period) rfr = simulation.calculate('rfr', period.start.offset('first-of', 'year').period('year').offset(-2)) plafonds_reference = simulation.legislation_at(period.start).bourses_education.bourse_lycee.plafonds_reference increments_par_point_de_charge = simulation.legislation_at(period.start).bourses_education.bourse_lycee.increments_par_point_de_charge plafond_10_parts = round(plafonds_reference['10_parts'] + ((points_de_charge - 9) * increments_par_point_de_charge['10_parts'])) plafond_9_parts = round(plafonds_reference['9_parts'] + ((points_de_charge - 9) * increments_par_point_de_charge['9_parts'])) plafond_8_parts = round(plafonds_reference['8_parts'] + ((points_de_charge - 9) * increments_par_point_de_charge['8_parts'])) plafond_7_parts = round(plafonds_reference['7_parts'] + ((points_de_charge - 9) * increments_par_point_de_charge['7_parts'])) plafond_6_parts = round(plafonds_reference['6_parts'] + ((points_de_charge - 9) * increments_par_point_de_charge['6_parts'])) plafond_5_parts = round(plafonds_reference['5_parts'] + ((points_de_charge - 9) * increments_par_point_de_charge['5_parts'])) plafond_4_parts = round(plafonds_reference['4_parts'] + ((points_de_charge - 9) * increments_par_point_de_charge['4_parts'])) plafond_3_parts = round(plafonds_reference['3_parts'] + ((points_de_charge - 9) * increments_par_point_de_charge['3_parts'])) nombre_parts = zeros(len(rfr)) nombre_parts = ((rfr <= plafond_10_parts) * 10 + (rfr > plafond_10_parts) * (rfr <= plafond_9_parts) * 9 + (rfr > plafond_9_parts) * (rfr <= plafond_8_parts) * 8 + (rfr > plafond_8_parts) * (rfr <= plafond_7_parts) * 7 + (rfr > plafond_7_parts) * (rfr <= plafond_6_parts) * 6 + (rfr > plafond_6_parts) * (rfr <= plafond_5_parts) * 5 + (rfr > plafond_5_parts) * (rfr <= plafond_4_parts) * 4 + (rfr > plafond_4_parts) * (rfr <= plafond_3_parts) * 3) return period, nombre_parts @reference_formula class bourse_lycee(SimpleFormulaColumn): column = FloatCol label = u"Montant mensuel de la bourse de lycée" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') nombre_parts = simulation.calculate('bourse_lycee_nombre_parts', period) scolarite_holder = simulation.compute('scolarite', period) valeur_part = simulation.legislation_at(period.start).bourses_education.bourse_lycee.valeur_part scolarites = self.split_by_roles(scolarite_holder, roles = ENFS) nb_enfants_lycee = zeros(len(nombre_parts)) for scolarite in scolarites.itervalues(): nb_enfants_lycee += scolarite == SCOLARITE_LYCEE montant = nombre_parts * valeur_part * nb_enfants_lycee return period, montant / 12 reference_input_variable( column = EnumCol( enum = Enum( [ u"Inconnue", u"Collège", u"Lycée" ], ), default = 0 ), entity_class = Individus, label = u"Scolarité de l'enfant : collège, lycée...", name = "scolarite", ) reference_input_variable( column = BoolCol, entity_class = Individus, label = u"Élève ou étudiant boursier", name = 'boursier', ) PKoz 0, chomage_net_m_2 > 0) * taux_abattement * revenus_activite_pro params_abattement_frais_pro = simulation.legislation_at(period.start).ir.tspr.abatpro abattement = round((1 - params_abattement_frais_pro.taux) * abattement) return period, abattement @reference_formula class aide_logement_abattement_depart_retraite(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Montant de l'abattement sur les salaires en cas de départ en retraite" 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) retraite = simulation.calculate('activite', period) == 3 activite_n_2 = simulation.calculate('salaire_imposable', two_years_ago) retraite_n_2 = simulation.calculate('rst', two_years_ago) abattement = 0.3 * activite_n_2 * (retraite_n_2 == 0) * retraite params_abattement_frais_pro = simulation.legislation_at(period.start).ir.tspr.abatpro abattement = round((1 - params_abattement_frais_pro.taux) * abattement) return period, abattement @reference_formula class aide_logement_base_ressources_defaut(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Base ressource par défaut des allocations logement" 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) br_pf_i_holder = simulation.compute('br_pf_i', period) rev_coll_holder = simulation.compute('rev_coll', two_years_ago) 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 = self.split_by_roles(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]) ressources = br_pf_i[CHEF] + br_pf_i[PART] + rev_coll - abattement_chomage_indemnise - abattement_depart_retraite # 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 @reference_formula class aide_logement_base_ressources(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Base ressources des allocations logement" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') mois_precedent = period.offset(-1) last_day_reference_year = period.start.offset('first-of', 'year').period('year').offset(-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) concub = simulation.calculate('concub', 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).al.ressources.dar_8 plafond_salaire_jeune_couple = simulation.legislation_at(period.start).al.ressources.dar_9 plafond_salaire_jeune = not_(concub) * plafond_salaire_jeune_isole + concub * plafond_salaire_jeune_couple neutral_jeune = or_(age[CHEF] < 25, and_(concub, 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 = ( base_ressources_eval_forfaitaire * eval_forfaitaire + base_ressources_defaut * not_(eval_forfaitaire) ) # Planchers de ressources pour étudiants # Seul le statut étudiant (et boursier) du demandeur importe, pas celui du conjoint Pr = simulation.legislation_at(period.start).al.ressources etu_holder = simulation.compute('etu', period) boursier_holder = simulation.compute('boursier', period) etudiant = self.split_by_roles(etu_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 @reference_formula class aide_logement_montant_brut(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Formule des aides aux logements en secteur locatif en montant brut avant CRDS" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') # Situation familiale concub = simulation.calculate('concub', period) enceinte_fam = simulation.calculate('enceinte_fam', period) couple = or_(concub, enceinte_fam) # le barème "couple" est utilisé pour les femmes enceintes isolées personne_seule = not_(couple) al_pac = simulation.calculate('al_pac', period) # Logement statut_occupation_holder = simulation.compute('statut_occupation', period) statut_occupation = self.cast_from_entity_to_roles(statut_occupation_holder) statut_occupation = self.filter_role(statut_occupation, role = CHEF) loyer_holder = simulation.compute('loyer', period) loyer = self.cast_from_entity_to_roles(loyer_holder) loyer = self.filter_role(loyer, role = CHEF) coloc_holder = simulation.compute('coloc', period) coloc = self.any_by_roles(coloc_holder) logement_chambre_holder = simulation.compute('logement_chambre', period) chambre = self.any_by_roles(logement_chambre_holder) zone_apl_famille = simulation.calculate('zone_apl_famille', period) zone_apl = zone_apl_famille locataire = ((3 <= statut_occupation) & (5 >= statut_occupation)) | (statut_occupation == 7) accedant = statut_occupation == 1 # Ressources aide_logement_base_ressources = simulation.calculate('aide_logement_base_ressources', period) # Parametres législatifs al = simulation.legislation_at(period.start).al pfam_n_2 = simulation.legislation_at(period.start.offset(-2, 'year')).fam def loyer_retenu(): # loyer mensuel réel, multiplié par 2/3 pour les meublés L1 = round((statut_occupation == 5) * loyer * 2 / 3 + (statut_occupation != 5) * loyer, 2) # taux à appliquer sur le loyer plafond taux_loyer_plafond = (and_(not_(coloc), not_(chambre)) * 1 + chambre * al.loyers_plafond.chambre + not_(chambre) * coloc * al.loyers_plafond.colocation) loyer_plafond_personne_seule = or_(personne_seule * (al_pac == 0), chambre) loyer_plafond_famille = not_(loyer_plafond_personne_seule) * (al_pac > 0) loyer_plafond_couple = and_(not_(loyer_plafond_famille), not_(loyer_plafond_personne_seule)) z1 = al.loyers_plafond.zone1 z2 = al.loyers_plafond.zone2 z3 = al.loyers_plafond.zone3 Lz1 = ( loyer_plafond_personne_seule * z1.L1 + loyer_plafond_couple * z1.L2 + loyer_plafond_famille * (z1.L3 + (al_pac > 1) * (al_pac - 1) * z1.L4) ) Lz2 = ( loyer_plafond_personne_seule * z2.L1 + loyer_plafond_couple * z2.L2 + loyer_plafond_famille * (z2.L3 + (al_pac > 1) * (al_pac - 1) * z2.L4) ) Lz3 = ( loyer_plafond_personne_seule * z3.L1 + loyer_plafond_couple * z3.L2 + loyer_plafond_famille * (z3.L3 + (al_pac > 1) * (al_pac - 1) * z3.L4) ) L2 = Lz1 * (zone_apl == 1) + Lz2 * (zone_apl == 2) + Lz3 * (zone_apl == 3) L2 = round(L2 * taux_loyer_plafond, 2) # loyer retenu L = min_(L1, L2) return L def depense_eligible(): # Loyer chargé pris en compte par la CAF comme montant des dépenses liées au logement # forfait de charges P_fc = al.forfait_charges C = ( not_(coloc) * (P_fc.fc1 + al_pac * P_fc.fc2) + coloc * ((personne_seule * 0.5 + couple) * P_fc.fc1 + al_pac * P_fc.fc2) ) # dépense éligible E = loyer_retenu() + C return E def indice_ressources_Rp(): # Indice de ressource utilisé par la CAF, en € # Différence entre les ressources du foyer et un revenu R0 de référence # ressources prises en compte R = aide_logement_base_ressources # Plafond RO rmi = al.rmi R1 = ( al.R1.taux1 * rmi * personne_seule * (al_pac == 0) + al.R1.taux2 * rmi * couple * (al_pac == 0) + al.R1.taux3 * rmi * (al_pac == 1) + al.R1.taux4 * rmi * (al_pac >= 2) + al.R1.taux5 * rmi * (al_pac > 2) * (al_pac - 2) ) bmaf = pfam_n_2.af.bmaf R2 = ( al.R2.taux4 * bmaf * (al_pac >= 2) + al.R2.taux5 * bmaf * (al_pac > 2) * (al_pac - 2) ) Ro = round(12 * (R1 - R2) * (1 - al.autres.abat_sal)) Rp = max_(0, R - Ro) return Rp def taux_famille(): # Taux représentant la situation familiale. Plus il est faible, moins la famille a de personnes à charge. TF = ( al.TF.taux1 * (personne_seule) * (al_pac == 0) + al.TF.taux2 * (couple) * (al_pac == 0) + al.TF.taux3 * (al_pac == 1) + al.TF.taux4 * (al_pac == 2) + al.TF.taux5 * (al_pac == 3) + al.TF.taux6 * (al_pac >= 4) + al.TF.taux7 * (al_pac > 4) * (al_pac - 4) ) return TF def taux_loyer(): # Taux obscur basé sur une comparaison du loyer retenu à un loyer de référence. L = loyer_retenu() z2 = al.loyers_plafond.zone2 # Loyer de référence L_Ref = ( z2.L1 * (personne_seule) * (al_pac == 0) + z2.L2 * (couple) * (al_pac == 0) + z2.L3 * (al_pac >= 1) + z2.L4 * (al_pac > 1) * (al_pac - 1) ) RL = L / L_Ref # TODO: paramètres en dur ?? TL = max_( max_(0, al.TL.taux2 * (RL - 0.45)), al.TL.taux3 * (RL - 0.75) + al.TL.taux2 * (0.75 - 0.45) ) return TL def participation_personelle(): # Participation du demandeur à ses dépenses de logement # Depense eligible E = depense_eligible() # participatioion personnelle minimale Po = max_(al.pp.taux * E, al.pp.min) # Taux de participation Tp = taux_famille() + taux_loyer() # Indice ressources Rp = indice_ressources_Rp() Pp = Po + Tp * Rp return Pp al_locataire = max_(0, depense_eligible() - participation_personelle()) * locataire # Montant minimal de versement al_locataire = al_locataire * (al_locataire >= al.autres.nv_seuil) # TODO: APL pour les accédants à la propriété al_accedants = 0 * accedant al = al_locataire + al_accedants return period, al @reference_formula class aide_logement_montant(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Montant des aides au logement net de CRDS" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') aide_logement_montant_brut = simulation.calculate('aide_logement_montant_brut', period) crds_logement = simulation.calculate('crds_logement', period) montant = round(aide_logement_montant_brut + crds_logement, 2) return period, montant @reference_formula class alf(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol entity_class = Familles label = u"Allocation logement familiale" url = u"http://vosdroits.service-public.fr/particuliers/F13132.xhtml" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') aide_logement_montant = simulation.calculate('aide_logement_montant', period) al_pac = simulation.calculate('al_pac', period) statut_occupation_famille = simulation.calculate('statut_occupation_famille', period) proprietaire_proche_famille = simulation.calculate('proprietaire_proche_famille', period) statut_occupation = statut_occupation_famille result = (al_pac >= 1) * (statut_occupation != 3) * not_(proprietaire_proche_famille) * aide_logement_montant return period, result @reference_formula class als_nonet(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Allocation logement sociale (non étudiante)" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') aide_logement_montant = simulation.calculate('aide_logement_montant', period) al_pac = simulation.calculate('al_pac', period) etu_holder = simulation.compute('etu', period) statut_occupation_famille = simulation.calculate('statut_occupation_famille', period) proprietaire_proche_famille = simulation.calculate('proprietaire_proche_famille', period) statut_occupation = statut_occupation_famille etu = self.split_by_roles(etu_holder, roles = [CHEF, PART]) return period, ( (al_pac == 0) * (statut_occupation != 3) * not_(proprietaire_proche_famille) * not_(etu[CHEF] | etu[PART]) * aide_logement_montant ) @reference_formula class alset(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol entity_class = Familles label = u"Allocation logement sociale (étudiante)" url = u"https://www.caf.fr/actualites/2012/etudiants-tout-savoir-sur-les-aides-au-logement" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') aide_logement_montant = simulation.calculate('aide_logement_montant', period) al_pac = simulation.calculate('al_pac', period) etu_holder = simulation.compute('etu', period) statut_occupation_holder = simulation.compute('statut_occupation', period) proprietaire_proche_famille = simulation.calculate('proprietaire_proche_famille', period) statut_occupation = self.cast_from_entity_to_roles(statut_occupation_holder) statut_occupation = self.filter_role(statut_occupation, role = CHEF) etu = self.split_by_roles(etu_holder, roles = [CHEF, PART]) return period, ( (al_pac == 0) * (statut_occupation != 3) * not_(proprietaire_proche_famille) * (etu[CHEF] | etu[PART]) * aide_logement_montant ) @reference_formula class als(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol entity_class = Familles label = u"Allocation logement sociale" url = u"http://vosdroits.service-public.fr/particuliers/F1280.xhtml" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') als_nonet = simulation.calculate('als_nonet', period) alset = simulation.calculate('alset', period) result = (als_nonet + alset) return period, result @reference_formula class apl(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol entity_class = Familles label = u" Aide personnalisée au logement" # (réservée aux logements conventionné, surtout des HLM, et financé par le fonds national de l'habitation)" url = u"http://vosdroits.service-public.fr/particuliers/F12006.xhtml", def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') aide_logement_montant = simulation.calculate('aide_logement_montant', period) statut_occupation_holder = simulation.compute('statut_occupation', period) statut_occupation = self.cast_from_entity_to_roles(statut_occupation_holder) statut_occupation = self.filter_role(statut_occupation, role = CHEF) return period, aide_logement_montant * (statut_occupation == 3) @reference_formula class aide_logement_non_calculable(SimpleFormulaColumn): column = EnumCol( enum = Enum([ u"", u"primo_accedant", u"locataire_foyer" ]), default = 0 ) entity_class = Familles label = u"Aide au logement non calculable" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') statut_occupation = simulation.calculate('statut_occupation', period) return period, (statut_occupation == 1) * 1 + (statut_occupation == 7) * 2 @reference_formula class aide_logement(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Aide au logement (tout type)" 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) @reference_formula class crds_logement(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol entity_class = Familles label = u"CRDS des allocations logement" url = u"http://vosdroits.service-public.fr/particuliers/F17585.xhtml" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') aide_logement_montant_brut = simulation.calculate('aide_logement_montant_brut', period) crds = simulation.legislation_at(period.start).fam.af.crds return period, -aide_logement_montant_brut * crds @reference_formula class statut_occupation_individu(EntityToPersonColumn): entity_class = Individus label = u"Statut d'occupation de l'individu" variable = Menages.column_by_name['statut_occupation'] @reference_formula class statut_occupation_famille(PersonToEntityColumn): entity_class = Familles label = u"Statut d'occupation de la famille" role = CHEF variable = Individus.column_by_name['statut_occupation_individu'] @reference_formula class zone_apl(SimpleFormulaColumn): column = EnumCol( enum = Enum([ u"Non renseigné", u"Zone 1", u"Zone 2", u"Zone 3", ]), default = 2 ) entity_class = Menages label = u"Zone APL" def function(self, simulation, period): ''' Retrouve la zone APL (aide personnalisée au logement) de la commune en fonction du depcom (code INSEE) ''' period = period depcom = simulation.calculate('depcom', period) preload_zone_apl() default_value = 2 return period, fromiter( ( zone_apl_by_depcom.get(depcom_cell, default_value) for depcom_cell in depcom ), dtype = int16, ) def preload_zone_apl(): global zone_apl_by_depcom if zone_apl_by_depcom is None: with pkg_resources.resource_stream( openfisca_france.__name__, 'assets/apl/20110914_zonage.csv', ) as csv_file: csv_reader = csv.DictReader(csv_file) zone_apl_by_depcom = { # Keep only first char of Zonage column because of 1bis value considered equivalent to 1. row['CODGEO']: int(row['Zonage'][0]) for row in csv_reader } # Add subcommunes (arrondissements and communes associées), use the same value as their parent commune. with pkg_resources.resource_stream( openfisca_france.__name__, 'assets/apl/commune_depcom_by_subcommune_depcom.json', ) as json_file: commune_depcom_by_subcommune_depcom = json.load(json_file) for subcommune_depcom, commune_depcom in commune_depcom_by_subcommune_depcom.iteritems(): zone_apl_by_depcom[subcommune_depcom] = zone_apl_by_depcom[commune_depcom] @reference_formula class zone_apl_individu(EntityToPersonColumn): entity_class = Individus label = u"Zone apl de la personne" variable = zone_apl @reference_formula class zone_apl_famille(PersonToEntityColumn): entity_class = Familles label = u"Zone apl de la famille" role = CHEF variable = zone_apl_individu PKFEopenfisca_france/model/prestations/prestations_familiales/__init__.pyPKoz= pfam.enfants.age_minimal) * (age < pfam.enfants.age_intermediaire) * rempli_obligation_scolaire) condition_jeune = (age >= pfam.enfants.age_intermediaire) * (age < pfam.af.age3) * not_(smic55) return period, or_(condition_enfant, condition_jeune) * est_enfant_dans_famille @reference_formula class af_nbenf(SimpleFormulaColumn): column = IntCol entity_class = Familles label = u"Nombre d'enfants dans la famille au sens des allocations familiales" def function(self, simulation, period): period_mois = period.start.offset('first-of', 'month').period('month') af_enfant_a_charge_holder = simulation.compute('af_enfant_a_charge', period_mois) af_nbenf = self.sum_by_entity(af_enfant_a_charge_holder) return period, af_nbenf @reference_formula class af_forf_nbenf(SimpleFormulaColumn): column = IntCol entity_class = Familles label = u"Nombre d'enfants dans la famille éligibles à l'allocation forfaitaire des AF" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age_holder = simulation.compute('age', period) age = self.split_by_roles(age_holder, roles = ENFS) smic55_holder = simulation.compute('smic55', period) smic55 = self.split_by_roles(smic55_holder, roles = ENFS) pfam = simulation.legislation_at(period.start).fam.af af_forf_nbenf = nb_enf(age, smic55, pfam.age3, pfam.age3) return period, af_forf_nbenf @reference_formula class af_eligibilite_base(SimpleFormulaColumn): column = BoolCol entity_class = Familles label = u"Allocations familiales - Éligibilité pour la France métropolitaine sous condition de ressources" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') residence_dom = simulation.calculate('residence_dom', period) af_nbenf = simulation.calculate('af_nbenf', period) return period, not_(residence_dom) * (af_nbenf >= 2) @reference_formula class af_eligibilite_dom(SimpleFormulaColumn): column = BoolCol entity_class = Familles label = u"Allocations familiales - Éligibilité pour les DOM (hors Mayotte) sous condition de ressources" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') residence_dom = simulation.calculate('residence_dom', period) residence_mayotte = simulation.calculate('residence_mayotte', period) af_nbenf = simulation.calculate('af_nbenf', period) return period, residence_dom * not_(residence_mayotte) * (af_nbenf >= 1) @reference_formula class af_base(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Allocations familiales - allocation de base" # prestations familiales (brutes de crds) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') eligibilite_base = simulation.calculate('af_eligibilite_base', period) eligibilite_dom = simulation.calculate('af_eligibilite_dom', period) af_nbenf = simulation.calculate('af_nbenf', period) pfam = simulation.legislation_at(period.start).fam.af eligibilite = or_(eligibilite_base, eligibilite_dom) un_seul_enfant = eligibilite_dom * (af_nbenf == 1) * pfam.taux.enf_seul plus_de_deux_enfants = (af_nbenf >= 2) * pfam.taux.enf2 plus_de_trois_enfants = max_(af_nbenf - 2, 0) * pfam.taux.enf3 taux_total = un_seul_enfant + plus_de_deux_enfants + plus_de_trois_enfants montant_base = eligibilite * round(pfam.bmaf * taux_total, 2) af_taux_modulation = simulation.calculate('af_taux_modulation', period) montant_base_module = montant_base * af_taux_modulation return period, montant_base_module @reference_formula class af_taux_modulation(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"Taux de modulation à appliquer au montant des AF depuis 2015" @dated_function(start = date(2002, 1, 1)) def function_2002(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_nbenf = simulation.calculate('af_nbenf', period) return period, 1 + 0 * af_nbenf # Trick pour avoir la bonne longueur d'array numpy. #Todo trouver mieux @dated_function(start = date(2015, 7, 1)) def function_2015(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_nbenf = simulation.calculate('af_nbenf', period) pfam = simulation.legislation_at(period.start).fam.af br_pf = simulation.calculate('br_pf', period) modulation = pfam.modulation plafond1 = modulation.plafond1 + af_nbenf * modulation.enfant_supp plafond2 = modulation.plafond2 + af_nbenf * modulation.enfant_supp taux = ( (br_pf <= plafond1) * 1 + (br_pf > plafond1) * (br_pf <= plafond2) * modulation.taux1 + (br_pf > plafond2) * modulation.taux2 ) return period, taux @reference_formula class af_forf_taux_modulation(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"Taux de modulation à appliquer à l'allocation forfaitaire des AF depuis 2015" @dated_function(start = date(2002, 1, 1)) def function_2002(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_nbenf = simulation.calculate('af_nbenf', period) return period, 1 + 0 * af_nbenf # Trick pour avoir la bonne longueur d'array numpy. #Todo trouver mieux @dated_function(start = date(2015, 7, 1)) def function_2015(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') pfam = simulation.legislation_at(period.start).fam.af af_nbenf = simulation.calculate('af_nbenf', period) af_forf_nbenf = simulation.calculate('af_forf_nbenf', period) nb_enf_tot = af_nbenf + af_forf_nbenf br_pf = simulation.calculate('br_pf', period) modulation = pfam.modulation plafond1 = modulation.plafond1 + nb_enf_tot * modulation.enfant_supp plafond2 = modulation.plafond2 + nb_enf_tot * modulation.enfant_supp taux = ( (br_pf <= plafond1) * 1 + (br_pf > plafond1) * (br_pf <= plafond2) * modulation.taux1 + (br_pf > plafond2) * modulation.taux2 ) return period, taux @reference_formula class af_age_aine(SimpleFormulaColumn): column = IntCol entity_class = Familles label = u"Allocations familiales - Âge de l'aîné des enfants éligibles" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age_holder = simulation.compute('age', period) age_enfants = self.split_by_roles(age_holder, roles = ENFS) af_enfant_a_charge_holder = simulation.compute('af_enfant_a_charge', period) af_enfants_a_charge = self.split_by_roles(af_enfant_a_charge_holder, roles = ENFS) pfam = simulation.legislation_at(period.start).fam # Calcul de l'âge de l'aîné age_aine = -9999 for key, age in age_enfants.iteritems(): a_charge = af_enfants_a_charge[key] * (age <= pfam.af.age2) aine_potentiel = a_charge * (age > age_aine) age_aine = aine_potentiel * age + not_(aine_potentiel) * age_aine return period, age_aine @reference_formula class af_majoration_enfant(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Allocations familiales - Majoration pour âge applicable à l'enfant" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_enfant_a_charge = simulation.calculate('af_enfant_a_charge', period) age = simulation.calculate('age', period) age_aine_holder = simulation.compute('af_age_aine', period) age_aine = self.cast_from_entity_to_roles(age_aine_holder, roles = ENFS) af_nbenf_holder = simulation.compute('af_nbenf', period) af_nbenf = self.cast_from_entity_to_roles(af_nbenf_holder, roles = ENFS) af_base_holder = simulation.compute('af_base', period) af_base = self.cast_from_entity_to_roles(af_base_holder, roles = ENFS) pfam = simulation.legislation_at(period.start).fam montant_enfant_seul = pfam.af.bmaf * ( (pfam.af.maj_age_un_enfant.age1 <= age) * (age < pfam.af.maj_age_un_enfant.age2) * pfam.af.maj_age_un_enfant.taux1 + (pfam.af.maj_age_un_enfant.age2 <= age) * pfam.af.maj_age_un_enfant.taux2 ) montant_plusieurs_enfants = pfam.af.bmaf * ( (pfam.af.maj_age_deux_enfants.age1 <= age) * (age < pfam.af.maj_age_deux_enfants.age2) * pfam.af.maj_age_deux_enfants.taux1 + (pfam.af.maj_age_deux_enfants.age2 <= age) * pfam.af.maj_age_deux_enfants.taux2 ) montant = (af_nbenf == 1) * montant_enfant_seul + (af_nbenf > 1) * montant_plusieurs_enfants # Attention ! Ne fonctionne pas pour les enfants du même âge (typiquement les jumeaux...) pas_aine = or_(af_nbenf != 2, (af_nbenf == 2) * not_(age == age_aine)) return period, af_enfant_a_charge * (af_base > 0) * pas_aine * montant @reference_formula class af_majo(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Allocations familiales - majoration pour âge" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_majoration_enfant_holder = simulation.compute('af_majoration_enfant', period) af_majoration_enfants = self.sum_by_entity(af_majoration_enfant_holder, roles = ENFS) af_taux_modulation = simulation.calculate('af_taux_modulation', period) af_majoration_enfants_module = af_majoration_enfants * af_taux_modulation return period, af_majoration_enfants_module @reference_formula class af_complement_degressif(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"AF - Complément dégressif en cas de dépassement du plafond" @dated_function(start = date(2015, 7, 1)) def function_2015(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_nbenf = simulation.calculate('af_nbenf', period) br_pf = simulation.calculate('br_pf', period) af_base = simulation.calculate('af_base', period) af_majo = simulation.calculate('af_majo', period) pfam = simulation.legislation_at(period.start).fam.af modulation = pfam.modulation plafond1 = modulation.plafond1 + af_nbenf * modulation.enfant_supp plafond2 = modulation.plafond2 + af_nbenf * modulation.enfant_supp depassement_plafond1 = max_(0, br_pf - plafond1) depassement_plafond2 = max_(0, br_pf - plafond2) depassement_mensuel = ( (depassement_plafond2 == 0) * depassement_plafond1 + (depassement_plafond2 > 0) * depassement_plafond2 ) / 12 af = af_base + af_majo return period, max_(0, af - depassement_mensuel) * (depassement_mensuel > 0) @reference_formula class af_forf_complement_degressif(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"AF - Complément dégressif pour l'allocation forfaitaire en cas de dépassement du plafond" @dated_function(start = date(2015, 7, 1)) def function_2015(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_nbenf = simulation.calculate('af_nbenf', period) af_forf_nbenf = simulation.calculate('af_forf_nbenf', period) pfam = simulation.legislation_at(period.start).fam.af nb_enf_tot = af_nbenf + af_forf_nbenf br_pf = simulation.calculate('br_pf', period) af_forf = simulation.calculate('af_forf', period) modulation = pfam.modulation plafond1 = modulation.plafond1 + nb_enf_tot * modulation.enfant_supp plafond2 = modulation.plafond2 + nb_enf_tot * modulation.enfant_supp depassement_plafond1 = max_(0, br_pf - plafond1) depassement_plafond2 = max_(0, br_pf - plafond2) depassement_mensuel = ( (depassement_plafond2 == 0) * depassement_plafond1 + (depassement_plafond2 > 0) * depassement_plafond2 ) / 12 return period, max_(0, af_forf - depassement_mensuel) * (depassement_mensuel > 0) @reference_formula class af_forf(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Allocations familiales - forfait" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_nbenf = simulation.calculate('af_nbenf', period) af_forf_nbenf = simulation.calculate('af_forf_nbenf', period) P = simulation.legislation_at(period.start).fam.af bmaf = P.bmaf af_forfait = round(bmaf * P.taux.forfait, 2) af_forf = ((af_nbenf >= 2) * af_forf_nbenf) * af_forfait af_forf_taux_modulation = simulation.calculate('af_forf_taux_modulation', period) af_forf_module = af_forf * af_forf_taux_modulation return period, af_forf_module @reference_formula class af(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol entity_class = Familles label = u"Allocations familiales - total des allocations" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_base = simulation.calculate('af_base', period) af_majo = simulation.calculate('af_majo', period) af_forf = simulation.calculate('af_forf', period) af_complement_degressif = simulation.calculate('af_complement_degressif', period) af_forf_complement_degressif = simulation.calculate('af_forf_complement_degressif', period) return period, af_base + af_majo + af_forf + af_complement_degressif + af_forf_complement_degressif PKoz 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 period_br, ars * (ars >= P.ars.seuil_nv) PKoz= (_P.fam.af.seuil_rev_taux * smic_mensuel_brut) @reference_formula class pfam_enfant_a_charge(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = Individus label = u"Enfant considéré à charge au sens des prestations familiales" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') est_enfant_dans_famille = simulation.calculate('est_enfant_dans_famille', period) smic55 = simulation.calculate('smic55', period) age = simulation.calculate('age', period) rempli_obligation_scolaire = simulation.calculate('rempli_obligation_scolaire', period) pfam = simulation.legislation_at(period.start).fam condition_enfant = ((age >= pfam.enfants.age_minimal) * (age < pfam.enfants.age_intermediaire) * rempli_obligation_scolaire) condition_jeune = (age >= pfam.enfants.age_intermediaire) * (age < pfam.enfants.age_limite) * not_(smic55) return period, or_(condition_enfant, condition_jeune) * est_enfant_dans_famille @reference_formula class pfam_ressources_i(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Ressources de l'individu prises en compte dans le cadre des prestations familiales" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') br_pf_i = simulation.calculate('br_pf_i', period) est_enfant_dans_famille = simulation.calculate('est_enfant_dans_famille', period) pfam_enfant_a_charge = simulation.calculate('pfam_enfant_a_charge', period) return period, or_(not_(est_enfant_dans_famille), pfam_enfant_a_charge) * br_pf_i @reference_formula class br_pf_i(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Base ressource individuelle des prestations familiales" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') annee_fiscale_n_2 = period.start.offset('first-of', 'year').period('year').offset(-2) tspr = simulation.calculate('tspr', annee_fiscale_n_2) hsup = simulation.calculate('hsup', annee_fiscale_n_2) rpns = simulation.calculate('rpns', annee_fiscale_n_2) return period, tspr + hsup + rpns @reference_formula class biact(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = Familles label = u"Indicatrice de biactivité" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') annee_fiscale_n_2 = period.start.offset('first-of', 'year').period('year').offset(-2) br_pf_i_holder = simulation.compute('br_pf_i', period) br_pf_i = self.split_by_roles(br_pf_i_holder, roles = [CHEF, PART]) pfam = simulation.legislation_at(annee_fiscale_n_2.start).fam seuil_rev = 12 * pfam.af.bmaf return period, (br_pf_i[CHEF] >= seuil_rev) & (br_pf_i[PART] >= seuil_rev) @reference_formula class div(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"div" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('year') rpns_pvce = simulation.calculate('rpns_pvce', period) rpns_pvct = simulation.calculate('rpns_pvct', period) rpns_mvct = simulation.calculate('rpns_mvct', period) rpns_mvlt = simulation.calculate('rpns_mvlt', period) f3vc_holder = simulation.compute('f3vc', period) f3ve_holder = simulation.compute('f3ve', period) f3vg_holder = simulation.compute('f3vg', period) f3vh_holder = simulation.compute('f3vh', period) f3vl_holder = simulation.compute('f3vl', period) f3vm_holder = simulation.compute('f3vm', period) f3vc = self.cast_from_entity_to_role(f3vc_holder, role = VOUS) f3ve = self.cast_from_entity_to_role(f3ve_holder, role = VOUS) f3vg = self.cast_from_entity_to_role(f3vg_holder, role = VOUS) f3vh = self.cast_from_entity_to_role(f3vh_holder, role = VOUS) f3vl = self.cast_from_entity_to_role(f3vl_holder, role = VOUS) f3vm = self.cast_from_entity_to_role(f3vm_holder, role = VOUS) return period, f3vc + f3ve + f3vg - f3vh + f3vl + f3vm + rpns_pvce + rpns_pvct - rpns_mvct - rpns_mvlt @reference_formula class rev_coll(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Revenus collectifs" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('year') # Quand rev_coll est calculé sur une année glissante, rto_net_declarant1 est calculé sur l'année légale # correspondante. rto_net_declarant1 = simulation.calculate('rto_net_declarant1', period.offset('first-of')) rev_cap_lib_holder = simulation.compute_add('rev_cap_lib', period) rev_cat_rvcm_holder = simulation.compute('rev_cat_rvcm', period) # div = simulation.calculate('div', period) # TODO why is this variable not used ? abat_spe_holder = simulation.compute('abat_spe', period) glo = simulation.calculate('glo', period) fon_holder = simulation.compute('fon', period) # Quand rev_coll est calculé sur une année glissante, pensions_alimentaires_versees_declarant1 est calculé sur l'année légale # correspondante. pensions_alimentaires_versees_declarant1 = simulation.calculate('pensions_alimentaires_versees_declarant1', period.offset('first-of')) f7ga_holder = simulation.compute('f7ga', period) f7gb_holder = simulation.compute('f7gb', period) f7gc_holder = simulation.compute('f7gc', period) rev_cat_pv_holder = simulation.compute('rev_cat_pv', period) # TODO: ajouter les revenus de l'étranger etr*0.9 # pensions_alimentaires_versees_declarant1 is negative since it is paid by the declaree rev_cap_lib = self.cast_from_entity_to_role(rev_cap_lib_holder, role = VOUS) rev_cat_rvcm = self.cast_from_entity_to_role(rev_cat_rvcm_holder, role = VOUS) abat_spe = self.cast_from_entity_to_role(abat_spe_holder, role = VOUS) fon = self.cast_from_entity_to_role(fon_holder, role = VOUS) f7ga = self.cast_from_entity_to_role(f7ga_holder, role = VOUS) f7gb = self.cast_from_entity_to_role(f7gb_holder, role = VOUS) f7gc = self.cast_from_entity_to_role(f7gc_holder, role = VOUS) rev_cat_pv = self.cast_from_entity_to_role(rev_cat_pv_holder, role = VOUS) return period, (rto_net_declarant1 + rev_cap_lib + rev_cat_rvcm + fon + glo + pensions_alimentaires_versees_declarant1 - f7ga - f7gb - f7gc - abat_spe + rev_cat_pv) @reference_formula class br_pf(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Base ressource des prestations familiales" def function(self, simulation, period): ''' Base ressource des prestations familiales de la famille 'fam' ''' period = period.start.offset('first-of', 'month').period('month') # period_legacy = period.start.offset('first-of', 'month').period('year') annee_fiscale_n_2 = period.start.offset('first-of', 'year').period('year').offset(-2) pfam_ressources_i_holder = simulation.compute('pfam_ressources_i', period) rev_coll_holder = simulation.compute('rev_coll', annee_fiscale_n_2) br_pf_i_total = self.sum_by_entity(pfam_ressources_i_holder) rev_coll = self.split_by_roles(rev_coll_holder, roles = [CHEF, PART]) br_pf = br_pf_i_total + rev_coll[CHEF] + rev_coll[PART] return period, br_pf ############################################################################ # Helper functions ############################################################################ def nb_enf(ages, smic55, ag1, ag2): """ Renvoie le nombre d'enfant au sens des allocations familiales dont l'âge est compris entre ag1 et ag2 """ # Les allocations sont dues à compter du mois civil qui suit la naissance # ag1==0 ou suivant les anniversaires ag1>0. # Un enfant est reconnu à charge pour le versement des prestations # jusqu'au mois précédant son age limite supérieur (ag2 + 1) mais # le versement à lieu en début de mois suivant res = None for key, age in ages.iteritems(): if res is None: res = zeros(len(age), dtype = int32) res += (ag1 <= age) & (age <= ag2) & not_(smic55[key]) return res def age_en_mois_benjamin(ages_en_mois): ''' Renvoie un vecteur (une entree pour chaque famille) avec l'age du benjamin. # TODO check age_en_mois > 0 ''' age_en_mois_benjamin = 12 * 9999 for age_en_mois in ages_en_mois.itervalues(): isbenjamin = (age_en_mois < age_en_mois_benjamin) & (age_en_mois != -9999) age_en_mois_benjamin = isbenjamin * age_en_mois + not_(isbenjamin) * age_en_mois_benjamin return age_en_mois_benjamin PKoz= 0) * (age < pfam.cf.age2) condition_situation = est_enfant_dans_famille * not_(smic55) return period, condition_age * condition_situation @reference_formula class cf_enfant_eligible(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Complément familial - Enfant pris en compte pour l'éligibilité" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') cf_enfant_a_charge = simulation.calculate('cf_enfant_a_charge', period) age = simulation.calculate('age', period) rempli_obligation_scolaire = simulation.calculate('rempli_obligation_scolaire', period) pfam = simulation.legislation_at(period.start).fam condition_enfant = ((age >= pfam.cf.age1) * (age < pfam.enfants.age_intermediaire) * rempli_obligation_scolaire) condition_jeune = (age >= pfam.enfants.age_intermediaire) * (age < pfam.cf.age2) return period, or_(condition_enfant, condition_jeune) * cf_enfant_a_charge @reference_formula class cf_dom_enfant_eligible(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Complément familial (DOM) - Enfant pris en compte pour l'éligibilité" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') cf_enfant_a_charge = simulation.calculate('cf_enfant_a_charge', period) age = simulation.calculate('age', period) rempli_obligation_scolaire = simulation.calculate('rempli_obligation_scolaire', period) pfam = simulation.legislation_at(period.start).fam condition_age = (age >= pfam.cf.age1) * (age < pfam.cf.age_limite_dom) condition_situation = cf_enfant_a_charge * rempli_obligation_scolaire return period, condition_age * condition_situation @reference_formula class cf_dom_enfant_trop_jeune(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Complément familial (DOM) - Enfant trop jeune pour ouvrir le droit" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') est_enfant_dans_famille = simulation.calculate('est_enfant_dans_famille', period) age = simulation.calculate('age', period) pfam = simulation.legislation_at(period.start).fam condition_age = (age >= 0) * (age < pfam.cf.age1) return period, condition_age * est_enfant_dans_famille @reference_formula class cf_ressources_i(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Complément familial - Ressources de l'individu prises en compte" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') br_pf_i = simulation.calculate('br_pf_i', period) est_enfant_dans_famille = simulation.calculate('est_enfant_dans_famille', period) cf_enfant_a_charge = simulation.calculate('cf_enfant_a_charge', period) return period, or_(not_(est_enfant_dans_famille), cf_enfant_a_charge) * br_pf_i @reference_formula class cf_plafond(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Plafond d'éligibilité au Complément Familial" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') pfam = simulation.legislation_at(period.start).fam eligibilite_base = simulation.calculate('cf_eligibilite_base', period) eligibilite_dom = simulation.calculate('cf_eligibilite_dom', period) isol = simulation.calculate('isol', period) biact = simulation.calculate('biact', period) cf_enfant_a_charge_holder = simulation.compute('cf_enfant_a_charge', period) # Calcul du nombre d'enfants à charge au sens du CF cf_nbenf = self.sum_by_entity(cf_enfant_a_charge_holder) # Calcul du taux à appliquer au plafond de base pour la France métropolitaine taux_plafond_metropole = 1 + pfam.cf.majoration_plafond_tx1 * min_(cf_nbenf, 2) + pfam.cf.majoration_plafond_tx2 * max_(cf_nbenf - 2, 0) # Majoration du plafond pour biactivité ou isolement (France métropolitaine) majoration_plafond = (isol | biact) # Calcul du plafond pour la France métropolitaine plafond_metropole = pfam.cf.plafond * taux_plafond_metropole + pfam.cf.majoration_plafond_biact_isole * majoration_plafond # Calcul du taux à appliquer au plafond de base pour les DOM taux_plafond_dom = 1 + cf_nbenf * pfam.ars.plaf_enf_supp # Calcul du plafond pour les DOM plafond_dom = pfam.ars.plaf * taux_plafond_dom plafond = (eligibilite_base * plafond_metropole + eligibilite_dom * plafond_dom) return period, plafond @reference_formula class cf_majore_plafond(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"Plafond d'éligibilité au Complément Familial majoré" @dated_function(date(2014, 4, 1)) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') plafond_base = simulation.calculate('cf_plafond', period) pfam = simulation.legislation_at(period.start).fam return period, plafond_base * pfam.cf.plafond_cf_majore @reference_formula class cf_ressources(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Ressources prises en compte pour l'éligibilité au complément familial" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') cf_ressources_i_holder = simulation.compute('cf_ressources_i', period) ressources = self.sum_by_entity(cf_ressources_i_holder) return period, ressources @reference_formula class cf_eligibilite_base(SimpleFormulaColumn): column = BoolCol entity_class = Familles label = u"Éligibilité au complément familial sous condition de ressources et avant cumul" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') residence_dom = simulation.calculate('residence_dom', period) cf_enfant_eligible_holder = simulation.compute('cf_enfant_eligible', period) cf_nbenf = self.sum_by_entity(cf_enfant_eligible_holder) return period, not_(residence_dom) * (cf_nbenf >= 3) @reference_formula class cf_eligibilite_dom(SimpleFormulaColumn): column = BoolCol entity_class = Familles label = u"Éligibilité au complément familial pour les DOM sous condition de ressources et avant cumul" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') residence_dom = simulation.calculate('residence_dom', period) residence_mayotte = simulation.calculate('residence_mayotte', period) cf_dom_enfant_eligible_holder = simulation.compute('cf_dom_enfant_eligible', period) cf_nbenf = self.sum_by_entity(cf_dom_enfant_eligible_holder) cf_dom_enfant_trop_jeune_holder = simulation.compute('cf_dom_enfant_trop_jeune', period) cf_nbenf_trop_jeune = self.sum_by_entity(cf_dom_enfant_trop_jeune_holder) condition_composition_famille = (cf_nbenf >= 1) * (cf_nbenf_trop_jeune == 0) condition_residence = residence_dom * not_(residence_mayotte) return period, condition_composition_famille * condition_residence @reference_formula class cf_non_majore_avant_cumul(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Complément familial non majoré avant cumul" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') eligibilite_base = simulation.calculate('cf_eligibilite_base', period) eligibilite_dom = simulation.calculate('cf_eligibilite_dom', period) ressources = simulation.calculate('cf_ressources', period) plafond = simulation.calculate('cf_plafond', period) pfam = simulation.legislation_at(period.start).fam eligibilite_sous_condition = or_(eligibilite_base, eligibilite_dom) # Montant montant = pfam.af.bmaf * (pfam.cf.tx * eligibilite_base + pfam.cf.tx_dom * eligibilite_dom) # Complément familial eligibilite = eligibilite_sous_condition * (ressources <= plafond) # Complément familial différentiel plafond_diff = plafond + 12 * montant eligibilite_diff = not_(eligibilite) * eligibilite_sous_condition * ( ressources <= plafond_diff) montant_diff = (plafond_diff - ressources) / 12 return period, max_(eligibilite * montant, eligibilite_diff * montant_diff) @reference_formula class cf_majore_avant_cumul(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"Complément familial majoré avant cumul" @dated_function(date(2014, 4, 1)) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') eligibilite_base = simulation.calculate('cf_eligibilite_base', period) eligibilite_dom = simulation.calculate('cf_eligibilite_dom', period) ressources = simulation.calculate('cf_ressources', period) plafond_majore = simulation.calculate('cf_majore_plafond', period) pfam = simulation.legislation_at(period.start).fam eligibilite_sous_condition = or_(eligibilite_base, eligibilite_dom) # Montant montant = pfam.af.bmaf * (pfam.cf.tx_majore * eligibilite_base + pfam.cf.tx_majore_dom * eligibilite_dom) eligibilite = eligibilite_sous_condition * (ressources <= plafond_majore) return period, eligibilite * montant @reference_formula class cf_montant(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Montant du complément familial, avant prise en compte d'éventuels cumuls" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') cf_non_majore_avant_cumul = simulation.calculate('cf_non_majore_avant_cumul', period) cf_majore_avant_cumul = simulation.calculate('cf_majore_avant_cumul', period) return period, max_(cf_non_majore_avant_cumul, cf_majore_avant_cumul) @reference_formula class cf(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = Familles label = u"Complément familial" url = "http://vosdroits.service-public.fr/particuliers/F13214.xhtml" def function(self, simulation, period): ''' L'allocation de base de la paje n'est pas cumulable avec le complément familial ''' period = period.start.offset('first-of', 'month').period('month') paje_base_montant = simulation.calculate('paje_base_montant', period) apje_temp = simulation.calculate('apje_temp', period) ape_temp = simulation.calculate('ape_temp', period) cf_montant = simulation.calculate('cf_montant', period) residence_mayotte = simulation.calculate('residence_mayotte', period) cf_brut = (paje_base_montant < cf_montant) * (apje_temp <= cf_montant) * (ape_temp <= cf_montant) * cf_montant return period, not_(residence_mayotte) * round(cf_brut, 2) PKoz plafond_taux_plein()) * montant_taux_partiel ) return montant montant = ( enfant_eligible_ne_avant_avril_2014() * montant_enfant_ne_avant_avril_2014() + not_(enfant_eligible_ne_avant_avril_2014()) * enfant_eligible_ne_apres_avril_2014() * montant_enfant_ne_apres_avril_2014() ) return period, montant @reference_formula class paje_base_enfant_eligible_avant_reforme_2014(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Enfant ouvrant droit à la PAJE de base né avant le 1er avril 2014" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age = simulation.calculate('age', period) smic55 = simulation.calculate('smic55', period) birth = simulation.calculate('birth', period) ne_avant_2014 = (datetime64('2014-04-01') - birth) > 0 age_limite = simulation.legislation_at(period.start).fam.paje.base.age # L'allocation de base est versée jusqu'au dernier jour du mois civil précédant # celui au cours duquel l'enfant atteint l'âge de 3 ans. return period, (age < age_limite) * not_(smic55) * ne_avant_2014 @reference_formula class paje_base_enfant_eligible_apres_reforme_2014(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Enfant ouvrant droit à la PAJE de base né après le 1er avril 2014" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age = simulation.calculate('age', period) smic55 = simulation.calculate('smic55', period) birth = simulation.calculate('birth', period) ne_avant_2014 = (datetime64('2014-04-01') - birth) > 0 age_limite = simulation.legislation_at(period.start).fam.paje.base.age # L'allocation de base est versée jusqu'au dernier jour du mois civil précédant # celui au cours duquel l'enfant atteint l'âge de 3 ans. return period, (age < age_limite) * not_(smic55) * not_(ne_avant_2014) @reference_formula class paje_naissance(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = Familles label = u"Allocation de naissance de la PAJE" start_date = date(2004, 1, 1) url = "http://vosdroits.service-public.fr/particuliers/F2550.xhtml" def function(self, simulation, period): ''' Prestation d'accueil du jeune enfant - Allocation de naissance ''' period = period.start.offset('first-of', 'month').period('month') age_en_mois_holder = simulation.compute('age_en_mois', period) # age_holder = simulation.compute('age', period) af_nbenf = simulation.calculate('af_nbenf', period) br_pf = simulation.calculate('br_pf', period) isol = simulation.calculate('isol', period) biact = simulation.calculate('biact', period) P = simulation.legislation_at(period.start).fam # age = self.split_by_roles(age_holder, roles = ENFS) age_en_mois = self.split_by_roles(age_en_mois_holder, roles = ENFS) bmaf = P.af.bmaf nais_prime = round(100 * P.paje.nais.prime_tx * bmaf) / 100 # Versée au 7e mois de grossesse dans l'année # donc les enfants concernés sont les enfants qui ont -2 mois nbnais = 0 for age_m in age_en_mois.itervalues(): nbnais += (age_m == -2) # cas mensuel # nbnais += (age_m >= -2) * (age_m < 10) # cas annuel nbenf = af_nbenf + nbnais # On ajoute l'enfant à naître; # Est-ce que ces taux n'ont pas été mis à jour en avril 2014 ? plaf_tx = (nbenf > 0) + P.paje.base.avant_2014.plaf_tx1 * min_(nbenf, 2) + P.paje.base.avant_2014.plaf_tx2 * max_(nbenf - 2, 0) majo = isol | biact plaf = P.paje.base.avant_2014.plaf * plaf_tx + (plaf_tx > 0) * P.paje.base.avant_2014.plaf_maj * majo elig = (br_pf <= plaf) * (nbnais != 0) nais_brut = nais_prime * elig * (nbnais) return period, nais_brut @reference_formula class paje_clca(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = Familles label = u"PAJE - Complément de libre choix d'activité" start_date = date(2004, 1, 1) url = "http://vosdroits.service-public.fr/particuliers/F313.xhtml" def function(self, simulation, period): """ Prestation d'accueil du jeune enfant - Complément de libre choix d'activité 'fam' Parameters: ----------- age : âge en mois af_nbenf : nombre d'enfants aus sens des allocations familiales paje_base : allocation de base de la PAJE inactif : indicatrice d'inactivité partiel1 : Salarié: Temps de travail ne dépassant pas 50 % de la durée du travail fixée dans l'entreprise pour les salariés VRP ou non salarié travaillant à temps partiel: Temps de travail ne dépassant pas 76 heures par mois et un revenu professionnel mensuel inférieur ou égal à (smic_8.27*169*85 %) partiel2 : Salarié: Temps de travail compris entre 50 et 80 % de la durée du travail fixée dans l'entreprise. VRP ou non salarié travaillant à temps partiel: Temps de travail compris entre 77 et 122 heures par mois et un revenu professionnel mensuel ne dépassant pas (smic_8.27*169*136 %) http://www.caf.fr/wps/portal/particuliers/catalogue/metropole/paje """ period = period.start.offset('first-of', 'month').period('month') age_en_mois_holder = simulation.compute('age_en_mois', period) af_nbenf = simulation.calculate('af_nbenf', period) paje_base = simulation.calculate('paje_base', period) inactif = simulation.calculate('inactif', period) partiel1 = simulation.calculate('partiel1', period) partiel2 = simulation.calculate('partiel2', period) P = simulation.legislation_at(period.start).fam age_en_mois = self.split_by_roles(age_en_mois_holder, roles = ENFS) paje = paje_base >= 0 # durée de versement : # Pour un seul enfant à charge, le CLCA est versé pendant une période de 6 mois (P.paje.clca.duree1) # à partir de la naissance ou de la cessation des IJ maternité et paternité. # A partir du 2ème enfant, il est versé jusqu’au mois précédant le 3ème anniversaire # de l’enfant. # Calcul de l'année et mois de naisage_in_months( du cadet # TODO: ajuster en fonction de la cessation des IJ etc age_m_benjamin = age_en_mois_benjamin(age_en_mois) condition1 = (af_nbenf == 1) * (age_m_benjamin >= 0) * (age_m_benjamin < P.paje.clca.duree1) age_benjamin = floor(age_m_benjamin / 12) condition2 = (age_benjamin <= (P.paje.base.age - 1)) condition = (af_nbenf >= 2) * condition2 + condition1 paje_clca = (condition * P.af.bmaf) * ( (not_(paje)) * (inactif * P.paje.clca.sansab_tx_inactif + partiel1 * P.paje.clca.sansab_tx_partiel1 + partiel2 * P.paje.clca.sansab_tx_partiel2) + (paje) * (inactif * P.paje.clca.avecab_tx_inactif + partiel1 * P.paje.clca.avecab_tx_partiel1 + partiel2 * P.paje.clca.avecab_tx_partiel2)) return period, paje_clca reference_input_variable( name ='paje_prepare', column = FloatCol, entity_class = Familles, label = u"Prestation Partagée d’éducation de l’Enfant (PreParE)", set_input = set_input_divide_by_period ) @reference_formula class paje_clca_taux_plein(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = Familles label = u"Indicatrice Clca taux plein" start_date = date(2004, 1, 1) url = "http://vosdroits.service-public.fr/particuliers/F313.xhtml" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') paje_clca = simulation.calculate('paje_clca', period) inactif = simulation.calculate('inactif', period) return period, (paje_clca > 0) * inactif @reference_formula class paje_clca_taux_partiel(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = Familles label = u"Indicatrice Clca taux partiel" start_date = date(2004, 1, 1) url = "http://vosdroits.service-public.fr/particuliers/F313.xhtml" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') paje_clca = simulation.calculate('paje_clca', period) partiel1 = simulation.calculate('partiel1', period) return period, (paje_clca > 0) * partiel1 # TODO gérer les cumuls avec autres revenus et colca voir site caf @reference_formula class paje_clmg(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = Familles label = u"PAJE - Complément de libre choix du mode de garde" start_date = date(2004, 1, 1) url = "http://www.caf.fr/aides-et-services/s-informer-sur-les-aides/petite-enfance/le-complement-de-libre-choix-du-mode-de-garde" # noqa def function(self, simulation, period): ''' Prestation d accueil du jeune enfant - Complément de libre choix du mode de garde Les conditions Vous devez : avoir un enfant de moins de 6 ans né, adopté ou recueilli en vue d'adoption à partir du 1er janvier 2004 employer une assistante maternelle agréée ou une garde à domicile. avoir une activité professionnelle minimale si vous êtes salarié cette activité doit vous procurer un revenu minimum de : si vous vivez seul : une fois la BMAF si vous vivez en couple soit 2 fois la BMAF si vous êtes non salarié, vous devez être à jour de vos cotisations sociales d'assurance vieillesse Vous n'avez pas besoin de justifier d'une activité min_ si vous êtes : bénéficiaire de l'allocation aux adultes handicapés (Aah) au chômage et bénéficiaire de l'allocation d'insertion ou de l'allocation de solidarité spécifique bénéficiaire du Revenu de solidarité active (Rsa), sous certaines conditions de ressources étudiées par votre Caf, et inscrit dans une démarche d'insertionétudiant (si vous vivez en couple, vous devez être tous les deux étudiants). Autres conditions à remplir : Assistante maternelle agréée Garde à domicile Son salaire brut ne doit pas dépasser par jour de garde et par enfant 5 fois le montant du Smic horaire brut, soit au max 45,00 €. Vous ne devez pas bénéficier de l'exonération des cotisations sociales dues pour la personne employée. ''' period = period.start.offset('first-of', 'month').period('month') aah_holder = simulation.compute('aah', period) age_holder = simulation.compute('age', period) smic55_holder = simulation.compute('smic55', period, accept_other_period = True) etu_holder = simulation.compute('etu', period) salaire_imposable_holder = simulation.compute('salaire_imposable', period) hsup_holder = simulation.compute('hsup', period) concub = simulation.calculate('concub', period) af_nbenf = simulation.calculate('af_nbenf', period) br_pf = simulation.calculate('br_pf', period.start.offset('first-of', 'month').period('month')) empl_dir = simulation.calculate('empl_dir', period) ass_mat = simulation.calculate('ass_mat', period) gar_dom = simulation.calculate('gar_dom', period) paje_clca_taux_partiel = simulation.calculate('paje_clca_taux_partiel', period) paje_clca_taux_plein = simulation.calculate('paje_clca_taux_plein', period) P = simulation.legislation_at(period.start).fam P_n_2 = simulation.legislation_at(period.start.offset(-2, 'year')).fam age = self.split_by_roles(age_holder, roles = ENFS) etu = self.split_by_roles(etu_holder, roles = [CHEF, PART]) hsup = self.split_by_roles(hsup_holder, roles = [CHEF, PART]) salaire_imposable = self.split_by_roles(salaire_imposable_holder, roles = [CHEF, PART]) smic55 = self.split_by_roles(smic55_holder, roles = ENFS) aah = self.sum_by_entity(aah_holder) # condition de revenu minimal bmaf_n_2 = P_n_2.af.bmaf cond_age_enf = (nb_enf(age, smic55, P.paje.clmg.age1, P.paje.clmg.age2 - 1) > 0) cond_sal = ( salaire_imposable[CHEF] + salaire_imposable[PART] + hsup[CHEF] + hsup[PART] > 12 * bmaf_n_2 * (1 + concub) ) # TODO: cond_rpns = cond_act = cond_sal # | cond_rpns cond_nonact = (aah > 0) | (etu[CHEF] & etu[PART]) # | (ass>0) # TODO: RSA insertion, alloc insertion, ass elig = cond_age_enf & (cond_act | cond_nonact) nbenf = af_nbenf seuil1 = (P.paje.clmg.seuil11 * (nbenf == 1) + P.paje.clmg.seuil12 * (nbenf >= 2) + max_(nbenf - 2, 0) * P.paje.clmg.seuil1sup) seuil2 = (P.paje.clmg.seuil21 * (nbenf == 1) + P.paje.clmg.seuil22 * (nbenf >= 2) + max_(nbenf - 2, 0) * P.paje.clmg.seuil2sup) # Si vous bénéficiez du Clca taux partiel (= vous travaillez entre 50 et 80% de la durée du travail fixée # dans l'entreprise), vous cumulez intégralement le Clca et le Cmg. # Si vous bénéficiez du Clca taux partiel (= vous travaillez à 50% ou moins de la durée # du travail fixée dans l'entreprise), le montant des plafonds Cmg est divisé par 2. seuil1 = seuil1 * (1 - .5 * paje_clca_taux_partiel) seuil2 = seuil2 * (1 - .5 * paje_clca_taux_partiel) clmg = P.af.bmaf * ((nb_enf(age, smic55, 0, P.paje.clmg.age1 - 1) > 0) + 0.5 * (nb_enf(age, smic55, P.paje.clmg.age1, P.paje.clmg.age2 - 1) > 0) ) * ( empl_dir * ( (br_pf < seuil1) * P.paje.clmg.empl_dir1 + ((br_pf >= seuil1) & (br_pf < seuil2)) * P.paje.clmg.empl_dir2 + (br_pf >= seuil2) * P.paje.clmg.empl_dir3) + ass_mat * ( (br_pf < seuil1) * P.paje.clmg.ass_mat1 + ((br_pf >= seuil1) & (br_pf < seuil2)) * P.paje.clmg.ass_mat2 + (br_pf >= seuil2) * P.paje.clmg.ass_mat3) + gar_dom * ( (br_pf < seuil1) * P.paje.clmg.domi1 + ((br_pf >= seuil1) & (br_pf < seuil2)) * P.paje.clmg.domi2 + (br_pf >= seuil2) * P.paje.clmg.domi3)) # TODO: connecter avec le crédit d'impôt # Si vous bénéficiez du Clca taux plein # (= vous ne travaillez plus ou interrompez votre activité professionnelle), # vous ne pouvez pas bénéficier du Cmg. paje_clmg = elig * not_(paje_clca_taux_plein) * clmg # TODO vérfiez les règles de cumul return period, paje_clmg @reference_formula class paje_colca(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = Familles label = u"PAJE - Complément optionnel de libre choix d'activité" start_date = date(2004, 1, 1) url = "http://vosdroits.service-public.fr/particuliers/F15110.xhtml" def function(self, simulation, period): ''' Prestation d'accueil du jeune enfant - Complément optionnel de libre choix du mode de garde ''' period = period.start.offset('first-of', 'month').period('month') af_nbenf = simulation.calculate('af_nbenf', period) age_en_mois_holder = simulation.compute('age_en_mois', period) opt_colca = simulation.calculate('opt_colca', period) paje_base = simulation.calculate('paje_base', period) P = simulation.legislation_at(period.start).fam age_en_mois = self.split_by_roles(age_en_mois_holder, roles = ENFS) age_m_benjamin = age_en_mois_benjamin(age_en_mois) condition = (age_m_benjamin < 12 * P.paje.colca.age) * (age_m_benjamin >= 0) nbenf = af_nbenf paje = (paje_base > 0) paje_colca = opt_colca * condition * (nbenf >= 3) * P.af.bmaf * ( (paje) * P.paje.colca.avecab + not_(paje) * P.paje.colca.sansab) return period, paje_colca # TODO: cumul avec clca self.colca_tot_m @reference_formula class paje_base(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = Familles label = u"Allocation de base de la PAJE" start_date = date(2004, 1, 1) url = "http://vosdroits.service-public.fr/particuliers/F2552.xhtml" def function(self, simulation, period): ''' L'allocation de base de la paje n'est pas cumulable avec le complément familial ''' period = period.start.offset('first-of', 'month').period('month') paje_base_montant = simulation.calculate('paje_base_montant', period) cf_montant = simulation.calculate('cf_montant', period) # On regarde ce qui est le plus intéressant pour la famille, chaque mois paje_base = (paje_base_montant >= cf_montant) * paje_base_montant return period, paje_base # def _afeama(self, age_holder, smic55_holder, ape, af_nbenf, br_pf, P = law.fam): # ''' # Aide à la famille pour l'emploi d'une assistante maternelle agréée # ''' # age = self.split_by_roles(age_holder, roles = ENFS) # smic55 = self.split_by_roles(smic55_holder, roles = ENFS) # # # TODO http://web.archive.org/web/20080205163300/http://www.caf.fr/wps/portal/particuliers/catalogue/metropole/afeama # # Les seuils sont de 80 et 110 % de l'ARS # # Vérifier que c'est la même chose pour le clmg # # elig = not_(ape) # assistante maternelle agréee # # Vous devez: # # faire garder votre enfant de moins de 6 ans par une assistante maternelle agréée dont vous êtes l'employeur # # déclarer son embauche à l'Urssaf # # lui verser un salaire ne dépassant pas par jour de garde et par enfant 5 fois le montant horaire du Smic, # # soit au max_ 42,20 € # # # # Si vous cessez de travailler et bénéficiez de l'allocation parentale d'éducation, vous ne recevrez plus l'Afeama. # # Vos enfants doivent être nés avant le 1er janvier 2004. # # # TODO calcul des cotisations urssaf # # # nbenf_afeama = nb_enf(age, smic55, P.af.age1, P.afeama.age - 1) # nbenf = elig * af_nbenf * (nbenf_afeama > 0) # # nb_par_ars = (nbenf == 1 + max_(nbenf - 1, 0) * (1 + P.ars.plaf_enf_supp)) # seuil1 = (P.afeama.mult_seuil1 * P.ars.plaf) * nb_par_ars # seuil2 = (P.afeama.mult_seuil2 * P.ars.plaf) * nb_par_ars # # afeama = nbenf_afeama * P.af.bmaf * ( # (br_pf < seuil1) * P.afeama.taux_mini + # ((br_pf >= seuil1) & (br_pf < seuil2)) * P.afeama.taux_median + # (br_pf >= seuil2) * P.afeama.taux_maxi) # return 12 * afeama # annualisé # # # L'AFEAMA comporte 2 volets complémentaires: l'AFEAMA proprement dit qui consiste à prendre en charge les # # cotisations sociales sur les salaires, d'une part, et une allocation complémentaire versée aux parents, # # la majoration AFEAMA, d'autre part. # # Le système de majoration AFEAMA a été modifié au 1er janvier 2001 : # # Jusqu'en décembre 2000, son montant ne dépendait que de l'âge de l'enfant. # # Depuis janvier 2001, il dépend également de la catégorie de revenus des parents employeurs (fonction de leur base # # ressources et du nombre d'enfants qu'ils ont à charge). # # Parallélement, son plafonnement a été ramené de 100 % à 85 % du salaire net versé à l'assistante maternelle # # (sauf si ces 85 % sont inférieurs au montant de la majoration la moins élevée, compte tenu de l'âge de l'enfant). # # La catégorie de revenus des parents employeurs est déterminée par la CAF en fonction de la base ressources # # du ménage. # # Le tableau suivant récapitule les montants pris en compte depuis le 1er juillet 2007 pour la détermination du # # montant maximal de la majoration AFEAMA selon les catégories de revenus : # # Base ressources du ménage # # 1 enfant 2 enfants par enfant suppémentaire # # revenus inférieurs à 17 593 € inférieurs à 21 653 € 4060 € # # inférieurs à 24 190 € inférieurs à 29 773 € 5583 € # # supérieurs à 24 190 € supérieurs à 29 773 € 5583 € # # Montant base ressources 2006, au 1er juillet 2007 # # # 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é @reference_formula class ape_temp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Allocation parentale d'éducation" stop_date = date(2004, 1, 1) url = "http://fr.wikipedia.org/wiki/Allocation_parentale_d'%C3%A9ducation_en_France" def function(self, simulation, period): ''' Allocation parentale d'éducation 'fam' L’allocation parentale d’éducation s’adresse aux parents qui souhaitent arrêter ou réduire leur activité pour s’occuper de leurs jeunes enfants, à condition que ceux-ci soient nés avant le 01/01/2004. En effet, pour les enfants nés depuis cette date, dans le cadre de la Prestation d’Accueil du Jeune Enfant, les parents peuvent bénéficier du « complément de libre choix d’activité. » Les personnes en couple peuvent toutes deux bénéficier de l’APE à taux plein, mais pas en même temps. En revanche, elles peuvent cumuler deux taux partiels, à condition que leur total ne dépasse pas le montant du taux plein. TODO: cumul, adoption, triplés, Cumul d'allocations : Cette allocation n'est pas cumulable pour un même ménage avec - une autre APE (sauf à taux partiel), - ou l'allocation pour jeune enfant (APJE) versée à partir de la naissance, - ou le complément familial, - ou l'allocation d’adulte handicapé (AAH). Enfin, il est à noter que cette allocation n’est pas cumulable avec : - une pension d’invalidité ou une retraite ; - des indemnités journalières de maladie, de maternité ou d’accident du travail ; - des allocations chômage. Il est tout de même possible de demander aux ASSEDIC la suspension de ces dernières pour percevoir l’APE. L'allocation parentale d'éducation n'est pas soumise à condition de ressources, sauf l’APE à taux partiel pour les professions non salariées. ''' period = period.start.offset('first-of', 'month').period('month') age_holder = simulation.compute('age', period) smic55_holder = simulation.compute('smic55', accept_other_period = True) inactif = simulation.calculate('inactif', period) partiel1 = simulation.calculate('partiel1', period) partiel2 = simulation.calculate('partiel2', period) P = simulation.legislation_at(period.start).fam age = self.split_by_roles(age_holder, roles = ENFS) smic55 = self.split_by_roles(smic55_holder, roles = ENFS) elig = (nb_enf(age, smic55, 0, P.ape.age - 1) >= 1) & (nb_enf(age, smic55, 0, P.af.age2) >= 2) # Inactif # Temps partiel 1 # Salarié: # Temps de travail ne dépassant pas 50 % de la durée du travail fixée dans l'entreprise # VRP ou non salarié travaillant à temps partiel: # Temps de travail ne dépassant pas 76 heures par mois et un revenu professionnel mensuel inférieur ou égal à # (smic_8.27*169*85 %) # partiel1 = zeros((12,self.taille)) # Temps partiel 2 # Salarié: # Salarié: Temps de travail compris entre 50 et 80 % de la durée du travail fixée dans l'entreprise. # Temps de travail compris entre 77 et 122 heures par mois et un revenu professionnel mensuel ne dépassant pas # (smic_8.27*169*136 %) ape = elig * (inactif * P.ape.tx_inactif + partiel1 * P.ape.tx_50 + partiel2 * P.ape.tx_80) # Cummul APE APJE CF return period, ape # annualisé @reference_formula class apje_temp(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Allocation pour le jeune enfant" stop_date = date(2004, 1, 1) url = "http://vosdroits.service-public.fr/particuliers/F2552.xhtml" def function(self, simulation, period): ''' Allocation pour jeune enfant ''' period = period.start.offset('first-of', 'month').period('month') br_pf = simulation.calculate('br_pf', period.start.offset('first-of', 'month').period('month')) age_holder = simulation.compute('age', period) smic55_holder = simulation.compute('smic55', period.start.offset('first-of', 'month').period('month')) biact = simulation.calculate_add('biact', period) isol = simulation.calculate('isol', period) P = simulation.legislation_at(period.start).fam P_n_2 = simulation.legislation_at(period.start.offset(-2, 'year')).fam age = self.split_by_roles(age_holder, roles = ENFS) smic55 = self.split_by_roles(smic55_holder, roles = ENFS) # TODO: APJE courte voir doc ERF 2006 nbenf = nb_enf(age, smic55, 0, P.apje.age - 1) bmaf = P.af.bmaf bmaf_n_2 = P_n_2.af.bmaf 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 period, apje @reference_formula class ape(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Allocation parentale d'éducation" stop_date = date(2004, 1, 1) url = "http://fr.wikipedia.org/wiki/Allocation_parentale_d'%C3%A9ducation_en_France" def function(self, simulation, period): ''' L'allocation de base de la paje n'est pas cumulable avec le complément familial ''' period = period.start.offset('first-of', 'month').period('month') apje_temp = simulation.calculate('apje_temp', period) ape_temp = simulation.calculate('ape_temp', period) cf_montant = simulation.calculate('cf_montant', period) ape = (apje_temp < ape_temp) * (cf_montant < ape_temp) * ape_temp return period, round(ape, 2) @reference_formula class apje(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Allocation pour le jeune enfant" stop_date = date(2004, 1, 1) url = "http://vosdroits.service-public.fr/particuliers/F2552.xhtml" def function(self, simulation, period): # L'APJE n'est pas cumulable avec le complément familial et l'APE period = period.start.offset('first-of', 'month').period('month') apje_temp = simulation.calculate('apje_temp', period) ape_temp = simulation.calculate('ape_temp', period) cf_montant = simulation.calculate('cf_montant', period) apje = (cf_montant < apje_temp) * (ape_temp < apje_temp) * apje_temp return period, round(apje, 2) PKoz= pfam.af.age1) * (age <= pfam.af.age3) * # Âge compatible avec les prestations familiales not_(smic55)) # Ne perçoit pas plus de ressources que "55% du SMIC" au sens CAF return period, eligibilite @reference_formula class asf_enfant(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"Montant du droit à l'ASF ouvert par l'enfant" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') asf_elig_enfant = simulation.calculate('asf_elig_enfant', period) pfam = simulation.legislation_at(period.start).fam return period, asf_elig_enfant * pfam.af.bmaf * pfam.asf.taux1 @reference_formula class asf_elig(SimpleFormulaColumn): column = BoolCol(default = False) entity_class = Familles label = u"Éligibilité à l'ASF" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') pensions_alimentaires_percues_holder = simulation.compute('pensions_alimentaires_percues', period) pensions_alimentaires_percues = self.sum_by_entity(pensions_alimentaires_percues_holder) isol = simulation.calculate('isol', period) residence_mayotte = simulation.calculate('residence_mayotte', period) return period, not_(residence_mayotte) * isol * not_(pensions_alimentaires_percues) # Parent isolé et ne résident pas à Mayotte @reference_formula class asf(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol(default = 0) entity_class = Familles label = u"Allocation de soutien familial (ASF)" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') asf_elig = simulation.calculate('asf_elig', period) asf_enfant_holder = simulation.compute('asf_enfant', period) montant = self.sum_by_entity(asf_enfant_holder, roles = ENFS) return period, asf_elig * montant PKF=openfisca_france/model/prestations/minima_sociaux/__init__.pyPKoz= law.fam.aeeh.age) | ((age >= 16) & (smic55))) ) return period, eligible_aah # TODO: dated_function : avant 2008, il fallait ne pas avoir travaillé pendant les 12 mois précédant la demande. @reference_formula class nb_eligib_aah(SimpleFormulaColumn): column = FloatCol label = "Nombre d'allocataires de l'AAH dans la famille" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') br_aah = simulation.calculate('br_aah', period) aah_eligible_holder = simulation.calculate('aah_eligible', period) aah_eligible = self.split_by_roles(aah_eligible_holder) nb_eligib_aah = 0.0 * br_aah for eligible in aah_eligible.values(): nb_eligib_aah = nb_eligib_aah + eligible return period, nb_eligib_aah @reference_formula class aah_famille(SimpleFormulaColumn): column = FloatCol label = u"Allocation adulte handicapé (Familles) mensualisée" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') law = simulation.legislation_at(period.start) br_aah = simulation.calculate('br_aah', period) concub = simulation.calculate('concub', period) af_nbenf = simulation.calculate('af_nbenf', period) nb_eligib_aah = simulation.calculate('nb_eligib_aah', period) plaf_ress_aah = 12 * law.minim.aah.montant * (1 + concub + law.minim.aah.tx_plaf_supp * af_nbenf) return period, nb_eligib_aah * max_(plaf_ress_aah - br_aah, 0) / 12 @reference_formula class aah(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol label = u"Allocation adulte handicapé (Individus) mensualisée" entity_class = Individus def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') aah_eligible = simulation.calculate('aah_eligible', period) aah_famille_holder = simulation.compute('aah_famille', period) aah_famille = self.cast_from_entity_to_role(aah_famille_holder, role = VOUS) nb_eligib_aah_holder = simulation.compute('nb_eligib_aah', period) nb_eligib_aah = self.cast_from_entity_to_role(nb_eligib_aah_holder, role = VOUS) return period, aah_eligible * ( (nb_eligib_aah > 0) * aah_famille / max_(nb_eligib_aah, 1) ) @reference_formula class caah(DatedFormulaColumn): calculate_output = calculate_output_add column = FloatCol label = u"Complément d'allocation adulte handicapé (mensualisé)" entity_class = Individus ''' Complément d'allocation adulte handicapé : complément de ressources ou majoration vie autonome. Complément de ressources Pour bénéficier du complément de ressources, l’intéressé doit remplir les conditions suivantes : - percevoir l’allocation aux adultes handicapés à taux normal ou en complément d’une pension d’invalidité, d’une pension de vieillesse ou d’une rente accident du travail ; - avoir un taux d’incapacité égal ou supérieur à 80 % ; - avoir une capacité de travail, appréciée par la commission des droits et de l’autonomie (CDAPH) inférieure à 5 % du fait du handicap ; - ne pas avoir perçu de revenu à caractère professionnel depuis un an à la date du dépôt de la demande de complément ; - disposer d’un logement indépendant. A noter : une personne hébergée par un particulier à son domicile n’est pas considérée disposer d’un logement indépendant, sauf s’il s’agit de son conjoint, de son concubin ou de la personne avec laquelle elle est liée par un pacte civil de solidarité. Le complément de ressources est destiné aux personnes handicapées dans l’incapacité de travailler. Il est égal à la différence entre la garantie de ressources pour les personnes handicapées (GRPH) et l’AAH. Majoration pour la vie autonome La majoration pour la vie autonome est destinée à permettre aux personnes, en capacité de travailler et au chômage en raison de leur handicap, de pourvoir faire face à leur dépense de logement. Conditions d'attribution La majoration pour la vie autonome est versée automatiquement aux personnes qui remplissent les conditions suivantes : - percevoir l'AAH à taux normal ou en complément d'un avantage vieillesse ou d'invalidité ou d'une rente accident du travail, - avoir un taux d'incapacité au moins égal à 80 %, - disposer d'un logement indépendant, - bénéficier d'une aide au logement (aide personnelle au logement, ou allocation de logement sociale ou familiale), comme titulaire du droit, ou comme conjoint, concubin ou partenaire lié par un Pacs au titulaire du droit, - ne pas percevoir de revenu d'activité à caractère professionnel propre. Choix entre la majoration ou la garantie de ressources La majoration pour la vie autonome n'est pas cumulable avec la garantie de ressources pour les personnes handicapées. La personne qui remplit les conditions d'octroi de ces deux avantages doit choisir de bénéficier de l'un ou de l'autre. ''' @dated_function(start = date(2005, 7, 1)) def function_2005_07_01(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') law = simulation.legislation_at(period.start) grph = law.minim.caah.grph aah_montant = law.minim.aah.montant aah = simulation.calculate('aah', period) asi_elig = simulation.calculate('asi_elig', 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_elig * (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'invalidité >= 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'invalidité >= 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) @dated_function(start = date(2002, 1, 1), stop = date(2005, 6, 30)) # TODO FIXME start date def function_2005_06_30(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') law = simulation.legislation_at(period.start) cpltx = law.minim.caah.cpltx aah_montant = law.minim.aah.montant aah = simulation.calculate('aah', period) asi_elig = simulation.calculate('asi_elig', 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_elig * (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_ancien_caah = (al > 0) * ((aah > 0) | (benef_asi > 0)) # TODO: & invalidité >= 80% & logement indépendant ancien_caah = cpltx * aah_montant * elig_ancien_caah # En fait le taux cpltx perdure jusqu'en 2008 return period, ancien_caah PKoz 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 ) @reference_formula class ass_base_ressources_conjoint(SimpleFormulaColumn): column = FloatCol label = u"Base de ressources individuelle pour le conjoint du demandeur de l'ASS" entity_class = Individus 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 @reference_formula class ass_eligibilite_i(SimpleFormulaColumn): column = BoolCol label = u"Éligibilité individuelle à l'ASS" entity_class = Individus def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') # 1 si demandeur d'emploi activite = simulation.calculate('activite', period) # Indique que l'user a travaillé 5 ans au cours des 10 dernieres années. ass_precondition_remplie = simulation.calculate('ass_precondition_remplie', period) are_perceived_this_month = simulation.calculate('chonet', period) return period, and_(and_(activite == 1, ass_precondition_remplie), are_perceived_this_month == 0) PKoz= 0 sorted_alt_matrix = (sorted_age_and_alt_matrix % 10) * sorted_present_matrix weighted_alt_matrix = sorted_present_matrix - sorted_alt_matrix * 0.5 # Calcul final du coefficient coeff_pac = weighted_alt_matrix.dot(coefficients_array) return period, (P.plafond_base * (1 + cmu_eligible_majoration_dom * P.majoration_dom) * (1 + coeff_pac) ) @reference_formula class acs_plafond(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Plafond annuel de ressources pour l'éligibilité à l'ACS" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') cmu_c_plafond = simulation.calculate('cmu_c_plafond', period) P = simulation.legislation_at(period.start).cmu return period, cmu_c_plafond * (1 + P.majoration_plafond_acs) @reference_formula class cmu_base_ressources_i(SimpleFormulaColumn): column = FloatCol label = u"Base de ressources de l'individu prise en compte pour l'éligibilité à la CMU-C / ACS" entity_class = Individus 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) @reference_formula class cmu_base_ressources(SimpleFormulaColumn): column = FloatCol label = u"Base de ressources prise en compte pour l'éligibilité à la CMU-C / ACS" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') previous_year = period.start.period('year').offset(-1) aspa = simulation.calculate_add('aspa', previous_year) ass = simulation.calculate_add('ass', previous_year) asi = simulation.calculate_add('asi', previous_year) af = simulation.calculate_add('af', previous_year) cf = simulation.calculate_add('cf', previous_year) asf = simulation.calculate_add('asf', previous_year) paje_clca = simulation.calculate_add('paje_clca', previous_year) paje_prepare = simulation.calculate_add('paje_prepare', previous_year) aide_logement = simulation.calculate_add('aide_logement', previous_year) statut_occupation_holder = simulation.compute('statut_occupation', period) cmu_forfait_logement_base = simulation.calculate('cmu_forfait_logement_base', period) cmu_forfait_logement_al = simulation.calculate('cmu_forfait_logement_al', period) age_holder = simulation.compute('age', period) cmu_base_ressources_i_holder = simulation.compute('cmu_base_ressources_i', period) P = simulation.legislation_at(period.start).cmu statut_occupation = self.cast_from_entity_to_roles(statut_occupation_holder) statut_occupation = self.filter_role(statut_occupation, role = CHEF) cmu_br_i_par = self.split_by_roles(cmu_base_ressources_i_holder, roles = [CHEF, PART]) cmu_br_i_pac = self.split_by_roles(cmu_base_ressources_i_holder, roles = ENFS) age_pac = self.split_by_roles(age_holder, roles = ENFS) forfait_logement = (((statut_occupation == 2) + (statut_occupation == 6)) * cmu_forfait_logement_base + (aide_logement > 0) * min_(cmu_forfait_logement_al, aide_logement)) res = cmu_br_i_par[CHEF] + cmu_br_i_par[PART] + forfait_logement # Prestations calculées, donc valeurs mensuelles. On estime l'annuel en multipliant par 12 res += (aspa + ass + asi + af + cf + asf) res += paje_clca + paje_prepare for key, age in age_pac.iteritems(): res += (0 <= age) * (age <= P.age_limite_pac) * cmu_br_i_pac[key] return period, res @reference_formula class cmu_nb_pac(SimpleFormulaColumn): column = PeriodSizeIndependentIntCol entity_class = Familles label = u"Nombre de personnes à charge au titre de la CMU" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age_holder = simulation.compute('age', period) P = simulation.legislation_at(period.start).cmu ages = self.split_by_roles(age_holder, roles = ENFS) return period, nb_par_age(ages, 0, P.age_limite_pac) @reference_formula class cmu_c(SimpleFormulaColumn): ''' Détermine si le foyer a droit à la CMU complémentaire ''' column = BoolCol label = u"Éligibilité à la CMU-C" entity_class = Familles def function(self, simulation, period): # Note : Cette variable est calculée pour un an, mais si elle est demandée pour une période plus petite, elle # répond pour la période demandée. this_month = period.start.period('month').offset('first-of') this_rolling_year = this_month.start.period('year') if period.stop > this_rolling_year.stop: period = this_rolling_year else: period = this_month cmu_c_plafond = simulation.calculate('cmu_c_plafond', this_month) cmu_base_ressources = simulation.calculate('cmu_base_ressources', this_month) residence_mayotte = simulation.calculate('residence_mayotte', this_month) rsa_socle = simulation.calculate('rsa_socle', this_month) rsa_socle_majore = simulation.calculate('rsa_socle_majore', this_month) rsa_forfait_logement = simulation.calculate('rsa_forfait_logement', this_month) br_rmi = simulation.calculate('br_rmi', this_month) socle = max_(rsa_socle, rsa_socle_majore) eligibilite_basique = cmu_base_ressources <= cmu_c_plafond eligibilite_rsa = (socle > 0) * (br_rmi < socle - rsa_forfait_logement) return period, not_(residence_mayotte) * or_(eligibilite_basique, eligibilite_rsa) @reference_formula class acs(SimpleFormulaColumn): ''' Calcule le montant de l'ACS auquel le foyer a droit ''' column = FloatCol label = u"Éligibilité à l'ACS" entity_class = Familles def function(self, simulation, period): period = period.start.period('month').offset('first-of') cmu_c = simulation.calculate('cmu_c', period) cmu_base_ressources = simulation.calculate('cmu_base_ressources', period) acs_plafond = simulation.calculate('acs_plafond', period) acs_montant = simulation.calculate('acs_montant', period) residence_mayotte = simulation.calculate('residence_mayotte', period) return period, not_(residence_mayotte) * not_(cmu_c) * (cmu_base_ressources <= acs_plafond) * acs_montant / 12 ############################################################################ # Helper functions ############################################################################ def forfait_logement(nbp_foyer, P, law_rsa): ''' Calcule le forfait logement en fonction du nombre de personnes dans le "foyer CMU" et d'un jeu de taux ''' return (12 * rsa_socle_base(nbp_foyer, law_rsa) * ((nbp_foyer == 1) * P.taux_1p + (nbp_foyer == 2) * P.taux_2p + (nbp_foyer > 2) * P.taux_3p_plus)) def nb_par_age(ages, min, max): ''' Calcule le nombre d'individus ayant un âge compris entre min et max ''' res = None for key, age in ages.iteritems(): if res is None: res = zeros(len(age), dtype = int32) res += (min <= age) & (age <= max) return res def rsa_socle_base(nbp, P): ''' Calcule le RSA socle du foyer pour nombre de personnes donné ''' return P.rmi * (1 + P.txp2 * (nbp >= 2) + P.txp3 * (nbp >= 3) + P.txps * max_(0, nbp - 3)) PKvTG Y$T=T==openfisca_france/model/prestations/minima_sociaux/asi_aspa.py# -*- coding: utf-8 -*- from __future__ import division from numpy import abs as abs_, logical_not as not_, logical_or as or_, maximum as max_ from ...base import * # noqa analysis:ignore reference_input_variable( name = "inapte_travail", column = BoolCol, entity_class = Individus, label = u"Reconnu inapte au travail", ) reference_input_variable( name = "taux_invalidite", column = FloatCol, entity_class = Individus, label = u"Taux d'invalidité", ) @reference_formula class br_mv_i(SimpleFormulaColumn): column = FloatCol label = u"Base ressources individuelle du minimum vieillesse/ASPA" entity_class = Individus 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('rfon_ms', 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) 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 @reference_formula class br_mv(SimpleFormulaColumn): column = FloatCol label = u"Base ressource du minimum vieillesse et assimilés (ASPA)" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') br_mv_i_holder = simulation.compute('br_mv_i', period) ass = simulation.calculate('ass', period) br_mv_i = self.split_by_roles(br_mv_i_holder, roles = [CHEF, PART]) return period, ass + br_mv_i[CHEF] + br_mv_i[PART] @reference_formula class aspa_elig(SimpleFormulaColumn): column = BoolCol label = u"Indicatrice individuelle d'éligibilité à l'allocation de solidarité aux personnes agées" entity_class = Individus def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age = simulation.calculate('age', period) inapte_travail = simulation.calculate('inapte_travail', period) taux_invalidite = simulation.calculate('taux_invalidite', period) P = simulation.legislation_at(period.start).minim condition_invalidite = (taux_invalidite > P.aspa.taux_invalidite_aspa_anticipe) + inapte_travail condition_age_base = (age >= P.aspa.age_min) condition_age_anticipe = (age >= P.aah.age_legal_retraite) * condition_invalidite condition_age = condition_age_base + condition_age_anticipe condition_nationalite = simulation.calculate('asi_aspa_condition_nationalite', period) return period, condition_age * condition_nationalite @reference_formula class asi_elig(SimpleFormulaColumn): column = BoolCol label = u"Indicatrice individuelle d'éligibilité à l'allocation supplémentaire d'invalidité" entity_class = Individus def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') last_month = period.start.period('month').offset(-1) aspa_elig = simulation.calculate('aspa_elig', period) invalide = simulation.calculate('invalide', period) rstnet = simulation.calculate('rstnet', last_month) pensions_invalidite = simulation.calculate('pensions_invalidite', last_month) condition_situation = invalide & not_(aspa_elig) condition_pensionnement = (rstnet + pensions_invalidite) > 0 condition_nationalite = simulation.calculate('asi_aspa_condition_nationalite', period) return period, condition_situation * condition_pensionnement * condition_nationalite @reference_formula class asi_aspa_condition_nationalite(SimpleFormulaColumn): column = BoolCol label = u"Condition de nationnalité et de titre de séjour pour bénéficier de l'ASPA ou l'ASI" entity_class = Individus def function(self, simulation, period): ressortissant_eee = simulation.calculate('ressortissant_eee', period) duree_possession_titre_sejour= simulation.calculate('duree_possession_titre_sejour', period) duree_min_titre_sejour = simulation.legislation_at(period.start).minim.aspa.duree_min_titre_sejour return period, or_(ressortissant_eee, duree_possession_titre_sejour >= duree_min_titre_sejour) @reference_formula class asi_aspa_nb_alloc(SimpleFormulaColumn): column = IntCol label = u"Nombre d'allocataires ASI/ASPA" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') aspa_elig_holder = simulation.compute('aspa_elig', period) asi_elig_holder = simulation.compute('asi_elig', period) asi_elig = self.split_by_roles(asi_elig_holder, roles = [CHEF, PART]) aspa_elig = self.split_by_roles(aspa_elig_holder, roles = [CHEF, PART]) return period, (1 * aspa_elig[CHEF] + 1 * aspa_elig[PART] + 1 * asi_elig[CHEF] + 1 * asi_elig[PART]) @reference_formula class asi(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol label = u"Allocation supplémentaire d'invalidité" start_date = date(2007, 1, 1) url = u"http://vosdroits.service-public.fr/particuliers/F16940.xhtml" entity_class = Familles def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') asi_elig_holder = simulation.compute('asi_elig', period) aspa_elig_holder = simulation.compute('aspa_elig', period) maries = simulation.calculate('maries', period) concub = simulation.calculate('concub', period) asi_aspa_nb_alloc = simulation.calculate('asi_aspa_nb_alloc', period) br_mv = simulation.calculate('br_mv', period) P = simulation.legislation_at(period.start).minim asi_elig = self.split_by_roles(asi_elig_holder, roles = [CHEF, PART]) aspa_elig = self.split_by_roles(aspa_elig_holder, roles = [CHEF, PART]) # Un seul éligible elig1 = ((asi_aspa_nb_alloc == 1) & (asi_elig[CHEF] | asi_elig[PART])) # Couple d'éligibles mariés elig2 = asi_elig[CHEF] & asi_elig[PART] & maries # Couple d'éligibles non mariés elig3 = asi_elig[CHEF] & asi_elig[PART] & not_(maries) # Un seul éligible et époux éligible ASPA elig4 = ((asi_elig[CHEF] & aspa_elig[PART]) | (asi_elig[PART] & aspa_elig[CHEF])) & maries # Un seul éligible et conjoint non marié éligible ASPA elig5 = ((asi_elig[CHEF] & aspa_elig[PART]) | (asi_elig[PART] & aspa_elig[CHEF])) & not_(maries) elig = elig1 | elig2 | elig3 | elig4 | elig5 montant_max = (elig1 * P.asi.montant_seul + elig2 * P.asi.montant_couple + elig3 * 2 * P.asi.montant_seul + elig4 * (P.asi.montant_couple / 2 + P.aspa.montant_couple / 2) + elig5 * (P.asi.montant_seul + P.aspa.montant_couple / 2)) / 12 ressources = br_mv + montant_max plafond_ressources = (elig1 * (P.asi.plaf_seul * not_(concub) + P.asi.plaf_couple * concub) + elig2 * P.asi.plaf_couple + elig3 * P.asi.plaf_couple + elig4 * P.aspa.plaf_couple + elig5 * P.aspa.plaf_couple) / 12 depassement = max_(ressources - plafond_ressources, 0) diff = ((elig1 | elig2 | elig3) * (montant_max - depassement) + elig4 * (P.asi.montant_couple / 12 / 2 - depassement / 2) + elig5 * (P.asi.montant_seul / 12 - depassement / 2)) # Montant mensuel servi (sous réserve d'éligibilité) montant_servi_asi = max_(diff, 0) # TODO: Faute de mieux, on verse l'asi à la famille plutôt qu'aux individus # asi[CHEF] = asi_elig[CHEF]*montant_servi_asi*(elig1*1 + elig2/2 + elig3/2) # asi[PART] = asi_elig[PART]*montant_servi_asi*(elig1*1 + elig2/2 + elig3/2) return period, elig * montant_servi_asi @reference_formula class aspa_couple(DatedFormulaColumn): column = BoolCol label = u"Couple au sens de l'ASPA" entity_class = Familles @dated_function(date(2002, 1, 1), date(2006, 12, 31)) def function_2002_2006(self, simulation, period): period = period maries = simulation.calculate('maries', period) return period, maries @dated_function(date(2007, 1, 1)) def function_2007(self, simulation, period): period = period concub = simulation.calculate('concub', period) return period, concub @reference_formula class aspa(SimpleFormulaColumn): calculate_output = calculate_output_add column = FloatCol entity_class = Familles label = u"Allocation de solidarité aux personnes agées" url = "http://vosdroits.service-public.fr/particuliers/F16871.xhtml" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') asi_elig_holder = simulation.compute('asi_elig', period) aspa_elig_holder = simulation.compute('aspa_elig', period) maries = simulation.calculate('maries', period) concub = simulation.calculate('concub', period) asi_aspa_nb_alloc = simulation.calculate('asi_aspa_nb_alloc', period) br_mv = simulation.calculate('br_mv', period) P = simulation.legislation_at(period.start).minim asi_elig = self.split_by_roles(asi_elig_holder, roles = [CHEF, PART]) aspa_elig = self.split_by_roles(aspa_elig_holder, roles = [CHEF, PART]) # Un seul éligible elig1 = ((asi_aspa_nb_alloc == 1) & (aspa_elig[CHEF] | aspa_elig[PART])) # Couple d'éligibles elig2 = (aspa_elig[CHEF] & aspa_elig[PART]) # Un seul éligible et époux éligible ASI elig3 = ((asi_elig[CHEF] & aspa_elig[PART]) | (asi_elig[PART] & aspa_elig[CHEF])) & maries # Un seul éligible et conjoint non marié éligible ASI elig4 = ((asi_elig[CHEF] & aspa_elig[PART]) | (asi_elig[PART] & aspa_elig[CHEF])) & not_(maries) elig = elig1 | elig2 | elig3 | elig4 montant_max = ( elig1 * P.aspa.montant_seul + elig2 * P.aspa.montant_couple + elig3 * (P.asi.montant_couple / 2 + P.aspa.montant_couple / 2) + elig4 * (P.asi.montant_seul + P.aspa.montant_couple / 2) ) / 12 ressources = br_mv + montant_max plafond_ressources = (elig1 * (P.aspa.plaf_seul * not_(concub) + P.aspa.plaf_couple * concub) + (elig2 | elig3 | elig4) * P.aspa.plaf_couple) / 12 depassement = max_(ressources - plafond_ressources, 0) diff = ((elig1 | elig2) * (montant_max - depassement) + (elig3 | elig4) * (P.aspa.montant_couple / 12 / 2 - depassement / 2)) # Montant mensuel servi (sous réserve d'éligibilité) montant_servi_aspa = max_(diff, 0) # TODO: Faute de mieux, on verse l'aspa à la famille plutôt qu'aux individus # aspa[CHEF] = aspa_elig[CHEF]*montant_servi_aspa*(elig1 + elig2/2) # aspa[PART] = aspa_elig[PART]*montant_servi_aspa*(elig1 + elig2/2) return period, elig * montant_servi_aspa PKvTGW8openfisca_france/model/prestations/minima_sociaux/rsa.py# -*- coding: utf-8 -*- from __future__ import division from numpy import (floor, logical_and as and_, logical_not as not_, logical_or as or_, maximum as max_, minimum as min_) from ...base import * # noqa analysis:ignore from ..prestations_familiales.base_ressource import nb_enf, age_en_mois_benjamin @reference_formula class aefa(DatedFormulaColumn): ''' Aide exceptionelle de fin d'année (prime de Noël) Instituée en 1998 Apparaît sous le nom de complément de rmi dans les ERF 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 à Pour bénéficier de la Prime de Noël 2011, vous devez être éligible pour le compte du mois de novembre 2011 ou au plus de décembre 2011, soit d’une allocation de solidarité spécifique (ASS), de la prime forfaitaire mensuelle de reprise d'activité, de l'allocation équivalent retraite (allocataire AER), du revenu de solidarité active (Bénéficiaires RSA), de l'allocation de parent isolé (API), du revenu minimum d'insertion (RMI), de l’Allocation pour la Création ou la Reprise d'Entreprise (ACCRE-ASS) ou encore allocation chômage. ''' column = FloatCol entity_class = Familles label = u"Aide exceptionelle de fin d'année (prime de Noël)" url = u"http://www.pole-emploi.fr/candidat/aide-exceptionnelle-de-fin-d-annee-dite-prime-de-noel--@/suarticle.jspz?id=70996" # noqa @dated_function(start = date(2009, 1, 1), stop = date(2015, 12, 31)) 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, 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 @dated_function(start = date(2008, 1, 1), stop = date(2008, 12, 31)) def function_2008(self, simulation, period): period = period.start.offset('first-of', 'year').period('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('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 += condition * P.forf2008 aefa_maj = P.mon_seul * maj aefa = max_(aefa_maj, aefa) return period, aefa @dated_function(start = date(2002, 1, 1), stop = date(2007, 12, 31)) def function__2008_(self, simulation, period): period = period.start.offset('first-of', 'year').period('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('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 @reference_formula class api(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"Allocation de parent isolé" url = u"http://fr.wikipedia.org/wiki/Allocation_de_parent_isol%C3%A9", @dated_function(stop = date(2009, 5, 31)) def function__2009(self, simulation, period): """ Allocation de parent isolé """ period = period.start.offset('first-of', 'month').period('month') age_en_mois_holder = simulation.compute('age_en_mois', period) age_holder = simulation.compute('age', period) smic55_holder = simulation.compute('smic55', period) isol = simulation.calculate('isol', period) rsa_forfait_logement = simulation.calculate('rsa_forfait_logement', period) br_rmi = simulation.calculate('br_rmi', period) af_majo = simulation.calculate('af_majo', period) rsa = simulation.calculate('rsa', period) af = simulation.legislation_at(period.start).fam.af api = simulation.legislation_at(period.start).minim.api age = self.split_by_roles(age_holder, roles = ENFS) age_en_mois = self.split_by_roles(age_en_mois_holder, roles = ENFS) smic55 = self.split_by_roles(smic55_holder, roles = ENFS) # TODO: # Majoration pour isolement # Si vous êtes parent isolé, c’est-à-dire célibataire, divorcé(e), séparé(e) ou veuf(ve) avec des enfants # à charge ou enceinte, le montant forfaitaire garanti est majoré. # Ce montant forfaitaire majoré est accordé à partir du mois au cours duquel survient l'un des événements # suivants : # - déclaration de grossesse, # - naissance d'un enfant, # - prise en charge d'un enfant, # - séparation, veuvage, # - dépôt de la demande si l’événement est antérieur. # # Le montant forfaitaire majoré peut être accordé pendant 12 mois, continus ou discontinus, au cours # d’une période de 18 mois suivant l’événement. # Si votre plus jeune enfant à charge a moins de 3 ans, le montant forfaitaire majoré vous est accordé # jusqu'à ses 3 ans. benjamin = age_en_mois_benjamin(age_en_mois) enceinte = (benjamin < 0) * (benjamin > -6) # TODO: quel mois mettre ? # TODO: pas complètement exact # L'allocataire perçoit l'API : # jusqu'�� ce que le plus jeune enfant ait 3 ans, # ou pendant 12 mois consécutifs si les enfants sont âgés de plus de 3 ans # et s'il a présenté sa demande dans les 6 mois à partir du moment où il # assure seul la charge de l'enfant. # TODO: API courte gens pour les gens qui ont divorcés dans l'année # Le droit à l'allocation est réétudié tous les 3 mois. # # Calcul de l'année et mois de naissance du benjamin condition = (floor(benjamin / 12) <= api.age - 1) eligib = isol * ((enceinte != 0) | (nb_enf(age, smic55, 0, api.age - 1) > 0)) * condition # moins de 20 ans avant inclusion dans rsa # moins de 25 ans après inclusion dans rsa api1 = eligib * af.bmaf * (api.base + api.enf_sup * nb_enf(age, smic55, af.age1, api.age_pac - 1)) rsa = (api.age_pac >= 25) # dummy passage au rsa majoré br_api = br_rmi + af_majo * not_(rsa) # On pourrait mensualiser RMI, BRrmi et forfait logement api = max_(0, api1 - rsa_forfait_logement / 12 - br_api / 12 - rsa / 12) # L'API est exonérée de CRDS return period, api # annualisé # TODO API: temps partiel qui modifie la base ressource # Cumul # Cumul avec un revenu # Si l'allocataire reprend une activité ou suit une formation professionnelle rémunérée, les revenus sont # cumulables intégralement au cours des 3 premiers mois de reprise d'activité. # Du 4e au 12e mois qui suit, le montant de l'allocation varie en fonction de la durée de l'activité # ou de la formation. # Durée d'activité de 78 heures ou plus par mois ou activité non salariée # Lorsque la durée d'activité est de 78 heures minimum par mois, le montant de l'API perçu par l'allocataire est # diminué de la totalité du salaire. Tous les revenus d'activité sont pris en compte pour le calcul de l'API, # sauf si l'allocataire perçoit des revenus issus d'un contrat insertion-revenu minimum d'activité (CIRMA) # ou d'un contrat d'avenir (CAV). # L'allocataire peut bénéficier, sous certaines conditions : # • de la prime de retour à l'emploi si son activité est d'une durée d'au moins 4 mois consécutifs, # sauf s'il effectue un stage de formation professionnelle, # • de la prime forfaitaire pendant 9 mois, sauf s'il exerce une activité salariée dans le cadre d'un CIRMA # ou d'un CAV. # Durée d'activité de moins de 78 heures par mois # Lorsque la durée d'activité est inférieure à 78 heures par mois, le montant de l'API perçu par l'allocataire # est diminué de la moitié du salaire. # Si l'allocataire exerce une activité dans le cadre d'un CIRMA ou d'un CAV, ses revenus d'activité ne sont pas # pris en compte pour le calcul de son API. @reference_formula class br_rmi(DatedFormulaColumn): column = FloatCol label = u"Base ressources du Rmi ou du Rsa" entity_class = Familles @dated_function(stop = date(2009, 5, 31)) def function_rmi(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') br_rmi_pf = simulation.calculate('br_rmi_pf', period) br_rmi_ms = simulation.calculate('br_rmi_ms', period) br_rmi_i_holder = simulation.compute('br_rmi_i', period) br_rmi_i_total = self.sum_by_entity(br_rmi_i_holder) return period, br_rmi_pf + br_rmi_ms + br_rmi_i_total @dated_function(start = date(2009, 6, 1)) def function_rsa(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') br_rmi_pf = simulation.calculate('br_rmi_pf', period) br_rmi_ms = simulation.calculate('br_rmi_ms', period) br_rmi_i_holder = simulation.compute('br_rmi_i', period) ra_rsa_i_holder = simulation.compute('ra_rsa_i', period) br_rmi_i_total = self.sum_by_entity(br_rmi_i_holder) ra_rsa_i_total = self.sum_by_entity(ra_rsa_i_holder) return period, br_rmi_pf + br_rmi_ms + br_rmi_i_total + ra_rsa_i_total @reference_formula class br_rmi_i(SimpleFormulaColumn): column = FloatCol label = u"Base ressource individuelle du RSA/RMI (hors revenus d'actvité)" entity_class = Individus def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') three_previous_months = period.start.period('month', 3).offset(-3) r = rsa_ressource_calculator(simulation, period) # Ressources professionelles chonet = r.calcule_ressource('chonet', revenu_pro = True) rstnet = r.calcule_ressource('rstnet', revenu_pro = True) pensions_alimentaires_percues = r.calcule_ressource('pensions_alimentaires_percues') allocation_aide_retour_emploi = r.calcule_ressource('allocation_aide_retour_emploi') allocation_securisation_professionnelle = r.calcule_ressource('allocation_securisation_professionnelle') prestation_compensatoire = r.calcule_ressource('prestation_compensatoire') rto_declarant1 = r.calcule_ressource('rto_declarant1') rfon_ms = r.calcule_ressource('rfon_ms') div_ms = r.calcule_ressource('div_ms') gains_exceptionnels = r.calcule_ressource('gains_exceptionnels') dedommagement_victime_amiante = r.calcule_ressource('dedommagement_victime_amiante') pensions_invalidite = r.calcule_ressource('pensions_invalidite') rsa_base_ressources_patrimoine_i = r.calcule_ressource('rsa_base_ressources_patrimoine_i') rev_cap_bar_holder = simulation.compute_add('rev_cap_bar', three_previous_months) rev_cap_lib_holder = simulation.compute_add('rev_cap_lib', three_previous_months) 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) result = ( chonet + rstnet + pensions_alimentaires_percues + rto_declarant1 + rev_cap_bar + rev_cap_lib + rfon_ms + div_ms + gains_exceptionnels + dedommagement_victime_amiante + pensions_invalidite + allocation_aide_retour_emploi + allocation_securisation_professionnelle + prestation_compensatoire + rsa_base_ressources_patrimoine_i ) / 3 return period, result @reference_formula class br_rmi_ms(SimpleFormulaColumn): column = FloatCol label = u"Minima sociaux inclus dans la base ressource RSA/RMI" entity_class = Familles 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 = simulation.calculate('aspa', period) asi = simulation.calculate('asi', period) ass = simulation.calculate('ass', period) aah_holder = simulation.compute_add('aah', three_previous_months) caah_holder = simulation.compute_add('caah', three_previous_months) aah = self.sum_by_entity(aah_holder) / 3 caah = self.sum_by_entity(caah_holder) / 3 return period, aspa + asi + ass + aah + caah @reference_formula class br_rmi_pf(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"Prestations familiales inclues dans la base ressource RSA/RMI" @dated_function(date(2002, 1, 1), date(2003, 12, 31)) def function_2002(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_base = simulation.calculate('af_base', period) cf = simulation.calculate('cf', period) asf = simulation.calculate('asf', period) apje = simulation.calculate('apje', period) ape = simulation.calculate('ape', period) P = simulation.legislation_at(period.start).minim return period, P.rmi.pfInBRrmi * (af_base + cf + asf + apje + ape) @dated_function(start = date(2004, 1, 1), stop = date(2014, 3, 31)) def function_2003(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') af_base = simulation.calculate('af_base', period) cf = simulation.calculate('cf', period) asf = simulation.calculate('asf', period) paje_base = simulation.calculate('paje_base', period) paje_clca = simulation.calculate('paje_clca', period) paje_prepare = simulation.calculate('paje_prepare', period) paje_colca = simulation.calculate('paje_colca', period) P = simulation.legislation_at(period.start).minim return period, P.rmi.pfInBRrmi * (af_base + cf + asf + paje_base + paje_clca + paje_prepare + paje_colca) @dated_function(start = date(2014, 4, 1)) def function_2014(self, simulation, period): # TODO : Neutraliser les ressources de type prestations familiales quand elles sont interrompues period = period.start.offset('first-of', 'month').period('month') af_base = simulation.calculate('af_base', period) cf_non_majore_avant_cumul = simulation.calculate('cf_non_majore_avant_cumul', period) cf = simulation.calculate('cf', period) rsa_forfait_asf = simulation.calculate('rsa_forfait_asf', period) paje_base = simulation.calculate('paje_base', period) paje_clca = simulation.calculate('paje_clca', period) paje_prepare = simulation.calculate('paje_prepare', period) paje_colca = simulation.calculate('paje_colca', period) P = simulation.legislation_at(period.start).minim # Seul le montant non majoré est pris en compte dans la base de ressources du RSA cf_non_majore = (cf > 0) * cf_non_majore_avant_cumul return period, P.rmi.pfInBRrmi * (af_base + rsa_forfait_asf + cf_non_majore + paje_base + paje_clca + paje_prepare + paje_colca) @reference_formula class crds_mini(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"CRDS versée sur les minimas sociaux" @dated_function(start = date(2009, 6, 1)) def function_2009_(self, simulation, period): """ CRDS sur les minima sociaux """ period = period.start.offset('first-of', 'month').period('month') rsa_act = simulation.calculate('rsa_act', period) taux_crds = simulation.legislation_at(period.start).fam.af.crds return period, - taux_crds * rsa_act @reference_formula class div_ms(SimpleFormulaColumn): column = FloatCol entity_class = Individus def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') period_declaration = period.start.offset('first-of', 'year').period('year') f3vc_holder = simulation.compute('f3vc', period_declaration) f3ve_holder = simulation.compute('f3ve', period_declaration) f3vg_holder = simulation.compute('f3vg', period_declaration) f3vl_holder = simulation.compute('f3vl', period_declaration) f3vm_holder = simulation.compute('f3vm', period_declaration) f3vc = self.cast_from_entity_to_role(f3vc_holder, role = VOUS) f3ve = self.cast_from_entity_to_role(f3ve_holder, role = VOUS) f3vg = self.cast_from_entity_to_role(f3vg_holder, role = VOUS) f3vl = self.cast_from_entity_to_role(f3vl_holder, role = VOUS) f3vm = self.cast_from_entity_to_role(f3vm_holder, role = VOUS) return period, (f3vc + f3ve + f3vg + f3vl + f3vm) / 12 @reference_formula class enceinte_fam(SimpleFormulaColumn): column = BoolCol entity_class = Familles def function(self, simulation, period): period = period age_en_mois_holder = simulation.compute('age_en_mois', period) enceinte_holder = simulation.compute('enceinte', period) age_en_mois_enf = self.split_by_roles(age_en_mois_holder, roles = ENFS) enceinte = self.split_by_roles(enceinte_holder, roles = [CHEF, PART]) benjamin = age_en_mois_benjamin(age_en_mois_enf) enceinte_compat = and_(benjamin < 0, benjamin > -6) return period, or_(or_(enceinte_compat, enceinte[CHEF]), enceinte[PART]) @reference_formula class nb_enfant_rsa(SimpleFormulaColumn): column = IntCol entity_class = Familles label = u"Nombre d'enfants pris en compte pour le calcul du RSA" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') rmi = simulation.legislation_at(period.start).minim.rmi age_holder = simulation.compute('age', period) smic55_holder = simulation.compute('smic55', period) age_enf = self.split_by_roles(age_holder, roles = ENFS) smic55_enf = self.split_by_roles(smic55_holder, roles = ENFS) nbenf = nb_enf(age_enf, smic55_enf, 0, rmi.age_pac) return period, nbenf @reference_formula class psa(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"Prime de solidarité active" url = u"http://www.service-public.fr/actualites/001077.html" @dated_function(start = date(2009, 4, 1), stop = date(2009, 4, 30)) def function_2009(self, simulation, period): ''' Prime de solidarité active (exceptionnelle, 200€ versés une fois en avril 2009) Versement en avril 2009 d’une prime de solidarité active (Psa) aux familles modestes qui ont bénéficié en janvier, février ou mars 2009 du Rmi, de l’Api (du Rsa expérimental, du Cav ou du Rma pour les ex-bénéficiaires du Rmi ou de l’Api), de la prime forfaitaire mensuelle au titre du Rmi ou de l’Api ou enfin d’une aide au logement (à condition d’exercer une activité professionnelle et d’être âgé de plus de 25 ans ou d’avoir au moins un enfant à charge). La Psa, prime exceptionnelle, s’élève à 200 euros par foyer bénéficiaire. ''' period = period.start.offset('first-of', 'month').period('month') api = simulation.calculate('api', period) rsa = simulation.calculate('rsa', period) activite_holder = simulation.compute('activite', period) af_nbenf = simulation.calculate('af_nbenf', period) aide_logement = simulation.calculate('aide_logement', period) P = simulation.legislation_at(period.start).minim.rmi activite = self.split_by_roles(activite_holder, roles = [CHEF, PART]) dummy_api = api > 0 dummy_rmi = rsa > 0 dummy_al = and_(aide_logement > 0, or_(af_nbenf > 0, or_(activite[CHEF] == 0, activite[PART] == 0))) condition = (dummy_api + dummy_rmi + dummy_al > 0) psa = condition * P.psa return period, psa @reference_formula class ra_rsa(SimpleFormulaColumn): column = FloatCol label = u"Revenus d'activité du RSA" entity_class = Familles start_date = date(2009, 6, 1) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') ra_rsa_i_holder = simulation.compute('ra_rsa_i', period) ra_rsa = self.sum_by_entity(ra_rsa_i_holder) return period, ra_rsa @reference_formula class ra_rsa_i(SimpleFormulaColumn): column = FloatCol label = u"Revenus d'activité du Rsa - Individuel" entity_class = Individus start_date = date(2009, 6, 1) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') r = rsa_ressource_calculator(simulation, period) salaire_net = r.calcule_ressource('salaire_net', revenu_pro = True) indemnites_journalieres = r.calcule_ressource('indemnites_journalieres', revenu_pro = True) indemnites_chomage_partiel = r.calcule_ressource('indemnites_chomage_partiel', revenu_pro = True) indemnites_volontariat = r.calcule_ressource('indemnites_volontariat', revenu_pro = True) revenus_stage_formation_pro = r.calcule_ressource('revenus_stage_formation_pro', revenu_pro = True) indemnites_stage = r.calcule_ressource('indemnites_stage', revenu_pro = True) bourse_recherche = r.calcule_ressource('bourse_recherche', revenu_pro = True) hsup = r.calcule_ressource('hsup', revenu_pro = True) etr = r.calcule_ressource('etr', revenu_pro = True) # Ressources TNS # WARNING : D'après les caisses, le revenu pris en compte pour les AE pour le RSA ne prend en compte que # l'abattement standard sur le CA, mais pas les cotisations pour charges sociales. Dans l'attente d'une # éventuelle correction, nous implémentons selon leurs instructions. Si changement, il suffira de remplacer le # tns_auto_entrepreneur_benefice par tns_auto_entrepreneur_revenus_net tns_auto_entrepreneur_revenus_rsa = r.calcule_ressource('tns_auto_entrepreneur_benefice', revenu_pro = True) result = ( salaire_net + indemnites_journalieres + indemnites_chomage_partiel + indemnites_volontariat + revenus_stage_formation_pro + indemnites_stage + bourse_recherche + hsup + etr + tns_auto_entrepreneur_revenus_rsa ) / 3 return period, result @reference_formula class rfon_ms(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Revenus fonciers pour la base ressource du rmi/rsa" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') period_declaration = period.start.offset('first-of', 'year').period('year') f4ba_holder = simulation.compute('f4ba', period_declaration) f4be_holder = simulation.compute('f4be', period_declaration) f4ba = self.cast_from_entity_to_role(f4ba_holder, role = VOUS) f4be = self.cast_from_entity_to_role(f4be_holder, role = VOUS) return period, (f4ba + f4be) / 12 @reference_formula class rmi(DatedFormulaColumn): column = FloatCol entity_class = Familles label = u"Revenu Minimum d'Insertion" @dated_function(start = date(1988, 12, 1), stop = date(2009, 5, 31)) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') activite = simulation.calculate('activite', period) br_rmi = simulation.calculate('br_rmi', period) rsa_socle = simulation.calculate('rsa_socle', period) rsa_forfait_logement = simulation.calculate('rsa_forfait_logement', period) return period, (activite != 0) * (activite != 2) * (activite != 3) * ( max_(0, rsa_socle - rsa_forfait_logement - br_rmi)) # TODO: Migré lors de la mensualisation. Probablement faux @reference_formula class rmi_nbp(SimpleFormulaColumn): column = IntCol entity_class = Familles label = u"Nombre de personne à charge au sens du Rmi/Rsa" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') age_holder = simulation.compute('age', period) smic55_holder = simulation.compute('smic55', period) nb_par = simulation.calculate('nb_par', period) P = simulation.legislation_at(period.start).minim.rmi age = self.split_by_roles(age_holder, roles = ENFS) smic55 = self.split_by_roles(smic55_holder, roles = ENFS) return period, nb_par + nb_enf(age, smic55, 0, P.age_pac - 1) # TODO: check limite d'âge in legislation @reference_formula class rsa(DatedFormulaColumn): calculate_output = calculate_output_add column = FloatCol label = u"Revenu de solidarité active" entity_class = Familles @dated_function(start = date(2009, 06, 1)) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') rsa_majore = simulation.calculate('rsa_majore', period) rsa_non_majore = simulation.calculate('rsa_non_majore', period) rsa_non_calculable = simulation.calculate('rsa_non_calculable', period) rsa = (1 - rsa_non_calculable) * max_(rsa_majore, rsa_non_majore) return period, rsa @reference_formula class rsa_act(DatedFormulaColumn): base_function = requested_period_added_value column = FloatCol entity_class = Familles label = u"Revenu de solidarité active - activité" start_date = date(2009, 6, 1) @dated_function(start = date(2009, 6, 1)) def function_2009(self, simulation, period): ''' Calcule le montant du RSA activité Note: le partage en moitié est un point de législation, pas un choix arbitraire ''' period = period rsa = simulation.calculate('rsa', period) rmi = simulation.calculate('rmi', period) return period, max_(rsa - rmi, 0) @reference_formula class rsa_act_i(DatedFormulaColumn): column = FloatCol entity_class = Individus label = u"Revenu de solidarité active - activité au niveau de l'individu" start_date = date(2009, 6, 1) @dated_function(start = date(2009, 6, 1)) def function_2009_(self, simulation, period): period = period # TODO: rentre dans le calcul de la PPE check period !!! rsa_act_holder = simulation.compute('rsa_act', period) concub_holder = simulation.compute('concub', period) maries_holder = simulation.compute('maries', period) quifam = simulation.calculate('quifam', period) concub = self.cast_from_entity_to_roles(concub_holder) maries = self.cast_from_entity_to_roles(maries_holder) rsa_act = self.cast_from_entity_to_roles(rsa_act_holder) conj = or_(concub, maries) rsa_act_i = 0 * quifam # TODO Generate an array of float for rsa_act_i, add method self.zeros(). chef_filter = quifam == 0 rsa_act_i[chef_filter] = rsa_act[chef_filter] / (1 + conj[chef_filter]) partenaire_filter = quifam == 1 rsa_act_i[partenaire_filter] = rsa_act[partenaire_filter] * conj[partenaire_filter] / 2 return period, rsa_act_i @reference_formula class rsa_base_ressources_patrimoine_i(DatedFormulaColumn): column = FloatCol label = u"Base de ressources des revenus du patrimoine du RSA" entity_class = Individus start_date = date(2009, 6, 1) @dated_function(start = date(2009, 6, 1)) def function_2009_(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') interets_epargne_sur_livrets = simulation.calculate('interets_epargne_sur_livrets', period) epargne_non_remuneree = simulation.calculate('epargne_non_remuneree', period) revenus_capital = simulation.calculate('revenus_capital', period) valeur_locative_immo_non_loue = simulation.calculate('valeur_locative_immo_non_loue', period) valeur_locative_terrains_non_loue = simulation.calculate('valeur_locative_terrains_non_loue', period) revenus_locatifs = simulation.calculate('revenus_locatifs', period) rsa = simulation.legislation_at(period.start).minim.rmi return period, ( interets_epargne_sur_livrets / 12 + epargne_non_remuneree * rsa.patrimoine.taux_interet_forfaitaire_epargne_non_remunere / 12 + revenus_capital + valeur_locative_immo_non_loue * rsa.patrimoine.abattement_valeur_locative_immo_non_loue + valeur_locative_terrains_non_loue * rsa.patrimoine.abattement_valeur_locative_terrains_non_loue + revenus_locatifs ) @reference_formula class rsa_condition_nationalite(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"Conditions de nationnalité et de titre de séjour pour bénéficier du RSA" def function(self, simulation, period): period = period.this_month ressortissant_eee = simulation.calculate('ressortissant_eee', period) duree_possession_titre_sejour= simulation.calculate('duree_possession_titre_sejour', period) duree_min_titre_sejour = simulation.legislation_at(period.start).minim.rmi.duree_min_titre_sejour return period, or_(ressortissant_eee, duree_possession_titre_sejour >= duree_min_titre_sejour) @reference_formula class rsa_eligibilite(SimpleFormulaColumn): column = BoolCol entity_class = Familles label = u"Eligibilité au RSA" def function(self, simulation, period): period = period.this_month age_holder = simulation.compute('age', period) age_parents = self.split_by_roles(age_holder, roles = [CHEF, PART]) activite_holder = simulation.compute('activite', period) activite_parents = self.split_by_roles(activite_holder, roles = [CHEF, PART]) nb_enfant_rsa = simulation.calculate('nb_enfant_rsa', period) rsa_eligibilite_tns = simulation.calculate('rsa_eligibilite_tns', period) rsa_condition_nationalite = simulation.compute('rsa_condition_nationalite', period) condition_nationalite = self.any_by_roles(rsa_condition_nationalite, roles = [CHEF, PART]) rmi = simulation.legislation_at(period.start).minim.rmi age_min = (nb_enfant_rsa == 0) * rmi.age_pac eligib = ( (age_parents[CHEF] >= age_min) * not_(activite_parents[CHEF] == 2) + (age_parents[PART] >= age_min) * not_(activite_parents[PART] == 2) ) eligib = eligib * ( condition_nationalite * rsa_eligibilite_tns ) return period, eligib @reference_formula class rsa_eligibilite_tns(SimpleFormulaColumn): column = BoolCol entity_class = Familles label = u"Eligibilité au RSA pour un travailleur non salarié" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') tns_benefice_exploitant_agricole_holder = simulation.compute('tns_benefice_exploitant_agricole', period) tns_benefice_exploitant_agricole = self.sum_by_entity(tns_benefice_exploitant_agricole_holder) tns_employe_holder = simulation.compute('tns_employe', period) tns_employe = self.any_by_roles(tns_employe_holder) tns_autres_revenus_chiffre_affaires_holder = simulation.compute('tns_autres_revenus_chiffre_affaires', period) tns_autres_revenus_chiffre_affaires = self.split_by_roles(tns_autres_revenus_chiffre_affaires_holder) tns_autres_revenus_type_activite_holder = simulation.compute('tns_autres_revenus_type_activite', period) tns_autres_revenus_type_activite = self.split_by_roles(tns_autres_revenus_type_activite_holder) has_conjoint = simulation.calculate('nb_par', period) > 1 nb_enfant_rsa = simulation.calculate('nb_enfant_rsa', period) P = simulation.legislation_at(period.start) P_agr = P.tns.exploitant_agricole P_micro = P.ir.rpns.microentreprise maj_2p = P_agr.maj_2p maj_1e_2ad = P_agr.maj_1e_2ad maj_e_sup = P_agr.maj_e_sup def eligibilite_agricole(has_conjoint, nb_enfant_rsa, tns_benefice_exploitant_agricole, P_agr): plafond_benefice_agricole = P_agr.plafond_rsa * P.cotsoc.gen.smic_h_b taux_avec_conjoint = 1 + maj_2p + maj_1e_2ad * (nb_enfant_rsa > 0) + maj_e_sup * max_(nb_enfant_rsa - 1, 0) taux_sans_conjoint = 1 + maj_2p * (nb_enfant_rsa > 0) + maj_e_sup * max_(nb_enfant_rsa - 1, 0) taux_majoration = has_conjoint * taux_avec_conjoint + (1 - has_conjoint) * taux_sans_conjoint plafond_benefice_agricole_majore = taux_majoration * plafond_benefice_agricole return tns_benefice_exploitant_agricole < plafond_benefice_agricole_majore def eligibilite_chiffre_affaire(ca, type_activite, P_micro): plaf_vente = P_micro.vente.max plaf_service = P_micro.servi.max return ((type_activite == 0) * (ca <= plaf_vente)) + ((type_activite >= 1) * (ca <= plaf_service)) eligibilite_agricole = eligibilite_agricole( has_conjoint, nb_enfant_rsa, tns_benefice_exploitant_agricole, P_agr ) eligibilite_chiffre_affaire = ( eligibilite_chiffre_affaire( tns_autres_revenus_chiffre_affaires[CHEF], tns_autres_revenus_type_activite[CHEF], P_micro ) * eligibilite_chiffre_affaire( tns_autres_revenus_chiffre_affaires[PART], tns_autres_revenus_type_activite[PART], P_micro ) ) return period, eligibilite_agricole * (1 - tns_employe) * eligibilite_chiffre_affaire @reference_formula class rsa_forfait_asf(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Familles label = u"Allocation de soutien familial forfaitisée pour le RSA" start_date = date(2014, 4, 1) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') asf_elig = simulation.calculate('asf_elig', period) rsa_forfait_asf_i_holder = simulation.compute('rsa_forfait_asf_i', period) montant = self.sum_by_entity(rsa_forfait_asf_i_holder, roles = ENFS) return period, asf_elig * montant @reference_formula class rsa_forfait_asf_i(SimpleFormulaColumn): column = FloatCol(default = 0) entity_class = Individus label = u"RSA - Montant individuel de forfait ASF" start_date = date(2014, 4, 1) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') asf_elig_enfant = simulation.calculate('asf_elig_enfant', period) pfam = simulation.legislation_at(period.start).fam minim = simulation.legislation_at(period.start).minim return period, asf_elig_enfant * pfam.af.bmaf * minim.rmi.forfait_asf.taux1 @reference_formula class rsa_forfait_logement(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Forfait logement intervenant dans le calcul du Rmi ou du Rsa" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') forf_logement = simulation.legislation_at(period.start).minim.rmi.forfait_logement rmi = simulation.legislation_at(period.start).minim.rmi.rmi rmi_nbp = simulation.calculate('rmi_nbp', period) statut_occupation_holder = simulation.compute('statut_occupation', period) aide_logement = simulation.calculate('aide_logement', period) statut_occupation = self.cast_from_entity_to_roles(statut_occupation_holder) statut_occupation = self.filter_role(statut_occupation, role = CHEF) avantage_nature = or_(statut_occupation == 2, statut_occupation == 6) avantage_al = aide_logement > 0 montant_forfait = rmi * ( (rmi_nbp == 1) * forf_logement.taux1 + (rmi_nbp == 2) * forf_logement.taux2 + (rmi_nbp >= 3) * forf_logement.taux3 ) montant_al = avantage_al * min_(aide_logement, montant_forfait) montant_nature = avantage_nature * montant_forfait return period, max_(montant_al, montant_nature) @reference_formula class rsa_majore(DatedFormulaColumn): column = FloatCol label = u"Revenu de solidarité active - majoré" entity_class = Familles @dated_function(start = date(2009, 06, 1)) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') rsa_socle_majore = simulation.calculate('rsa_socle_majore', period) ra_rsa = simulation.calculate('ra_rsa', period) rsa_forfait_logement = simulation.calculate('rsa_forfait_logement', period) br_rmi = simulation.calculate('br_rmi', period) P = simulation.legislation_at(period.start).minim.rmi base_normalise = max_(rsa_socle_majore - rsa_forfait_logement - br_rmi + P.pente * ra_rsa, 0) return period, base_normalise * (base_normalise >= P.rsa_nv) @reference_formula class rsa_majore_eligibilite(SimpleFormulaColumn): column = BoolCol entity_class = Familles label = u"Eligibilité au RSA majoré pour parent isolé" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') isol = simulation.calculate('isol', period) enceinte_fam = simulation.calculate('enceinte_fam', period) nbenf = simulation.calculate('nb_enfant_rsa', period) rsa_eligibilite_tns = simulation.calculate('rsa_eligibilite_tns', period) eligib = isol * (enceinte_fam | (nbenf > 0)) * rsa_eligibilite_tns return period, eligib @reference_formula class rsa_non_calculable(SimpleFormulaColumn): column = EnumCol( enum = Enum([ u"", u"tns", u"conjoint_tns" ]), default = 0 ) entity_class = Familles label = u"RSA non calculable pour la Famille (voir rsa_non_calculable_i)" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') eligible_rsa = ( simulation.calculate('rsa_eligibilite', period) + simulation.calculate('rsa_majore_eligibilite', period) ) non_calculable_tns_holder = simulation.compute('rsa_non_calculable_tns_i', period) non_calculable_tns_parents = self.split_by_roles(non_calculable_tns_holder, roles = [CHEF, PART]) non_calculable = ( (non_calculable_tns_parents[CHEF] > 0) * 1 + ((1 - non_calculable_tns_parents[CHEF]) * non_calculable_tns_parents[PART] > 0) * 2 ) non_calculable = eligible_rsa * non_calculable return period, non_calculable @reference_formula class rsa_non_calculable_tns_i(SimpleFormulaColumn): column = BoolCol entity_class = Individus label = u"RSA non calculable du fait de la situation de l'individu. Dans le cas des TNS, l'utilisateur est renvoyé vers son PCG" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') tns_benefice_exploitant_agricole = simulation.calculate('tns_benefice_exploitant_agricole', period) tns_micro_entreprise_chiffre_affaires = simulation.calculate('tns_micro_entreprise_chiffre_affaires', period) tns_autres_revenus = simulation.calculate('tns_autres_revenus', period) return period, ( (tns_benefice_exploitant_agricole > 0) + (tns_micro_entreprise_chiffre_affaires > 0) + (tns_autres_revenus > 0) ) @reference_formula class rsa_non_majore(DatedFormulaColumn): column = FloatCol label = u"Revenu de solidarité active - non majoré" entity_class = Familles @dated_function(start = date(2009, 06, 1)) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') rsa_socle = simulation.calculate('rsa_socle', period) ra_rsa = simulation.calculate('ra_rsa', period) rsa_forfait_logement = simulation.calculate('rsa_forfait_logement', period) br_rmi = simulation.calculate('br_rmi', period) P = simulation.legislation_at(period.start).minim.rmi base_normalise = max_(rsa_socle - rsa_forfait_logement - br_rmi + P.pente * ra_rsa, 0) return period, base_normalise * (base_normalise >= P.rsa_nv) class rsa_ressource_calculator: def __init__(self, simulation, period): self.period = period self.simulation = simulation self.three_previous_months = self.period.start.period('month', 3).offset(-3) self.last_month = period.start.period('month').offset(-1) self.has_ressources_substitution = ( simulation.calculate('chonet', period) + simulation.calculate('indemnites_journalieres', period) + simulation.calculate('rstnet', period) # + # simulation.calculate('ass', last_month) ) > 0 self.neutral_max_forfaitaire = 3 * simulation.legislation_at(period.start).minim.rmi.rmi def calcule_ressource(self, variable_name, revenu_pro = False): ressource_trois_derniers_mois = self.simulation.calculate_add(variable_name, self.three_previous_months) ressource_mois_courant = self.simulation.calculate(variable_name, self.period) ressource_last_month = self.simulation.calculate(variable_name, self.last_month) if revenu_pro: condition = ( (ressource_mois_courant == 0) * (ressource_last_month > 0) * not_(self.has_ressources_substitution) ) return (1 - condition) * ressource_trois_derniers_mois else: condition = ( (ressource_mois_courant == 0) * (ressource_last_month > 0) ) return max_(0, ressource_trois_derniers_mois - condition * self.neutral_max_forfaitaire) @reference_formula class rsa_socle(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = "RSA socle" def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') nb_par = simulation.calculate('nb_par', period) eligib = simulation.calculate('rsa_eligibilite', period) nb_enfant_rsa = simulation.calculate('nb_enfant_rsa', period) rmi = simulation.legislation_at(period.start).minim.rmi nbp = nb_par + nb_enfant_rsa taux = ( 1 + (nbp >= 2) * rmi.txp2 + (nbp >= 3) * rmi.txp3 + (nbp >= 4) * ((nb_par == 1) * rmi.txps + (nb_par != 1) * rmi.txp3) + max_(nbp - 4, 0) * rmi.txps ) return period, eligib * rmi.rmi * taux @reference_formula class rsa_socle_majore(SimpleFormulaColumn): column = FloatCol entity_class = Familles label = u"Majoration pour parent isolé du Revenu de solidarité active socle" start_date = date(2009, 6, 1) def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') rmi = simulation.legislation_at(period.start).minim.rmi eligib = simulation.calculate('rsa_majore_eligibilite', period) nbenf = simulation.calculate('nb_enfant_rsa', period) taux = rmi.majo_rsa.pac0 + rmi.majo_rsa.pac_enf_sup * nbenf return period, eligib * rmi.rmi * taux PKF*openfisca_france/model/revenus/__init__.pyPKoz= 2) @reference_formula class indice_majore(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Indice majoré" 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) _P = simulation.legislation_at(period.start) traitement_annuel_brut = _P.fonc.IM_100 return period, (traitement_indiciaire_brut * 100 * 12 / traitement_annuel_brut) * (type_sal >= 2) @reference_formula class primes_fonction_publique(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Calcul des primes pour les fonctionnaries" url = u"http://vosdroits.service-public.fr/particuliers/F465.xhtml" 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) public = ( (type_sal == CAT['public_titulaire_etat']) + (type_sal == CAT['public_titulaire_territoriale']) + (type_sal == CAT['public_titulaire_hospitaliere']) ) return period, TAUX_DE_PRIME * traitement_indiciaire_brut * public @reference_formula class af_nbenf_fonc(SimpleFormulaColumn): column = IntCol entity_class = Familles label = u"Nombre d'enfants dans la famille au sens des allocations familiales pour le fonctionnaires" # Hack pour éviter une boucle infinie def function(self, simulation, period): # Note : Cette variable est "instantanée" : quelque soit la période demandée, elle retourne la valeur au premier # jour, sans changer la période. age_holder = simulation.compute('age', period) salaire_de_base = simulation.calculate_add('salaire_de_base', period.start.period('month', 6).offset(-6)) law = simulation.legislation_at(period.start) nbh_travaillees = 169 smic_mensuel_brut = law.cotsoc.gen.smic_h_b * nbh_travaillees smic55_holder = (salaire_de_base / 6) >= (law.fam.af.seuil_rev_taux * smic_mensuel_brut) age = self.split_by_roles(age_holder, roles = ENFS) smic55 = self.split_by_roles(smic55_holder, roles = ENFS) af_nbenf = nb_enf(age, smic55, law.fam.af.age1, law.fam.af.age2) return period, af_nbenf @reference_formula class supp_familial_traitement(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"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 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_fonc_holder = simulation.compute('af_nbenf_fonc', period) _P = simulation.legislation_at(period.start) fonc_nbenf = self.cast_from_entity_to_role(af_nbenf_fonc_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 def _traitement_brut_mensuel(indice_maj, law): Indice_majore_100_annuel = law.fonc.IM_100 traitement_brut = Indice_majore_100_annuel * indice_maj / 100 / 12 return traitement_brut @reference_formula class remuneration_principale(SimpleFormulaColumn): column = FloatCol entity_class = Individus label = u"Rémunération principale des agents titulaires de la fonction publique" def function(self, simulation, period): traitement_indiciaire_brut = simulation.calculate('traitement_indiciaire_brut', period) nouvelle_bonification_indiciaire = simulation.calculate('nouvelle_bonification_indiciaire', period) type_sal = simulation.calculate('type_sal', period) return period, ( (type_sal >= 2) * (type_sal <= 5) * ( traitement_indiciaire_brut + nouvelle_bonification_indiciaire ) ) @reference_formula class salaire_net_a_payer(SimpleFormulaColumn): base_function = requested_period_added_value column = FloatCol entity_class = Individus label = u"Salaire net à payer (fiche de paie)" set_input = set_input_divide_by_period def function(self, simulation, period): ''' Calcul du salaire net à payer après déduction des sommes dues par les salarié avancées par l'employeur ''' period = period salaire_net = simulation.calculate_add('salaire_net', period) depense_cantine_titre_restaurant_employe = simulation.calculate( 'depense_cantine_titre_restaurant_employe') indemnites_forfaitaires = simulation.calculate('indemnites_forfaitaires', period) remuneration_apprenti = simulation.calculate('remuneration_apprenti', period) stage_gratification = simulation.calculate('stage_gratification', period) salaire_net_a_payer = ( salaire_net + remuneration_apprenti + stage_gratification + depense_cantine_titre_restaurant_employe + indemnites_forfaitaires ) return period, salaire_net_a_payer @reference_formula class salsuperbrut(SimpleFormulaColumn): base_function = requested_period_added_value column = FloatCol entity_class = Individus label = u"Salaires superbruts/coût du travail" set_input = set_input_divide_by_period def function(self, simulation, period): period = period remuneration_apprenti = simulation.calculate_add('remuneration_apprenti', period) salaire_de_base = simulation.calculate('salaire_de_base', period) primes_fonction_publique = simulation.calculate_add('primes_fonction_publique', period) indemnite_residence = simulation.calculate_add('indemnite_residence', period) supp_familial_traitement = simulation.calculate_add('supp_familial_traitement', period) cotisations_employeur = simulation.calculate('cotisations_employeur', period) depense_cantine_titre_restaurant_employeur = simulation.calculate( 'depense_cantine_titre_restaurant_employeur', period) exoneration_cotisations_employeur_apprenti = simulation.calculate_add( 'exoneration_cotisations_employeur_apprenti', period) exoneration_cotisations_employeur_geographiques = simulation.calculate( 'exoneration_cotisations_employeur_geographiques', period) exoneration_cotisations_employeur_jei = simulation.calculate_add( 'exoneration_cotisations_employeur_jei', period) exoneration_cotisations_employeur_stagiaire = simulation.calculate_add( 'exoneration_cotisations_employeur_stagiaire', period) allegement_fillon = simulation.calculate_add('allegement_fillon', period) credit_impot_competitivite_emploi = simulation.calculate_add('credit_impot_competitivite_emploi', period) reintegration_titre_restaurant_employeur = simulation.calculate( 'reintegration_titre_restaurant_employeur', period) remuneration_principale = simulation.calculate('remuneration_principale', period) tehr = simulation.calculate_divide('tehr', period) salsuperbrut = ( remuneration_apprenti + salaire_de_base + depense_cantine_titre_restaurant_employeur - reintegration_titre_restaurant_employeur + remuneration_principale + primes_fonction_publique + indemnite_residence + supp_familial_traitement - cotisations_employeur - allegement_fillon - exoneration_cotisations_employeur_geographiques - exoneration_cotisations_employeur_jei - exoneration_cotisations_employeur_apprenti - exoneration_cotisations_employeur_stagiaire - credit_impot_competitivite_emploi - tehr ) return period, salsuperbrut PKF3openfisca_france/model/revenus/activite/__init__.pyPKoz # Suppression du bouclier fiscal à compter des revenus réalisés en 2011. # # Wild distinction between the rates. TODO: handle the extreme diversity... # TODO: update, get more info... # TODO: update, get more info... # TODO: update, get more info.. # Find a better place # TODO check starting dates # TODO check starting dates # TODO check starting dates # TODO: find a better place # TODO: find a better place # TODO check and check for coherence with previous taux # TODO check and check for coherence with previous taux # TODO: find a better place # TODO: CHECK change because reforme # TODO check. Pas dispo dans barème IPP # TODO: c'est une contribution donc à mettre avec la CSG/CRDS # Voir L 1ère tranche commune aux cadres et aux non-cadres # TODO: check in july 2014 for "fin" # TODO: check in july 2014 for "fin" #TODO: Check quel article de loi # TODO : Quel article de loi # TODO: 400 par pac # TODO: Check 2013 # TODO: à partir de 2013: imposition au barême progressif de l'ir avec abattement de 20 % (détention 2 à 4 ans), 30 % (4-6 ans), 40% (au-delà) # TODO: check boxes (XC...XO) over the years # TODO: check 2013 # TODO: check 2013 # TODO: check 2013 # suppr # Check 2014 #TODO: check doesn't seams consitent with fiche de calcul # TODO: CHECK wild extension of date # Réforme sarkozy jamais appliquée ## parts actions détenus par salariés et mandataires sociaux intro en 2006 ## ## ce type de réductions apparaît seulement en 2008 ## # ## no upperbound before 2009- set arbitrarily large## # taux set to 0 to avoid error- expect prog to pass when date inf to 2008 # # # taux set to 0 to avoid error- expect prog to pass when date inf to 2008 # # taux set to 0 to avoid error- expect prog to pass when date inf to 2008 # PK'Gf##/openfisca_france/param/param-to-parameters.yaml# ir.bareme: null ir: impot_revenu PK'Gݑi**Dopenfisca_france/param/ipp-tax-and-benefit-tables-to-parameters.yamlbaremes-ipp-chomage: chomage baremes-ipp-impot-revenu: RENAME: impot_revenu bareme-ir: RENAME: bareme TYPE: BAREME Nombre de tranches: null Seuils inférieurs des tranches: SEUIL Taux marginaux des tranches: TAUX baremes-ipp-marche-du-travail: marche_du_travail baremes-ipp-prelevements-sociaux: prelevements_sociaux baremes-ipp-prestations: prestations baremes-ipp-retraite: retraite baremes-ipp-taxation-du-capital: taxation_du_capital baremes-ipp-taxation-indirecte: taxation_indirecte baremes-ipp-taxes-locales: taxes_locales PKuVG "w%% openfisca_france/param/param.xml # Wild distinction between the rates. TODO: handle the extreme diversity... # TODO: update, get more info... # TODO: update, get more info... # TODO: update, get more info.. # Find a better place # TODO check starting dates # TODO check starting dates # TODO check starting dates # TODO: find a better place # TODO check and check for coherence with previous taux # TODO check and check for coherence with previous taux # TODO: find a better place # TODO: find a better place # TODO: c'est une contribution donc à mettre avec la CSG/CRDS # TODO check. Pas dispo dans barème IPP # TODO: CHECK change because reforme #TODO: check doesn't seams consitent with fiche de calcul # TODO: CHECK wild extension of date # Check 2014 # TODO : Quel article de loi #TODO: Check quel article de loi # TODO: check boxes (XC...XO) over the years # TODO: check 2013 # TODO: check 2013 # TODO: check 2013 # suppr # TODO: Check 2013 # TODO: à partir de 2013: imposition au barême progressif de l'ir avec abattement de 20 % (détention 2 à 4 ans), 30 % (4-6 ans), 40% (au-delà) # TODO: check in july 2014 for "fin" # TODO: check in july 2014 for "fin" F # Réforme sarkozy jamais appliquée ## parts actions détenus par salariés et mandataires sociaux intro en 2006 ## ## ce type de réductions apparaît seulement en 2008 ## # # taux set to 0 to avoid error- expect prog to pass when date inf to 2008 # # ## no upperbound before 2009- set arbitrarily large## # taux set to 0 to avoid error- expect prog to pass when date inf to 2008 # # taux set to 0 to avoid error- expect prog to pass when date inf to 2008 # # Suppression du bouclier fiscal à compter des revenus réalisés en 2011. # PKQcE$openfisca_france/reforms/__init__.pyPKoz # # # return period, salbrut + hsup @Reform.formula class chobrut(formulas.SimpleFormulaColumn): column = columns.FloatCol entity_class = entities.Individus label = u"Allocations chômage brutes" url = u"http://vosdroits.service-public.fr/particuliers/N549.xhtml" def function(self, simulation, period): """"Calcule les allocations chômage brutes à partir des allocations imposables ou sinon des allocations nettes. """ # Get value for year and divide below. choi = simulation.get_array('choi', period.start.offset('first-of', 'year').period('year')) if choi is None: chonet = simulation.get_array('chonet', period) if chonet is not None: # Calcule les allocations chomage brutes à partir des allocations nettes par inversion numérique. if (chonet == 0).all(): # Quick path to avoid fsolve when using default value of input variables. return period, chonet simulation = self.holder.entity.simulation def solve_function(chobrut): return brut_to_target( chobrut = chobrut, target_name = 'chonet', period = period, simulation = simulation, ) - chonet return period, fsolve(solve_function, chonet) choi = simulation.calculate_add_divide('choi', period) # Calcule les allocations chômage brutes à partir des allocations imposables. # taux_csg_remplacement = simulation.calculate('taux_csg_remplacement', period) if (choi == 0).all(): # Quick path to avoid fsolve when using default value of input variables. return period, choi simulation = self.holder.entity.simulation def solve_function(chobrut): return brut_to_target( chobrut = chobrut, # taux_csg_remplacement = taux_csg_remplacement, target_name = 'cho', period = period, simulation = simulation, ) - choi return period, fsolve(solve_function, choi) @Reform.formula class rstbrut(formulas.SimpleFormulaColumn): column = columns.FloatCol entity_class = entities.Individus label = u"Pensions de retraite brutes" url = u"http://vosdroits.service-public.fr/particuliers/N20166.xhtml" def function(self, simulation, period): """"Calcule les pensions de retraite brutes à partir des pensions imposables ou sinon des pensions nettes. """ # period = period.start.offset('first-of', 'month').period('month') # Get value for year and divide below. rsti = simulation.get_array('rsti', period.start.offset('first-of', 'year').period('year')) if rsti is None: rstnet = simulation.get_array('rstnet', period) if rstnet is not None: # Calcule les pensions de retraite brutes à partir des pensions nettes par inversion numérique. if (rstnet == 0).all(): # Quick path to avoid fsolve when using default value of input variables. return period, rstnet simulation = self.holder.entity.simulation def solve_function(rstbrut): return brut_to_target( target_name = 'rstnet', period = period, rstbrut = rstbrut, simulation = simulation, ) - rstnet return period, fsolve(solve_function, rstnet) rsti = simulation.calculate_add_divide('rsti', period) # Calcule les pensions de retraite brutes à partir des pensions imposables. taux_csg_remplacement = simulation.calculate('taux_csg_remplacement', period) if (rsti == 0).all(): # Quick path to avoid fsolve when using default value of input variables. return period, rsti simulation = self.holder.entity.simulation def solve_function(rstbrut): return brut_to_target( rstbrut = rstbrut, taux_csg_remplacement = taux_csg_remplacement, target_name = 'rst', period = period, simulation = simulation, ) - rsti return period, fsolve(solve_function, rsti) return Reform() PKuVG>uS S #openfisca_france/reforms/plf2015.py# -*- coding: utf-8 -*- from __future__ import division from openfisca_core import formulas, periods, reforms from ..model.base import * from ..model.prelevements_obligatoires.impot_revenu import ir def build_reform(tax_benefit_system): Reform = reforms.make_reform( key = 'plf2015', name = u'Projet de Loi de Finances 2015 appliquée aux revenus 2013', reference = tax_benefit_system, ) @Reform.formula class decote(formulas.DatedFormulaColumn): label = u"Décote IR 2015 appliquée sur IR 2014 (revenus 2013)" reference = ir.decote @dated_function(start = date(2013, 1, 1), stop = date(2013, 12, 31)) def function_2013(self, simulation, period): period = period.start.offset('first-of', 'year').period('year') ir_plaf_qf = simulation.calculate('ir_plaf_qf', period) nb_adult = simulation.calculate('nb_adult', period) plf = simulation.legislation_at(period.start).plf2015 decote_celib = (ir_plaf_qf < plf.decote.seuil_celib) * (plf.decote.seuil_celib - ir_plaf_qf) decote_couple = (ir_plaf_qf < plf.decote.seuil_couple) * (plf.decote.seuil_couple - ir_plaf_qf) return period, (nb_adult == 1) * decote_celib + (nb_adult == 2) * decote_couple reform = Reform() reform.modify_legislation_json(modifier_function = modify_legislation_json) return reform def modify_legislation_json(reference_legislation_json_copy): reform_legislation_subtree = { "@type": "Node", "description": "PLF 2015 sur revenus 2013 (Décote)", "children": { "seuil_celib": { "@type": "Parameter", "description": "Seuil de la décote pour un célibataire", "format": "integer", "unit": "currency", "values": [{'start': u'2013-01-01', 'stop': u'2013-12-31', 'value': 1135}], }, "seuil_couple": { "@type": "Parameter", "description": "Seuil de la décote pour un couple", "format": "integer", "unit": "currency", "values": [{'start': u'2013-01-01', 'stop': u'2013-12-31', 'value': 1870}], }, }, } reform_year = 2013 reform_period = periods.period('year', reform_year) # FIXME update_legislation is deprecated. reference_legislation_json_copy = reforms.update_legislation( legislation_json = reference_legislation_json_copy, path = ('children', 'ir', 'children', 'bareme', 'brackets', 1, 'rate'), period = reform_period, value = 0, ) # FIXME update_legislation is deprecated. reference_legislation_json_copy = reforms.update_legislation( legislation_json = reference_legislation_json_copy, path = ('children', 'ir', 'children', 'bareme', 'brackets', 2, 'threshold'), period = reform_period, value = 9690, ) reference_legislation_json_copy['children']['plf2015'] = reform_legislation_subtree return reference_legislation_json_copy PKoz 0) * (br <= plafond) * montant # Si tous les enfants handicapés sont en garde alternée garde_alternee = nb_enf_handicape - nb_enf_handicape_garde_alternee == 0 deduction_garde_alternee = garde_alternee * 0.5 * plf_handicap plf_handicap = plf_handicap - deduction_garde_alternee return period, plf_handicap @Reform.formula class paris_logement_familles(formulas.SimpleFormulaColumn): column = columns.FloatCol label = u"Allocation Paris Logement Familles" entity_class = entities.Familles url = "http://www.paris.fr/pratique/toutes-les-aides-et-allocations/aides-sociales/paris-logement-familles-prestation-ville-de-paris/rub_9737_stand_88805_port_24193" # noqa def function(self, simulation, period): period = period.start.offset('first-of', 'month').period('month') elig = simulation.calculate('paris_logement_familles_elig', period) br = simulation.calculate('paris_logement_familles_br', period) plf_enfant = simulation.compute('plf_enfant', period) nbenf = self.sum_by_entity(plf_enfant) plf_enfant_garde_alternee = simulation.compute('plf_enfant_garde_alternee', period) nbenf_garde_alternee = self.sum_by_entity(plf_enfant_garde_alternee) plf_handicap = simulation.calculate('plf_handicap', period) loyer = simulation.calculate('loyer', period) + simulation.calculate('charges_locatives', period) P = simulation.legislation_at(period.start).aides_locales.paris.paris_logement_familles ressources_sous_plaf_bas = (br <= P.plafond_bas_3enf) ressources_sous_plaf_haut = (br <= P.plafond_haut_3enf) * (br > P.plafond_bas_3enf) montant_base_3enfs = (nbenf >= 3) * ( ressources_sous_plaf_bas * P.montant_haut_3enf + ressources_sous_plaf_haut * P.montant_bas_3enf ) montant_enf_sup = ( ressources_sous_plaf_bas * P.montant_haut_enf_sup + ressources_sous_plaf_haut * P.montant_bas_enf_sup ) montant_3enfs = montant_base_3enfs + montant_enf_sup * max_(nbenf - 3, 0) montant_2enfs = (nbenf == 2) * (br <= P.plafond_2enf) * P.montant_2enf plf = montant_2enfs + montant_3enfs deduction_garde_alternee = (nbenf_garde_alternee > 0) * ( (nbenf - nbenf_garde_alternee < 3) * 0.5 * plf + (nbenf - nbenf_garde_alternee >= 3) * nbenf_garde_alternee * 0.5 * montant_enf_sup ) plf = plf - deduction_garde_alternee plf = max_(plf, plf_handicap) plf = elig * plf plf = min_(plf, loyer) return period, plf reform = Reform() reform.modify_legislation_json(modifier_function = modify_legislation_json) return reform def modify_legislation_json(reference_legislation_json_copy): reform_legislation_subtree = { "@type": "Node", "description": "Aides locales", "children": { "paris": { "@type": "Node", "description": "Aides de la ville de Paris", "children": { "paris_logement_familles": { "@type": "Node", "description": "Paris Logement Famille", "children": { "plafond_haut_3enf": { "@type": "Parameter", "description": "Plafond haut de PLF pour les familles à 3 enfants, aussi plafond de PLF avec enfant handicapé", # noqa "unit": "currency", "format": "float", "values": [{'start': u'2014-01-01', 'stop': u'2015-12-31', 'value': 5000}], }, "plafond_bas_3enf": { "@type": "Parameter", "description": "Plafond bas de PLF pour les familles à 3 enfants", "unit": "currency", "format": "float", "values": [{'start': u'2014-01-01', 'stop': u'2015-12-31', 'value': 3000}], }, "plafond_2enf": { "@type": "Parameter", "description": "Plafond de PLF pour les familles à deux enfants.", "unit": "currency", "format": "float", "values": [{'start': u'2014-01-01', 'stop': u'2015-12-31', 'value': 2000}], }, "montant_haut_3enf": { "@type": "Parameter", "description": "Montant haut PLF pour famille à 3 enfants", "unit": "currency", "format": "float", "values": [{'start': u'2014-01-01', 'stop': u'2015-12-31', 'value': 128}], }, "montant_bas_3enf": { "@type": "Parameter", "description": "Montant bas PLF pour famille à 3 enfants.", "unit": "currency", "format": "float", "values": [{'start': u'2014-01-01', 'stop': u'2015-12-31', 'value': 84}], }, "montant_2enf": { "@type": "Parameter", "description": "Montant PLF pour les familles à deux enfants.", "unit": "currency", "format": "float", "values": [{'start': u'2014-01-01', 'stop': u'2015-12-31', 'value': 116}], }, "montant_haut_enf_sup": { "@type": "Parameter", "description": "Montant haut sup par enfant", "unit": "currency", "format": "float", "values": [{'start': u'2014-01-01', 'stop': u'2015-12-31', 'value': 41}], }, "montant_bas_enf_sup": { "@type": "Parameter", "description": "Montant bas sup par enfant.", "unit": "currency", "format": "float", "values": [{'start': u'2014-01-01', 'stop': u'2015-12-31', 'value': 21}], }, } } } }, }, } reference_legislation_json_copy['children']['aides_locales'] = reform_legislation_subtree return reference_legislation_json_copy PKoz P.seuil) * ((pre_result < P.min) * (pre_result > 0) * iai * 0 + ((pre_result <= 0) + (pre_result >= P.min)) * (- pre_result)) + (iai <= P.seuil) * ((pre_result < 0) * (-pre_result) + (pre_result >= 0) * 0 * iai)) reform = Reform() reform.modify_legislation_json(modifier_function = modify_legislation_json) return reform def modify_legislation_json(reference_legislation_json_copy): reform_legislation_subtree = { "@type": "Node", "description": "Contribution execptionnelle sur les très hauts revenus d'activité", "children": { "seuil": { "@type": "Parameter", "description": "Seuil", "format": "integer", "unit": "currency", "values": [{'start': u'2012-01-01', 'stop': u'2013-12-31', 'value': 1000000}], }, "taux": { "@type": "Parameter", "description": "Taux", "format": "rate", "unit": "currency", "values": [{'start': u'2012-01-01', 'stop': u'2013-12-31', 'value': .75}], }, }, } reference_legislation_json_copy['children']['cesthra'] = reform_legislation_subtree return reference_legislation_json_copy PKhIE"openfisca_france/tests/__init__.pyPKoz 1: self.rmvPerson() self.simulation.reset_scenario self.emit(SIGNAL('compoChanged()')) def openDeclaration(self): """ Open the declaration widget """ noi = int(self.sender().objectName()[3]) self.scenario.genNbEnf() msg = self.scenario.check_consistency() if msg: QMessageBox.critical(self, u"Ménage non valide", msg, QMessageBox.Ok, QMessageBox.NoButton) return False self._declaration = Declaration(self, noi) self._declaration.exec_() self.emit(SIGNAL('compoChanged()')) def openLogement(self): self._logement = Logement(self.scenario, self) self._logement.exec_() self.emit(SIGNAL('compoChanged()')) def openInfoComp(self): self._infocomp = InfoComp(self.scenario, self) self._infocomp.exec_() self.emit(SIGNAL('compoChanged()')) def disconnectAll(self): for person in self._listPerson: QObject.disconnect(person[S.birth], SIGNAL('dateChanged(QDate)'), self.birthChanged) QObject.disconnect(person[S.decpos], SIGNAL('currentIndexChanged(QString)'), self.quifoyChanged) QObject.disconnect(person[S.decnum], SIGNAL('currentIndexChanged(int)'), self.foyerChanged) QObject.disconnect(person[S.fampos], SIGNAL('currentIndexChanged(QString)'), self.quifamChanged) QObject.disconnect(person[S.famnum], SIGNAL('currentIndexChanged(int)'), self.familleChanged) QObject.disconnect(person[S.decbtn], SIGNAL('clicked()'), self.openDeclaration) def connectAll(self): for person in self._listPerson: QObject.connect(person[S.birth], SIGNAL('dateChanged(QDate)'), self.birthChanged) QObject.connect(person[S.decpos], SIGNAL('currentIndexChanged(QString)'), self.quifoyChanged) QObject.connect(person[S.decnum], SIGNAL('currentIndexChanged(int)'), self.foyerChanged) QObject.connect(person[S.fampos], SIGNAL('currentIndexChanged(QString)'), self.quifamChanged) QObject.connect(person[S.famnum], SIGNAL('currentIndexChanged(int)'), self.familleChanged) QObject.connect(person[S.decbtn], SIGNAL('clicked()'), self.openDeclaration) def load(self): cas_type_dir = self.get_option('import_dir') fileName = QFileDialog.getOpenFileName(self, _("Open a test case"), cas_type_dir, u"Cas type OpenFisca (*.ofct)") if not fileName == '': n = len(self.scenario.indiv) try: self.scenario.openFile(fileName) while n < self.nbRow(): self.addRow() n += 1 while n > self.nbRow(): self.rmvRow() n -= 1 self.emit(SIGNAL('compoChanged()')) self.emit(SIGNAL("ok()")) except Exception, e: QMessageBox.critical( self, "Erreur", u"Erreur lors de l'ouverture du fichier : le fichier n'est pas reconnu : \n " + e, QMessageBox.Ok, QMessageBox.NoButton) def save(self): cas_type_dir = self.get_option('export_dir') default_fileName = os.path.join(cas_type_dir, 'sans-titre') fileName = QFileDialog.getSaveFileName(self, _("Save a test case"), default_fileName, u"Cas type OpenFisca (*.ofct)") if not fileName == '': self.scenario.saveFile(fileName) def compute(self): """ Computing the test case """ self.starting_long_process(_("Computing test case ...")) # TODO # Consistency check on scenario # msg = self.scenario.check_consistency() # if msg: # QMessageBox.critical(self, u"Ménage non valide", # msg, # QMessageBox.Ok, QMessageBox.NoButton) # return False # If it is consistent starts the computation self.action_compute.setEnabled(False) # P, P_default = self.main.parameters.getParam(), self.main.parameters.getParam(defaut = True) # self.simulation.set_param(P, P_default) import openfisca_france TaxBenefitSystem = openfisca_france.init_country() tax_benefit_system = TaxBenefitSystem() axes = [ dict( count = self.nmen, name = 'salaire_imposable', max = self.maxrev, min = 0, ), ] test_case = { "familles": { "fam0": { "parents": ['ind0'], "enfants": [], }, }, "foyers_fiscaux": { "foy0": { "declarants": ['ind0'], "personnes_a_charge": [], } }, "individus": { "ind0": { "activite": 0, "birth": '1970-01-01', "statmarit": 2, }, }, "menages": { "men0": { "personne_de_reference": 'ind0', "conjoint": None, "enfants": [], "autres": [], }, } } self.scenario = tax_benefit_system.new_scenario().init_from_attributes( axes = axes, test_case = test_case, year = 2013, ) print self.scenario.test_case self.scenario.simulation = self.scenario.new_simulation(debug = True) self.scenario.simulation.compute('revdisp') self.main.scenario = self.scenario self.main.refresh_test_case_plugins() self.ending_long_process(_("Test case results are updated")) def set_reform(self, reform): ''' Toggle reform mode for test case # TODO should be in another widget ''' if (not reform) and self.action_set_reform.isChecked(): self.action_set_reform.toggle() if (not self.action_set_reform.isChecked()) and reform: self.action_set_reform.toggle() self.scenario.set_config(reforme = reform, maxrev=self.maxrev) self.action_compute.setEnabled(True) def set_single(self, is_single = True): if is_single: self.scenario.set_config(nmen = 1, mode = 'castype') # TODO: this might be removed ?? self.action_compute.setEnabled(True) self.action_set_bareme.setChecked(False) else: self.action_set_bareme.setChecked(True) self.set_bareme() self.action_compute.setEnabled(True) def set_bareme(self, is_bareme = True): if is_bareme: nmen = self.get_option('nmen') self.scenario.set_config(nmen = nmen, mode = 'bareme') # # TODO: this might be removed ?? self.action_compute.setEnabled(True) self.action_set_single.setChecked(False) else: self.action_set_single.setChecked(True) self.set_single() self.action_compute.setEnabled(True) #------ OpenfiscaPluginMixin API --------------------------------------------- def apply_plugin_settings(self, options): """ Apply configuration file's plugin settings """ if 'maxrev' in options: maxrev = self.get_option('maxrev') self.maxrev_box.setValue(maxrev) self.maxrev = maxrev print "in apply setting :", self.maxrev if 'x_axis' in options: x_axis = self.get_option('x_axis') axes_names = [ axe.name for axe in self.XAXIS_PROPERTIES.itervalues() ] self.x_axis_box.setCurrentIndex(axes_names.index(x_axis)) #------ OpenfiscaPluginWidget API --------------------------------------------- def get_plugin_title(self): """ Return plugin title Note: after some thinking, it appears that using a method is more flexible here than using a class attribute """ return _("Composer") def get_plugin_icon(self): """ Return plugin icon (QIcon instance) Note: this is required for plugins creating a main window (see OpenfiscaPluginMixin.create_mainwindow) and for configuration dialog widgets creation """ return get_icon('OpenFisca22.png') def get_plugin_actions(self): """ Return a list of actions related to plugin Note: these actions will be enabled when plugin's dockwidget is visible and they will be disabled when it's hidden """ for index, (qobject, context, name, default) in enumerate(self.main.shortcut_data): if context == "Composer": self.main.shortcut_data.pop(index) qobject.deleteLater() del name, default # File menu actions and shortcuts self.open_action = create_action( self, _("&Open composition..."), icon='fileopen.png', tip =_("Open composition file"), triggered=self.load ) self.register_shortcut( self.open_action, context = "Composer", name = _("Open composition file"), default="Ctrl+O" ) self.save_action = create_action( self, _("&Save composition"), icon='filesave.png', tip=_("Save current composition"), triggered=self.save ) self.register_shortcut( self.save_action, context="Composer", name=_("Save current composition"), default="Ctrl+S" ) self.file_menu_actions = [self.open_action, self.save_action] self.main.file_menu_actions += self.file_menu_actions self.action_compute = create_action( self, _('Compute test case'), icon = 'calculator_green.png', triggered = self.compute ) self.register_shortcut( self.action_compute, context = 'Composer', name = _('Compute test case'), default = 'F9' ) self.action_set_bareme = create_action( self, _('Varying revenues'), icon = 'bareme22.png', toggled = self.set_bareme ) self.action_set_single = create_action( self, _('Single test case'), icon = 'castype22.png', toggled = self.set_single ) self.action_set_reform = create_action( self, _('Reform mode'), icon = 'comparison22.png', toggled = self.set_reform, tip = u"Différence entre la situation simulée et la situation actuelle" ) self.run_menu_actions = [self.action_compute, self.action_set_bareme, self.action_set_single, self.action_set_reform, None] self.main.run_menu_actions += self.run_menu_actions self.main.test_case_toolbar_actions += self.run_menu_actions return self.file_menu_actions + self.run_menu_actions def register_plugin(self): """ Register plugin in OpenFisca's main window """ self.main.add_dockwidget(self) self.action_set_bareme.trigger() def refresh_plugin(self): ''' Update Scenario Table ''' pass def closing_plugin(self, cancelable=False): """ Perform actions before parent main window is closed Return True or False whether the plugin may be closed immediately or not Note: returned value is ignored if *cancelable* is False """ return True # # OpenfiscaPluginWidget.visibility_changed(self, enable) # if self.dockwidget.isWindow(): # self.dock_toolbar.show() # else: # self.dock_toolbar.hide() # if enable: # self.refresh_plugin() def get_zone(code, filename = None): ''' Gets commune name and zone apl from postal code ''' if filename is None: code_file = open(os.path.join(DATA_DIR, 'code_apl'), 'r') else: code_file = open(filename, 'r') code_dict = pickle.load(code_file) code_file.close() if str(code) in code_dict: commune = code_dict[str(code)] return commune else: return None class Logement(QDialog, Ui_Logement): def __init__(self, scenario, parent = None): super(Logement, self).__init__(parent) self.setupUi(self) self.parent = parent self.scenario = scenario self.spinCP.setValue(scenario.menage[0]['code_postal']) self.spinLoyer.setValue(scenario.menage[0]['loyer']) self.comboSo.setCurrentIndex(scenario.menage[0]['statut_occupation'] - 1) # -1 because 0 is "non renseigné" self.spinTH.setValue(scenario.menage[0]['taxe_habitation']) # -1 because 0 is "non renseigné" def update_ville(code): commune = get_zone(code) if commune is not None: self.bbox.button(QDialogButtonBox.Ok).setEnabled(True) else: commune = ("Ce code postal n'est pas reconnu", '2') self.bbox.button(QDialogButtonBox.Ok).setEnabled(False) self.commune.setText(commune[0]) self.spinZone.setValue(int(commune[1])) update_ville(self.spinCP.value()) self.connect(self.spinCP, SIGNAL('valueChanged(int)'), update_ville) def update_th(value): self.spinTH.setValue(int(value)) self.connect(self.spinTH, SIGNAL('valueChanged(int)'), update_th) def so_changed(value): if value in (0, 1): self.spinLoyer.setValue(0) self.spinLoyer.setEnabled(False) else: self.spinLoyer.setValue(500) self.spinLoyer.setEnabled(True) self.connect(self.comboSo, SIGNAL('currentIndexChanged(int)'), so_changed) self.connect(self.bbox, SIGNAL("accepted()"), SLOT("accept()")) self.connect(self.bbox, SIGNAL("rejected()"), SLOT("reject()")) def accept(self): self.scenario.menage[0].update({ 'loyer': int(self.spinLoyer.value()), 'statut_occupation': int(self.comboSo.currentIndex() + 1), # +1 because 0 is "non renseigné" 'zone_apl': int(self.spinZone.value()), 'code_postal': int(self.spinCP.value()), 'taxe_habitation': int(self.spinTH.value()) }) QDialog.accept(self) PKozsPKj2G2$ 6openfisca_france/decompositions/decomp_prestations.xml PKj2GE%:XX<openfisca_france/decompositions/decompositions-multiples.xml # TODO: missing indemnite_residence and sft # TODO: change color # TODO: change color PK'G,!!?openfisca_france/decompositions/fiche_de_paie_decomposition.xml PKj2G(w--*openfisca_france/decompositions/decomp.xml PKj2Gob112openfisca_france/decompositions/decomp_contrib.xml # TODO: change color PKByVG]POpenFisca_France-0.5.3.data/data/share/locale/fr/LC_MESSAGES/openfisca-france.mo<=AV)h1& <HYrPTk(0 5 H iw#+ & &Open composition...&Save compositionA "famille" must have at most 2 "parents"A "foyer_fiscal" must have at most 2 "declarants"ComposerCompute test caseComputing test case ...Individual is missing from {}Open a test caseOpen composition fileReform modeSave a test caseSave current compositionSingle test caseTest case results are updatedVarying revenuesProject-Id-Version: OpenFisca-France 0.5.dev0 Report-Msgid-Bugs-To: contact@openfisca.fr POT-Creation-Date: 2015-09-07 18:56+0200 PO-Revision-Date: 2014-05-23 09:50+0100 Last-Translator: Emmanuel Raviart Language-Team: fr Plural-Forms: nplurals=2; plural=(n > 1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 1.3 & &Ouvrir composition...&Enregistrer compositionUne famille doit avoir au plus 2 parentsUn foyer fiscal doit avoir au plus 2 déclarantsComposeurCalculer le cas typeComputing test case ...L'individu est manquant dans {}Ouvrir un cas typeOuvrir le fichier de compositionMode réformeEnregistrer un cas typeEnregistrer la composition actuelleCas type uniqueLes résultats du cas type sont mis à jourVariation des revenusPKP)G3W׆׆IOpenFisca_France-0.5.3.data/data/share/openfisca/openfisca-france/LICENSE GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see .PKyVGfNOpenFisca_France-0.5.3.data/data/share/openfisca/openfisca-france/CHANGELOG.md# Changelog ## 0.5.3 * Fix vieillesse deplafonnee baremes * Fix some dates in arrco and formation prof. baremes * Remove obsolete or unuseful comment which induces indentation problem when using parameters fusion scripts * Improve decote legislation parameters * Removing unused obsolete reform parameters still in param.xml * Add tests * Round ceilings values * Resources need to be non superior to ceilings, not inferior * update bourse_college params * flake8 * Do not pre-initialize reforms cache * Remove licence from code files * Introduce asi_aspa_condition_nationalite Introduce rsa_condition_nationalite * Introduce ressortissant_eee Introduce duree_possession_titre_sejour * change it in the tests too... * Change name and description of the prestation * add a test for decote where the individual is below the first tax threshold * implement true_decote that is the decote amount provided by dgfip (at list on their simulator) which is the fiscal gain accountable to the decote mechanism * add a test for irpp couples * Actualize legislation for min/max abattements pour frais pro add a test for IR 2015 ; change label of reform plf 2015. * Change reforms.plf2015 decote to a DatedFormulaColumn * Conform to instructions given by @benjello for PR * add empty line * add an empty line for two empty lines between two classes * add decote ir2014 on income 2014 from reform plf hardcoded. * Small changes, trash plf2015 reform * Put reforms/plf2015.py into legislation. WIP still need a proper test on decote * Return ape_temp for a month, not for a weird period * Repair imports in test_basics.py * Remove irrelevant calculate_divide and calculate_add_divide in rsa.py, cf.py, asi_aspa.py * Merge formulas and formulas_mes_aides folder * Typo in cerfa field * Add test for psoc formula * Clean test_plf2015 * NOT WORKING Reform plf2015 on revenus 2013 * Rename paje_nais to paje_naissance * Fix params references * Redefine period in functions * Fix indentation in params * Fix param for retro-compatibility * Kid age need to be *strictly* < 3 * Réécriture et update de la paje * Rename cf_temp to cf_montant Rename paje_base_temp to paje_base_montant * Refactor aide_logement_montant_brut * Add clean-mo target * Add make clean target * Add MANIFEST.in * Do not package tests * Remove unnecessary __init__.py in scripts * Add data_files in setup.py * Use extras_require in setup.py * Remove nose section from setup.cfg * Add CONTRIBUTING.md file ## 0.5.2 * Merge pull request #304 from sgmap/taille_entreprise * Remove unmaintainable tests * Merge pull request #307 from sgmap/al-abattement-30-retraite * Merge pull request #301 from sgmap/several-updates * Move doc to openfisca-gitbook * Massive test update * Rename asf_elig_i to asf_elig_enfant Rename asf_i to asf_enfant * Rename fra to frais_reels Rename cho_ld to chomeur_longue_duree * Give RSA to young people with kids * Enhance error when loading a cached reform which was undeclared * Merge remote-tracking branch 'sgmap/executable-test' into next * Merge remote-tracking branch 'origin/master' into next * Merge pull request #303 from sgmap/plafonds-fillon * Display YAML file path on test error * Use relative error margin in fillon test * Add tests for fillon from embauche.sgmap.fr * Update end date for fillon seuil * Update plafonds for fillon * Merge remote-tracking branch 'sgmap/plafonds-fillon' into next * Add tests for fillon from embauche.sgmap.fr * Make test_yaml.py executable * Merge pull request #302 from sgmap/no-bom * Remove leading U+FEFF from param.xml * Update travis according to http://docs.travis-ci.com/user/migrating-from-legacy/ * Do not install scipy in travis * Do not use relative import in script (__main__) * Add biryani extra require ## 0.5.1 * Remove scipy by default ## 0.5.0 * First release uploaded to PyPI PKj/GI~KOpenFisca_France-0.5.3.data/data/share/openfisca/openfisca-france/README.md# OpenFisca France [![Build Status](https://travis-ci.org/openfisca/openfisca-france.svg?branch=master)](https://travis-ci.org/openfisca/openfisca-france) [More build status](http://www.openfisca.fr/build-status) [OpenFisca](http://www.openfisca.fr/) is a versatile microsimulation free software. This is the source code of the France module. Please consult http://www.openfisca.fr/documentation PKVG^- 0OpenFisca_France-0.5.3.dist-info/DESCRIPTION.rstUNKNOWN PKVG- <.OpenFisca_France-0.5.3.dist-info/metadata.json{"classifiers": ["Development Status :: 2 - Pre-Alpha", "License :: OSI Approved :: GNU Affero General Public License v3", "Operating System :: POSIX", "Programming Language :: Python", "Topic :: Scientific/Engineering :: Information Analysis"], "extensions": {"python.details": {"contacts": [{"email": "contact@openfisca.fr", "name": "OpenFisca Team", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/openfisca/openfisca-france"}}}, "extras": ["inversion_revenus", "taxipp", "test"], "generator": "bdist_wheel (0.26.0)", "keywords": ["benefit", "france", "microsimulation", "social", "tax"], "license": "http://www.fsf.org/licensing/licenses/agpl-3.0.html", "metadata_version": "2.0", "name": "OpenFisca-France", "run_requires": [{"requires": ["Babel (>=0.9.4)", "Biryani[datetimeconv] (>=0.10.4)", "OpenFisca-Core (>=0.5.0)", "PyYAML (>=3.10)", "numpy (>=1.6)"]}, {"extra": "test", "requires": ["nose"]}, {"extra": "taxipp", "requires": ["pandas (>=0.13)"]}, {"extra": "inversion_revenus", "requires": ["scipy (>=0.12)"]}], "summary": "French tax and benefit system for OpenFisca", "version": "0.5.3"}PKgo0GҺD//)OpenFisca_France-0.5.3.dist-info/pbr.json{"is_release": false, "git_version": "c17285b"}PKVGw.OpenFisca_France-0.5.3.dist-info/top_level.txtopenfisca_france PKVG''\\&OpenFisca_France-0.5.3.dist-info/WHEELWheel-Version: 1.0 Generator: bdist_wheel (0.26.0) Root-Is-Purelib: true Tag: py2-none-any PKVG> )OpenFisca_France-0.5.3.dist-info/METADATAMetadata-Version: 2.0 Name: OpenFisca-France Version: 0.5.3 Summary: French tax and benefit system for OpenFisca Home-page: https://github.com/openfisca/openfisca-france Author: OpenFisca Team Author-email: contact@openfisca.fr License: http://www.fsf.org/licensing/licenses/agpl-3.0.html Keywords: benefit france microsimulation social tax Platform: UNKNOWN Classifier: Development Status :: 2 - Pre-Alpha Classifier: License :: OSI Approved :: GNU Affero General Public License v3 Classifier: Operating System :: POSIX Classifier: Programming Language :: Python Classifier: Topic :: Scientific/Engineering :: Information Analysis Requires-Dist: Babel (>=0.9.4) Requires-Dist: Biryani[datetimeconv] (>=0.10.4) Requires-Dist: OpenFisca-Core (>=0.5.0) Requires-Dist: PyYAML (>=3.10) Requires-Dist: numpy (>=1.6) Provides-Extra: inversion_revenus Requires-Dist: scipy (>=0.12); extra == 'inversion_revenus' Provides-Extra: taxipp Requires-Dist: pandas (>=0.13); extra == 'taxipp' Provides-Extra: test Requires-Dist: nose; extra == 'test' UNKNOWN PKVGAA'OpenFisca_France-0.5.3.dist-info/RECORDOpenFisca_France-0.5.3.data/data/share/locale/fr/LC_MESSAGES/openfisca-france.mo,sha256=8c4V7YnWzB-_09YczEEAelx7Dvp5mWjYINI12x4CIYg,1541 OpenFisca_France-0.5.3.data/data/share/openfisca/openfisca-france/CHANGELOG.md,sha256=enWNSaFASYltZH3Ni4e67xz_tFKGhjVvojMu7H_bLDg,3828 OpenFisca_France-0.5.3.data/data/share/openfisca/openfisca-france/LICENSE,sha256=2N5ReRelkdqkR9a-KP-y-shmcD5P62XoYiG-miLTAzo,34519 OpenFisca_France-0.5.3.data/data/share/openfisca/openfisca-france/README.md,sha256=gREsX1n5bzZg9oHblwpt2El5L4IoM7r7DPvC9WieIYs,400 OpenFisca_France-0.5.3.dist-info/DESCRIPTION.rst,sha256=OCTuuN6LcWulhHS3d5rfjdsQtW22n7HENFRh6jC6ego,10 OpenFisca_France-0.5.3.dist-info/METADATA,sha256=nsXNf2v3uz1ZqEKFy-COz2gcfbBL8Rv2cY9fl49O8lw,1047 OpenFisca_France-0.5.3.dist-info/RECORD,, OpenFisca_France-0.5.3.dist-info/WHEEL,sha256=JTb7YztR8fkPg6aSjc571Q4eiVHCwmUDlX8PhuuqIIE,92 OpenFisca_France-0.5.3.dist-info/metadata.json,sha256=9qX3g-z_Tx3JaJfs3pB2-Sx9BSiOfwNJQJLQfe1EUAI,1173 OpenFisca_France-0.5.3.dist-info/pbr.json,sha256=lCi_sX7uj7KwAfecGcGWEE-XgrPAnMvOcphRQNsVJao,47 OpenFisca_France-0.5.3.dist-info/top_level.txt,sha256=1LbD6QJWehKGIcjtaJ45tbQOSDiFEXOlIdgWRI_jaHU,17 openfisca_france/__init__.py,sha256=MoZNg2_7tunqvetEEtq8012lGdX_r244ZPxQH_NzIe8,3926 openfisca_france/entities.py,sha256=pwcFJOyIZx6CQAJFyjgcJYpiHqwjOEzar9KosPJv6Oo,4850 openfisca_france/scenarios.py,sha256=hTx59B0OuaE9pIu2fv8Faz1REsD6af_LVfBn-LIOTv4,54012 openfisca_france/assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/assets/holidays.py,sha256=4vNRGwdGyguQ9lMLvtA7iMzIGjYdPOfyazd1AIu3S0I,24250 openfisca_france/assets/apl/20110914_zonage.csv,sha256=rUJFOc2i82vHXByzwqSIi4QKRkLoSQwox4x4rOUEUwY,989584 openfisca_france/assets/apl/README.md,sha256=e5hcLK5He50iujp2jgcq1NhUm4I-G_O-XVfO4iLr9Ko,645 openfisca_france/assets/apl/commune_depcom_by_subcommune_depcom.json,sha256=etgSqeakYSTsoJOn5g9xfqESqhtFBt_p3cHbsMA6fP0,15458 openfisca_france/assets/apl/extract_subcommunes.py,sha256=qg8vAsgwcp41TXV4VVm9EXrNYQK-AhsD18yFemQbQAQ,1411 openfisca_france/decompositions/__init__.py,sha256=8CikRbX7Pg23XctSPVzPvh1_4FYAHsImXGDf5r7BH8c,34 openfisca_france/decompositions/__init__.pyc,sha256=-oTWQrBsJbDrFlw93Ec6syMQLMpAJFMPGMTzJhQAtIk,218 openfisca_france/decompositions/decomp.xml,sha256=JpxmMXocOsp0YGgkfoN-QycP47baNJE4lTrVsxQ1Eyk,11767 openfisca_france/decompositions/decomp_contrib.xml,sha256=BRcLy6YB8mSUGd8kVcHZD5po3enmgqt5tvSRCD5bWh4,12774 openfisca_france/decompositions/decomp_prestations.xml,sha256=pFkBYdgAuBS-WOiVjZcVz-GprKLplu_TSQjrFvrAioM,2946 openfisca_france/decompositions/decompositions-multiples.xml,sha256=0aLRUbF5Fc_DBH2nfQ_y5Z6Vfxpzde03X3pQeB2Zfgk,22777 openfisca_france/decompositions/fiche_de_paie_decomposition.xml,sha256=IfCp4_xfTeKBfvl7FgNfoDSqjDrDar2wZDgf2dpJDHY,8598 openfisca_france/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/base.py,sha256=GEwA_VVtFLcK_UXlexv5AbH5p65NpcgcPeK0PGahuV8,3116 openfisca_france/model/datatrees.py,sha256=-MKRqnPXV3laxr4o8X9h_Dptq3qBkcwihH_5wEFTiOY,145961 openfisca_france/model/mesures.py,sha256=kddTlf-qzEE7Mdqu_9k8aTONx8iYuNGoDnAAxtzZKA4,24472 openfisca_france/model/model.py,sha256=xS3Qi_gG1OrVmqn7skr5SqWm2rpe326naY27Rp1zWxA,1800 openfisca_france/model/caracteristiques_socio_demographiques/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/caracteristiques_socio_demographiques/demographie.py,sha256=I6gJS7DVJ6NY6o3fUXRBC4avG3CRoGLbFNYqZx0UJw4,9370 openfisca_france/model/caracteristiques_socio_demographiques/logement.py,sha256=yzttdGz53LnC3z7SrqzE8FcZFS6IkHh_xkNylvjI50c,4565 openfisca_france/model/consommation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/patrimoine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prelevements_obligatoires/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prelevements_obligatoires/isf.py,sha256=ZrfJNWZGSZkcxexWmOP_YdDE4eGOB3cjb5IABT2voVE,29760 openfisca_france/model/prelevements_obligatoires/taxe_habitation.py,sha256=8yGSjfoVhbm0RzVTJkAXYYSE8cBm-FgUyUW_e57csS8,8853 openfisca_france/model/prelevements_obligatoires/impot_revenu/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prelevements_obligatoires/impot_revenu/charges_deductibles.py,sha256=0wczyCU4jiQ1D-rmud2FmPBZL5kCwWtKeXgxzt5pH74,26976 openfisca_france/model/prelevements_obligatoires/impot_revenu/credits_impot.py,sha256=7pTmPDK5OYoflmVSr6VpYgSro-8UvKH9DpVyftrRsPo,76616 openfisca_france/model/prelevements_obligatoires/impot_revenu/ir.py,sha256=Vj3MsWwgVVh-oJ9GbMlZ4iZAxMSyAslzWGZvwgN9rN0,129616 openfisca_france/model/prelevements_obligatoires/impot_revenu/plus_values_immobilieres.py,sha256=Cdz3KHP-F1tw7SENYEBp5d3I3906mHUbxXr9t77JIz4,5950 openfisca_france/model/prelevements_obligatoires/impot_revenu/reductions_impot.py,sha256=wg8wZKbB0uCjK-2r6BGCd1mWsSTd3YpuA5PvPX5CHMY,144609 openfisca_france/model/prelevements_obligatoires/impot_revenu/variables_reductions_credits.py,sha256=OtupobPsc-dDy9MSO_ruYW5wd2d6GVCXBXouU8lu34M,168807 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/penalites.py,sha256=A0FA5Astlwb-ufXPuvceq7nL4iszxqwzq9BeqceDVqU,3813 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/taxes_salaires_main_oeuvre.py,sha256=Ubm75ruLF0cRZl-Ifu15IQ4FU5g6ui_Lhgs1j2MjlTA,14483 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/contributions_sociales/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/contributions_sociales/activite.py,sha256=CqMOiUm2zY-4NSSaZHM8KWoLkDpQ8OR3B_uRqDNP1g4,11455 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/contributions_sociales/base.py,sha256=eBMRrRyrQkARn3lVYj3SzsaS6En0-Koaz6DACdr1LWQ,920 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/contributions_sociales/capital.py,sha256=CktHPREuXeFd_jnflMuJIkSP4tAPB5CXhNfNkukG-C8,18691 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/contributions_sociales/remplacement.py,sha256=WpBVCovrWkoibttWvhQOf1feSmRduElFR4eYdc7BWoA,12645 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/allegements.py,sha256=E4Z4qxgNAzl1oQpzQqI5VUi1VIRkBpNso8NociPfpjQ,10771 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/apprentissage.py,sha256=5yGmypX3s9ZxVq4xqhs3VjFsH2GJZRagphtOKgczYKo,11644 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/base.py,sha256=vO2k96xdsP4u8Q5oqNC4AtrjU4eHPYtWqWRfXmDo1qE,4290 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/contrat_professionnalisation.py,sha256=dH5WZboZOORdovbuSc5PqAkw_M81tJIaEQccA5a5vsc,6634 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/exonerations.py,sha256=d01HcK1BubJJEQjnmbpc3dF7NL4AtzCetTLOzaA1Wsc,25230 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/preprocessing.py,sha256=r5ZzpJfUCIBu5imUCioPxnYozyo7AL9scaZFBBnzEiA,6519 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/stage.py,sha256=MeNgZ2YL-0BlUy0cCxvye-xdAgvniC9MbJHH6yThb-0,6576 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/travail_fonction_publique.py,sha256=l-32YaJP5RTVOxFAWZ-H03bzEe_l_1DXSbWsjlSykhQ,14032 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/travail_prive.py,sha256=_nzs0oRBiylNgZik0qINrzY0c35u4ZDd7tkvREG1xDM,26922 openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/travail_totaux.py,sha256=NBOjqL1iTuiQrSN0JYNzRTTO8HY24rTua9l4BRg_clQ,8468 openfisca_france/model/prestations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prestations/aides_logement.py,sha256=yqsbhk34QmAGDtTiRHETecD1rC5zD9uwn0LGx0_wlk8,27507 openfisca_france/model/prestations/education.py,sha256=wPQz-PsnpQb27uq_DbiDNRwRaK9DRLCEJf-mUTwgKLM,7084 openfisca_france/model/prestations/minima_sociaux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prestations/minima_sociaux/aah.py,sha256=DN2MurnefUQUHo_pgrio61Kj-5DHHQHoaYy5rSlja40,12353 openfisca_france/model/prestations/minima_sociaux/asi_aspa.py,sha256=sxASYa_QovrIbX_X6gIKms3pTV520hXHs3F2dXE3UCk,15700 openfisca_france/model/prestations/minima_sociaux/ass.py,sha256=dBzB5UhtiHuTlVb3r3vzKnh-6it-BtsEBgCKNBRTWWs,8658 openfisca_france/model/prestations/minima_sociaux/cmu.py,sha256=sVX5OyEn3hoO9hUOilkYTAA6NteQvfDLvqfxnWy3J7o,16883 openfisca_france/model/prestations/minima_sociaux/rsa.py,sha256=pmY7V5YoAL-UgkZaDgIoheCqYcXom3lgCFc9E1x8pa4,48126 openfisca_france/model/prestations/prestations_familiales/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/prestations/prestations_familiales/aeeh.py,sha256=i5RORMDQ_N5PWcp1gJ_g0GdlYA9cb5C_dEP9n5mGXGM,5510 openfisca_france/model/prestations/prestations_familiales/af.py,sha256=6MEXo_4l1WExtas6-zvHrLrf8n_WLh6hGlTg9Hjnw7g,15357 openfisca_france/model/prestations/prestations_familiales/ars.py,sha256=lWZAdPMadtuMed-hG3HwhEDZU_sKf606v_w1psY3DCs,2898 openfisca_france/model/prestations/prestations_familiales/asf.py,sha256=yAFp4y6uwGn9jU72IRAlTueGDyMCIzlm3G6wrir7xyU,2757 openfisca_france/model/prestations/prestations_familiales/base_ressource.py,sha256=K3xdyz747sDfKP_iFmp5hQndU3t5InbHmBvSS3bPv3c,10091 openfisca_france/model/prestations/prestations_familiales/cf.py,sha256=LAf2OPY8f3qzqIBhDkxHMMOz5loPdEHx8J4xbHtt6Uw,12394 openfisca_france/model/prestations/prestations_familiales/paje.py,sha256=jrcIYJIQUw6JSenkmeiP61yVElIaQ3F1VV_JO0u5Bjg,36157 openfisca_france/model/revenus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/revenus/autres.py,sha256=-Qq5jnQ-42sCQgrutbQBqZoWbKjy4ulfYXXHkbE69TU,3634 openfisca_france/model/revenus/activite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/revenus/activite/non_salarie.py,sha256=v9y7mWJgYIsy1i2f7HKAT2DA0R1wklgm1H4EvbWCn70,65703 openfisca_france/model/revenus/activite/salarie.py,sha256=eZwc5lXztJ0PFDZXpVzGlnn3iKEzLUBi1lx595tYcLw,31058 openfisca_france/model/revenus/capital/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/revenus/capital/financier.py,sha256=FYjwHe0LiVHB41vwNfoAvus5GKXg9B7DJWXkbpfUCFw,7437 openfisca_france/model/revenus/capital/foncier.py,sha256=mbzaXOHKaPamEfbw_Bn_icBkujehu29F2MvQ2cwoqAc,2890 openfisca_france/model/revenus/capital/plus_value.py,sha256=ES3UTBQhYYda3sxNxqeaa6aiDShQwGoFGi8-3gtDBxU,8740 openfisca_france/model/revenus/remplacement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/model/revenus/remplacement/chomage.py,sha256=_eOFTBaqBqikTG-IKegNm60KcpD8IhnF32PoopAAubs,1318 openfisca_france/model/revenus/remplacement/indemnites_journalieres_securite_sociale.py,sha256=DA0pyanl5fF6zukZGi6m4QceRYbnaIlunTRen0RdG_I,2916 openfisca_france/model/revenus/remplacement/retraite.py,sha256=cqxtVtPnHvYslatD-ZrlAOgA7YKsxF1tnWI-no2CL5k,962 openfisca_france/param/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/param/ipp-tax-and-benefit-tables-to-parameters.yaml,sha256=x7qvkkh5NqElJH9TCzxbI02KBMy1DGlOlNSjGAl8E_I,554 openfisca_france/param/param-to-parameters.yaml,sha256=3Uz5txov2M1xknQz-5aB_ROxMr9B8oA1A6fMQiDAuXI,35 openfisca_france/param/param.xml,sha256=CxDo2tdJLUdTz7c5duarFJYoog-0zk94vIr4ZNrU_sk,337179 openfisca_france/param/parameters.xml,sha256=qn0AgFLnXzp7q07MYbeEA6tScRVj6w1iTCjvEhhoHJY,1189327 openfisca_france/reforms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/reforms/aides_ville_paris.py,sha256=GbTEMifTocDf6B-dLqAxx-FStcEefBiKOWOGePkOuIo,15673 openfisca_france/reforms/allocations_familiales_imposables.py,sha256=CzZmIjSBZO8UbpMK7psMRMa2gesGU5Ikylj5LnpDovo,4579 openfisca_france/reforms/cesthra_invalidee.py,sha256=Oe1CGaZDbMXXTiBxg65zB5gUov7fK8Gacn5xqTjlvUA,3560 openfisca_france/reforms/inversion_revenus.py,sha256=W43X8I8mO4PyRrbfC8QpveX29k2QiGlmDCg03_L0IzE,13010 openfisca_france/reforms/plf2015.py,sha256=QYp-qaLJ3qTJbPAPjqubWHUl4kxPPHkNJhgTwrRqvzo,3155 openfisca_france/reforms/plfr2014.py,sha256=QCV8zdvrGXh7DV_tNKH95J1Eb1XyEHUL0n3SaitXQhk,15414 openfisca_france/reforms/trannoy_wasmer.py,sha256=xkYucMhMXXBLrDpIQ1z62rpj-no2T7MQ2U3mVppFV9E,3348 openfisca_france/scripts/calculate_all_columns.py,sha256=34xa22wUYwBBI4hHBLvNPV8fR5U_7NNtXjCfH9sD718,3505 openfisca_france/scripts/date_variables.py,sha256=btDuHPt-wrxORf8DiWQoA8j0XBUN6Xw0frUSK5vn2Ak,3511 openfisca_france/scripts/dates_variables.json,sha256=YUiIszBcCtPpc1iWZ3jaLygb12h8yGa2wseyuJHiP2Q,67467 openfisca_france/scripts/extract_data_from_tests_log.py,sha256=xTDGQSWKoH_hl8jmdaep_Vs_eBs6VXbY3BRIorx528s,1112 openfisca_france/scripts/generate_columns_tree.py,sha256=Djdl7keOvsa1-nKAK_9tdMFVwy0yURrwVXUjLJQg8Ow,6397 openfisca_france/scripts/holidays_generator.py,sha256=LAUI9ZKT0ZdR659Xf9XufbmMdOA_f5qAzrMv7TIaIg4,707 openfisca_france/scripts/inspect_dgfip_variable.py,sha256=roRBvU-PGNztWgemtZRBsQkOPceaMHqBlH-VbbfNWQQ,3042 openfisca_france/scripts/link_ipp_tax_and_benefit_tables_to_parameters.py,sha256=vIjcpFofCvjdig6AcINq5v3Ljwn_Try6aW90c0UpjzE,11618 openfisca_france/scripts/measure_performances.py,sha256=vRW9BWKhMbZmxQubbYfNN_ArXbp4h6w5rStYEs7j-9E,10354 openfisca_france/scripts/merge_ipp_tax_and_benefit_tables_with_parameters.py,sha256=l45vOmTGGhwNHooxv48wO7tM9ZprxVSVzMQIz5o2VS4,22397 openfisca_france/scripts/rattachement.py,sha256=i4NRN3HPJLuQ6EaTEr9Q9io-nwP8t3Q3cTonoEP4ixw,5128 openfisca_france/scripts/reindent_xml_files.py,sha256=hfW4sjRlZvSablsnzEV1jdjgafeEaNk9vF3EGpXPKbg,1950 openfisca_france/scripts/smoke_test.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/scripts/web_trace.py,sha256=ptnI0u00XOK0Iv6OgBLgkxUIJXYR8lwPjEKuTFMBqyM,1652 openfisca_france/scripts/calculateur_impots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/scripts/calculateur_impots/base.py,sha256=h9-Z2ZeFaDGWRwUU6P-uW5yIWnev8wgO3mI5qHri-n8,8612 openfisca_france/scripts/calculateur_impots/calcul_impots.py,sha256=3uv5OGXAl-RwThgev2V0XyU3VyeIleqZa_ZuvSaxczs,4609 openfisca_france/scripts/calculateur_impots/compare_openfisca_impots.py,sha256=htKkJUJAxxZVWtIxX9LaS1K9USfxReRn_2hBpOWzER8,11516 openfisca_france/scripts/calculateur_impots/convert_json_to_yaml.py,sha256=qogjaxQkrwDA44DOaxJQRinoAL06wE8948nMoogSLZ8,14049 openfisca_france/scripts/calculateur_impots/create_json_then_test.py,sha256=SbY-Aaz4mjKZXFUvKDulQYVEMgvcSQwSNyjexahxSII,3997 openfisca_france/scripts/calculateur_impots/extraction_champs_impots.py,sha256=CIkUk4kD6U6R_1EEDq41eclccPjVYT0e7aKucnHuM9g,3057 openfisca_france/scripts/calculateur_impots/generate_json.py,sha256=_9KNN3cQgPNME5Q834vzH00WpkcpX0yWFCdHVYn-05c,2826 openfisca_france/scripts/calculateur_impots/request_impots.py,sha256=ARM7XIHBHqDoIK_-GNTDr-oezURU28Nl90hdlJJ-szQ,10461 openfisca_france/scripts/calculateur_impots/validations.txt,sha256=eTgr6UeOdcgzNg9epLTe6Oc15YM6jJjfMx77gaKt1fk,1845 openfisca_france/scripts/cnaf/exploitation_rsa.py,sha256=uOsYUwEbYsIw0apmnT0LDWoTWyeLASiNrOTQ-12R9g0,983 openfisca_france/scripts/cnaf/formulaires_caf.py,sha256=o-ppTsanqXqiIObGe-ujt0Nr9IwyTOtIk400JiOFBHI,10552 openfisca_france/scripts/cnaf/get_tree.py,sha256=7fX2-zmW67Xx79MkxYo1nL1N4kNaMmb2IFgw64UvS7I,7360 openfisca_france/scripts/cnaf/simul_logement.py,sha256=sCyzbskgiT7NCAWC1sFO-cTblRruBmB3HEfq79T3q5Y,3298 openfisca_france/scripts/cnaf/simul_rsa.py,sha256=vtH07OetAplycYp0nvUEdL6D7wavkioOobMk2VxLuSo,2425 openfisca_france/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 openfisca_france/tests/base.py,sha256=_pjg0hdmShzjisAGLepi-IjpuKY4vifP0tCu6e9a4XA,2179 openfisca_france/tests/test_basics.py,sha256=Xo8qeq1OF13iMGnpJnyE8EvvgJLZy7UTXgJYesnSl4o,1228 openfisca_france/widgets/Composition.py,sha256=kIFWzRk7Jvjc13yd6rvjwso-d9AZi2qYiSgsDX9LAy0,31181 openfisca_france/widgets/InfoIndiv.py,sha256=ojqq8dZLHqxsLgHKjDP5hCovC0rm5H-d08JnAtYtvOo,758 openfisca_france/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 PKoz>Y~>openfisca_france/model/prelevements_obligatoires/impot_revenu/plus_values_immobilieres.pyPKozuS S #?openfisca_france/reforms/plf2015.pyPKoz )BOpenFisca_France-0.5.3.dist-info/METADATAPKVGAA'BOpenFisca_France-0.5.3.dist-info/RECORDPK1;B