Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Calculators to State Folders #318

Merged
merged 7 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 4 additions & 58 deletions programs/programs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,8 @@
from .rtdlive.calculator import RtdLive
from .child_care_assistance.calculator import ChildCareAssistance
from .mydenver.calculator import MyDenver
from .cash_back.calculator import CashBack
from .energy_assistance.calculator import EnergyAssistance
from .energy_resource_center.calculator import EnergyResourceCenter
from .omnisalud.calculator import OmniSalud
from .dental_health_care_seniors.calculator import DentalHealthCareSeniors
from .reproductive_health_care.calculator import ReproductiveHealthCare
from .connect_for_health.calculator import ConnectForHealth
from .medicaid.family_planning_services.calculator import FamilyPlanningServices
from .denver_preschool_program.calculator import DenverPreschoolProgram
from .head_start.calculator import HeadStart
from .every_day_eats.calculator import EveryDayEats
from .property_credit_rebate.calculator import PropertyCreditRebate
from .universal_preschool.calculator import UniversalPreschool
from .my_spark.calculator import MySpark
from .ssdi.calculator import Ssdi
from .low_wage_covid_relief.calculator import LowWageCovidRelief
from .medicaid.child_with_disability.calculator import MedicaidChildWithDisability
from .medicaid.adult_with_disability.calculator import MedicaidAdultWithDisability
from .medicaid.emergency.calculator import EmergencyMedicaid
from .medicare_savings.calculator import MedicareSavings
from .basic_cash_assistance.calculator import BasicCashAssistance
from .weatherization_assistance.calculator import WeatherizationAssistance
from .tabor.calculator import Tabor
from .trua.calculator import Trua
from .utility_bill_pay.calculator import UtilityBillPay
from .co import co_calculators
from .federal import federal_calculators
from .calc import ProgramCalculator
from .rental_assistance_grant.calculator import RentalAssistanceGrant

calculators: dict[str, type[ProgramCalculator]] = {
'rtdlive': RtdLive,
'cccap': ChildCareAssistance,
'mydenver': MyDenver,
'cocb': CashBack,
'leap': EnergyAssistance,
'erc': EnergyResourceCenter,
'omnisalud': OmniSalud,
'cdhcs': DentalHealthCareSeniors,
'rhc': ReproductiveHealthCare,
'cfhc': ConnectForHealth,
'fps': FamilyPlanningServices,
'chs': HeadStart,
'dpp': DenverPreschoolProgram,
'ede': EveryDayEats,
'cpcr': PropertyCreditRebate,
'upk': UniversalPreschool,
'myspark': MySpark,
'ssdi': Ssdi,
'lwcr': LowWageCovidRelief,
'cwd_medicaid': MedicaidChildWithDisability,
'awd_medicaid': MedicaidAdultWithDisability,
'emergency_medicaid': EmergencyMedicaid,
'medicare_savings': MedicareSavings,
'bca': BasicCashAssistance,
'cowap': WeatherizationAssistance,
'tabor': Tabor,
'trua': Trua,
'ubp': UtilityBillPay,
'rag': RentalAssistanceGrant,
**co_calculators,
**federal_calculators
}
60 changes: 60 additions & 0 deletions programs/programs/co/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from .rtdlive.calculator import RtdLive
from .child_care_assistance.calculator import ChildCareAssistance
from .mydenver.calculator import MyDenver
from .cash_back.calculator import CashBack
from .energy_assistance.calculator import EnergyAssistance
from .energy_resource_center.calculator import EnergyResourceCenter
from .omnisalud.calculator import OmniSalud
from .dental_health_care_seniors.calculator import DentalHealthCareSeniors
from .reproductive_health_care.calculator import ReproductiveHealthCare
from .connect_for_health.calculator import ConnectForHealth
from .medicaid.family_planning_services.calculator import FamilyPlanningServices
from .denver_preschool_program.calculator import DenverPreschoolProgram
from .every_day_eats.calculator import EveryDayEats
from .property_credit_rebate.calculator import PropertyCreditRebate
from .universal_preschool.calculator import UniversalPreschool
from .my_spark.calculator import MySpark
from .low_wage_covid_relief.calculator import LowWageCovidRelief
from .medicaid.child_with_disability.calculator import MedicaidChildWithDisability
from .medicaid.adult_with_disability.calculator import MedicaidAdultWithDisability
from .medicaid.emergency.calculator import EmergencyMedicaid
from .basic_cash_assistance.calculator import BasicCashAssistance
from .weatherization_assistance.calculator import WeatherizationAssistance
from .tabor.calculator import Tabor
from .trua.calculator import Trua
from .utility_bill_pay.calculator import UtilityBillPay
from ..calc import ProgramCalculator
from .rental_assistance_grant.calculator import RentalAssistanceGrant
from .emergency_rental_assistance.calculator import EmergencyRentalAssistance


