Skip to content

Commit

Permalink
Merge pull request #907 from PolicyEngine/fix/include_other_credits
Browse files Browse the repository at this point in the history
SPI model fixes
  • Loading branch information
nikhilwoodruff authored Jul 27, 2024
2 parents 88bde84 + ca5c835 commit 3a36c59
Show file tree
Hide file tree
Showing 38 changed files with 3,790 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ policyengine_uk/calibration/*.h5
**/*.log
**/ukmod.json
*.ipynb

!test9.ipynb
11 changes: 11 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- bump: minor
changes:
added:
- Tax on excess pension contributions
fixed:
- Include Scottish income tax calculation within overall UK income tax calculation
- Apply allowances to all types of income
- Prevent negative income tax output
- Update Dividend Allowance values
- Correct Starter Rate for Savings taper structure
- Prevent calculation errors due to empty extra dividend bracket with conflicting rates
31 changes: 25 additions & 6 deletions policyengine_uk/data/datasets/spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,39 @@ def generate(self):
)
data["savings_interest_income"] = df.INCBBS
data["property_income"] = df.INCPROP
data["employment_income"] = df.PAY
data["employment_income"] = df.PAY + df.EPB
data["employment_expenses"] = df.EXPS
data["pension_income"] = df.PENSION
data["pension_contributions"] = df.PENSRLF - df.PSAV_XS
data["private_pension_income"] = df.PENSION
# The below underestimates those with high amounts of excess pension
# savings, as it does not include the Annual Allowance
data["private_pension_contributions"] = df.PSAV_XS
data["pension_contributions_relief"] = df.PENSRLF
data["self_employment_income"] = df.PROFITS
# HMRC seems to assume the trading allowance is already deducted (per record inspection of SREF 15494988 in 2020-21)
# HMRC seems to assume the trading and property allowance are already deducted
# (per record inspection of SREF 15494988 in 2020-21)
data["trading_allowance"] = np.zeros(len(df))
data["property_allowance"] = np.zeros(len(df))
data["savings_starter_rate_income"] = np.zeros(len(df))
data["capital_allowances"] = df.CAPALL
data["loss_relief"] = df.LOSSBF
data["is_SP_age"] = df.SPA == 1
data["state_pension"] = df.SRP
data["other_tax_credits"] = df.TAX_CRED
data["miscellaneous_income"] = df.MOTHINC
data["miscellaneous_income"] = (
df.MOTHINC
+ df.INCPBEN
+ df.OSSBEN
+ df.TAXTERM
+ df.UBISJA
+ df.OTHERINC
)
data["gift_aid"] = df.GIFTAID + df.GIFTINV
data["other_investment_income"] = df.OTHERINV
data["covenanted_payments"] = df.COVNTS
data["other_deductions"] = df.MOTHDED + df.DEFICIEN
data["married_couples_allowance"] = df.MCAS
data["blind_persons_allowance"] = df.BPADUE
data["marriage_allowance"] = np.where(df.MAIND == 1, 1_250, 0)

for field in data:
data[field] = {self.time_period: data[field]}
Expand All @@ -71,7 +90,7 @@ def generate(self):


class SPI_2020_21(SPI):
spi_data_file_path = "~/Downloads/UKDA-9121-tab/tab/put2021uk.tab"
spi_data_file_path = "~/Desktop/put2021uk.tab"
file_path = STORAGE_FOLDER / "spi_2020_21.h5"
label = "SPI 2020-21"
name = "spi_2020_21"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
description: Amount of dividend income untaxed per year
values:
2015-06-05: 2_000
2016-04-06: 5_000
2018-04-06: 2_000
2023-04-06: 1_000
2024-04-06: 500
metadata:
name: dividend_allowance
label: Dividend Allowance
period: year
unit: currency-GBP
reference: https://www.gov.uk/government/publications/rates-and-allowances-income-tax/income-tax-rates-and-allowances-current-and-past
reference:
- title: Tax on dividends
href: https://www.gov.uk/tax-on-dividends
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ values:
0000-01-01:
- taxable_savings_interest_income
- taxable_dividend_income
- allowances
- received_allowances_earned_income
- marriage_allowance
- pension_contributions_relief

