1.8 KiB
Dynamic Tardiness Sync
Problem Description
The Legacy DB explicitly tracked the raw decimal of late_hours per check-in (e.g. Paul was exactly 0.23 hours late on Jan 14). During the initial migration, our engine resorted to an arbitrary 0.5 approximation penalty because our new database schema didn't have a mathematical slot for late_hours.
This caused our mathematical engine to compute Paul's late penalty as ₱52.88 instead of the physical ₱24.67 derived directly from his 0.23 late hours.
User Review Required
Note
Are you clear to proceed with structurally injecting the
late_hoursprecision column into the local Database so the Payroll Engine can natively calculate exact down-to-the-minute deductions?
Proposed Changes
Phase 1: Database Migration
[NEW] database/migrations/..._add_late_hours_to_attendance_records.php
Add decimal('late_hours', 8, 2)->nullable() to the system schema.
[MODIFY] app/Models/AttendanceRecord.php
Add late_hours to the $fillable array and casting logic.
Phase 2: Rapid Data Extraction (Sync)
[NEW] app/Console/Commands/SyncLegacyLateHours.php
Write a quick-run Artisan command that loops over the legacy.attendances table and permanently copies the late_hours float directly into our local attendance_records.
Phase 3: Engine Calibration
[MODIFY] app/Services/PayrollService.php
Erase the 0.5 fallback penalty and replace it with:
if ($att->is_late) {
// If we have exact physical minutes imported, use those natively!
$lateHours += (float) ($att->late_hours ?? 0);
}
Verification Plan
- Run the migration.
- Run the tardiness Sync command.
- Generate standard PDF computation for Paul, which will drop his Late Penalty exactly back to the
24.67client target!