co_calculators: dict[str, type[ProgramCalculator]] = {
'rtdlive': RtdLive,
'cccap': ChildCareAssistance,
'mydenver': MyDenver,
'cocb': CashBack,
'leap': EnergyAssistance,
'erc': EnergyResourceCenter,
'omnisalud': OmniSalud,
'cdhcs': DentalHealthCareSeniors,
'rhc': ReproductiveHealthCare,
'cfhc': ConnectForHealth,
'fps': FamilyPlanningServices,
'dpp': DenverPreschoolProgram,
'ede': EveryDayEats,
'cpcr': PropertyCreditRebate,
'upk': UniversalPreschool,
'myspark': MySpark,
'lwcr': LowWageCovidRelief,
'cwd_medicaid': MedicaidChildWithDisability,
'awd_medicaid': MedicaidAdultWithDisability,
'emergency_medicaid': EmergencyMedicaid,
'bca': BasicCashAssistance,
'cowap': WeatherizationAssistance,
'tabor': Tabor,
'trua': Trua,
'ubp': UtilityBillPay,
'rag': RentalAssistanceGrant,
'erap': EmergencyRentalAssistance,
}

44 changes: 44 additions & 0 deletions programs/programs/co/emergency_rental_assistance/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from programs.programs.calc import Eligibility, ProgramCalculator
import programs.programs.messages as messages
from integrations.util.cache import Cache
from programs.sheets import sheets_get_data
from programs.co_county_zips import counties_from_zip


class EmergencyRentalAssistanceIncomeLimitsCache(Cache):
expire_time = 60 * 60 * 24
default = {}

def update(self):
spreadsheet_id = '1QHb-ZT0Y2oWjFMoeP_wy8ClveslINWdehb-CXhB8WSE'
range_name = "'2022 80% AMI'!A2:I"
sheet_values = sheets_get_data(spreadsheet_id, range_name)

if not sheet_values:
raise Exception('Sheet unavailable')

data = {d[0].strip() + ' County': [int(v.replace(',', '')) for v in d[1:]] for d in sheet_values}

return data


class EmergencyRentalAssistance(ProgramCalculator):
amount = 13_848
dependencies = ['income_amount', 'income_frequency', 'household_size', 'zipcode']
income_cache = EmergencyRentalAssistanceIncomeLimitsCache()
income_limit_percent = .8

def eligible(self) -> Eligibility:
e = Eligibility()

# Income test
counties = counties_from_zip(self.screen.zipcode)
county_name = self.screen.county if self.screen.county is not None else counties[0]

income = self.screen.calc_gross_income('yearly', ['all'])
income_limits = EmergencyRentalAssistance.income_cache.fetch()
income_limit = income_limits[county_name][self.screen.household_size - 1] * EmergencyRentalAssistance.income_limit_percent
e.condition(income < income_limit, messages.income(income, income_limit))

return e

22 changes: 22 additions & 0 deletions programs/programs/co/pe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import programs.programs.co.pe.tax as tax
import programs.programs.co.pe.member as member
from programs.programs.policyengine.calculators.base import PolicyEngineCalulator


co_member_calculators = {
'co_medicaid': member.CoMedicaid,
'andcs': member.AidToTheNeedyAndDisabled,
'oap': member.OldAgePension,
'chp': member.Chp,
}

co_tax_unit_calculators = {
'coeitc': tax.Coeitc,
'coctc': tax.Coctc,
}

co_pe_calculators: dict[str, type[PolicyEngineCalulator]] = {
**co_member_calculators,
**co_tax_unit_calculators,
}

61 changes: 61 additions & 0 deletions programs/programs/co/pe/member.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from programs.programs.policyengine.calculators.base import PolicyEngineMembersCalculator
from programs.programs.federal.pe.member import Medicaid
import programs.programs.policyengine.calculators.dependencies as dependency


class CoMedicaid(Medicaid):
child_medicaid_average = 200 * 12
adult_medicaid_average = 310 * 12
aged_medicaid_average = 170 * 12


class AidToTheNeedyAndDisabled(PolicyEngineMembersCalculator):
pe_name = 'co_state_supplement'
pe_inputs = [
dependency.member.SsiCountableResourcesDependency,
dependency.member.SsiReportedDependency,
dependency.member.IsBlindDependency,
dependency.member.IsDisabledDependency,
dependency.member.SsiEarnedIncomeDependency,
dependency.member.SsiUnearnedIncomeDependency,
dependency.member.AgeDependency,
dependency.member.TaxUnitSpouseDependency,
dependency.member.TaxUnitHeadDependency,
dependency.member.TaxUnitDependentDependency,
]
pe_outputs = [dependency.member.Andcs]


