Fix ? / 0.00h display for in-progress shifts

Frontend: pivotWfShifts now skips entries where times='?' and hours=0
— immediately removes the visual glitch from any stale DB rows.

Backend: when today's timesheet pull finds no completed shifts, write
a source='workforce' row instead of skipping, so the stale timesheet
entry is overwritten and rota sync can restore schedule data for today.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-23 12:21:31 +00:00
parent e3c8f143ef
commit b194cf1278
5 changed files with 30 additions and 28 deletions

View file

@ -106,13 +106,13 @@ export async function runTimesheetSync(from, to) {
while (day <= toDate) {
const d = fmtDate(day)
const staffForDate = byDate[d] || []
// For today: only write a timesheet row if at least one shift has clocked out.
// An empty row would overwrite rota data with nothing while staff are still working.
if (d === today && staffForDate.length === 0) {
day.setDate(day.getDate() + 1)
continue
// Nobody has clocked out yet — write a workforce-sourced row so this clears any
// stale timesheet entry and rota sync can overwrite with schedule data again
dailyRows.push({ date: d, staff: [], source: 'workforce' })
} else {
dailyRows.push({ date: d, staff: staffForDate, source: 'timesheet' })
}
dailyRows.push({ date: d, staff: staffForDate, source: 'timesheet' })
day.setDate(day.getDate() + 1)
}