fix enrollment, invoice, payment and financila aid
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 47s
Tests / PHPUnit (push) Failing after 1m19s

This commit is contained in:
root
2026-08-24 21:20:58 -04:00
parent 576da3bd78
commit 608aca79b8
30 changed files with 3327 additions and 774 deletions
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Models;
use InvalidArgumentException;
/**
* PHP port of app/Controllers/financial_aid_formula.py
*/
class FinancialAidEstimateModel
{
private const FEDERAL_POVERTY_BASE = 15960.0;
private const FEDERAL_POVERTY_STEP = 5680.0;
private const MASSACHUSETTS_COST_FACTOR = 1.05757;
private const PROTECTED_INCOME_MULTIPLIER = 2.0;
private const DISCRETIONARY_CONTRIBUTION_RATE = 0.10;
public function estimatedAid(float $totalBalance, int $householdSize, float $householdIncome): float
{
if ($householdSize < 1) {
throw new InvalidArgumentException('household_size must be at least 1');
}
if ($totalBalance < 0 || $householdIncome < 0) {
throw new InvalidArgumentException('balance and income cannot be negative');
}
$federalPovertyLevel = self::FEDERAL_POVERTY_BASE + (self::FEDERAL_POVERTY_STEP * ($householdSize - 1));
$adjustedNeedThreshold = $federalPovertyLevel * self::MASSACHUSETTS_COST_FACTOR;
$protectedIncome = self::PROTECTED_INCOME_MULTIPLIER * $adjustedNeedThreshold;
$discretionaryIncome = max(0.0, $householdIncome - $protectedIncome);
$expectedContribution = self::DISCRETIONARY_CONTRIBUTION_RATE * $discretionaryIncome;
$estimated = $totalBalance - $expectedContribution;
return round(max(0.0, min($totalBalance, $estimated)), 2);
}
public function finalRebate(
float $totalBalance,
int $householdSize,
float $householdIncome,
float $amountRequested
): float {
if ($amountRequested < 0) {
throw new InvalidArgumentException('amount_requested cannot be negative');
}
$estimated = $this->estimatedAid($totalBalance, $householdSize, $householdIncome);
return min($estimated, $amountRequested, $totalBalance);
}
}
+1
View File
@@ -16,6 +16,7 @@ class FinancialAidRequestModel extends Model
'school_year',
'student_ids_json',
'household_size',
'household_income',
'need_statement',
'requested_amount',
'status',
+1 -1
View File
@@ -25,7 +25,7 @@ class InventoryCategoryModel extends Model
'school_year',
];
protected $validationRules = [
'school_year' => 'required|string|max_length[9]',
'school_year' => 'permit_empty|string|max_length[9]',
];
-4
View File
@@ -25,9 +25,7 @@ class SchoolYearModel extends Model
'administrative_exceptions_permitted',
'registration_exception_roles',
'adult_student_registration_enabled',
'registration_fee',
'tuition_due_at_registration',
'mandatory_fees',
'carry_over_balance_behavior',
'financial_policy_message',
'payment_plan_available',
@@ -60,9 +58,7 @@ class SchoolYearModel extends Model
'late_registration_blocked' => 'permit_empty|in_list[0,1]',
'administrative_exceptions_permitted' => 'permit_empty|in_list[0,1]',
'adult_student_registration_enabled' => 'permit_empty|in_list[0,1]',
'registration_fee' => 'permit_empty|decimal',
'tuition_due_at_registration' => 'permit_empty|decimal',
'mandatory_fees' => 'permit_empty|decimal',
'carry_over_balance_behavior' => 'permit_empty|in_list[information_only,payment_plan_required,submission_allowed_confirmation_blocked,submission_blocked_until_payment,admin_approval_required]',
'payment_plan_available' => 'permit_empty|in_list[0,1]',
'registration_launch_approved_at' => 'permit_empty|valid_date[Y-m-d H:i:s]',