Function: upsertSyncedEntries()
upsertSyncedEntries(
entries,companyId):Promise<SyncResult>
Defined in: src/server/integrations/hubstaff/sync.ts:26
Upsert normalized Hubstaff entries as time_entries. Maps member → contractor (contractors.hubstaff_member_id) and project → assignment (assignments.hubstaff_project_id), falling back to the contractor's active assignment when no project mapping matches.
companyId scopes the member lookup to the caller's company (required for the admin CSV import so
one tenant can't write another tenant's hours); pass null only for the org-wide webhook on a
single-tenant deployment. Never overwrites a locked/approved entry or a manual correction,
and never downgrades an existing entry's status (avoids reverting facility-approved overage).
Idempotent on (contractor, assignment, date). DB write failures are counted separately.
Parameters
entries
companyId
string | null
Returns
Promise<SyncResult>