Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameters for qualified business income and update to taxcalc 3.0 #38

Merged
merged 18 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from 12 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
18 changes: 12 additions & 6 deletions cs-config/cs_config/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import paramtools
import pandas as pd
import inspect
from .helpers import convert_defaults, convert_adj
from .outputs import credit_plot, rate_plot, liability_plot
from .constants import MetaParameters
from bokeh.models import ColumnDataSource
Expand All @@ -20,11 +19,9 @@
with open(os.path.join(TCDIR, "policy_current_law.json"), "r") as f:
pcl = json.loads(f.read())

RES = convert_defaults(pcl)


class TCParams(paramtools.Parameters):
defaults = RES
defaults = pcl
Peter-Metz marked this conversation as resolved.
Show resolved Hide resolved


def get_version():
Expand Down Expand Up @@ -73,6 +70,10 @@ def get_inputs(meta_params_dict):
"otheritem",
"childcare",
"mortgage",
"businc",
"sstb",
"w2paid",
"qualprop",
"mtr_options",
"schema"
]
Expand Down Expand Up @@ -110,7 +111,9 @@ def run_model(meta_params_dict, adjustment):
meta_params = MetaParameters()
meta_params.adjust(meta_params_dict)

policy_mods = convert_adj(adjustment["Policy"], meta_params.year.tolist())
policy_params = TCParams()
policy_params.adjust(adjustment["Policy"])
policy_mods = policy_params.specification(serializable=True)

adjustment["Tax Information"]["year"] = meta_params.year
params = CruncherParams()
Expand All @@ -120,7 +123,7 @@ def run_model(meta_params_dict, adjustment):
crunch = Cruncher(inputs=newvals, custom_reform=policy_mods)

# make dataset for bokeh plots
ivar = crunch.ivar
ivar = crunch.batch_ivar
_, mtr_opt, _ = crunch.taxsim_inputs()
df = pd.concat([ivar] * 5000, ignore_index=True)
increments = pd.DataFrame(list(range(0, 500000, 100)))
Expand Down Expand Up @@ -156,6 +159,9 @@ def run_model(meta_params_dict, adjustment):
elif mtr_opt == 'Mortgage':
span = int(ivar[23])
df[23] = increments
elif mtr_opt == 'Business Income':
span = int(ivar[24])
df[24] = increments

b = Batch(df)
df_base = b.create_table()
Expand Down
130 changes: 0 additions & 130 deletions cs-config/cs_config/helpers.py

This file was deleted.

31 changes: 2 additions & 29 deletions cs-config/cs_config/tests/test_functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cs_kit import CoreTestFunctions

from cs_config import functions, helpers
from cs_config import functions


class TestFunctions1(CoreTestFunctions):
Expand All @@ -10,31 +10,4 @@ class TestFunctions1(CoreTestFunctions):
bad_adjustment = {"Tax Information": {"mstat": [{"value": 2}]}, "Policy":{"STD": -1}}
ok_adjustment = {"Tax Information": {"mstat": [{"value": "Joint"}]}, "Policy":{}}
get_inputs = functions.get_inputs
get_version = functions.get_version


def test_convert_adj():
adj = {
"STD": [
{"MARS": "single", "year": "2019", "value": 0},
{"MARS": "mjoint", "year": 2019, "value": 1}
],
"EITC_c": [{"EIC": "0kids", "year": "2019", "value": 1000.0}],
"BEN_ssi_repeal": [
{"year": 2019, "value": True}
]
}

res = helpers.convert_adj(adj, 2019)

assert res == {
"STD": {
2019: [0, 1, 12200.0, 18350.0, 24400.0]
},
"EITC_c": {
2019: [1000.0, 3526.0, 5828.0, 6557.0]
},
"BEN_ssi_repeal": {
2019: True
}
}
get_version = functions.get_version
9 changes: 7 additions & 2 deletions docs/INPUT_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ To analyze multiple tax filers, the user must specify a csv file with the filers

1. RECID (ID for tax filer)
2. year
3. mstat (1 - single; 2 - joint (married))
3. mstat (1 - single; 2 - married)
4. page (age of primary taxpayer)
5. sage (age of spouse)
6. depx (number of dependents)
Expand All @@ -27,9 +27,14 @@ To analyze multiple tax filers, the user must specify a csv file with the filers
22. otheritem (other itemized deductions subject to SALT cap, e.g. state and local taxes)
23. childcare (child care expenses)
24. mortgage (itemized deductions not subject to SALT cap, e.g., charitable contributions and home mortgage interest)
25. pbusinc (business income of primary filer)
26. sbusinc (business income of spouse)
27. sstb (1 - business income from professional services business; 0 - business income not from professional pervices business)
28. w2paid (W-2 wages paid by business)
29. qualprop (filer's share of qualified property)

For example, a 50-year old single filer with 3 dependents under 13 who makes $50,000 per year could be represented by the following:

```
1,2019,1,50,0,3,3,3,3,50000,0,0,0,0,0,0,0,0,0,0,0,0,0,0
1,2019,1,50,0,3,3,3,3,50000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
```
Loading