Fix timesheetLevel cost field — use t.total_cost not t.cost

The timesheets/on/{date} response has total_cost at the timesheet level,
not cost or cost_with_oncosts. Previous code was reading undefined and
summing zeros.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-23 15:06:39 +00:00
parent 241524c9ce
commit be1ef7f99e

View file

@ -367,8 +367,9 @@ async function fetchTimesheetsByDay(from, to, locationDeptIds) {
return locationDeptIds.has(String(sh.department_id ?? 'unknown')) return locationDeptIds.has(String(sh.department_id ?? 'unknown'))
}) })
if (hasLocationShift) { if (hasLocationShift) {
const tCost = parseFloat(t.cost ?? 0) // Timesheet-level cost field is `total_cost` (not `cost` or `cost_with_oncosts`)
const tOncost = parseFloat(t.cost_with_oncosts ?? t.cost ?? 0) const tCost = parseFloat(t.total_cost ?? t.cost ?? 0)
const tOncost = parseFloat(t.cost_with_oncosts ?? t.total_cost ?? t.cost ?? 0)
const isLeaveTs = t.leave_request_id != null const isLeaveTs = t.leave_request_id != null
if (isLeaveTs) { tsLeaveBaseCost += tCost; tsLeaveOncostTotal += tOncost } if (isLeaveTs) { tsLeaveBaseCost += tCost; tsLeaveOncostTotal += tOncost }
else { tsBaseCost += tCost; tsOncostTotal += tOncost } else { tsBaseCost += tCost; tsOncostTotal += tOncost }