From b00e5d5b191e9e9b1378ba4859afce5489efb316 Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Sat, 7 Mar 2026 20:48:54 +0300 Subject: [PATCH] fix(ERP-254): throw 404 when no open shift found on close TimetableFactModel::getLast() returns null if no open fact exists for the admin on the current/previous date. Accessing checkin_start_id on null caused PHP Warning and 500 response. Now returns proper 404. --- erp24/api3/core/services/TimetableService.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erp24/api3/core/services/TimetableService.php b/erp24/api3/core/services/TimetableService.php index 953d6748..61585761 100644 --- a/erp24/api3/core/services/TimetableService.php +++ b/erp24/api3/core/services/TimetableService.php @@ -132,6 +132,10 @@ class TimetableService $fact = TimetableFactModel::getLast($data->admin_id, date('Y-m-d')); + if ($fact === null) { + throw new NotFoundHttpException("Открытая смена не найдена"); + } + $currentDate = date('Y-m-d H:i:s'); $admin_id = $data->admin_id; -- 2.39.5