Skip to content

Commit de23951

Browse files
hua7450claude
andcommitted
Fix Kansas TANF implementation issues from review
- Fix broken KEESM reference URLs (case sensitivity: EES/KEESM/Current) - Optimize code pattern: combine add() calls in ks_tanf_gross_income_eligible.py - Add integration tests: multiple earners (Case 7), large family of 5 (Case 8) - Add boundary tests: work expense at $89 and $91 thresholds - Apply black formatting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 257cf57 commit de23951

File tree

6 files changed

+135
-10
lines changed

6 files changed

+135
-10
lines changed

policyengine_us/parameters/gov/states/ks/dcf/tanf/resource_limit/amount.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metadata:
88
period: month
99
label: Kansas TANF resource limit
1010
reference:
11+
- title: K.A.R. 30-4-105 - Resources
12+
href: https://www.law.cornell.edu/regulations/kansas/K-A-R-30-4-105
1113
- title: KEESM 5110 - Resource Limitation
12-
href: https://content.dcf.ks.gov/ees/keesm/current/keesm5110.htm
13-
- title: KEESM 5000 - Resources
14-
href: https://content.dcf.ks.gov/ees/keesm/current/keesm5000.htm
14+
href: https://content.dcf.ks.gov/EES/KEESM/Current/keesm5110.htm

policyengine_us/parameters/gov/states/ks/dcf/tanf/work_expense_deduction/amount.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metadata:
88
period: month
99
label: Kansas TANF work expense deduction
1010
reference:
11-
- title: KEESM 8151 - Deduction From Earned Income
12-
href: https://content.dcf.ks.gov/ees/keesm/robo10-17/keesm8151.htm
1311
- title: K.A.R. 30-4-110 - Income
1412
href: https://www.law.cornell.edu/regulations/kansas/K-A-R-30-4-110
13+
- title: KEESM 8151 - Deduction From Earned Income
14+
href: https://content.dcf.ks.gov/EES/KEESM/Current/keesm8151.htm

policyengine_us/tests/policy/baseline/gov/states/ks/dcf/tanf/integration.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,98 @@
228228
ks_tanf_eligible: true
229229
# Benefit: 386 - 124 = 262
230230
ks_tanf: 262
231+
232+
- name: Case 7, household with two earners.
233+
period: 2025-01
234+
input:
235+
people:
236+
person1:
237+
age: 30
238+
employment_income_before_lsr: 3_600 # $300/month
239+
person2:
240+
age: 28
241+
employment_income_before_lsr: 2_400 # $200/month
242+
person3:
243+
age: 5
244+
is_tax_unit_dependent: true
245+
spm_units:
246+
spm_unit:
247+
members: [person1, person2, person3]
248+
spm_unit_cash_assets: 800
249+
tax_units:
250+
tax_unit:
251+
members: [person1, person2, person3]
252+
households:
253+
household:
254+
members: [person1, person2, person3]
255+
state_code: KS
256+
output:
257+
# Two earners - income is summed at SPM unit level
258+
# Person1 gross: $300/month, Person2 gross: $200/month
259+
# Combined gross earned: $500/month
260+
# Work expense: $90 (applied once to combined total)
261+
# Remainder: $500 - $90 = $410
262+
# 60% disregard: $410 * 0.60 = $246
263+
# Total deductions: $90 + $246 = $336
264+
# Countable earned: $500 - $336 = $164
265+
spm_unit_size: 3
266+
ks_tanf_earned_income_deductions: 336
267+
ks_tanf_countable_income: 164
268+
ks_tanf_maximum_benefit: 386
269+
# Gross ($500) < 30% FPL for family of 3 (~$670)
270+
ks_tanf_gross_income_eligible: true
271+
ks_tanf_income_eligible: true
272+
ks_tanf_resources_eligible: true
273+
ks_tanf_eligible: true
274+
# Benefit: 386 - 164 = 222
275+
ks_tanf: 222
276+
277+
- name: Case 8, large family of 5.
278+
period: 2025-01
279+
input:
280+
people:
281+
adult1:
282+
age: 35
283+
employment_income_before_lsr: 7_200 # $600/month
284+
adult2:
285+
age: 32
286+
child1:
287+
age: 12
288+
is_tax_unit_dependent: true
289+
child2:
290+
age: 8
291+
is_tax_unit_dependent: true
292+
child3:
293+
age: 4
294+
is_tax_unit_dependent: true
295+
spm_units:
296+
spm_unit:
297+
members: [adult1, adult2, child1, child2, child3]
298+
spm_unit_cash_assets: 1_500
299+
tax_units:
300+
tax_unit:
301+
members: [adult1, adult2, child1, child2, child3]
302+
households:
303+
household:
304+
members: [adult1, adult2, child1, child2, child3]
305+
state_code: KS
306+
output:
307+
# Large family tests the additional-person formula for 5+ members
308+
# Payment standard for 5: $454 + $61 = $515
309+
# Gross earned: $7,200/year = $600/month
310+
# Work expense: $90
311+
# Remainder: $600 - $90 = $510
312+
# 60% disregard: $510 * 0.60 = $306
313+
# Total deductions: $90 + $306 = $396
314+
# Countable: $600 - $396 = $204
315+
spm_unit_size: 5
316+
ks_tanf_earned_income_deductions: 396
317+
ks_tanf_countable_income: 204
318+
ks_tanf_maximum_benefit: 515
319+
# Gross ($600) < 30% FPL for family of 5 (~$890)
320+
ks_tanf_gross_income_eligible: true
321+
ks_tanf_income_eligible: true
322+
ks_tanf_resources_eligible: true
323+
ks_tanf_eligible: true
324+
# Benefit: 515 - 204 = 311
325+
ks_tanf: 311

