Skip to content

Commit

Permalink
Merge pull request #596 from Gary-Community-Ventures/feat/snap_inelig…
Browse files Browse the repository at this point in the history
…ible_student

SNAP ineligible student
  • Loading branch information
CalebPena authored Oct 18, 2024
2 parents 2bc0de4 + 9d4ae0b commit af4db59
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 3 deletions.
1 change: 1 addition & 0 deletions programs/programs/federal/pe/spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Snap(PolicyEngineSpmCalulator):
dependency.member.AgeDependency,
dependency.member.MedicalExpenseDependency,
dependency.member.IsDisabledDependency,
dependency.member.SnapIneligibleStudentDependency,
# NOTE: remove this to always use the SUA in CO.
dependency.spm.SnapAlwaysUseSuaDependency,
]
Expand Down
22 changes: 22 additions & 0 deletions programs/programs/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from programs.programs.calc import Eligibility
from screener.models import Screen, HouseholdMember


STATE_MEDICAID_OPTIONS = ("co_medicaid", "nc_medicaid")
Expand All @@ -8,3 +9,24 @@ def medicaid_eligible(data: dict[str, Eligibility]):
for name in STATE_MEDICAID_OPTIONS:
if name in data:
return data[name].eligible


def snap_ineligible_student(screen: Screen, member: HouseholdMember):
if not member.student:
return False

if member.age < 18 or member.age >= 50:
return False

if member.disabled:
return False

head_or_spouse = member.is_head() or member.is_spouse()
if head_or_spouse and screen.num_children(age_max=5) > 0:
return False

single_parent = member.is_head() and not member.is_married()["is_married"]
if single_parent and screen.num_children(age_max=11) > 0:
return False

return True
11 changes: 11 additions & 0 deletions programs/programs/policyengine/calculators/dependencies/member.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from programs.programs.helpers import snap_ineligible_student
from .base import Member


Expand Down Expand Up @@ -221,6 +222,16 @@ class CommoditySupplementalFoodProgram(Member):
field = "commodity_supplemental_food_program"


class SnapIneligibleStudentDependency(Member):
field = "is_snap_ineligible_student"

dependencies = ("age",)

# PE does not take the age of the children into acount, so we calculate this ourselves
def value(self):
return snap_ineligible_student(self.screen, self.member)


class IncomeDependency(Member):
dependencies = (
"income_type",
Expand Down
3 changes: 2 additions & 1 deletion programs/programs/warnings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .tax_unit import TaxUnit
from .base import WarningCalculator
from .dont_show import DontShow
from .co import co_warning_calculators


general_calculators: dict[str, type[WarningCalculator]] = {
Expand All @@ -9,6 +10,6 @@
"_tax_unit": TaxUnit,
}

specific_calculators: dict[str, type[WarningCalculator]] = {}
specific_calculators: dict[str, type[WarningCalculator]] = {**co_warning_calculators}

warning_calculators: dict[str, type[WarningCalculator]] = {**general_calculators, **specific_calculators}
5 changes: 5 additions & 0 deletions programs/programs/warnings/co/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from programs.programs.warnings.base import WarningCalculator
from programs.programs.warnings.co.snap_student import SnapStudentWarning


co_warning_calculators: dict[str, type[WarningCalculator]] = {"co_snap_student": SnapStudentWarning}
15 changes: 15 additions & 0 deletions programs/programs/warnings/co/snap_student.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from programs.programs.helpers import snap_ineligible_student
from programs.programs.warnings.base import WarningCalculator


class SnapStudentWarning(WarningCalculator):
dependencies = [
"age",
]

def eligible(self) -> bool:
for member in self.screen.household_members.all():
if snap_ineligible_student(self.screen, member):
return True

return False
4 changes: 2 additions & 2 deletions screener/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,10 @@ def is_married(self):
def has_disability(self):
return self.disabled or self.visually_impaired or self.long_term_disability

def is_head(self):
def is_head(self) -> bool:
return self.relationship == "headOfHousehold"

def is_spouse(self):
def is_spouse(self) -> bool:
return self.screen.relationship_map()[self.screen.get_head().id] == self.id

def is_dependent(self):
Expand Down

0 comments on commit af4db59

Please sign in to comment.