diff --git a/backend/main.py b/backend/main.py index 6b5ad32..efe67da 100644 --- a/backend/main.py +++ b/backend/main.py @@ -705,13 +705,17 @@ def calculate_attendance_status(check_in, check_out, shift_start, shift_end): expected_end_dt = datetime.combine(check_out_dt.date(), shift_end) if check_out_dt < expected_end_dt: - diff = (expected_end_dt - check_out_dt).total_seconds() / 60 - result["early_minutes"] = round(diff) + diff_seconds = (expected_end_dt - check_out_dt).total_seconds() + result["early_minutes"] = round(diff_seconds / 60) if diff_seconds >= 30 else 0 # Calculate OT minutes (leaving after scheduled end) if check_out_dt > expected_end_dt: - diff = (check_out_dt - expected_end_dt).total_seconds() / 60 - result["ot_minutes"] = round(diff) + diff_seconds = (check_out_dt - expected_end_dt).total_seconds() + # Ignore tiny differences (< 30 seconds) to avoid floating-point noise + if diff_seconds >= 30: + result["ot_minutes"] = round(diff_seconds / 60) + else: + result["ot_minutes"] = 0 # Determine status code and text status_parts = []