Skip to content

Commit

Permalink
update upk
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebPena committed Dec 4, 2024
1 parent ea63440 commit 279f99d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
25 changes: 16 additions & 9 deletions programs/programs/co/universal_preschool/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
class UniversalPreschool(ProgramCalculator):
qualifying_age = 3
age = 4
percent_of_fpl = 2.7
amount_by_hours = {"10_hours": 4_837, "15_hours": 6_044, "30_hours": 10_655}
income_limit = 1
foster_income_limit = 2.7
amount_10_hr = 4_920
amount_15_hr = 6_204
amount_30_hr = 11_004
dependencies = ["age", "income_amount", "income_frequency", "relationship", "household_size"]

def member_eligible(self, e: MemberEligibility):
Expand All @@ -23,16 +26,20 @@ def member_value(self, member: HouseholdMember):
qualifying_condition = self._has_qualifying_condition(member)

if not qualifying_condition:
return UniversalPreschool.amount_by_hours["15_hours"]
return UniversalPreschool.amount_15_hr

if member.age == UniversalPreschool.age:
return UniversalPreschool.amount_by_hours["30_hours"]
return UniversalPreschool.amount_30_hr

return UniversalPreschool.amount_by_hours["10_hours"]
return UniversalPreschool.amount_10_hr

def _has_qualifying_condition(self, member: HouseholdMember):
fpl = self.program.fpl.as_dict()
income_limit = int(UniversalPreschool.percent_of_fpl * fpl[self.screen.household_size])
income_condition = self.screen.calc_gross_income("yearly", ["all"]) < income_limit
fpl = self.program.fpl.as_dict()[self.screen.household_size]
income = self.screen.calc_gross_income("yearly", ["all"])

return income_condition or member.relationship == "fosterChild"
income_limit = int(UniversalPreschool.income_limit * fpl)

if member.relationship == "fosterChild":
income_limit = int(UniversalPreschool.foster_income_limit * fpl)

return income < income_limit
6 changes: 5 additions & 1 deletion programs/programs/warnings/base.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from programs.models import WarningMessage
from programs.programs.calc import Eligibility
from programs.util import Dependencies
from screener.models import Screen


class WarningCalculator:
dependencies = tuple()

def __init__(self, screen: Screen, warning: WarningMessage, missing_dependencies: Dependencies):
def __init__(
self, screen: Screen, warning: WarningMessage, eligibility: Eligibility, missing_dependencies: Dependencies
):
self.screen = screen
self.warning = warning
self.eligibility = eligibility
self.missing_dependencies = missing_dependencies

def calc(self) -> bool:
Expand Down
6 changes: 5 additions & 1 deletion programs/programs/warnings/co/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from programs.programs.warnings.base import WarningCalculator
from programs.programs.warnings.co.snap_student import SnapStudentWarning
from programs.programs.warnings.co.universal_preschool import UniversalPreschool


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


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

def eligible(self) -> bool:
for member_eligibility in self.eligibility.eligible_members:
if member_eligibility.eligible and member_eligibility.member.age == 3:
return True

return False
4 changes: 3 additions & 1 deletion screener/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ def sort_first(program):
if warning.calculator not in warning_calculators:
raise Exception(f"{warning.calculator} is not a valid calculator name")

warning_calculator = warning_calculators[warning.calculator](screen, warning, missing_dependencies)
warning_calculator = warning_calculators[warning.calculator](
screen, warning, eligibility, missing_dependencies
)

if warning_calculator.calc():
warnings.append(warning)
Expand Down

0 comments on commit 279f99d

Please sign in to comment.