From 2ecce8a990798cedbca2602be6bbe714a7db3c8b Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 18 May 2026 14:46:49 +0800 Subject: [PATCH] feat: enforce time rounding down to the nearest 30 mins for total_hours --- app/Models/AttendanceRecord.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Models/AttendanceRecord.php b/app/Models/AttendanceRecord.php index d19ee0bee..5894e9b21 100644 --- a/app/Models/AttendanceRecord.php +++ b/app/Models/AttendanceRecord.php @@ -150,7 +150,11 @@ class AttendanceRecord extends BaseModel } $workingMinutes = max(0, $totalMinutes - $breakMinutes); - $calculatedHours = round($workingMinutes / 60, 2); + + // Round DOWN to the nearest 30 minutes (0.5 hours) + // e.g. 6.28 hours becomes 6.0 hours, 6.75 hours becomes 6.5 hours + $rawHours = $workingMinutes / 60; + $calculatedHours = floor($rawHours * 2) / 2; $this->attributes['total_hours'] = $calculatedHours; $this->attributes['break_hours'] = round($breakMinutes / 60, 2);