Fix customer lookup: prioritize Order.UserID over Task.UserID

For order-based tasks, the customer comes from Order.UserID.
For standalone tasks without an order, fall back to Task.UserID.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-02-06 18:28:36 -08:00
parent c1edb20e53
commit e1000dbe19

View file

@ -74,7 +74,7 @@
LEFT JOIN Businesses b ON b.ID = t.BusinessID
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID
LEFT JOIN ServicePoints tsp ON tsp.ID = t.ServicePointID
LEFT JOIN Users u ON u.ID = COALESCE(NULLIF(t.UserID, 0), o.UserID)
LEFT JOIN Users u ON u.ID = COALESCE(o.UserID, t.UserID)
WHERE t.ID = ?
", [ { value = TaskID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>