diff --git a/app/modules/employees/service.py b/app/modules/employees/service.py index 8d30e6d..4c73ab6 100644 --- a/app/modules/employees/service.py +++ b/app/modules/employees/service.py @@ -896,7 +896,13 @@ def _evaluate_attendance_timing(branch: Branch | None, settings: BranchSettings def _attendance_duration_minutes(row: EmployeeAttendance) -> int | None: if not row.punch_in_utc or not row.punch_out_utc: return None - delta = row.punch_out_utc - row.punch_in_utc + + punch_in_utc = _as_utc_aware(row.punch_in_utc) + punch_out_utc = _as_utc_aware(row.punch_out_utc) + if not punch_in_utc or not punch_out_utc: + return None + + delta = punch_out_utc - punch_in_utc minutes = int(delta.total_seconds() // 60) return max(minutes, 0)