This commit is contained in:
@@ -129,11 +129,21 @@ final class SchoolYearContextService
|
||||
{
|
||||
$active = $this->schoolYearModel->active();
|
||||
|
||||
if ($active === null) {
|
||||
if ($active !== null) {
|
||||
return $this->fromRow($active, false);
|
||||
}
|
||||
|
||||
$closing = $this->schoolYearModel
|
||||
->where('status', SchoolYearStatus::CLOSING)
|
||||
->orderBy('closing_started_at', 'DESC')
|
||||
->orderBy('id', 'DESC')
|
||||
->findAll(2);
|
||||
|
||||
if (count($closing) !== 1) {
|
||||
throw new SchoolYearConfigurationException('Exactly one active school year must be configured.');
|
||||
}
|
||||
|
||||
return $this->fromRow($active, false);
|
||||
return $this->fromRow($closing[0], false);
|
||||
}
|
||||
|
||||
private function normalizeInt(mixed $value): ?int
|
||||
|
||||
Reference in New Issue
Block a user