Fix employee name lookup — use name field not first_name/last_name; remove temp logs

This commit is contained in:
jtricerolph 2026-07-23 11:33:45 +00:00
parent 6661189127
commit 95103280c3

View file

@ -76,9 +76,8 @@ async function getDeptNameMap() {
async function getUserNameMap() { async function getUserNameMap() {
const all = await wfFetchPaged('/api/v2/users') const all = await wfFetchPaged('/api/v2/users')
if (all.length > 0) console.log('USER_SAMPLE', JSON.stringify(all[0]))
return Object.fromEntries( return Object.fromEntries(
all.map(u => [String(u.id), `${u.first_name || ''} ${u.last_name || ''}`.trim() || `User ${u.id}`]) all.map(u => [String(u.id), u.name || `${u.legal_first_name || ''} ${u.legal_last_name || ''}`.trim() || `User ${u.id}`])
) )
} }
@ -92,9 +91,6 @@ export async function syncActuals(from, to) {
const shifts = await wfFetchPaged(path) const shifts = await wfFetchPaged(path)
const [deptNameMap, userNameMap] = await Promise.all([getDeptNameMap(), getUserNameMap()]) const [deptNameMap, userNameMap] = await Promise.all([getDeptNameMap(), getUserNameMap()])
const statusCosts = {}
for (const s of shifts) { statusCosts[s.status] = (statusCosts[s.status] || 0) + parseFloat(s.cost_with_oncosts ?? s.cost ?? 0) }
console.log('SHIFT_STATUS_COSTS', JSON.stringify(statusCosts))
const byDateDept = {} const byDateDept = {}
const byDateDeptEmp = {} const byDateDeptEmp = {}