Fix last-name exception carry-forward and parent action label
Tests / PHPUnit (push) Successful in 55s
Tests / PHPUnit (push) Successful in 55s
This commit is contained in:
@@ -1445,6 +1445,20 @@ final class EnrollmentTransitionService
|
||||
return;
|
||||
}
|
||||
|
||||
$approvedStudentIds = $this->exceptionFamilyStudentIds($prior);
|
||||
$currentStudentIds = $this->linkedStudentIds($parentId);
|
||||
sort($currentStudentIds);
|
||||
if ($approvedStudentIds !== [] && $approvedStudentIds !== $currentStudentIds) {
|
||||
$evaluation['last_name_exception_carry_forward'] = [
|
||||
'eligible' => false,
|
||||
'prior_exception_id' => (int) ($prior['id'] ?? 0),
|
||||
'prior_school_year' => (string) ($prior['school_year'] ?? ''),
|
||||
'approved_student_ids' => $approvedStudentIds,
|
||||
'reason' => 'NEW_STUDENT_ADDED',
|
||||
];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->removeRuleCode($evaluation, 'SIBLING_LAST_NAME_MISMATCH');
|
||||
$this->addRuleCode($evaluation, 'LAST_NAME_EXCEPTION_CARRIED_FORWARD', 'warning');
|
||||
$evaluation['warnings'] = array_values(array_unique(array_merge(
|
||||
@@ -1456,7 +1470,7 @@ final class EnrollmentTransitionService
|
||||
'eligible' => true,
|
||||
'prior_exception_id' => (int) ($prior['id'] ?? 0),
|
||||
'prior_school_year' => (string) ($prior['school_year'] ?? ''),
|
||||
'approved_student_ids' => [(int) ($prior['student_id'] ?? $studentId)],
|
||||
'approved_student_ids' => $approvedStudentIds !== [] ? $approvedStudentIds : [(int) ($prior['student_id'] ?? $studentId)],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1522,6 +1536,25 @@ final class EnrollmentTransitionService
|
||||
return in_array('SIBLING_LAST_NAME_MISMATCH', $codes, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
private function exceptionFamilyStudentIds(array $exception): array
|
||||
{
|
||||
$ids = json_decode((string) ($exception['family_student_ids_json'] ?? ''), true);
|
||||
if (! is_array($ids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ids = array_values(array_unique(array_filter(array_map(
|
||||
static fn ($id): int => (int) $id,
|
||||
$ids
|
||||
), static fn (int $id): bool => $id > 0)));
|
||||
sort($ids);
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
private function linkedStudentsForParent(int $parentId): array
|
||||
{
|
||||
if ($parentId <= 0 || ! $this->db->tableExists('students')) {
|
||||
|
||||
Reference in New Issue
Block a user