Files
root 576da3bd78
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 49s
Tests / PHPUnit (push) Successful in 1m21s
fix the home page
2026-08-24 03:07:02 -04:00

62 lines
1.9 KiB
Python

def estimated_aid(total_balance, household_size, household_income):
"""Estimate aid using a Massachusetts cost-adjusted poverty benchmark."""
if household_size < 1:
raise ValueError("household_size must be at least 1")
if total_balance < 0 or household_income < 0:
raise ValueError("balance and income cannot be negative")
# Official 2026 federal poverty guideline for the contiguous states.
federal_poverty_level = (
15_960 + 5_680 * (household_size - 1)
)
# Massachusetts prices are approximately 5.757% above the
# national average according to the latest available BEA data.
massachusetts_cost_factor = 1.05757
# This is an internal cost-adjusted benchmark, not the official FPL.
adjusted_need_threshold = (
federal_poverty_level * massachusetts_cost_factor
)
# Protect household income up to 200% of the adjusted benchmark.
protected_income = 2.0 * adjusted_need_threshold
# Only income exceeding the protected amount is considered available.
discretionary_income = max(
0.0,
household_income - protected_income,
)
# Expect 10% of discretionary income to be available for school fees.
expected_contribution = 0.10 * discretionary_income
# Aid covers the remaining fee balance.
estimated = total_balance - expected_contribution
# Prevent negative awards or awards exceeding the fee balance.
return round(
max(0.0, min(total_balance, estimated)),
2,
)
def final_rebate(
total_balance,
household_size,
household_income,
amount_requested,
):
"""Return estimated aid capped by the request and fee balance."""
if amount_requested < 0:
raise ValueError("amount_requested cannot be negative")
estimated = estimated_aid(
total_balance,
household_size,
household_income,
)
return min(estimated, amount_requested, total_balance)