policyengine_us/tests/policy/baseline/gov/states/ks/dcf/tanf/ks_tanf_earned_income_deductions.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,27 @@
6969
# 60% disregard: 910 * 0.60 = 546
7070
# Total: 90 + 546 = 636
7171
ks_tanf_earned_income_deductions: 636
72+
73+
- name: Case 7, earned income at $89 (just below $90 threshold).
74+
period: 2025-01
75+
input:
76+
state_code: KS
77+
tanf_gross_earned_income: 89
78+
output:
79+
# Work expense capped at gross: min(89, 90) = 89
80+
# Remainder: max(89 - 89, 0) = 0
81+
# 60% disregard: 0 * 0.60 = 0
82+
# Total: 89 + 0 = 89
83+
ks_tanf_earned_income_deductions: 89
84+
85+
- name: Case 8, earned income at $91 (just above $90 threshold).
86+
period: 2025-01
87+
input:
88+
state_code: KS
89+
tanf_gross_earned_income: 91
90+
output:
91+
# Work expense: min(91, 90) = 90
92+
# Remainder: max(91 - 90, 0) = 1
93+
# 60% disregard: 1 * 0.60 = 0.60
94+
# Total: 90 + 0.60 = 90.60
95+
ks_tanf_earned_income_deductions: 90.6

policyengine_us/variables/gov/states/ks/dcf/tanf/ks_tanf_eligible.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
class ks_tanf_eligible(Variable):
55
value_type = bool
66
entity = SPMUnit
7-
label = "Eligible for Kansas Temporary Assistance for Needy Families (TANF)"
7+
label = (
8+
"Eligible for Kansas Temporary Assistance for Needy Families (TANF)"
9+
)
810
definition_period = MONTH
911
reference = (
1012
"https://www.law.cornell.edu/regulations/kansas/K-A-R-30-4-70",
@@ -19,7 +21,9 @@ def formula(spm_unit, period, parameters):
1921
has_eligible_member = (
2022
add(spm_unit, period, ["is_person_demographic_tanf_eligible"]) > 0
2123
)
22-
gross_income_eligible = spm_unit("ks_tanf_gross_income_eligible", period)
24+
gross_income_eligible = spm_unit(
25+
"ks_tanf_gross_income_eligible", period
26+
)
2327
net_income_eligible = spm_unit("ks_tanf_income_eligible", period)
2428
resources_eligible = spm_unit("ks_tanf_resources_eligible", period)
2529
return (

policyengine_us/variables/gov/states/ks/dcf/tanf/ks_tanf_gross_income_eligible.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class ks_tanf_gross_income_eligible(Variable):
1515
def formula(spm_unit, period, parameters):
1616
# Per K.S.A. 39-709 and Kansas TANF State Plan:
1717
# Gross income must be less than 30% of Federal Poverty Level
18-
gross_earned = add(spm_unit, period, ["tanf_gross_earned_income"])
19-
gross_unearned = add(spm_unit, period, ["tanf_gross_unearned_income"])
20-
gross_income = gross_earned + gross_unearned
18+
gross_income = add(
19+
spm_unit,
20+
period,
21+
["tanf_gross_earned_income", "tanf_gross_unearned_income"],
22+
)
2123
# Get FPL for family size
2224
family_size = spm_unit("spm_unit_size", period.this_year)
2325
state_group = spm_unit.household("state_group_str", period.this_year)

0 commit comments

Comments
 (0)