Skip to content

Commit f44b543

Browse files
vahid-ahmadiclaudeMaxGhenis
authored
Remove pass-through allowance variables (#414) (#1640)
* Remove pass-through allowance variables (#414) `trading_allowance`, `property_allowance`, and `dividend_allowance` variables each just returned their same-named parameter. Callers (`trading_allowance_deduction`, `property_allowance_deduction`, `taxable_property_income`, `taxed_dividend_income`) now read the parameter directly. The `taxable_self_employment_income` deductions list now references `trading_allowance_deduction` (the capped amount actually deductible against self-employment income) instead of the raw allowance. This gives identical taxable-income outputs since the pre-existing `max_(0, ...)` clamp already absorbed any over-deduction. Tests that previously injected these variables as inputs now override the corresponding parameter path. The obsolete test that asserted the default `dividend_allowance` value is dropped since the variable no longer exists. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Use allowance deduction variables in taxable income * Format carbon tax notebook --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Max Ghenis <mghenis@gmail.com>
1 parent cbff36d commit f44b543

14 files changed

Lines changed: 70 additions & 86 deletions

File tree

changelog.d/414.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Remove `trading_allowance`, `property_allowance`, and `dividend_allowance` variables that were pure pass-throughs around their same-named parameters. Callers now read the parameter directly, and the `taxable_self_employment_income` deductions list references `trading_allowance_deduction` (the capped amount actually deductible against self-employment income) rather than the raw allowance.

docs/book/programs/contrib/ubi-center/carbon-tax.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@
978978
" yaxis_title=None,\n",
979979
" width=800,\n",
980980
" height=600,\n",
981-
")\n"
981+
")"
982982
]
983983
}
984984
],

policyengine_uk/parameters/gov/hmrc/income_tax/bases/taxable_self_employment_income_deductions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ values:
33
0000-01-01:
44
- loss_relief
55
- capital_allowances
6-
- trading_allowance
6+
- trading_allowance_deduction
77
metadata:
88
unit: list
99
label: Deductions from self-employment income

policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/allowances/is_allowance_eligible.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,26 @@
3939
- name: Trading Allowance Deduction
4040
period: 2024
4141
input:
42-
trading_allowance: 2000
42+
gov.hmrc.income_tax.allowances.trading_allowance: 2000
4343
self_employment_income: 1500
44-
output:
44+
output:
4545
trading_allowance_deduction: 1500.0
4646

4747
- name: Property Allowance Deduction
4848
period: 2024
4949
input:
5050
property_income: 3000
51-
property_allowance: 1000
52-
output:
51+
gov.hmrc.income_tax.allowances.property_allowance: 1000
52+
output:
5353
property_allowance_deduction: 1000.0
5454

5555
- name: Savings Allowance
5656
period: 2024
5757
input:
5858
tax_band: STARTER
59-
output:
59+
output:
6060
savings_allowance: 1000.0
6161

62-
- name: Dividend Allowance
63-
period: 2024
64-
input: {}
65-
output:
66-
dividend_allowance: 500.0
67-
6862
- name: Allowances Applicable to Adjusted Net Income
6963
period: 2024
7064
input:

policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxable_property_income.yaml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,78 @@
22
period: 2024
33
input:
44
property_income: 0
5-
property_allowance: 0
5+
gov.hmrc.income_tax.allowances.property_allowance: 0
66
output:
77
taxable_property_income: 0
88

99
- name: Property income fully covered by allowance
1010
period: 2024
1111
input:
1212
property_income: 1000
13-
property_allowance: 1000
13+
gov.hmrc.income_tax.allowances.property_allowance: 1000
1414
output:
1515
taxable_property_income: 0
1616

1717
- name: Property income partially taxable
1818
period: 2024
1919
input:
2020
property_income: 10000
21-
property_allowance: 1000
21+
gov.hmrc.income_tax.allowances.property_allowance: 1000
2222
output:
2323
taxable_property_income: 9000
2424

2525
- name: High property income with standard allowance
2626
period: 2024
2727
input:
2828
property_income: 50000
29-
property_allowance: 1000
29+
gov.hmrc.income_tax.allowances.property_allowance: 1000
3030
output:
3131
taxable_property_income: 49000
3232

3333
- name: Property income with no allowance
3434
period: 2024
3535
input:
3636
property_income: 5000
37-
property_allowance: 0
37+
gov.hmrc.income_tax.allowances.property_allowance: 0
3838
output:
3939
taxable_property_income: 5000
4040

