fix close year and ignore not active students
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 48s
Tests / PHPUnit (push) Successful in 1m17s

This commit is contained in:
root
2026-08-20 17:27:28 -04:00
parent 2b0206e7f2
commit 127098b87c
4 changed files with 346 additions and 98 deletions
+24
View File
@@ -587,6 +587,9 @@ final class SchoolYearClosingService
$hasEventOnly = $this->db->fieldExists('is_event_only', 'student_class');
$hasActive = $this->db->fieldExists('is_active', 'students');
$hasEnrollments = $this->db->tableExists('enrollments');
$hasEnrollmentStatus = $hasEnrollments && $this->db->fieldExists('enrollment_status', 'enrollments');
$hasEnrollmentWithdrawn = $hasEnrollments && $this->db->fieldExists('is_withdrawn', 'enrollments');
$hasDob = $this->db->fieldExists('dob', 'students');
$hasRegistrationGrade = $this->db->fieldExists('registration_grade', 'students');
@@ -600,6 +603,14 @@ 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');
}
@@ -619,6 +630,19 @@ 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);
}
$assignmentRows = $builder
->orderBy('sc.student_id', 'ASC')
->orderBy('sc.updated_at', 'DESC')