From bab328a9037b1a77f8f75689bbc4f48574d6feed Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Tue, 9 Jul 2024 17:30:03 -0400 Subject: [PATCH 1/7] fix: Improvements to relief portion of tax policy --- .../finance/tax/income_tax/relief.yaml | 83 --- .../baseline/gov/hmrc/income_tax/relief.yaml | 663 ++++++++++++++++++ 2 files changed, 663 insertions(+), 83 deletions(-) delete mode 100644 policyengine_uk/tests/policy/baseline/finance/tax/income_tax/relief.yaml create mode 100644 policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/relief.yaml diff --git a/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/relief.yaml b/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/relief.yaml deleted file mode 100644 index 8a5c96c71..000000000 --- a/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/relief.yaml +++ /dev/null @@ -1,83 +0,0 @@ -- name: Deductions from employment - period: 2020 - absolute_error_margin: 0 - input: - employment_income: 15000 - employment_deductions: 5000 - output: - taxable_employment_income: 10000 -- name: Deductions from employment stay positive - period: 2020 - absolute_error_margin: 0 - input: - employment_income: 15000 - employment_deductions: 25000 - output: - taxable_employment_income: 0 -- name: Specific deductions from employment (not pension contributions at this stage) - period: 2020 - absolute_error_margin: 0 - input: - employment_income: 15000 - pension_contributions: 1000 - employment_expenses: 2000 - output: - taxable_employment_income: 13000 -- name: Pension relief - period: 2020 - absolute_error_margin: 0 - input: - employment_income: 76000 - pension_contributions: 40000 - output: - pension_contributions_relief: 40000 -- name: Pension relief excessive - period: 2020 - absolute_error_margin: 0 - input: - employment_income: 2000000 - pension_contributions: 400000 - output: - pension_contributions_relief: 4000 -- name: Trading loss relief - period: 2020 - absolute_error_margin: 0 - input: - self_employment_income: 1000 - loss_relief: 2000 - output: - taxable_self_employment_income: 0 -- name: Trading loss relief of previous year - period: 2020 - absolute_error_margin: 0 - input: - self_employment_income: 1000 - loss_relief: - 2019: 2000 - output: - taxable_self_employment_income: 0 -- name: Trading loss relief doesn't offset other income - period: 2020 - absolute_error_margin: 0 - input: - self_employment_income: 1000 - employment_income: 1000 - loss_relief: 2000 - output: - taxable_self_employment_income: 0 - taxable_employment_income: 1000 -- name: Property income within allowance - period: 2020 - absolute_error_margin: 0 - input: - property_income: 1000 - output: - taxable_property_income: 0 -- name: Dividend income with deficiency relief - period: 2020 - absolute_error_margin: 0 - input: - dividend_income: 10000 - deficiency_relief: 1000 - output: - taxable_dividend_income: 9000 diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/relief.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/relief.yaml new file mode 100644 index 000000000..ba7d4d2fe --- /dev/null +++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/relief.yaml @@ -0,0 +1,663 @@ +- name: Deductions from employment + period: 2020 + absolute_error_margin: 0 + input: + employment_income: 15000 + employment_deductions: 5000 + output: + taxable_employment_income: 10000 +- name: Deductions from employment stay positive + period: 2020 + absolute_error_margin: 0 + input: + employment_income: 15000 + employment_deductions: 25000 + output: + taxable_employment_income: 0 +- name: Specific deductions from employment (not pension contributions at this stage) + period: 2020 + absolute_error_margin: 0 + input: + employment_income: 15000 + pension_contributions: 1000 + employment_expenses: 2000 + output: + taxable_employment_income: 13000 +- name: Pension relief + period: 2020 + absolute_error_margin: 0 + input: + employment_income: 76000 + pension_contributions: 40000 + output: + pension_contributions_relief: 40000 +- name: Pension relief excessive + period: 2020 + absolute_error_margin: 0 + input: + employment_income: 2000000 + pension_contributions: 400000 + output: + pension_contributions_relief: 4000 +- name: Trading loss relief + period: 2020 + absolute_error_margin: 0 + input: + self_employment_income: 1000 + loss_relief: 2000 + output: + taxable_self_employment_income: 0 +- name: Trading loss relief of previous year + period: 2020 + absolute_error_margin: 0 + input: + self_employment_income: 1000 + loss_relief: + 2019: 2000 + output: + taxable_self_employment_income: 0 +- name: Trading loss relief doesn't offset other income + period: 2020 + absolute_error_margin: 0 + input: + self_employment_income: 1000 + employment_income: 1000 + loss_relief: 2000 + output: + taxable_self_employment_income: 0 + taxable_employment_income: 1000 +- name: Property income within allowance + period: 2020 + absolute_error_margin: 0 + input: + property_income: 1000 + output: + taxable_property_income: 0 +- name: Dividend income with deficiency relief + period: 2020 + absolute_error_margin: 0 + input: + dividend_income: 10000 + deficiency_relief: 1000 + output: + taxable_dividend_income: 9000 + +# pension_contributions +- name: No pension contributions + period: 2024 + input: + private_pension_contributions: 0 + occupational_pension_contributions: 0 + output: + pension_contributions: 0 + +- name: Only private pension contributions + period: 2024 + input: + private_pension_contributions: 5000 + occupational_pension_contributions: 0 + output: + pension_contributions: 5000 + +- name: Only occupational pension contributions + period: 2024 + input: + private_pension_contributions: 0 + occupational_pension_contributions: 7500 + output: + pension_contributions: 7500 + +- name: Both types of pension contributions + period: 2024 + input: + private_pension_contributions: 3000 + occupational_pension_contributions: 4000 + output: + pension_contributions: 7000 + +- name: High contribution amounts + period: 2024 + input: + private_pension_contributions: 20000 + occupational_pension_contributions: 30000 + output: + pension_contributions: 50000 + +- name: Very low positive contributions + period: 2024 + input: + private_pension_contributions: 1 + occupational_pension_contributions: 1 + output: + pension_contributions: 2 + +- name: Uneven contributions + period: 2024 + input: + private_pension_contributions: 1234.56 + occupational_pension_contributions: 9876.54 + output: + pension_contributions: 11111.10 + +- name: Maximum allowed annual contributions (for 2023/2024 tax year) + period: 2024 + input: + private_pension_contributions: 40000 + occupational_pension_contributions: 20000 + output: + pension_contributions: 60000 + +# taxable_savings_interest_income +- name: No savings interest income + period: 2024 + input: + savings_interest_income: 0 + tax_free_savings_income: 0 + output: + taxable_savings_interest_income: 0 + +- name: Savings interest income fully covered by tax-free allowance + period: 2024 + input: + savings_interest_income: 1000 + tax_free_savings_income: 1000 + output: + taxable_savings_interest_income: 0 + +- name: Savings interest income partially taxable + period: 2024 + input: + savings_interest_income: 1500 + tax_free_savings_income: 1000 + output: + taxable_savings_interest_income: 500 + +- name: High savings interest income, standard tax-free allowance + period: 2024 + input: + savings_interest_income: 10000 + tax_free_savings_income: 1000 + output: + taxable_savings_interest_income: 9000 + +- name: Savings interest income, no tax-free allowance + period: 2024 + input: + savings_interest_income: 5000 + tax_free_savings_income: 0 + output: + taxable_savings_interest_income: 5000 + +- name: Very low positive savings interest income + period: 2024 + input: + savings_interest_income: 1 + tax_free_savings_income: 0 + output: + taxable_savings_interest_income: 1 + +- name: Tax-free allowance exceeds savings interest income + period: 2024 + input: + savings_interest_income: 500 + tax_free_savings_income: 1000 + output: + taxable_savings_interest_income: 0 + +- name: High values for both inputs + period: 2024 + input: + savings_interest_income: 100000 + tax_free_savings_income: 50000 + output: + taxable_savings_interest_income: 50000 + +- name: Decimal values + period: 2024 + input: + savings_interest_income: 1234.56 + tax_free_savings_income: 1000.00 + output: + taxable_savings_interest_income: 234.56 + +# loss_relief +- name: No trading losses + period: 2024 + input: + trading_loss: + 2023: 0 + 2024: 0 + output: + loss_relief: 0 + +- name: Current year trading loss only + period: 2024 + input: + trading_loss: + 2023: 0 + 2024: 5000 + output: + loss_relief: 5000 + +- name: Previous year trading loss only + period: 2024 + input: + trading_loss: + 2023: 3000 + 2024: 0 + output: + loss_relief: 3000 + +- name: Trading losses in both years + period: 2024 + input: + trading_loss: + 2023: 2500 + 2024: 3500 + output: + loss_relief: 6000 + +- name: High trading losses + period: 2024 + input: + trading_loss: + 2023: 50000 + 2024: 75000 + output: + loss_relief: 125000 + +- name: Very low positive trading losses + period: 2024 + input: + trading_loss: + 2023: 1 + 2024: 1 + output: + loss_relief: 2 + +- name: Uneven trading losses + period: 2024 + input: + trading_loss: + 2023: 1234.56 + 2024: 5678.90 + output: + loss_relief: 6913.46 + +- name: Large previous year loss, small current year loss + period: 2024 + input: + trading_loss: + 2023: 100000 + 2024: 1000 + output: + loss_relief: 101000 + +- name: Small previous year loss, large current year loss + period: 2024 + input: + trading_loss: + 2023: 1000 + 2024: 100000 + output: + loss_relief: 101000 + +# taxable_self_employment_income +- name: No self-employment income or deductions + period: 2024 + input: + self_employment_income: 0 + loss_relief: 0 + capital_allowances: 0 + trading_allowance: 0 + output: + taxable_self_employment_income: 0 + +- name: Self-employment income with no deductions + period: 2024 + input: + self_employment_income: 50000 + loss_relief: 0 + capital_allowances: 0 + trading_allowance: 0 + output: + taxable_self_employment_income: 50000 + +- name: Self-employment income fully offset by deductions + period: 2024 + input: + self_employment_income: 30000 + loss_relief: 10000 + capital_allowances: 15000 + trading_allowance: 5000 + output: + taxable_self_employment_income: 0 + +- name: Self-employment income partially offset by deductions + period: 2024 + input: + self_employment_income: 50000 + loss_relief: 5000 + capital_allowances: 10000 + trading_allowance: 1000 + output: + taxable_self_employment_income: 34000 + +- name: High self-employment income with some deductions + period: 2024 + input: + self_employment_income: 200000 + loss_relief: 20000 + capital_allowances: 30000 + trading_allowance: 1000 + output: + taxable_self_employment_income: 149000 + +- name: Low self-employment income with low deductions + period: 2024 + input: + self_employment_income: 1000 + loss_relief: 100 + capital_allowances: 200 + trading_allowance: 300 + output: + taxable_self_employment_income: 400 + +- name: Deductions exceed self-employment income + period: 2024 + input: + self_employment_income: 50000 + loss_relief: 30000 + capital_allowances: 25000 + trading_allowance: 1000 + output: + taxable_self_employment_income: 0 + +- name: Very high values + period: 2024 + input: + self_employment_income: 1000000 + loss_relief: 200000 + capital_allowances: 300000 + trading_allowance: 1000 + output: + taxable_self_employment_income: 499000 + +- name: Decimal values + period: 2024 + input: + self_employment_income: 50000.50 + loss_relief: 10000.25 + capital_allowances: 5000.75 + trading_allowance: 1000.00 + output: + taxable_self_employment_income: 33999.50 + +# taxable_property_income +- name: No property income or allowance + period: 2024 + input: + property_income: 0 + property_allowance: 0 + output: + taxable_property_income: 0 + +- name: Property income fully covered by allowance + period: 2024 + input: + property_income: 1000 + property_allowance: 1000 + output: + taxable_property_income: 0 + +- name: Property income partially taxable + period: 2024 + input: + property_income: 10000 + property_allowance: 1000 + output: + taxable_property_income: 9000 + +- name: High property income with standard allowance + period: 2024 + input: + property_income: 50000 + property_allowance: 1000 + output: + taxable_property_income: 49000 + +- name: Property income with no allowance + period: 2024 + input: + property_income: 5000 + property_allowance: 0 + output: + taxable_property_income: 5000 + +- name: Very low positive property income + period: 2024 + input: + property_income: 1 + property_allowance: 0 + output: + taxable_property_income: 1 + +- name: Property allowance exceeds income + period: 2024 + input: + property_income: 500 + property_allowance: 1000 + output: + taxable_property_income: 0 + +- name: High values for both income and allowance + period: 2024 + input: + property_income: 100000 + property_allowance: 50000 + output: + taxable_property_income: 50000 + +- name: Decimal values + period: 2024 + input: + property_income: 1234.56 + property_allowance: 1000.00 + output: + taxable_property_income: 234.56 + +# taxable_dividend_income +- name: No dividend income or deficiency relief + period: 2024 + input: + dividend_income: 0 + deficiency_relief: 0 + output: + taxable_dividend_income: 0 + +- name: Dividend income fully offset by deficiency relief + period: 2024 + input: + dividend_income: 5000 + deficiency_relief: 5000 + output: + taxable_dividend_income: 0 + +- name: Dividend income partially taxable + period: 2024 + input: + dividend_income: 10000 + deficiency_relief: 2000 + output: + taxable_dividend_income: 8000 + +- name: High dividend income with some deficiency relief + period: 2024 + input: + dividend_income: 50000 + deficiency_relief: 5000 + output: + taxable_dividend_income: 45000 + +- name: Dividend income with no deficiency relief + period: 2024 + input: + dividend_income: 15000 + deficiency_relief: 0 + output: + taxable_dividend_income: 15000 + +- name: Very low positive dividend income + period: 2024 + input: + dividend_income: 1 + deficiency_relief: 0 + output: + taxable_dividend_income: 1 + +- name: Deficiency relief exceeds dividend income + period: 2024 + input: + dividend_income: 3000 + deficiency_relief: 5000 + output: + taxable_dividend_income: 0 + +- name: High values for both dividend income and deficiency relief + period: 2024 + input: + dividend_income: 100000 + deficiency_relief: 40000 + output: + taxable_dividend_income: 60000 + +- name: Decimal values + period: 2024 + input: + dividend_income: 1234.56 + deficiency_relief: 234.56 + output: + taxable_dividend_income: 1000.00 + +# adjusted_net_income +- name: No income from any source + period: 2024 + input: + taxable_employment_income: 0 + taxable_pension_income: 0 + taxable_social_security_income: 0 + taxable_self_employment_income: 0 + taxable_property_income: 0 + taxable_savings_interest_income: 0 + taxable_dividend_income: 0 + taxable_miscellaneous_income: 0 + basic_income: 0 + output: + adjusted_net_income: 0 + +- name: Income from all sources + period: 2024 + input: + taxable_employment_income: 30000 + taxable_pension_income: 5000 + taxable_social_security_income: 2000 + taxable_self_employment_income: 10000 + taxable_property_income: 5000 + taxable_savings_interest_income: 1000 + taxable_dividend_income: 3000 + taxable_miscellaneous_income: 500 + basic_income: 0 + output: + adjusted_net_income: 56500 + +- name: Only employment income + period: 2024 + input: + taxable_employment_income: 40000 + taxable_pension_income: 0 + taxable_social_security_income: 0 + taxable_self_employment_income: 0 + taxable_property_income: 0 + taxable_savings_interest_income: 0 + taxable_dividend_income: 0 + taxable_miscellaneous_income: 0 + basic_income: 0 + output: + adjusted_net_income: 40000 + +- name: High income from multiple sources + period: 2024 + input: + taxable_employment_income: 100000 + taxable_pension_income: 50000 + taxable_social_security_income: 0 + taxable_self_employment_income: 75000 + taxable_property_income: 25000 + taxable_savings_interest_income: 10000 + taxable_dividend_income: 20000 + taxable_miscellaneous_income: 5000 + basic_income: 0 + output: + adjusted_net_income: 285000 + +- name: Low income from multiple sources + period: 2024 + input: + taxable_employment_income: 5000 + taxable_pension_income: 1000 + taxable_social_security_income: 500 + taxable_self_employment_income: 2000 + taxable_property_income: 1000 + taxable_savings_interest_income: 100 + taxable_dividend_income: 200 + taxable_miscellaneous_income: 50 + basic_income: 0 + output: + adjusted_net_income: 9850 + +- name: Decimal values + period: 2024 + input: + taxable_employment_income: 30000.50 + taxable_pension_income: 5000.25 + taxable_social_security_income: 2000.75 + taxable_self_employment_income: 10000.00 + taxable_property_income: 5000.50 + taxable_savings_interest_income: 1000.25 + taxable_dividend_income: 3000.75 + taxable_miscellaneous_income: 500.00 + basic_income: 0 + output: + adjusted_net_income: 56503.00 + +- name: With basic income included + period: 2024 + input: + gov.contrib.ubi_center.basic_income.interactions.include_in_taxable_income: true + taxable_employment_income: 30000 + taxable_pension_income: 5000 + taxable_social_security_income: 2000 + taxable_self_employment_income: 10000 + taxable_property_income: 5000 + taxable_savings_interest_income: 1000 + taxable_dividend_income: 3000 + taxable_miscellaneous_income: 500 + basic_income: 10000 + output: + adjusted_net_income: 66500 + +- name: Only basic income + period: 2024 + input: + gov.contrib.ubi_center.basic_income.interactions.include_in_taxable_income: true + taxable_employment_income: 0 + taxable_pension_income: 0 + taxable_social_security_income: 0 + taxable_self_employment_income: 0 + taxable_property_income: 0 + taxable_savings_interest_income: 0 + taxable_dividend_income: 0 + taxable_miscellaneous_income: 0 + basic_income: 10000 + output: + adjusted_net_income: 10000 \ No newline at end of file From 2045536dd4f0edfe8a69bd3a5dd3112eae321117 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Tue, 9 Jul 2024 18:04:36 -0400 Subject: [PATCH 2/7] fix: Add tests --- .../finance/tax/income_tax/liability.yaml | 52 ------- .../gov/hmrc/income_tax/liability.yaml | 134 ++++++++++++++++++ 2 files changed, 134 insertions(+), 52 deletions(-) delete mode 100644 policyengine_uk/tests/policy/baseline/finance/tax/income_tax/liability.yaml create mode 100644 policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/liability.yaml diff --git a/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/liability.yaml b/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/liability.yaml deleted file mode 100644 index 1176b56cc..000000000 --- a/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/liability.yaml +++ /dev/null @@ -1,52 +0,0 @@ -- name: Allowances are deducted to zero - period: 2020 - absolute_error_margin: 0 - input: - employment_income: 10000 - pension_income: 10000 - allowances: 20000 - output: - earned_taxable_income: 0 -- name: Earned income is split correctly - period: 2020 - absolute_error_margin: 0 - input: - earned_taxable_income: 100000 - output: - basic_rate_earned_income: 37500 - higher_rate_earned_income: 62500 - add_rate_earned_income: 0 -- name: Earned income is taxed correctly - period: 2020 - absolute_error_margin: 0 - input: - employment_income: 100000 - output: - allowances: 12500 - earned_taxable_income: 87500 - basic_rate_earned_income_tax: 7500 - higher_rate_earned_income_tax: 20000 - add_rate_earned_income_tax: 0 - earned_income_tax: 27500 - tax_band: "HIGHER" - taxed_income: 87500 -- name: Savings slice of basic rate band - period: 2020 - absolute_error_margin: 0 - input: - employment_income: 40000 - savings_interest_income: 15000 - output: - basic_rate_savings_income_pre_starter: 10000 - savings_starter_rate_income: 0 - basic_rate_savings_income: 10000 - savings_allowance: 500 - higher_rate_savings_income: 4500 - taxed_savings_income: 14500 -- name: Dividends taxed at the marginal rates - period: 2020 - absolute_error_margin: 0 - input: - dividend_income: 50000 - output: - dividend_income_tax: 6225 diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/liability.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/liability.yaml new file mode 100644 index 000000000..f90a32fe3 --- /dev/null +++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/liability.yaml @@ -0,0 +1,134 @@ +- name: Allowances are deducted to zero + period: 2020 + absolute_error_margin: 0 + input: + employment_income: 10000 + pension_income: 10000 + allowances: 20000 + output: + earned_taxable_income: 0 +- name: Earned income is split correctly + period: 2020 + absolute_error_margin: 0 + input: + earned_taxable_income: 100000 + output: + basic_rate_earned_income: 37500 + higher_rate_earned_income: 62500 + add_rate_earned_income: 0 +- name: Earned income is taxed correctly + period: 2020 + absolute_error_margin: 0 + input: + employment_income: 100000 + output: + allowances: 12500 + earned_taxable_income: 87500 + basic_rate_earned_income_tax: 7500 + higher_rate_earned_income_tax: 20000 + add_rate_earned_income_tax: 0 + earned_income_tax: 27500 + tax_band: "HIGHER" + taxed_income: 87500 +- name: Savings slice of basic rate band + period: 2020 + absolute_error_margin: 0 + input: + employment_income: 40000 + savings_interest_income: 15000 + output: + basic_rate_savings_income_pre_starter: 10000 + savings_starter_rate_income: 0 + basic_rate_savings_income: 10000 + savings_allowance: 500 + higher_rate_savings_income: 4500 + taxed_savings_income: 14500 +- name: Dividends taxed at the marginal rates + period: 2020 + absolute_error_margin: 0 + input: + dividend_income: 50000 + output: + dividend_income_tax: 6225 + +# taxed_dividend_income +- name: No dividend income + period: 2024 + input: + taxable_dividend_income: 0 + dividend_allowance: 1000 + output: + taxed_dividend_income: 0 + +- name: Dividend income below allowance + period: 2024 + input: + taxable_dividend_income: 500 + dividend_allowance: 1000 + output: + taxed_dividend_income: 0 + +- name: Dividend income equal to allowance + period: 2024 + input: + taxable_dividend_income: 1000 + dividend_allowance: 1000 + output: + taxed_dividend_income: 0 + +- name: Dividend income slightly above allowance + period: 2024 + input: + taxable_dividend_income: 1100 + dividend_allowance: 1000 + output: + taxed_dividend_income: 100 + +- name: High dividend income + period: 2024 + input: + taxable_dividend_income: 50000 + dividend_allowance: 2000 + output: + taxed_dividend_income: 48000 + +- name: Very high dividend income + period: 2024 + input: + taxable_dividend_income: 1000000 + dividend_allowance: 2000 + output: + taxed_dividend_income: 998000 + +- name: Dividend income with zero allowance + period: 2024 + input: + taxable_dividend_income: 5000 + dividend_allowance: 0 + output: + taxed_dividend_income: 5000 + +- name: Decimal values + period: 2024 + input: + taxable_dividend_income: 2500.50 + dividend_allowance: 2000.00 + output: + taxed_dividend_income: 500.50 + +- name: Allowance higher than income + period: 2024 + input: + taxable_dividend_income: 1000 + dividend_allowance: 2000 + output: + taxed_dividend_income: 0 + +- name: Very small positive difference + period: 2024 + input: + taxable_dividend_income: 1000.01 + dividend_allowance: 1000 + output: + taxed_dividend_income: 0.01 + From 33d13be423224e447248dcf64f38c5b7b57b8310 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Tue, 9 Jul 2024 18:20:57 -0400 Subject: [PATCH 3/7] chore: Changelog --- changelog_entry.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..74b9d49bb 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + added: + - Tests to income-related variables \ No newline at end of file From bea1a6318d0d65016de4d99108c7bc2b1f6cf962 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Tue, 9 Jul 2024 23:06:04 -0400 Subject: [PATCH 4/7] fix: Refactor pensions programs to use adds --- .../pension_contribution/pensions_programs.yaml | 10 ++++++++++ .../variables/gov/hmrc/income_tax/relief.py | 8 +------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 policyengine_uk/parameters/gov/hmrc/income_tax/reliefs/pension_contribution/pensions_programs.yaml diff --git a/policyengine_uk/parameters/gov/hmrc/income_tax/reliefs/pension_contribution/pensions_programs.yaml b/policyengine_uk/parameters/gov/hmrc/income_tax/reliefs/pension_contribution/pensions_programs.yaml new file mode 100644 index 000000000..b0ac8439a --- /dev/null +++ b/policyengine_uk/parameters/gov/hmrc/income_tax/reliefs/pension_contribution/pensions_programs.yaml @@ -0,0 +1,10 @@ +description: Pensions programs +values: + 0000-01-01: + - private_pension_contributions + - occupational_pension_contributions + +metadata: + unit: program + label: Refundable tax credits + period: year diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/relief.py b/policyengine_uk/variables/gov/hmrc/income_tax/relief.py index 210872237..645200416 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/relief.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/relief.py @@ -80,13 +80,7 @@ class pension_contributions(Variable): definition_period = YEAR unit = GBP - def formula(person, period, parameters): - PENSIONS = [ - "private_pension_contributions", - "occupational_pension_contributions", - ] - return add(person, period, PENSIONS) - + adds = "gov.hmrc.income_tax.reliefs.pension_contribution.pensions_programs" class pension_contributions_relief(Variable): value_type = float From 695331298326e53ceeec9fed47fa04c89e067aa5 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Tue, 9 Jul 2024 23:10:40 -0400 Subject: [PATCH 5/7] fix: Better match tests to folder structure --- .../tests/{policy/baseline/finance => integration}/income.yaml | 0 .../tests/{policy/baseline/finance/tax => integration}/tax.yaml | 0 .../baseline/{finance/tax => gov/hmrc}/income_tax/allowances.yaml | 0 .../baseline/{finance/tax => gov/hmrc}/income_tax/base.yaml | 0 .../baseline/{finance/tax => gov/hmrc}/income_tax/income_tax.yaml | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename policyengine_uk/tests/{policy/baseline/finance => integration}/income.yaml (100%) rename policyengine_uk/tests/{policy/baseline/finance/tax => integration}/tax.yaml (100%) rename policyengine_uk/tests/policy/baseline/{finance/tax => gov/hmrc}/income_tax/allowances.yaml (100%) rename policyengine_uk/tests/policy/baseline/{finance/tax => gov/hmrc}/income_tax/base.yaml (100%) rename policyengine_uk/tests/policy/baseline/{finance/tax => gov/hmrc}/income_tax/income_tax.yaml (100%) diff --git a/policyengine_uk/tests/policy/baseline/finance/income.yaml b/policyengine_uk/tests/integration/income.yaml similarity index 100% rename from policyengine_uk/tests/policy/baseline/finance/income.yaml rename to policyengine_uk/tests/integration/income.yaml diff --git a/policyengine_uk/tests/policy/baseline/finance/tax/tax.yaml b/policyengine_uk/tests/integration/tax.yaml similarity index 100% rename from policyengine_uk/tests/policy/baseline/finance/tax/tax.yaml rename to policyengine_uk/tests/integration/tax.yaml diff --git a/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/allowances.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances.yaml similarity index 100% rename from policyengine_uk/tests/policy/baseline/finance/tax/income_tax/allowances.yaml rename to policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances.yaml diff --git a/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/base.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/base.yaml similarity index 100% rename from policyengine_uk/tests/policy/baseline/finance/tax/income_tax/base.yaml rename to policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/base.yaml diff --git a/policyengine_uk/tests/policy/baseline/finance/tax/income_tax/income_tax.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml similarity index 100% rename from policyengine_uk/tests/policy/baseline/finance/tax/income_tax/income_tax.yaml rename to policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/income_tax.yaml From c2b4b483f8eb196f58d5e4f0eeb22169b31fe902 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Tue, 9 Jul 2024 23:11:19 -0400 Subject: [PATCH 6/7] chore: Lint --- policyengine_uk/variables/gov/hmrc/income_tax/relief.py | 1 + 1 file changed, 1 insertion(+) diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/relief.py b/policyengine_uk/variables/gov/hmrc/income_tax/relief.py index 645200416..e8c67861a 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/relief.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/relief.py @@ -82,6 +82,7 @@ class pension_contributions(Variable): adds = "gov.hmrc.income_tax.reliefs.pension_contribution.pensions_programs" + class pension_contributions_relief(Variable): value_type = float entity = Person From 4f45aa66344705820bdce7e986367ff94cf4bfd1 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Tue, 9 Jul 2024 23:38:40 -0400 Subject: [PATCH 7/7] chore: Add tests for capital gains tax --- .../capital_gains_tax/capital_gains_tax.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 policyengine_uk/tests/policy/baseline/gov/hmrc/capital_gains_tax/capital_gains_tax.yaml diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/capital_gains_tax/capital_gains_tax.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/capital_gains_tax/capital_gains_tax.yaml new file mode 100644 index 000000000..3640d97a5 --- /dev/null +++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/capital_gains_tax/capital_gains_tax.yaml @@ -0,0 +1,79 @@ +- name: No capital gains + period: 2024 + input: + adjusted_net_income: 0 + capital_gains: 0 + output: + capital_gains_tax: 0 + +- name: Capital gains below annual exempt amount + period: 2024 + input: + adjusted_net_income: 0 + capital_gains: 2_000 + output: + capital_gains_tax: 0 + +- name: Capital gains just above annual exempt amount + period: 2024 + input: + adjusted_net_income: 0 + capital_gains: 3_500 + output: + capital_gains_tax: 50 + +- name: Basic rate capital gains tax + period: 2024 + input: + adjusted_net_income: 20_000 + capital_gains: 23_000 + output: + capital_gains_tax: 2_230 + +- name: Higher rate capital gains tax + period: 2024 + input: + adjusted_net_income: 50_000 + capital_gains: 50_000 + output: + capital_gains_tax: 9_400 + +- name: Additional rate capital gains tax + period: 2024 + input: + adjusted_net_income: 150_000 + capital_gains: 100_000 + output: + capital_gains_tax: 19_400 + +- name: Mixed rates capital gains tax + period: 2024 + input: + adjusted_net_income: 35_000 + capital_gains: 40_000 + output: + capital_gains_tax: 7_130 + +- name: High capital gains, low income + period: 2024 + input: + adjusted_net_income: 10_000 + capital_gains: 200_000 + output: + capital_gains_tax: 36_630 + +- name: Very high capital gains and income + period: 2024 + input: + adjusted_net_income: 500_000 + capital_gains: 1_000_000 + output: + capital_gains_tax: 199_400 + +- name: Edge case, capital gains exactly equal to annual exempt amount + period: 2024 + input: + adjusted_net_income: 0 + capital_gains: 3_000 + output: + capital_gains_tax: 0 \ No newline at end of file