4141
- name: Very low positive property income
4242
period: 2024
4343
input:
4444
property_income: 1
45-
property_allowance: 0
45+
gov.hmrc.income_tax.allowances.property_allowance: 0
4646
output:
4747
taxable_property_income: 1
4848

4949
- name: Property allowance exceeds income
5050
period: 2024
5151
input:
5252
property_income: 500
53-
property_allowance: 1000
53+
gov.hmrc.income_tax.allowances.property_allowance: 1000
5454
output:
5555
taxable_property_income: 0
5656

5757
- name: High values for both income and allowance
5858
period: 2024
5959
input:
6060
property_income: 100000
61-
property_allowance: 50000
61+
gov.hmrc.income_tax.allowances.property_allowance: 50000
6262
output:
6363
taxable_property_income: 50000
6464

6565
- name: Decimal values
6666
period: 2024
6767
input:
6868
property_income: 1234.56
69-
property_allowance: 1000.00
69+
gov.hmrc.income_tax.allowances.property_allowance: 1000.00
7070
output:
71-
taxable_property_income: 234.56
71+
taxable_property_income: 234.56
72+
73+
- name: Pre-net property income can override allowance deduction
74+
period: 2024
75+
input:
76+
property_income: 1234.56
77+
property_allowance_deduction: 0
78+
output:
79+
taxable_property_income: 1234.56

policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxable_self_employment_income.yaml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
self_employment_income: 0
3232
loss_relief: 0
3333
capital_allowances: 0
34-
trading_allowance: 0
34+
gov.hmrc.income_tax.allowances.trading_allowance: 0
3535
output:
3636
taxable_self_employment_income: 0
3737

@@ -41,7 +41,7 @@
4141
self_employment_income: 50000
4242
loss_relief: 0
4343
capital_allowances: 0
44-
trading_allowance: 0
44+
gov.hmrc.income_tax.allowances.trading_allowance: 0
4545
output:
4646
taxable_self_employment_income: 50000
4747

@@ -51,7 +51,7 @@
5151
self_employment_income: 30000
5252
loss_relief: 10000
5353
capital_allowances: 15000
54-
trading_allowance: 5000
54+
gov.hmrc.income_tax.allowances.trading_allowance: 5000
5555
output:
5656
taxable_self_employment_income: 0
5757

@@ -61,7 +61,7 @@
6161
self_employment_income: 50000
6262
loss_relief: 5000
6363
capital_allowances: 10000
64-
trading_allowance: 1000
64+
gov.hmrc.income_tax.allowances.trading_allowance: 1000
6565
output:
6666
taxable_self_employment_income: 34000
6767

@@ -71,7 +71,7 @@
7171
self_employment_income: 200000
7272
loss_relief: 20000
7373
capital_allowances: 30000
74-
trading_allowance: 1000
74+
gov.hmrc.income_tax.allowances.trading_allowance: 1000
7575
output:
7676
taxable_self_employment_income: 149000
7777

@@ -81,7 +81,7 @@
8181
self_employment_income: 1000
8282
loss_relief: 100
8383
capital_allowances: 200
84-
trading_allowance: 300
84+
gov.hmrc.income_tax.allowances.trading_allowance: 300
8585
output:
8686
taxable_self_employment_income: 400
8787

@@ -91,7 +91,7 @@
9191
self_employment_income: 50000
9292
loss_relief: 30000
9393
capital_allowances: 25000
94-
trading_allowance: 1000
94+
gov.hmrc.income_tax.allowances.trading_allowance: 1000
9595
output:
9696
taxable_self_employment_income: 0
9797

@@ -101,7 +101,7 @@
101101
self_employment_income: 1000000
102102
loss_relief: 200000
103103
capital_allowances: 300000
104-
trading_allowance: 1000
104+
gov.hmrc.income_tax.allowances.trading_allowance: 1000
105105
output:
106106
taxable_self_employment_income: 499000
107107