metadata:
unit: list
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: All variables that are added together to calculate total income tax
metadata:
label: Additive components of total income tax
unit: list
values:
0000-01-01:
- earned_income_tax
- savings_income_tax
- dividend_income_tax
- CB_HITC
- private_pension_contributions_tax
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description: All variables that are subtracted from the base amount to calculate total income tax
metadata:
label: Subtractive components of total income tax
unit: list
values:
0000-01-01:
- capped_mcad
- other_tax_credits
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ brackets:
label: Extra dividend tax bracket rate
unit: /1
values:
2015-06-05: 0.3935
2015-06-01: 0.381
2022-06-05: 0.3935
threshold:
description: The lower threshold for the extra dividend bracket rate.
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description: Starter Rate for Savings phase-out rate
values:
2014-04-06: 1
metadata:
unit: currency_GBP
description: Rate, above the max Personal Allowance, at which Starter Rate for Savings total amount phases out, for each additional pound of non-savings income
reference:
- title: Tax on savings interest
href: https://www.gov.uk/apply-tax-free-interest-on-savings
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ brackets:
values:
2018-06-01: 2_000
2019-06-01: 2_049
2020-06-01: 2_085
2020-03-04:
value: 2_085
reference:
- title: "Capture in full: Tax rates 2020/21; Spring Budget 2020"
href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf
2022-01-01:
value: 2_162
reference:
Expand All @@ -53,7 +57,11 @@ brackets:
unit: currency-GBP
values:
2018-06-01: 12_150
2020-06-01: 12_444
2020-03-04:
value: 12_444
reference:
- title: "Capture in full: Tax rates 2020/21; Spring Budget 2020"
href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf
2021-06-01: 12_658
2022-01-01:
value: 13_118
Expand Down Expand Up @@ -81,7 +89,11 @@ brackets:
values:
2018-06-01: 31_580
2019-06-01: 30_930
2020-06-01: 30_930
2020-03-04:
value: 30_930
reference:
- title: "Capture in full: Tax rates 2020/21; Spring Budget 2020"
href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf
2022-01-01:
value: 31_092
reference:
Expand All @@ -99,6 +111,11 @@ brackets:
unit: /1
values:
2018-06-01: 0.47
2020-03-04:
value: 0.46
reference:
- title: "Capture in full: Tax rates 2020/21; Spring Budget 2020"
href: https://taxscape.deloitte.com/taxtables/deloitte-uk-tax-rates-2020-21--updated.pdf
threshold:
description: The threshold at which an individual pays the Scottish additional
rate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
person:
age: 30
employment_income: 30_000
pension_contributions: 1_000
private_pension_contributions: 1_000
weekly_hours: 20
benunits:
benunit:
Expand All @@ -30,7 +30,7 @@
person:
age: 30
employment_income: 3_000
pension_contributions: 1_000
private_pension_contributions: 1_000
weekly_hours: 20
benunits:
benunit:
Expand Down Expand Up @@ -85,7 +85,7 @@
age: 20
weekly_hours: 25
employment_income: 12_000
pension_contributions: 57
private_pension_contributions: 57
dla_m: 62.55 * 52
uc_limited_capability_for_WRA: true
person_2:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
- name: Full savings starter rate allowance
period: 2024
input:
basic_rate_savings_income_pre_starter: 5_000
earned_taxable_income: 15_000
taxable_dividend_income: 0
output:
savings_starter_rate_income: 5_000

- name: Partial savings starter rate allowance
period: 2024
input:
basic_rate_savings_income_pre_starter: 4_000
earned_taxable_income: 19_000
taxable_dividend_income: 0
output:
savings_starter_rate_income: 3_570

- name: No savings starter rate allowance due to high non-savings income
period: 2024
input:
basic_rate_savings_income_pre_starter: 2_000
earned_taxable_income: 22_000
taxable_dividend_income: 1_000
output:
savings_starter_rate_income: 0

- name: Savings income exceeds allowance
period: 2024
input:
basic_rate_savings_income_pre_starter: 10_000
earned_taxable_income: 16_000
taxable_dividend_income: 0
output:
savings_starter_rate_income: 5_000

- name: Partial allowance with dividend income
period: 2024
input:
basic_rate_savings_income_pre_starter: 5_000
earned_taxable_income: 16_000
taxable_dividend_income: 2_000
output:
savings_starter_rate_income: 4_570
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
period: 2024
input: {}
output:
dividend_allowance: 2000.0
dividend_allowance: 500.0

- name: Allowances Applicable to Adjusted Net Income
period: 2024
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
- name: Received allowances with low income
period: 2024
input:
received_allowances_earned_income: 8_000
received_allowances_savings_income: 1_000
received_allowances_dividend_income: 500
output:
received_allowances: 9_500

- name: Received allowances with medium income
period: 2024
input:
received_allowances_earned_income: 25_000
received_allowances_savings_income: 3_000
received_allowances_dividend_income: 2_000
output:
received_allowances: 30_000

- name: Received allowances with high income
period: 2024
input:
received_allowances_earned_income: 80_000
received_allowances_savings_income: 10_000
received_allowances_dividend_income: 5_000
output:
received_allowances: 95_000

- name: Received allowances with uneven amounts
period: 2024
input:
received_allowances_earned_income: 42_567.50
received_allowances_savings_income: 3_789.25
received_allowances_dividend_income: 1_234.75
output:
received_allowances: 47_591.50

- name: Received allowances with zero savings and dividend income
period: 2024
input:
received_allowances_earned_income: 50_000
received_allowances_savings_income: 0
received_allowances_dividend_income: 0
output:
received_allowances: 50_000
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
- name: Dividend income less than remaining allowance
period: 2024
input:
allowances: 12_570
received_allowances_earned_income: 8_000
received_allowances_savings_income: 2_000
taxable_dividend_income: 2_000
output:
received_allowances_dividend_income: 2_000

- name: Dividend income equal to remaining allowance
period: 2024
input:
allowances: 12_570
received_allowances_earned_income: 10_000
received_allowances_savings_income: 570
taxable_dividend_income: 2_000
output:
received_allowances_dividend_income: 2_000

- name: Dividend income greater than remaining allowance
period: 2024
input:
allowances: 12_570
received_allowances_earned_income: 11_000
received_allowances_savings_income: 1_000
taxable_dividend_income: 1_000
output:
received_allowances_dividend_income: 570

- name: No remaining allowance
period: 2024
input:
allowances: 12_570
received_allowances_earned_income: 10_570
received_allowances_savings_income: 2_000
taxable_dividend_income: 1_000
output:
received_allowances_dividend_income: 0

- name: Negative taxable dividend income
period: 2024
input:
allowances: 12_570
received_allowances_earned_income: 10_000
received_allowances_savings_income: 1_000
taxable_dividend_income: -500
output:
received_allowances_dividend_income: 0

- name: Negative remaining allowance
period: 2024
input:
allowances: 12_570
received_allowances_earned_income: 11_000
received_allowances_savings_income: 2_000
taxable_dividend_income: 1_000
output:
received_allowances_dividend_income: 0
Loading

0 comments on commit 3a36c59

Please sign in to comment.