fix logic and tests, update docker CI file

This commit is contained in:
root
2026-03-09 15:58:44 -04:00
parent 1cb3573d4b
commit 79e44fe037
188 changed files with 1776 additions and 524 deletions
@@ -91,7 +91,7 @@ class ClassPreparationCalculatorService
$qty = $isLowerGrades ? 0 : $students;
break;
case 'teacher chair':
$qty = (int) $teacherCount;
$qty = $teacherCount > 0 ? (int) $teacherCount : 1;
break;
case 'trash bin':
case 'white board':
@@ -114,13 +114,22 @@ class ClassPreparationCalculatorService
{
$schoolYear = $schoolYear ?: (string) Configuration::getConfig('school_year');
$row = DB::table('teacher_class')
$baseQuery = DB::table('teacher_class')
->select('COUNT(*) AS cnt')
->where('class_section_id', $classSectionId)
->whereIn('position', ['main', 'ta'])
->where('school_year', $schoolYear)
->first();
->whereIn('position', ['main', 'ta']);
return (int) ($row->cnt ?? 0);
$row = $schoolYear !== null && $schoolYear !== ''
? (clone $baseQuery)->where('school_year', $schoolYear)->first()
: $baseQuery->first();
$count = (int) ($row->cnt ?? 0);
if ($count === 0 && $schoolYear !== null && $schoolYear !== '') {
$row = $baseQuery->first();
$count = (int) ($row->cnt ?? 0);
}
return $count;
}
}