Fix shift hours overcounting automatic breaks + add version-check banner

Workforce's automatic_break_length is a payroll deduction setting, not a
scheduling field — applying it when no explicit breaks are present was silently
shortening all shifts (e.g. a 2h shift showing as 1.5h). Now only deducts
explicit break records from s.breaks. Also adds BUILD_VERSION to /health and
an UpdateBanner that prompts staff to reload when a new deploy lands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-21 15:30:17 +00:00
parent ba23d59b3d
commit e0b0f2f275
5 changed files with 100 additions and 8 deletions

View file

@ -7,11 +7,12 @@ import { configRoutes } from './routes/config.js'
import { workforceRoutes } from './routes/workforce.js'
const app = Fastify({ logger: true, trustProxy: true })
const startedAt = Date.now()
await app.register(cookie)
await app.register(cors, { origin: process.env.CORS_ORIGIN || false, credentials: true })
app.get('/health', async () => ({ status: 'healthy' }))
app.get('/health', async () => ({ status: 'healthy', version: process.env.BUILD_VERSION || String(startedAt) }))
await app.register(bookingRoutes)
await app.register(configRoutes)

View file

@ -95,8 +95,6 @@ export async function fetchShifts(from, to, deptIds) {
let breakHrs = 0
if (Array.isArray(s.breaks) && s.breaks.length) {
breakHrs = s.breaks.reduce((sum, b) => sum + (b.finish - b.start) / 3600, 0)
} else {
breakHrs = (s.automatic_break_length ?? 0) / 60
}
const shiftHrs = Math.max(0, (s.finish - s.start) / 3600 - breakHrs)