Fix getUserNameMap location filter; fix detail cost filter to match aggregate
This commit is contained in:
parent
cf0cd0a5e4
commit
6661189127
1 changed files with 5 additions and 8 deletions
|
|
@ -75,13 +75,10 @@ async function getDeptNameMap() {
|
|||
}
|
||||
|
||||
async function getUserNameMap() {
|
||||
const creds = await getWorkforceCreds()
|
||||
const locationId = creds.location_id ? String(creds.location_id) : null
|
||||
const all = await wfFetchPaged('/api/v2/users')
|
||||
const filtered = locationId ? all.filter(u => String(u.location_id) === locationId) : all
|
||||
if (filtered.length > 0) console.log('USER_SAMPLE', JSON.stringify(filtered[0]))
|
||||
if (all.length > 0) console.log('USER_SAMPLE', JSON.stringify(all[0]))
|
||||
return Object.fromEntries(
|
||||
filtered.map(u => [String(u.id), `${u.first_name || ''} ${u.last_name || ''}`.trim() || `User ${u.id}`])
|
||||
all.map(u => [String(u.id), `${u.first_name || ''} ${u.last_name || ''}`.trim() || `User ${u.id}`])
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -125,8 +122,8 @@ export async function syncActuals(from, to) {
|
|||
byDateDept[key].total_cost += totalCost
|
||||
byDateDept[key].shift_count += 1
|
||||
|
||||
// detail by date+dept+employee (APPROVED only — pending have cost 0 but clutter the list)
|
||||
if (s.status === 'APPROVED') {
|
||||
// detail by date+dept+employee — include any shift that contributed cost to the aggregate
|
||||
if (totalCost > 0 || baseCost > 0) {
|
||||
const empId = String(s.user_id)
|
||||
const empName = userNameMap[empId] || `Employee ${empId}`
|
||||
const empKey = `${date}:${deptId}:${empId}`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue