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: minor
changes:
added:
- partnership_se_income variable from Schedule K-1 Box 14 (k1bx14p + k1bx14s), representing partnership income subject to self-employment tax.
26 changes: 20 additions & 6 deletions policyengine_us_data/datasets/puf/puf.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,13 @@ def preprocess_puf(puf: pd.DataFrame) -> pd.DataFrame:
puf["unreported_payroll_tax"] = puf.E09800
# Ignore f2441 (AMT form attached)
# Ignore cmbtp (estimate of AMT income not in AGI)
# Ignore k1bx14s and k1bx14p (partner self-employment income included in partnership and S-corp income)

# Partnership self-employment income from Schedule K-1 Box 14
# This is the portion of partnership income subject to SE tax (general partners only)
# k1bx14p = taxpayer, k1bx14s = spouse
k1bx14p = puf["k1bx14p"] if "k1bx14p" in puf.columns else 0
k1bx14s = puf["k1bx14s"] if "k1bx14s" in puf.columns else 0
puf["partnership_se_income"] = k1bx14p + k1bx14s

# --- Qualified Business Income Deduction (QBID) simulation ---
w2, ubia = simulate_w2_and_ubia_from_puf(puf, seed=42)
Expand Down Expand Up @@ -491,6 +497,7 @@ def preprocess_puf(puf: pd.DataFrame) -> pd.DataFrame:
"business_is_sstb",
"deductible_mortgage_interest",
"partnership_s_corp_income",
"partnership_se_income",
"qualified_reit_and_ptp_income",
"qualified_bdc_income",
]
Expand Down Expand Up @@ -544,6 +551,13 @@ def generate(self):
for variable in system.variables
}

# Filter FINANCIAL_SUBSET to only include variables defined in
# policyengine-us. This allows us-data to be updated before or after
# policyengine-us without breaking.
self.available_financial_vars = [
v for v in FINANCIAL_SUBSET if v in self.variable_to_entity
]

VARIABLES = [
"person_id",
"tax_unit_id",
Expand All @@ -563,7 +577,7 @@ def generate(self):
"is_tax_unit_head",
"is_tax_unit_spouse",
"is_tax_unit_dependent",
] + FINANCIAL_SUBSET
] + self.available_financial_vars

self.holder = {variable: [] for variable in VARIABLES}

Expand Down Expand Up @@ -607,7 +621,7 @@ def generate(self):
def add_tax_unit(self, row, tax_unit_id):
self.holder["tax_unit_id"].append(tax_unit_id)

for key in FINANCIAL_SUBSET:
for key in self.available_financial_vars:
if self.variable_to_entity[key] == "tax_unit":
self.holder[key].append(row[key])

Expand Down Expand Up @@ -649,7 +663,7 @@ def add_filer(self, row, tax_unit_id):
row["interest_deduction"]
)

for key in FINANCIAL_SUBSET:
for key in self.available_financial_vars:
if key == "deductible_mortgage_interest":
# Skip this one- we are adding it artificially at the filer level.
continue
Expand Down Expand Up @@ -682,7 +696,7 @@ def add_spouse(self, row, tax_unit_id):

self.holder["deductible_mortgage_interest"].append(0)

for key in FINANCIAL_SUBSET:
for key in self.available_financial_vars:
if key == "deductible_mortgage_interest":
# Skip this one- we are adding it artificially at the filer level.
continue
Expand All @@ -706,7 +720,7 @@ def add_dependent(self, row, tax_unit_id, dependent_id):

self.holder["deductible_mortgage_interest"].append(0)

for key in FINANCIAL_SUBSET:
for key in self.available_financial_vars:
if key == "deductible_mortgage_interest":
# Skip this one- we are adding it artificially at the filer level.
continue
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.