From be1ef7f99e3775419d3272b468dd431429a10b25 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Thu, 23 Jul 2026 15:06:39 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20timesheetLevel=20cost=20field=20=E2=80=94?= =?UTF-8?q?=20use=20t.total=5Fcost=20not=20t.cost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- backend/src/lib/workforce.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/lib/workforce.js b/backend/src/lib/workforce.js index 01e204b..28a87c2 100644 --- a/backend/src/lib/workforce.js +++ b/backend/src/lib/workforce.js @@ -367,8 +367,9 @@ async function fetchTimesheetsByDay(from, to, locationDeptIds) { return locationDeptIds.has(String(sh.department_id ?? 'unknown')) }) if (hasLocationShift) { - const tCost = parseFloat(t.cost ?? 0) - const tOncost = parseFloat(t.cost_with_oncosts ?? t.cost ?? 0) + // Timesheet-level cost field is `total_cost` (not `cost` or `cost_with_oncosts`) + 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 if (isLeaveTs) { tsLeaveBaseCost += tCost; tsLeaveOncostTotal += tOncost } else { tsBaseCost += tCost; tsOncostTotal += tOncost }