feat: enforce time rounding down to the nearest 30 mins for total_hours

This commit is contained in:
2026-05-18 14:46:49 +08:00
parent 2d37e3d3da
commit 2ecce8a990

View File

@@ -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);