Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
fixed:
- Floor irs_employment_income at zero.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- name: Pre-tax contributions exceed employment income.
period: 2024
input:
employment_income: 100
pre_tax_contributions: 200
output:
irs_employment_income: 0

- name: Pre-tax contributions do not exceed employment income.
period: 2024
input:
employment_income: 100
pre_tax_contributions: 30
output:
irs_employment_income: 70

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ class irs_employment_income(Variable):
documentation = "Employment income less payroll deductions."
definition_period = YEAR

adds = ["employment_income"]
subtracts = ["pre_tax_contributions"]
def formula(person, period, parameters):
employment_income = person("employment_income", period)
pre_tax_contributions = person("pre_tax_contributions", period)
return max_(0, employment_income - pre_tax_contributions)
155 changes: 155 additions & 0 deletions test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,161 @@
"EnhancedCPS_2022().generate()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"from policyengine_us import Microsimulation\n",
"from policyengine_core.reforms import Reform\n",
"from policyengine_core.periods import instant"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def use_reported_state_income_tax(parameters):\n",
" parameters.simulation.reported_state_income_tax.update(\n",
" start=instant(\"2024-01-01\"), stop=instant(\"2024-12-31\"),\n",
" value=True)\n",
" return parameters\n",
"\n",
"\n",
"class baseline_reform(Reform):\n",
" def apply(self):\n",
" self.modify_parameters(use_reported_state_income_tax)\n",
"\n",
"\n",
"sim = Microsimulation(reform=baseline_reform)\n",
"sim.calc(\"irs_employment_income\", period=2024).min()"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-5936.919"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sim.calc(\"household_tax_before_refundable_credits\", period=2024).min()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sim.calc(\"employee_payroll_tax\", period=2024).min()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sim.calc(\"self_employment_tax\", period=2024).min()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-0.00019454956"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sim.calc(\"income_tax_before_refundable_credits\", period=2024).min()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"income_tax_before_credits 0.0\n",
"net_investment_income_tax 0.0\n",
"recapture_of_investment_credit 0.0\n",
"unreported_payroll_tax 0.0\n",
"qualified_retirement_penalty 0.0\n",
"income_tax_capped_non_refundable_credits 0.0\n",
"spm_unit_state_tax_reported -6045.521\n"
]
}
],
"source": [
"# Print the min of each of these.\n",
"COLS = [\n",
"\"income_tax_before_credits\",\n",
" \"net_investment_income_tax\",\n",
" \"recapture_of_investment_credit\",\n",
" \"unreported_payroll_tax\",\n",
" \"qualified_retirement_penalty\", \"income_tax_capped_non_refundable_credits\", \"spm_unit_state_tax_reported\"]\n",
"for col in COLS:\n",
" print(col, sim.calc(col, period=2024).min())"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down