Skip to content

Commit

Permalink
Reapply "Merge branch 'dev' into bug/no-results"
Browse files Browse the repository at this point in the history
This reverts commit 87cb693.
  • Loading branch information
msrezaie committed May 24, 2024
1 parent 87cb693 commit 440119a
Show file tree
Hide file tree
Showing 100 changed files with 662 additions and 346 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/enforcer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check Branch

on: pull_request

jobs:
check_branch:
name: Check base and head branches
runs-on: ubuntu-latest
steps:
- name: dev into main
if: ${{ github.base_ref == 'main' && github.head_ref == 'dev' }}
run: echo "Your pull request is for dev into main." && exit 0
- name: feature branch into dev
if: ${{ github.base_ref == 'dev' }}
run: echo "TESTING Your pull request is for a feature branch into dev." && exit 0
- name: non dev branch into main
if: ${{ github.base_ref == 'main' && github.head_ref != 'dev' }}
run: |
echo "ERROR: You can only merge the dev branch into main." && exit 1
File renamed without changes.
File renamed without changes.
81 changes: 81 additions & 0 deletions configuration/management/commands/add_config.py

Large diffs are not rendered by default.

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,
}

File renamed without changes.
File renamed without changes.
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

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
44 changes: 44 additions & 0 deletions programs/programs/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()

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()
# NOTE: 80% to income is already applied in the sheet.
income_limit = income_limits[county_name][self.screen.household_size - 1]
e.condition(income < income_limit, messages.income(income, income_limit))

return e

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,
}
Empty file.
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
File renamed without changes.
Empty file.
Loading

0 comments on commit 440119a

Please sign in to comment.