class OldAgePension(PolicyEngineMembersCalculator):
pe_name = 'co_oap'
pe_inputs = [
dependency.member.SsiCountableResourcesDependency,
dependency.member.SsiEarnedIncomeDependency,
dependency.member.SsiUnearnedIncomeDependency,
dependency.member.AgeDependency,
dependency.member.TaxUnitSpouseDependency,
dependency.member.TaxUnitHeadDependency,
dependency.member.TaxUnitDependentDependency,
]
pe_outputs = [dependency.member.Oap]


class Chp(PolicyEngineMembersCalculator):
pe_name = 'co_chp'
pe_inputs = [
dependency.member.AgeDependency,
dependency.member.PregnancyDependency,
*dependency.irs_gross_income,
]
pe_outputs = [dependency.member.ChpEligible]

amount = 200 * 12

def value(self):
total = 0

for _, pvalue in self.get_data().items():
if pvalue['co_chp_eligible'][self.pe_period] > 0 and self.screen.has_insurance_types(('none',)):
total += self.amount

return total
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,42 +1,14 @@
from ..base import PolicyEnigineCalulator
from ..constants import PREVIOUS_YEAR
from programs.programs.policyengine.calculators.base import PolicyEngineTaxUnitCalulator
from programs.programs.federal.pe.tax import Eitc
import programs.programs.policyengine.calculators.dependencies as dependency


class PolicyEngineTaxUnitCalulator(PolicyEnigineCalulator):
pe_category = 'tax_units'
pe_sub_category = 'tax_unit'
pe_period = PREVIOUS_YEAR


class Eitc(PolicyEngineTaxUnitCalulator):
pe_name = 'eitc'
pe_inputs = [
dependency.member.AgeDependency,
dependency.member.TaxUnitSpouseDependency,
dependency.member.TaxUnitDependentDependency,
*dependency.irs_gross_income,
]
pe_outputs = [dependency.tax.Eitc]


class Coeitc(PolicyEngineTaxUnitCalulator):
pe_name = 'co_eitc'
pe_inputs = Eitc.pe_inputs
pe_outputs = [dependency.tax.Coeitc]


class Ctc(PolicyEngineTaxUnitCalulator):
pe_name = 'ctc'
pe_inputs = [
dependency.member.AgeDependency,
dependency.member.TaxUnitDependentDependency,
dependency.member.TaxUnitSpouseDependency,
*dependency.irs_gross_income,
]
pe_outputs = [dependency.tax.Ctc]


class Coctc(PolicyEngineTaxUnitCalulator):
pe_name = 'ctc'
pe_inputs = [
Expand Down
10 changes: 10 additions & 0 deletions programs/programs/federal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .ssdi.calculator import Ssdi
from .head_start.calculator import HeadStart
from .medicare_savings.calculator import MedicareSavings
from ..calc import ProgramCalculator

federal_calculators: dict[str, type[ProgramCalculator]] = {
'ssdi': Ssdi,
'chs': HeadStart,
'medicare_savings': MedicareSavings,
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from programs.programs.calc import ProgramCalculator, Eligibility
import programs.programs.messages as messages
from programs.programs.head_start.eligible_zipcodes import eligible_zipcode
from programs.programs.federal.head_start.eligible_zipcodes import eligible_zipcode
from programs.co_county_zips import counties_from_zip


Expand Down
Empty file.
31 changes: 31 additions & 0 deletions programs/programs/federal/pe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import programs.programs.federal.pe.tax as tax
import programs.programs.federal.pe.spm as spm
import programs.programs.federal.pe.member as member
from programs.programs.policyengine.calculators.base import PolicyEngineCalulator


federal_member_calculators = {
'wic': member.Wic,
'pell_grant': member.PellGrant,
'ssi': member.Ssi,
}

federal_spm_unit_calculators = {
'acp': spm.Acp,
'lifeline': spm.Lifeline,
'nslp': spm.SchoolLunch,
'snap': spm.Snap,
'tanf': spm.Tanf,
}

federal_tax_unit_calculators = {
'eitc': tax.Eitc,
'ctc': tax.Ctc,
}

federal_pe_calculators: dict[str, type[PolicyEngineCalulator]] = {
**federal_member_calculators,
**federal_spm_unit_calculators,
**federal_tax_unit_calculators,
}

Loading