@@ -111,6 +111,16 @@
111111
self_employment_income: 50000.50
112112
loss_relief: 10000.25
113113
capital_allowances: 5000.75
114-
trading_allowance: 1000.00
114+
gov.hmrc.income_tax.allowances.trading_allowance: 1000.00
115115
output:
116-
taxable_self_employment_income: 33999.50
116+
taxable_self_employment_income: 33999.50
117+
118+
- name: Pre-net self-employment income can override trading allowance deduction
119+
period: 2024
120+
input:
121+
self_employment_income: 1234.56
122+
loss_relief: 0
123+
capital_allowances: 0
124+
trading_allowance_deduction: 0
125+
output:
126+
taxable_self_employment_income: 1234.56

policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxed_dividend_income.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
period: 2024
33
input:
44
taxable_dividend_income: 0
5-
dividend_allowance: 1000
5+
gov.hmrc.income_tax.allowances.dividend_allowance: 1000
66
# Nullify Personal Allowance for testing purposes
77
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
88
output:
@@ -12,7 +12,7 @@
1212
period: 2024
1313
input:
1414
taxable_dividend_income: 500
15-
dividend_allowance: 1000
15+
gov.hmrc.income_tax.allowances.dividend_allowance: 1000
1616
# Nullify Personal Allowance for testing purposes
1717
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
1818
output:
@@ -22,7 +22,7 @@
2222
period: 2024
2323
input:
2424
taxable_dividend_income: 1000
25-
dividend_allowance: 1000
25+
gov.hmrc.income_tax.allowances.dividend_allowance: 1000
2626
# Nullify Personal Allowance for testing purposes
2727
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
2828
output:
@@ -32,7 +32,7 @@
3232
period: 2024
3333
input:
3434
taxable_dividend_income: 1100
35-
dividend_allowance: 1000
35+
gov.hmrc.income_tax.allowances.dividend_allowance: 1000
3636
# Nullify Personal Allowance for testing purposes
3737
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
3838
output:
@@ -42,7 +42,7 @@
4242
period: 2024
4343
input:
4444
taxable_dividend_income: 50000
45-
dividend_allowance: 2000
45+
gov.hmrc.income_tax.allowances.dividend_allowance: 2000
4646
# Nullify Personal Allowance for testing purposes
4747
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
4848
output:
@@ -52,7 +52,7 @@
5252
period: 2024
5353
input:
5454
taxable_dividend_income: 1000000
55-
dividend_allowance: 2000
55+
gov.hmrc.income_tax.allowances.dividend_allowance: 2000
5656
# Nullify Personal Allowance for testing purposes
5757
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
5858
output:
@@ -62,7 +62,7 @@
6262
period: 2024
6363
input:
6464
taxable_dividend_income: 5000
65-
dividend_allowance: 0
65+
gov.hmrc.income_tax.allowances.dividend_allowance: 0
6666
# Nullify Personal Allowance for testing purposes
6767
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
6868
output:
@@ -72,7 +72,7 @@
7272
period: 2024
7373
input:
7474
taxable_dividend_income: 2500.50
75-
dividend_allowance: 2000.00
75+
gov.hmrc.income_tax.allowances.dividend_allowance: 2000.00
7676
# Nullify Personal Allowance for testing purposes
7777
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
7878
output:
@@ -82,7 +82,7 @@
8282
period: 2024
8383
input:
8484
taxable_dividend_income: 1000
85-
dividend_allowance: 2000
85+
gov.hmrc.income_tax.allowances.dividend_allowance: 2000
8686
# Nullify Personal Allowance for testing purposes
8787
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
8888
output:
@@ -92,7 +92,7 @@
9292
period: 2024
9393
input:
9494
taxable_dividend_income: 1000.01
95-
dividend_allowance: 1000
95+
gov.hmrc.income_tax.allowances.dividend_allowance: 1000
9696
# Nullify Personal Allowance for testing purposes
9797
gov.hmrc.income_tax.allowances.personal_allowance.amount: 0
9898
output:

policyengine_uk/variables/gov/hmrc/income_tax/allowances/dividend_allowance.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

policyengine_uk/variables/gov/hmrc/income_tax/allowances/property_allowance.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

policyengine_uk/variables/gov/hmrc/income_tax/allowances/property_allowance_deduction.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class property_allowance_deduction(Variable):
1010
unit = GBP
1111

1212
def formula(person, period, parameters):
13+
property_allowance = parameters(
14+
period
15+
).gov.hmrc.income_tax.allowances.property_allowance
1316
return min_(
1417
person("property_income", period),
15-
person("property_allowance", period),
18+
property_allowance,
1619
)

0 commit comments

Comments
 (0)