diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb2d..f84d0e1d420 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + added: + - Refactor the regular_tax_before_credits variable and add unit tests. diff --git a/policyengine_us/parameters/gov/irs/capital_gains/in_effect.yaml b/policyengine_us/parameters/gov/irs/capital_gains/in_effect.yaml new file mode 100644 index 00000000000..2ebe87f6ce2 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/capital_gains/in_effect.yaml @@ -0,0 +1,15 @@ +description: Whether the additional lines apply to Schedule D Tax Worksheet. +values: + 0000-01-01: false + 2018-01-01: true +metadata: + unit: bool + period: year + label: Schedule D Tax Worksheet additional line in effect + reference: + - title: 2017 Instructions for Schedule D - line 19 + href: https://www.irs.gov/pub/irs-prior/i1040sd--2017.pdf#page=15 + - title: 2018 Instructions for Schedule D - line 18b + href: https://www.irs.gov/pub/irs-prior/i1040sd--2018.pdf#page=19 + - title: 2019 Instructions for Schedule D - line 19 + href: https://www.irs.gov/pub/irs-prior/i1040sd--2019.pdf#page=16 diff --git a/policyengine_us/parameters/gov/irs/capital_gains/taxable_income_limit.yaml b/policyengine_us/parameters/gov/irs/capital_gains/taxable_income_limit.yaml new file mode 100644 index 00000000000..981d80dc999 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/capital_gains/taxable_income_limit.yaml @@ -0,0 +1,55 @@ +description: Taxable income thresholds and limits. +metadata: + unit: currency-USD + period: year + label: Taxable income thresholds + breakdown: filing_status + reference: + - title: 2018 Instructions for Schedule D - line 18b + href: https://www.irs.gov/pub/irs-prior/i1040sd--2018.pdf#page=19 + - title: 2019 Instructions for Schedule D - line 19 + href: https://www.irs.gov/pub/irs-prior/i1040sd--2019.pdf#page=16 + - title: 2020 Instructions for Schedule D - line 19 + href: https://www.irs.gov/pub/irs-prior/i1040sd--2020.pdf#page=16 + - title: 2021 Instructions for Schedule D - line 19 + href: https://www.irs.gov/pub/irs-prior/i1040sd--2021.pdf#page=16 + - title: 2022 Instructions for Schedule D - line 19 + href: https://www.irs.gov/pub/irs-prior/i1040sd--2022.pdf#page=16 + - title: 2023 Instructions for Schedule D - line 19 + href: https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16 + +SINGLE: + 2018-01-01: 157_500 + 2019-01-01: 160_725 + 2020-01-01: 163_300 + 2021-01-01: 164_925 + 2022-01-01: 170_050 + 2023-01-01: 182_100 +JOINT: + 2018-01-01: 315_000 + 2019-01-01: 321_450 + 2020-01-01: 326_600 + 2021-01-01: 329_850 + 2022-01-01: 340_100 + 2023-01-01: 364_200 +SEPARATE: + 2018-01-01: 157_500 + 2019-01-01: 160_725 + 2020-01-01: 163_300 + 2021-01-01: 164_925 + 2022-01-01: 170_050 + 2023-01-01: 182_100 +HEAD_OF_HOUSEHOLD: + 2018-01-01: 157_500 + 2019-01-01: 160_700 + 2020-01-01: 163_300 + 2021-01-01: 164_900 + 2022-01-01: 170_050 + 2023-01-01: 182_100 +SURVIVING_SPOUSE: + 2018-01-01: 315_000 + 2019-01-01: 321_450 + 2020-01-01: 326_600 + 2021-01-01: 329_850 + 2022-01-01: 340_100 + 2023-01-01: 364_200 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/adjusted_capital_gains_reduced_by_investment_income.yaml b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/adjusted_capital_gains_reduced_by_investment_income.yaml new file mode 100644 index 00000000000..6b29c09c5d4 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/adjusted_capital_gains_reduced_by_investment_income.yaml @@ -0,0 +1,43 @@ +- name: non_sch_d_capital_gains > 0, investment_income_form_4952 > 0 + period: 2019 + input: + long_term_capital_gains: 2_000 + qualified_dividend_income: 2_000 + net_capital_gains: 1_000 + non_sch_d_capital_gains: 3_000 + investment_income_form_4952: 2_000 + output: # 3000 - min(0, 2000) + adjusted_capital_gains_reduced_by_investment_income: 3_000 + +- name: non_sch_d_capital_gains > 0, investment_income_form_4952 < 0 + period: 2019 + input: + long_term_capital_gains: 2_000 + qualified_dividend_income: 2_000 + net_capital_gains: 1_000 + non_sch_d_capital_gains: 3_000 + investment_income_form_4952: -2_000 + output: # 3000 - min(0, -2000) + adjusted_capital_gains_reduced_by_investment_income: 5_000 + +- name: non_sch_d_capital_gains < 0, investment_income_form_4952 < 0 + period: 2019 + input: + long_term_capital_gains: 2_000 + qualified_dividend_income: 2_000 + net_capital_gains: 1_000 + non_sch_d_capital_gains: -1_000 + investment_income_form_4952: -2_000 + output: # min(2000 + 2000, 1000) - 1000 - min(0, -2000) + adjusted_capital_gains_reduced_by_investment_income: 2_000 + +- name: non_sch_d_capital_gains < 0, investment_income_form_4952 > 0 + period: 2019 + input: + long_term_capital_gains: 2_000 + qualified_dividend_income: 2_000 + net_capital_gains: 1_000 + non_sch_d_capital_gains: -3_000 + investment_income_form_4952: 2_000 + output: # min(2000 + 2000, 1000) - 3000 - min(0, 2000) + adjusted_capital_gains_reduced_by_investment_income: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_dividends_gains_whether_has_gains.yaml b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_dividends_gains_whether_has_gains.yaml new file mode 100644 index 00000000000..c1303a4e944 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_dividends_gains_whether_has_gains.yaml @@ -0,0 +1,51 @@ +- name: has_qdiv_or_ltcg + period: 2019 + input: + reduced_qualified_dividends_by_adjusted_investment_interest: 1_000 + adjusted_capital_gains_reduced_by_investment_income: 1_000 + long_term_capital_gains: 2_000 + qualified_dividend_income: 2_000 + net_capital_gains: 1_000 + non_sch_d_capital_gains: 1_000 + has_qdiv_or_ltcg: true + output: # 1000 + 1000 + computed_dividends_gains_whether_has_gains: 2_000 + +- name: no has_qdiv_or_ltcg, add_qdiv_or_ltcg > net_capital_gains + period: 2019 + input: + reduced_qualified_dividends_by_adjusted_investment_interest: 1_000 + adjusted_capital_gains_reduced_by_investment_income: 1_000 + long_term_capital_gains: 2_000 + qualified_dividend_income: 2_000 + net_capital_gains: 1_000 + non_sch_d_capital_gains: 2_000 + has_qdiv_or_ltcg: false + output: # min(2000 + 2000, 1000) + 2000 + computed_dividends_gains_whether_has_gains: 3_000 + +- name: no has_qdiv_or_ltcg, add_qdiv_or_ltcg < net_capital_gains + period: 2019 + input: + reduced_qualified_dividends_by_adjusted_investment_interest: 1_000 + adjusted_capital_gains_reduced_by_investment_income: 1_000 + long_term_capital_gains: 2_000 + qualified_dividend_income: 2_000 + net_capital_gains: 5_000 + non_sch_d_capital_gains: 2_000 + has_qdiv_or_ltcg: false + output: # min(2000 + 2000, 5000) + 2000 + computed_dividends_gains_whether_has_gains: 6_000 + +- name: no has_qdiv_or_ltcg, net_capital_gains < 0 + period: 2019 + input: + reduced_qualified_dividends_by_adjusted_investment_interest: 1_000 + adjusted_capital_gains_reduced_by_investment_income: 1_000 + long_term_capital_gains: 2_000 + qualified_dividend_income: 2_000 + net_capital_gains: -1_000 + non_sch_d_capital_gains: 4_000 + has_qdiv_or_ltcg: false + output: # max(0, min(2000 + 2000, -1000)) + 4000 + computed_dividends_gains_whether_has_gains: 4_000 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_final_gains_after_all_adjustments.yaml b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_final_gains_after_all_adjustments.yaml new file mode 100644 index 00000000000..7bc19f1e6b5 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_final_gains_after_all_adjustments.yaml @@ -0,0 +1,54 @@ +- name: has_qdiv_or_ltcg, taxable_income_minus_gains < taxable_income < capital_gains + period: 2017 + input: + filing_status: SINGLE + taxable_income: 4_000 + taxable_income_minus_gains: 3_000 + computed_dividends_gains_whether_has_gains: 2_000 + has_qdiv_or_ltcg: true + output: # max(min(37950, 4000, 3000), 4000 - 2000) * 1 + computed_final_gains_after_all_adjustments: 3_000 + +- name: has_qdiv_or_ltcg, capital_gains < taxable_income_minus_gains < taxable_income + period: 2017 + input: + filing_status: SINGLE + taxable_income: 50_000 + taxable_income_minus_gains: 45_000 + computed_dividends_gains_whether_has_gains: 20_000 + has_qdiv_or_ltcg: true + output: # max(min(37950, 50000, 45000), 50000 - 20000) * 1 + computed_final_gains_after_all_adjustments: 37_950 + +- name: has_qdiv_or_ltcg, capital_gains < taxable_income_minus_gains < taxable_income, taxable_income < computed_dividends_gains_whether_has_gains + period: 2017 + input: + filing_status: SINGLE + taxable_income: 10_000 + taxable_income_minus_gains: 5_000 + computed_dividends_gains_whether_has_gains: 20_000 + has_qdiv_or_ltcg: true + output: # max(min(37950, 10000, 5000), 10000 - 20000) * 1 + computed_final_gains_after_all_adjustments: 5_000 + +- name: no has_qdiv_or_ltcg + period: 2017 + input: + filing_status: SINGLE + taxable_income: 10_000 + taxable_income_minus_gains: 5_000 + computed_dividends_gains_whether_has_gains: 20_000 + has_qdiv_or_ltcg: false + output: # max(min(37950, 10000, 5000), 10000 - 20000) * 0 + computed_final_gains_after_all_adjustments: 0 + +- name: with additional steps + period: 2018 + input: + filing_status: SINGLE + taxable_income: 200_000 + taxable_income_minus_gains: 190_000 + computed_dividends_gains_whether_has_gains: 50_000 + has_qdiv_or_ltcg: true + output: # max(min(157500, 200000, 190000), 200000 - 50000) * 1 + computed_final_gains_after_all_adjustments: 157_500 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_gains_after_1250_and_28_percent_rate_gains.yaml b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_gains_after_1250_and_28_percent_rate_gains.yaml new file mode 100644 index 00000000000..9977058b7fa --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/computed_gains_after_1250_and_28_percent_rate_gains.yaml @@ -0,0 +1,43 @@ +- name: has_qdiv_or_ltcg, added_1250_and_28_percent_rate_gains < adjusted_capital_gains_reduced_by_investment_income + period: 2019 + input: + unrecaptured_section_1250_gain: 1_000 + capital_gains_28_percent_rate_gain: 1_000 + adjusted_capital_gains_reduced_by_investment_income: 3_000 + computed_dividends_gains_whether_has_gains: 2_000 + has_qdiv_or_ltcg: true + output: # (2000 - min(1000 + 1000, 3000)) * 1 + computed_gains_after_1250_and_28_percent_rate_gains: 0 + +- name: has_qdiv_or_ltcg, added_1250_and_28_percent_rate_gains < adjusted_capital_gains_reduced_by_investment_income + period: 2019 + input: + unrecaptured_section_1250_gain: 1_000 + capital_gains_28_percent_rate_gain: 1_000 + adjusted_capital_gains_reduced_by_investment_income: 1_000 + computed_dividends_gains_whether_has_gains: 2_000 + has_qdiv_or_ltcg: true + output: # (2000 - min(1000 + 1000, 1000)) * 1 + computed_gains_after_1250_and_28_percent_rate_gains: 1_000 + +- name: no has_qdiv_or_ltcg + period: 2019 + input: + unrecaptured_section_1250_gain: 1_000 + capital_gains_28_percent_rate_gain: 1_000 + adjusted_capital_gains_reduced_by_investment_income: 1_000 + computed_dividends_gains_whether_has_gains: 2_000 + has_qdiv_or_ltcg: false + output: # (2000 - min(1000 + 1000, 1000)) * 0 + computed_gains_after_1250_and_28_percent_rate_gains: 0 + +- name: negative result + period: 2019 + input: + unrecaptured_section_1250_gain: 2_000 + capital_gains_28_percent_rate_gain: 1_000 + adjusted_capital_gains_reduced_by_investment_income: 4_000 + computed_dividends_gains_whether_has_gains: 2_000 + has_qdiv_or_ltcg: true + output: # (2000 - min(2000 + 1000, 4000)) * 1 + computed_gains_after_1250_and_28_percent_rate_gains: -1_000 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/reduced_qualified_dividends_by_adjusted_investment_interest.yaml b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/reduced_qualified_dividends_by_adjusted_investment_interest.yaml new file mode 100644 index 00000000000..1b0bab9da47 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/reduced_qualified_dividends_by_adjusted_investment_interest.yaml @@ -0,0 +1,23 @@ +- name: qualified_dividend_income larger than investment_income_form_4952 + period: 2019 + input: + qualified_dividend_income: 2_000 + investment_income_form_4952: 1_000 + output: + reduced_qualified_dividends_by_adjusted_investment_interest: 1_000 + +- name: qualified_dividend_income smaller than investment_income_form_4952 + period: 2019 + input: + qualified_dividend_income: 1_000 + investment_income_form_4952: 2_000 + output: + reduced_qualified_dividends_by_adjusted_investment_interest: 0 + +- name: investment_income_form_4952 smaller than 0 + period: 2019 + input: + qualified_dividend_income: 2_000 + investment_income_form_4952: -2_000 + output: + reduced_qualified_dividends_by_adjusted_investment_interest: 2_000 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/taxable_income_minus_gains.yaml b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/taxable_income_minus_gains.yaml new file mode 100644 index 00000000000..bcc9a3fe943 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/capital_gains/taxable_income_minus_gains.yaml @@ -0,0 +1,26 @@ +- name: has_qdiv_or_ltcg, taxable_income > computed_gains_after_1250_and_28_percent_rate_gains + period: 2019 + input: + taxable_income: 3_000 + computed_gains_after_1250_and_28_percent_rate_gains: 1_000 + has_qdiv_or_ltcg: true + output: # (3000 - 1000) * 1 + taxable_income_minus_gains: 2_000 + +- name: has_qdiv_or_ltcg, taxable_income < computed_gains_after_1250_and_28_percent_rate_gains + period: 2019 + input: + taxable_income: 3_000 + computed_gains_after_1250_and_28_percent_rate_gains: 4_000 + has_qdiv_or_ltcg: true + output: # (3000 - 4000) * 1 + taxable_income_minus_gains: 0 + +- name: no has_qdiv_or_ltcg + period: 2019 + input: + taxable_income: 3_000 + computed_gains_after_1250_and_28_percent_rate_gains: 1_000 + has_qdiv_or_ltcg: false + output: # (3000 - 1000) * 0 + taxable_income_minus_gains: 0 diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/capital_gains_taxable_difference_after_gains_adjustments.py b/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/capital_gains_taxable_difference_after_gains_adjustments.py new file mode 100644 index 00000000000..b1ccdcd5c31 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/capital_gains_taxable_difference_after_gains_adjustments.py @@ -0,0 +1,40 @@ +from policyengine_us.model_api import * + + +class capital_gains_taxable_difference_after_gains_adjustments(Variable): + value_type = float + entity = TaxUnit + definition_period = YEAR + label = ( + "Capital gains taxable difference after gains adjustments" # DWKS20 + ) + unit = USD + reference = ( + "https://www.irs.gov/pub/irs-pdf/f1040sd.pdf", + "https://www.irs.gov/pub/irs-prior/i1040sd--2017.pdf#page=15", + "https://www.irs.gov/pub/irs-prior/i1040sd--2018.pdf#page=19", + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) + + def formula(tax_unit, period, parameters): + # Schedule D Tax Worksheet line 1 + taxable_income = tax_unit("taxable_income", period) # dwks1 + # Schedule D Tax Worksheet line 15 + filing_status = tax_unit("filing_status", period) + capital_gains = parameters(period).gov.irs.capital_gains.brackets + # Schedule D Tax Worksheet line 16 + min_capital_gains_and_taxable_income_1 = min_( + capital_gains.thresholds["1"][filing_status], taxable_income + ) # dwks16 + # Schedule D Tax Worksheet line 17 + min_capital_gains_and_taxable_income_and_taxable_income_minus_gains = ( + min_( + tax_unit("taxable_income_minus_gains", period), + min_capital_gains_and_taxable_income_1, + ) + ) # dwks17 = min_(tax_unit("dwks14", period), dwks16) + # Schedule D Tax Worksheet line 20 for 2017 and 2018, or line 22 for years after + return ( + min_capital_gains_and_taxable_income_1 + - min_capital_gains_and_taxable_income_and_taxable_income_minus_gains + ) # dwks20 = dwks16 - dwks17 diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/middle_rate_tax.py b/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/middle_rate_tax.py new file mode 100644 index 00000000000..8fb89aa5f61 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/middle_rate_tax.py @@ -0,0 +1,67 @@ +from policyengine_us.model_api import * + + +class middle_rate_tax(Variable): + value_type = float + entity = TaxUnit + definition_period = YEAR + label = "Middle rate tax" # DWKS29 + unit = USD + reference = ( + "https://www.irs.gov/pub/irs-pdf/f1040sd.pdf", + "https://www.irs.gov/pub/irs-prior/i1040sd--2017.pdf#page=15", + "https://www.irs.gov/pub/irs-prior/i1040sd--2018.pdf#page=19", + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) + + def formula(tax_unit, period, parameters): + # Schedule D Tax Worksheet line 1 + taxable_income = tax_unit("taxable_income", period) # dwks1 + # Schedule D Tax Worksheet line 24 + filing_status = tax_unit("filing_status", period) + capital_gains = parameters(period).gov.irs.capital_gains.brackets + computed_gains_after_1250_and_28_percent_rate_gains = tax_unit( + "computed_gains_after_1250_and_28_percent_rate_gains", period + ) # dwks13 + # Schedule D Tax Worksheet line 20 for 2017 and 2018, or line 22 for years after + capital_gains_taxable_difference_after_gains_adjustments = tax_unit( + "capital_gains_taxable_difference_after_gains_adjustments", period + ) + # Schedule D Tax Worksheet line 21 for 2017 and 2018, or line 23 for years after + minimum_of_taxable_income_and_adjusted_gains_after_special_rates_adjustments = min_( + taxable_income, computed_gains_after_1250_and_28_percent_rate_gains + ) # dwks21 = min_(dwks1, dwks13) + # Schedule D Tax Worksheet line 22 for 2017 and 2018, or line 24 for years after + capital_gains_taxable_difference_after_gains_adjustments_2 = capital_gains_taxable_difference_after_gains_adjustments # dwks22 = dwks20 + # Schedule D Tax Worksheet line 23 for 2017 and 2018, or line 25 for years after + adjusted_taxable_income_after_special_gains_and_threshold_deductions = max_( + 0, + minimum_of_taxable_income_and_adjusted_gains_after_special_rates_adjustments + - capital_gains_taxable_difference_after_gains_adjustments_2, + ) # dwks23 = max_(0, dwks21 - dwks22) + # Schedule D Tax Worksheet line 25 for 2017 and 2018, or line 27 for years after + min_capital_gains_and_taxable_income_2 = min_( + capital_gains.thresholds["2"][filing_status], taxable_income + ) # dwks25 = min_(capital_gains.thresholds["2"][filing_status], dwks1) + computed_final_gains_after_all_adjustments = tax_unit( + "computed_final_gains_after_all_adjustments", period + ) # dwks19 + minimum_of_adjusted_gains_and_taxable_difference_after_gains_adjustments = min_( + computed_final_gains_after_all_adjustments, + capital_gains_taxable_difference_after_gains_adjustments, + ) # dwks26 = min_(dwks19, dwks20) + # Schedule D Tax Worksheet line 27 for 2017 and 2018, or line 29 for years after + non_negative_adjusted_income_after_gains_and_taxable_difference_deductions = max_( + 0, + min_capital_gains_and_taxable_income_2 + - minimum_of_adjusted_gains_and_taxable_difference_after_gains_adjustments, + ) # dwks27 = max_(0, dwks25 - dwks26) + # Schedule D Tax Worksheet line 28 for 2017 and 2018, or line 30 for years after + dwks28 = min_( + adjusted_taxable_income_after_special_gains_and_threshold_deductions, + non_negative_adjusted_income_after_gains_and_taxable_difference_deductions, + ) # dwks28 = min_(dwks23, dwks27) + # Schedule D Tax Worksheet line 29 for 2017 and 2018, or line 31 for years after + return ( + capital_gains.rates["2"] * dwks28 + ) # dwks29 = capital_gains.rates["2"] * dwks28 diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/regular_tax_before_credits.py b/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/regular_tax_before_credits.py index be8813f2c30..8113c44ea8a 100644 --- a/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/regular_tax_before_credits.py +++ b/policyengine_us/variables/gov/irs/tax/federal_income/alternative_minimum_tax/regular_tax_before_credits.py @@ -8,51 +8,134 @@ class regular_tax_before_credits(Variable): label = "Regular tax before credits" documentation = "Regular tax on regular taxable income before credits" unit = USD + reference = ( + "https://www.irs.gov/pub/irs-pdf/f1040sd.pdf", + "https://www.irs.gov/pub/irs-prior/i1040sd--2017.pdf#page=15", + "https://www.irs.gov/pub/irs-prior/i1040sd--2018.pdf#page=19", + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) def formula(tax_unit, period, parameters): + # Schedule D Tax Worksheet line 1 + taxable_income = tax_unit("taxable_income", period) # dwks1 + # Schedule D Tax Worksheet line 15 filing_status = tax_unit("filing_status", period) - dwks1 = tax_unit("taxable_income", period) - capital_gains = parameters(period).gov.irs.capital_gains.brackets - - dwks16 = min_(capital_gains.thresholds["1"][filing_status], dwks1) - dwks17 = min_(tax_unit("dwks14", period), dwks16) - dwks20 = dwks16 - dwks17 - lowest_rate_tax = capital_gains.rates["1"] * dwks20 + # Schedule D Tax Worksheet line 16 + min_capital_gains_and_taxable_income_1 = min_( + capital_gains.thresholds["1"][filing_status], taxable_income + ) # dwks16 + # Schedule D Tax Worksheet line 17 + min_capital_gains_and_taxable_income_and_taxable_income_minus_gains = ( + min_( + tax_unit("taxable_income_minus_gains", period), + min_capital_gains_and_taxable_income_1, + ) + ) # dwks17 = min_(tax_unit("dwks14", period), dwks16) + # Schedule D Tax Worksheet line 20 for 2017 and 2018, or line 22 for years after + capital_gains_taxable_difference_after_gains_adjustments = ( + min_capital_gains_and_taxable_income_1 + - min_capital_gains_and_taxable_income_and_taxable_income_minus_gains + ) # dwks20 = dwks16 - dwks17 + lowest_rate_tax = ( + capital_gains.rates["1"] + * capital_gains_taxable_difference_after_gains_adjustments + ) # Break in worksheet lines - dwks13 = tax_unit("dwks13", period) - dwks21 = min_(dwks1, dwks13) - dwks22 = dwks20 - dwks23 = max_(0, dwks21 - dwks22) - dwks25 = min_(capital_gains.thresholds["2"][filing_status], dwks1) - dwks19 = tax_unit("dwks19", period) - dwks26 = min_(dwks19, dwks20) - dwks27 = max_(0, dwks25 - dwks26) - dwks28 = min_(dwks23, dwks27) - dwks29 = capital_gains.rates["2"] * dwks28 - dwks30 = dwks22 + dwks28 - dwks31 = dwks21 - dwks30 - dwks32 = capital_gains.rates["3"] * dwks31 + # Schedule D Tax Worksheet line 13 + computed_gains_after_1250_and_28_percent_rate_gains = tax_unit( + "computed_gains_after_1250_and_28_percent_rate_gains", period + ) # dwks13 + # Schedule D Tax Worksheet line 21 for 2017 and 2018, or line 23 for years after + minimum_of_taxable_income_and_adjusted_gains_after_special_rates_adjustments = min_( + taxable_income, computed_gains_after_1250_and_28_percent_rate_gains + ) # dwks21 = min_(dwks1, dwks13) + # Schedule D Tax Worksheet line 22 for 2017 and 2018, or line 24 for years after + capital_gains_taxable_difference_after_gains_adjustments_2 = capital_gains_taxable_difference_after_gains_adjustments # dwks22 = dwks20 + # Schedule D Tax Worksheet line 23 for 2017 and 2018, or line 25 for years after + adjusted_taxable_income_after_special_gains_and_threshold_deductions = max_( + 0, + minimum_of_taxable_income_and_adjusted_gains_after_special_rates_adjustments + - capital_gains_taxable_difference_after_gains_adjustments_2, + ) # dwks23 = max_(0, dwks21 - dwks22) + # Schedule D Tax Worksheet line 25 for 2017 and 2018, or line 27 for years after + min_capital_gains_and_taxable_income_2 = min_( + capital_gains.thresholds["2"][filing_status], taxable_income + ) # dwks25 = min_(capital_gains.thresholds["2"][filing_status], dwks1) + computed_final_gains_after_all_adjustments = tax_unit( + "computed_final_gains_after_all_adjustments", period + ) # dwks19 + minimum_of_adjusted_gains_and_taxable_difference_after_gains_adjustments = min_( + computed_final_gains_after_all_adjustments, + capital_gains_taxable_difference_after_gains_adjustments, + ) # dwks26 = min_(dwks19, dwks20) + # Schedule D Tax Worksheet line 27 for 2017 and 2018, or line 29 for years after + non_negative_adjusted_income_after_gains_and_taxable_difference_deductions = max_( + 0, + min_capital_gains_and_taxable_income_2 + - minimum_of_adjusted_gains_and_taxable_difference_after_gains_adjustments, + ) # dwks27 = max_(0, dwks25 - dwks26) + # Schedule D Tax Worksheet line 28 for 2017 and 2018, or line 30 for years after + dwks28 = min_( + adjusted_taxable_income_after_special_gains_and_threshold_deductions, + non_negative_adjusted_income_after_gains_and_taxable_difference_deductions, + ) # dwks28 = min_(dwks23, dwks27) + # Schedule D Tax Worksheet line 29 for 2017 and 2018, or line 31 for years after + dwks29 = ( + capital_gains.rates["2"] * dwks28 + ) # dwks29 = capital_gains.rates["2"] * dwks28 + # Schedule D Tax Worksheet line 30 for 2017 and 2018, or line 32 for years after + dwks30 = ( + capital_gains_taxable_difference_after_gains_adjustments_2 + dwks28 + ) # dwks30 = dwks22 + dwks28 + # Schedule D Tax Worksheet line 31 for 2017 and 2018, or line 33 for years after + dwks31 = ( + minimum_of_taxable_income_and_adjusted_gains_after_special_rates_adjustments + - dwks30 + ) # dwks31 = dwks21 - dwks30 + # Schedule D Tax Worksheet line 32 for 2017 and 2018, or line 34 for years after + dwks32 = ( + capital_gains.rates["3"] * dwks31 + ) # dwks32 = capital_gains.rates["3"] * dwks31 # Break in worksheet lines + # Schedule D Tax Worksheet line 33 for 2017 and 2018, or line 35 for years after dwks33 = min_( - tax_unit("dwks09", period), - add(tax_unit, period, ["unrecaptured_section_1250_gain"]), - ) - dwks10 = tax_unit("dwks10", period) - dwks34 = dwks10 + dwks19 - dwks36 = max_(0, dwks34 - dwks1) - dwks37 = max_(0, dwks33 - dwks36) - - p = parameters(period).gov.irs.income - - dwks38 = p.amt.capital_gains.capital_gain_excess_tax_rate * dwks37 + tax_unit( + "adjusted_capital_gains_reduced_by_investment_income", period + ), # dwks9 + add( + tax_unit, period, ["unrecaptured_section_1250_gain"] + ), # Unrecaptured Section 1250 Gain Worksheet—Line 19 + ) # dwks33 + # Schedule D Tax Worksheet line 10 + dwks10 = tax_unit("dwks10", period) # dwks10 + # Schedule D Tax Worksheet line 34 for 2017 and 2018, or line 36 for years after + dwks34 = ( + dwks10 + computed_final_gains_after_all_adjustments + ) # dwks34 = dwks10 + dwks19 + # Schedule D Tax Worksheet line 36 for 2017 and 2018, or line 38 for years after + dwks36 = max_(0, dwks34 - dwks1) # dwks36 = max_(0, dwks34 - dwks1) + # Schedule D Tax Worksheet line 37 for 2017 and 2018, or line 39 for years after + dwks37 = max_(0, dwks33 - dwks36) # dwks37 = max_(0, dwks33 - dwks36) + # Schedule D Tax Worksheet line 38 for 2017 and 2018, or line 40 for years after + dwks38 = 0.25 * dwks37 # dwks38 # Break in worksheet lines - dwks39 = dwks19 + dwks20 + dwks28 + dwks31 + dwks37 - dwks40 = dwks1 - dwks39 - dwks41 = p.amt.brackets.rates[-1] * dwks40 + # Schedule D Tax Worksheet line 39 for 2017 and 2018, or line 41 for years after + dwks39 = ( + computed_final_gains_after_all_adjustments + + dwks20 + + dwks28 + + dwks31 + + dwks37 + ) # dwks39 = dwks19 + dwks20 + dwks28 + dwks31 + dwks37 + # Schedule D Tax Worksheet line 40 for 2017 and 2018, or line 42 for years after + dwks40 = taxable_income - dwks39 # dwks40 = dwks1 - dwks39 + # Schedule D Tax Worksheet line 41 for 2017 and 2018, or line 43 for years after + dwks41 = 0.28 * dwks40 # dwks41 # Compute regular tax using bracket rates and thresholds - reg_taxinc = max_(0, dwks19) + reg_taxinc = max_(0, computed_final_gains_after_all_adjustments) + p = parameters(period).gov.irs.income bracket_tops = p.bracket.thresholds bracket_rates = p.bracket.rates reg_tax = 0 @@ -66,8 +149,29 @@ def formula(tax_unit, period, parameters): bracket_bottom = bracket_top # Return to worksheet lines - dwks42 = reg_tax - dwks43 = dwks29 + dwks32 + dwks38 + dwks41 + dwks42 + lowest_rate_tax - dwks44 = tax_unit("income_tax_main_rates", period) - dwks45 = min_(dwks43, dwks44) - return where(tax_unit("has_qdiv_or_ltcg", period), dwks45, dwks44) + # Schedule D Tax Worksheet line 42 for 2017 and 2018, or line 44 for years after + dwks42 = reg_tax # dwks 42 + # Schedule D Tax Worksheet line 43 for 2017 and 2018, or line 45 for years after + dwks43 = sum( + [ + dwks29, + dwks32, + dwks38, + dwks41, + dwks42, + lowest_rate_tax, + ] + ) # dwks43 + # Schedule D Tax Worksheet line 44 for 2017 and 2018, or line 46 for years after + income_tax_main_rates = tax_unit( + "income_tax_main_rates", period + ) # dwks44 + # Schedule D Tax Worksheet line 45 for 2017 and 2018, or line 47 for years after + dwks45 = min_( + dwks43, income_tax_main_rates + ) # dwks45 = min_(dwks43, dwks44) + hasqdivltcg = tax_unit("hasqdivltcg", period) + return where(hasqdivltcg, dwks45, income_tax_main_rates) + + +taxbc = variable_alias("taxbc", regular_tax_before_credits) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/adjusted_capital_gains_reduced_by_investment_income.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/adjusted_capital_gains_reduced_by_investment_income.py new file mode 100644 index 00000000000..1a3dd072780 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/adjusted_capital_gains_reduced_by_investment_income.py @@ -0,0 +1,40 @@ +from policyengine_us.model_api import * + + +class adjusted_capital_gains_reduced_by_investment_income(Variable): + value_type = float + entity = TaxUnit + label = "IRS Form 1040 Schedule D worksheet (part 2 of 6)" # DWKS09 + unit = USD + definition_period = YEAR + reference = ( + "https://www.irs.gov/pub/irs-pdf/f1040sd.pdf", + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) + + def formula(tax_unit, period, parameters): + # SchD lines 15 and 16, respectively + qdiv_plus_ltcg = add( + tax_unit, + period, + ["long_term_capital_gains", "qualified_dividend_income"], + ) # p23250 + # Schedule D Tax Worksheet line 7 + capped_net_capital_gains = min_( + qdiv_plus_ltcg, tax_unit("net_capital_gains", period) + ) # dwks7 + # Schedule D Tax Worksheet line 8 + # dwks8 = min(dwks3, dwks4) + # Schedule D Tax Worksheet line 9 + # adjusted_capital_gains_reduced_by_investment_income = max(0., capped_net_capital_gains - dwks8) + # BELOW TWO STATEMENTS ARE UNCLEAR IN LIGHT OF adjusted_capital_gains_reduced_by_investment_income=... COMMENT + other_cg = add(tax_unit, period, ["non_sch_d_capital_gains"]) # e01100 + mod_cg = where( + other_cg > 0, + other_cg, + max_(0, capped_net_capital_gains) + other_cg, + ) # c24510 + return max_( + 0, + mod_cg - min_(0, tax_unit("investment_income_form_4952", period)), + ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_dividends_gains_whether_has_gains.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_dividends_gains_whether_has_gains.py new file mode 100644 index 00000000000..9e93c79beb8 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_dividends_gains_whether_has_gains.py @@ -0,0 +1,39 @@ +from policyengine_us.model_api import * + + +class computed_dividends_gains_whether_has_gains(Variable): + value_type = float + entity = TaxUnit + definition_period = YEAR + label = "IRS Form 1040 Schedule D worksheet (part 3 of 6)" # DWKS10 + unit = USD + reference = ( + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) + + def formula(tax_unit, period, parameters): + # Schedule D Tax Worksheet line 10 + if_gains = add( + tax_unit, + period, + [ + "reduced_qualified_dividends_by_adjusted_investment_interest", + "adjusted_capital_gains_reduced_by_investment_income", + ], + ) # dwks6 & 9 + if_no_gains = max_( + 0, + min_( + add( + tax_unit, + period, + ["long_term_capital_gains", "qualified_dividend_income"], + ), + tax_unit("net_capital_gains", period), + ), + ) + add(tax_unit, period, ["non_sch_d_capital_gains"]) + return where( + tax_unit("has_qdiv_or_ltcg", period), + if_gains, + if_no_gains, + ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_final_gains_after_all_adjustments.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_final_gains_after_all_adjustments.py new file mode 100644 index 00000000000..77667e516da --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_final_gains_after_all_adjustments.py @@ -0,0 +1,68 @@ +from policyengine_us.model_api import * + + +class computed_final_gains_after_all_adjustments(Variable): + value_type = float + entity = TaxUnit + definition_period = YEAR + label = "IRS Form 1040 Schedule D worksheet (part 6 of 6)" # DWKS19 + unit = USD + reference = ( + "https://www.irs.gov/pub/irs-prior/i1040sd--2017.pdf#page=15", + "https://www.irs.gov/pub/irs-prior/i1040sd--2018.pdf#page=19", + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) + + def formula(tax_unit, period, parameters): + # Schedule D Tax Worksheet line 14 + taxable_income_minus_gains = tax_unit( + "taxable_income_minus_gains", period + ) # dwks14 + # Schedule D Tax Worksheet line 15 + capital_gains = parameters(period).gov.irs.capital_gains.brackets + filing_status = tax_unit("filing_status", period) + # Schedule D Tax Worksheet line 1 + taxable_income = tax_unit("taxable_income", period) # dwks1 + # Schedule D Tax Worksheet line 16 + min_capital_gains_and_taxable_income = min_( + capital_gains.thresholds["1"][filing_status], taxable_income + ) # dwks16 + # Schedule D Tax Worksheet line 17 + min_capital_gains_and_taxable_income_and_taxable_income_minus_gains = ( + min_( + taxable_income_minus_gains, + min_capital_gains_and_taxable_income, + ) + ) # dwks17 + # Schedule D Tax Worksheet line 10 + computed_dividends_gains_whether_has_gains = tax_unit( + "computed_dividends_gains_whether_has_gains", period + ) # dwks10 + # Schedule D Tax Worksheet line 18 + taxable_income_minus_computed_dividends_gains_whether_has_gains = max_( + 0, taxable_income - computed_dividends_gains_whether_has_gains + ) # dwks18 + + p = parameters(period).gov.irs.capital_gains + # 2017 and years before + if not p.in_effect: + # Schedule D Tax Worksheet line 19 + return max_( + min_capital_gains_and_taxable_income_and_taxable_income_minus_gains, + taxable_income_minus_computed_dividends_gains_whether_has_gains, + ) * tax_unit("has_qdiv_or_ltcg", period) + # 2018 and years after + else: + # Schedule D Tax Worksheet line 18b for 2018, or line 19 for years after + taxable_income_limit = min_( + taxable_income, p.taxable_income_limit[filing_status] + ) + # Schedule D Tax Worksheet line 18c for 2018, or line 20 for years after + taxable_income_minus_gains_limit = min_( + taxable_income_minus_gains, taxable_income_limit + ) + # Schedule D Tax Worksheet line 19 for 2018, or line 21 for years after + return max_( + taxable_income_minus_computed_dividends_gains_whether_has_gains, + taxable_income_minus_gains_limit, + ) * tax_unit("has_qdiv_or_ltcg", period) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_gains_after_1250_and_28_percent_rate_gains.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_gains_after_1250_and_28_percent_rate_gains.py new file mode 100644 index 00000000000..68a26b1857b --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/computed_gains_after_1250_and_28_percent_rate_gains.py @@ -0,0 +1,42 @@ +from policyengine_us.model_api import * + + +class computed_gains_after_1250_and_28_percent_rate_gains(Variable): + value_type = float + entity = TaxUnit + definition_period = YEAR + label = "IRS Form 1040 Schedule D worksheet (part 4 of 6)" # DWKS13 + unit = USD + reference = ( + "https://www.irs.gov/pub/irs-pdf/f1040sd.pdf", + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) + + def formula(tax_unit, period, parameters): + unrecaptured_section_1250_gain = add( + tax_unit, period, ["unrecaptured_section_1250_gain"] + ) # e24515 + # Sch D lines 18 and 19, respectively + # Schedule D Tax Worksheet line 11 + added_1250_and_28_percent_rate_gains = ( + unrecaptured_section_1250_gain + + add(tax_unit, period, ["capital_gains_28_percent_rate_gain"]) + ) # dwks11 + # Schedule D Tax Worksheet line 9 + adjusted_capital_gains_reduced_by_investment_income = tax_unit( + "adjusted_capital_gains_reduced_by_investment_income", period + ) # dwks09 + # Schedule D Tax Worksheet line 12 + min_adjusted_gains_and_added_gains = min_( + adjusted_capital_gains_reduced_by_investment_income, + added_1250_and_28_percent_rate_gains, + ) # dwks12 + # Schedule D Tax Worksheet line 10 + computed_dividends_gains_whether_has_gains = tax_unit( + "computed_dividends_gains_whether_has_gains", period + ) # dwks10 + # Schedule D Tax Worksheet line 13 + return ( + computed_dividends_gains_whether_has_gains + - min_adjusted_gains_and_added_gains + ) * tax_unit("has_qdiv_or_ltcg", period) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/reduced_qualified_dividends_by_adjusted_investment_interest.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/reduced_qualified_dividends_by_adjusted_investment_interest.py new file mode 100644 index 00000000000..748cc5fc94b --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/reduced_qualified_dividends_by_adjusted_investment_interest.py @@ -0,0 +1,29 @@ +from policyengine_us.model_api import * + + +class reduced_qualified_dividends_by_adjusted_investment_interest(Variable): + value_type = float + entity = TaxUnit + label = "IRS Form 1040 Schedule D worksheet (part 1 of 6)" # DWKS06 + unit = USD + definition_period = YEAR + reference = ( + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) + + def formula(tax_unit, period, parameters): + # Schedule D Tax Worksheet line 2 + qualified_dividends = add( + tax_unit, period, ["qualified_dividend_income"] + ) # dwks2 + # Schedule D Tax Worksheet line 3 + investment_interest = tax_unit( + "investment_income_form_4952", period + ) # dwks3 + # dwks4 always assumed to be zero + # Schedule D Tax Worksheet line 5 + adjusted_investment_interest = max_(0, investment_interest) # dwks5 + # Schedule D Tax Worksheet line 6 + return max_( + 0, qualified_dividends - adjusted_investment_interest + ) # dwks6 diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/taxable_income_minus_gains.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/taxable_income_minus_gains.py new file mode 100644 index 00000000000..aa2dcc3353f --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks/taxable_income_minus_gains.py @@ -0,0 +1,26 @@ +from policyengine_us.model_api import * + + +class taxable_income_minus_gains(Variable): + value_type = float + entity = TaxUnit + definition_period = YEAR + label = "IRS Form 1040 Schedule D worksheet (part 5 of 6)" # DWKS14 + unit = USD + reference = ( + "https://www.irs.gov/pub/irs-prior/i1040sd--2023.pdf#page=16", + ) + + def formula(tax_unit, period, parameters): + # Schedule D Tax Worksheet line 1 + taxable_income = tax_unit("taxable_income", period) # + # Schedule D Tax Worksheet line 13 + computed_gains_after_1250_and_28_percent_rate_gains = tax_unit( + "computed_gains_after_1250_and_28_percent_rate_gains", period + ) # dwks13 + # Schedule D Tax Worksheet line 14 + return max_( + 0, + taxable_income + - computed_gains_after_1250_and_28_percent_rate_gains, + ) * tax_unit("has_qdiv_or_ltcg", period) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks06.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks06.py deleted file mode 100644 index 41ad0d2ba0d..00000000000 --- a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks06.py +++ /dev/null @@ -1,16 +0,0 @@ -from policyengine_us.model_api import * - - -class dwks06(Variable): - value_type = float - entity = TaxUnit - definition_period = YEAR - label = "IRS Form 1040 Schedule D worksheet (part 1 of 6)" - unit = USD - - def formula(tax_unit, period, parameters): - dwks02 = add(tax_unit, period, ["qualified_dividend_income"]) - dwks03 = tax_unit("investment_income_form_4952", period) - # dwks04 always assumed to be zero - dwks05 = max_(0, dwks03) - return max_(0, dwks02 - dwks05) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks09.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks09.py deleted file mode 100644 index 30c949c0285..00000000000 --- a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks09.py +++ /dev/null @@ -1,27 +0,0 @@ -from policyengine_us.model_api import * - - -class dwks09(Variable): - value_type = float - entity = TaxUnit - definition_period = YEAR - label = "IRS Form 1040 Schedule D worksheet (part 2 of 6)" - unit = USD - - def formula(tax_unit, period, parameters): - # SchD lines 15 and 16, respectively - qdiv_plus_ltcg = add( - tax_unit, - period, - ["long_term_capital_gains", "qualified_dividend_income"], - ) - dwks07 = min_(qdiv_plus_ltcg, tax_unit("net_capital_gains", period)) - # dwks08 = min(dwks03, dwks04) - # dwks09 = max(0., dwks07 - dwks08) - # BELOW TWO STATEMENTS ARE UNCLEAR IN LIGHT OF dwks09=... COMMENT - other_cg = add(tax_unit, period, ["non_sch_d_capital_gains"]) - mod_cg = where(other_cg > 0, other_cg, max_(0, dwks07) + other_cg) - return max_( - 0, - mod_cg - min_(0, tax_unit("investment_income_form_4952", period)), - ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks10.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks10.py deleted file mode 100644 index 1aa2bd720e3..00000000000 --- a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks10.py +++ /dev/null @@ -1,28 +0,0 @@ -from policyengine_us.model_api import * - - -class dwks10(Variable): - value_type = float - entity = TaxUnit - definition_period = YEAR - label = "IRS Form 1040 Schedule D worksheet (part 3 of 6)" - unit = USD - - def formula(tax_unit, period, parameters): - dwks10_if_gains = add(tax_unit, period, ["dwks06", "dwks09"]) - dwks10_if_no_gains = max_( - 0, - min_( - add( - tax_unit, - period, - ["long_term_capital_gains", "qualified_dividend_income"], - ), - tax_unit("net_capital_gains", period), - ), - ) + add(tax_unit, period, ["non_sch_d_capital_gains"]) - return where( - tax_unit("has_qdiv_or_ltcg", period), - dwks10_if_gains, - dwks10_if_no_gains, - ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks13.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks13.py deleted file mode 100644 index 87753639b46..00000000000 --- a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks13.py +++ /dev/null @@ -1,19 +0,0 @@ -from policyengine_us.model_api import * - - -class dwks13(Variable): - value_type = float - entity = TaxUnit - definition_period = YEAR - label = "IRS Form 1040 Schedule D worksheet (part 4 of 6)" - unit = USD - - def formula(tax_unit, period, parameters): - e24515 = add(tax_unit, period, ["unrecaptured_section_1250_gain"]) - dwks11 = e24515 + add( - tax_unit, period, ["capital_gains_28_percent_rate_gain"] - ) # Sch D lines 18 and 19, respectively - dwks09 = tax_unit("dwks09", period) - dwks12 = min_(dwks09, dwks11) - dwks10 = tax_unit("dwks10", period) - return (dwks10 - dwks12) * tax_unit("has_qdiv_or_ltcg", period) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks14.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks14.py deleted file mode 100644 index 335d8e77527..00000000000 --- a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks14.py +++ /dev/null @@ -1,14 +0,0 @@ -from policyengine_us.model_api import * - - -class dwks14(Variable): - value_type = float - entity = TaxUnit - definition_period = YEAR - label = "IRS Form 1040 Schedule D worksheet (part 5 of 6)" - unit = USD - - def formula(tax_unit, period, parameters): - dwks01 = tax_unit("taxable_income", period) - dwks13 = tax_unit("dwks13", period) - return max_(0, dwks01 - dwks13) * tax_unit("has_qdiv_or_ltcg", period) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks19.py b/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks19.py deleted file mode 100644 index 3d647d75f0c..00000000000 --- a/policyengine_us/variables/gov/irs/tax/federal_income/capital_gains/dwks19.py +++ /dev/null @@ -1,20 +0,0 @@ -from policyengine_us.model_api import * - - -class dwks19(Variable): - value_type = float - entity = TaxUnit - definition_period = YEAR - label = "IRS Form 1040 Schedule D worksheet (part 6 of 6)" - unit = USD - - def formula(tax_unit, period, parameters): - dwks14 = tax_unit("dwks14", period) - capital_gains = parameters(period).gov.irs.capital_gains.brackets - filing_status = tax_unit("filing_status", period) - dwks01 = tax_unit("taxable_income", period) - dwks16 = min_(capital_gains.thresholds["1"][filing_status], dwks01) - dwks17 = min_(dwks14, dwks16) - dwks10 = tax_unit("dwks10", period) - dwks18 = max_(0, dwks01 - dwks10) - return max_(dwks17, dwks18) * tax_unit("has_qdiv_or_ltcg", period)