-
Notifications
You must be signed in to change notification settings - Fork 15
/
modify_social_security_taxation.py
57 lines (43 loc) · 2.01 KB
/
modify_social_security_taxation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""This file defines a reform.
A reform is a set of modifications to be applied to a reference tax and benefit
system to carry out experiments.
See https://openfisca.org/doc/key-concepts/reforms.html
"""
# Import from openfisca-core the objects used to code the legislation in OpenFisca
from openfisca_core.parameters import ParameterScaleBracket
from openfisca_core.reforms import Reform
class modify_social_security_taxation(Reform):
def apply(self):
"""Apply reform.
A reform always defines an `apply` method that builds the reformed tax
and benefit system from the reference one. See
https://openfisca.org/doc/coding-the-legislation/reforms.html#writing-a-reform
Our reform modifies the `social_security_contribution` parameter, which
is a scale. This parameter is declared in
`parameters/taxes/social_security_contribution.yaml`.
See https://openfisca.org/doc/coding-the-legislation/legislation_parameters.html
"""
self.modify_parameters(modifier_function=self.modify_brackets)
@staticmethod
def modify_brackets(parameters):
"""Social security taxation reform.
This function takes an argument `parameters` which is a in-memory representation
of the YAML parameters. It can be modified and must be returned.
"""
# Access the right parameter node:
brackets = parameters.taxes.social_security_contribution.brackets
# Add 0.1 to the rates of the second bracket, keeping the same thresholds:
for rate in brackets[1].rate.values_list:
rate.value += 0.1
# Remove the first bracket:
del brackets[0]
# Add a new bracket with a higher tax rate for rich people:
new_bracket = ParameterScaleBracket(
"new_bracket",
data={
"rate": {"2017-01-01": {"value": 0.4}},
"threshold": {"2017-01-01": {"value": 40000}},
},
)
brackets.append(new_bracket)
return parameters