diff --git a/app/Services/HR/AttendanceService.php b/app/Services/HR/AttendanceService.php index d5f66d22..cde236a8 100644 --- a/app/Services/HR/AttendanceService.php +++ b/app/Services/HR/AttendanceService.php @@ -357,7 +357,7 @@ public function getEmployeeMonthlySummary(int $year, int $month): array 'user_id', 'status', DB::raw('COUNT(*) as cnt'), - DB::raw("SUM(CAST(JSON_UNQUOTE(JSON_EXTRACT(json_details, '$.work_minutes')) AS UNSIGNED)) as total_minutes") + DB::raw("SUM(GREATEST(0, COALESCE(CAST(JSON_UNQUOTE(JSON_EXTRACT(json_details, '$.work_minutes')) AS SIGNED), 0))) as total_minutes") ) ->groupBy('user_id', 'status') ->get(); @@ -409,7 +409,7 @@ public function getOvertimeAlerts(): array ->betweenDates($weekStart, $weekEnd) ->select( 'user_id', - DB::raw("SUM(CAST(JSON_UNQUOTE(JSON_EXTRACT(json_details, '$.work_minutes')) AS UNSIGNED)) as week_minutes") + DB::raw("SUM(GREATEST(0, COALESCE(CAST(JSON_UNQUOTE(JSON_EXTRACT(json_details, '$.work_minutes')) AS SIGNED), 0))) as week_minutes") ) ->groupBy('user_id') ->having('week_minutes', '>=', 2880) // 48시간 = 2880분