fix is_new issue with enrollment fixes
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 48s
Tests / PHPUnit (push) Failing after 1m22s

This commit is contained in:
root
2026-08-20 19:57:25 -04:00
parent 127098b87c
commit 889c037660
29 changed files with 77306 additions and 293 deletions
+39 -20
View File
@@ -603,14 +603,6 @@ final class SchoolYearClosingService
->where('sc.school_year', $schoolYear)
->where('sc.class_section_id IS NOT NULL', null, false);
if ($hasEnrollments && ($hasEnrollmentStatus || $hasEnrollmentWithdrawn)) {
$builder->join(
'enrollments e',
'e.student_id = sc.student_id AND e.school_year = ' . $this->db->escape($schoolYear),
'left'
);
}
if ($hasDob) {
$builder->select('s.dob');
}
@@ -630,18 +622,12 @@ final class SchoolYearClosingService
$builder->where('s.is_active', 1);
}
if ($hasEnrollmentStatus) {
$inactiveStatuses = implode(',', array_map([$this->db, 'escape'], EnrollmentStatusService::INACTIVE_STATUSES));
$builder->where(
'(e.enrollment_status IS NULL OR LOWER(TRIM(e.enrollment_status)) NOT IN (' . $inactiveStatuses . '))',
null,
false
);
}
if ($hasEnrollmentWithdrawn) {
$builder->where('(e.is_withdrawn IS NULL OR e.is_withdrawn != 1)', null, false);
}
$this->excludeWithdrawnStudentsFromClosingBlockers(
$builder,
$schoolYear,
$hasEnrollmentStatus,
$hasEnrollmentWithdrawn
);
$assignmentRows = $builder
->orderBy('sc.student_id', 'ASC')
@@ -783,6 +769,39 @@ final class SchoolYearClosingService
];
}
private function excludeWithdrawnStudentsFromClosingBlockers(
$builder,
string $schoolYear,
bool $hasEnrollmentStatus,
bool $hasEnrollmentWithdrawn
): void {
if (! $hasEnrollmentStatus && ! $hasEnrollmentWithdrawn) {
return;
}
$conditions = [];
if ($hasEnrollmentStatus) {
$inactiveStatuses = implode(',', array_map([$this->db, 'escape'], EnrollmentStatusService::INACTIVE_STATUSES));
$conditions[] = 'LOWER(TRIM(e.enrollment_status)) IN (' . $inactiveStatuses . ')';
}
if ($hasEnrollmentWithdrawn) {
$conditions[] = 'e.is_withdrawn = 1';
}
$builder->where(
'NOT EXISTS (
SELECT 1
FROM enrollments e
WHERE e.student_id = sc.student_id
AND e.school_year = ' . $this->db->escape($schoolYear) . '
AND (' . implode(' OR ', $conditions) . ')
)',
null,
false
);
}
private function isKgStudent(array $student): bool
{
foreach (['class_name', 'class_section_name'] as $field) {