fix(fusion_clock): NFC clock-out shows gross worked time, not net-of-penalty

The result card showed x_fclk_net_hours = worked_hours − break − early-out
penalty minutes. Tapping out before the scheduled end adds a 15-min early-out
penalty to the break field, so short shifts clamped to 0 → "Worked 0h 0m".

Show GROSS attendance.worked_hours (the actual clock-in → clock-out elapsed
time) instead, and format adaptively (Xh Ym / Ym / Ys) so brief shifts and
quick tests don't all read 0. Net-of-deductions stays in the payroll reports.

Live as 19.0.3.11.5 (verified worked_hours computes correctly in the DB).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-30 18:59:10 -04:00
parent 3fd074ff6d
commit 2c8ad83d43
3 changed files with 17 additions and 7 deletions

View File

@@ -248,10 +248,17 @@
const action = payload.action === "clock_in" ? "CLOCKED IN" : "CLOCKED OUT";
let hoursLine = "";
if (payload.action === "clock_out") {
const mins = Math.round((payload.net_hours_today || 0) * 60);
const h = Math.floor(mins / 60);
const m = mins % 60;
hoursLine = `<div class="hours">Worked ${h}h ${m}m this shift</div>`;
// Gross clock-in → clock-out time. Adaptive units so short shifts
// (and quick tests) don't all read "0h 0m".
const totalSec = Math.round((payload.worked_hours || 0) * 3600);
const h = Math.floor(totalSec / 3600);
const m = Math.floor((totalSec % 3600) / 60);
const s = totalSec % 60;
let dur;
if (h > 0) dur = `${h}h ${m}m`;
else if (m > 0) dur = `${m}m`;
else dur = `${s}s`;
hoursLine = `<div class="hours">Worked ${dur} this shift</div>`;
}
const time = new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", hour12: true });
stateContainer.innerHTML = `