fix enrollment for the new school-year
Tests / PHPUnit (push) Successful in 1m26s

This commit is contained in:
root
2026-08-07 23:43:31 -04:00
parent b6f3b14e7b
commit 1ef2800f12
66 changed files with 8997 additions and 498 deletions
@@ -488,6 +488,7 @@ class ReimbursementController extends BaseController
'error' => 'Expense not found.',
]);
}
$this->assertSchoolYearNameWritable((string)($expense['school_year'] ?? ''));
if (!empty($expense['reimbursement_id'])) {
return $this->response->setStatusCode(409)->setJSON([
@@ -655,6 +656,12 @@ public function updateBatchAssignment()
$this->db->transBegin();
try {
$expense = $this->expenseModel->find($expenseId);
if (!$expense) {
throw new \RuntimeException('Expense not found.');
}
$this->assertSchoolYearNameWritable((string)($expense['school_year'] ?? ''));
$activeItem = $this->batchItemModel
->where('expense_id', $expenseId)
->where('unassigned_at IS NULL', null, false)
@@ -698,6 +705,7 @@ public function updateBatchAssignment()
'error' => 'Batch not found or already closed.',
]);
}
$this->assertSchoolYearNameWritable((string)($batch['school_year'] ?? ''));
if (!$reimbursementId) {
if ($activeItem && !empty($activeItem['reimbursement_id'])) {
@@ -847,6 +855,7 @@ public function updateBatchAssignment()
'error' => 'Batch not found or already closed.',
]);
}
$this->assertSchoolYearNameWritable((string)($batch['school_year'] ?? ''));
$adminRows = $this->batchItemModel
->select('DISTINCT COALESCE(admin_id, 0) AS admin_id')
@@ -1038,6 +1047,7 @@ public function updateBatchAssignment()
'error' => 'Batch not found.',
]);
}
$this->assertSchoolYearNameWritable((string)($batch['school_year'] ?? ''));
if (strtolower((string) ($batch['status'] ?? '')) !== 'open') {
return $this->response->setStatusCode(409)->setJSON([
'success' => false,
@@ -1618,6 +1628,7 @@ public function updateBatchAssignment()
'error' => 'Requested batch was not found.',
]);
}
$this->assertSchoolYearNameWritable((string)($batch['school_year'] ?? ''));
$receiptRows = !empty($receiptIds) ? $this->fetchBatchReceiptRows($batchId, $receiptIds) : [];
@@ -2108,6 +2119,7 @@ public function updateBatchAssignment()
if (!$reimb) {
throw PageNotFoundException::forPageNotFound("Reimbursement #$id not found");
}
$this->assertSchoolYearNameWritable((string)($reimb['school_year'] ?? ''));
if ($this->isPaidReimbursement($reimb)) {
return redirect()->to('/reimbursements')->with('error', 'Paid reimbursements are immutable. Reverse and replace the transaction instead.');
}
@@ -2207,6 +2219,7 @@ public function updateBatchAssignment()
if (!$reimbursement) {
throw new \RuntimeException('Reimbursement not found.');
}
$this->assertSchoolYearNameWritable((string)($reimbursement['school_year'] ?? ''));
if (FinancialStatus::normalizeReimbursementStatus($reimbursement['status'] ?? null) !== FinancialStatus::REIMBURSEMENT_PAID) {
throw new \RuntimeException('Only paid reimbursements can be reversed.');
}
@@ -2277,6 +2290,7 @@ public function updateBatchAssignment()
if (!$expense) {
throw new \RuntimeException('Expense not found.');
}
$this->assertSchoolYearNameWritable((string)($expense['school_year'] ?? ''));
if (FinancialStatus::normalize((string) ($expense['status'] ?? '')) !== 'approved') {
throw new \RuntimeException('Expense must be approved before reimbursement.');
}