From 7fc5bbd8ed05a939c140bbc4f33bbf0c4ee5e07f Mon Sep 17 00:00:00 2001 From: A R R R Associates Date: Mon, 6 Jul 2026 15:04:01 +0530 Subject: [PATCH] Fix attendance punch duration timezone handling --- app/modules/employees/service.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)