Fix customer lookup: treat Order.UserID=0 as NULL

COALESCE treats 0 as valid, so Order.UserID=0 was matching User 0
(Payfrit Network) instead of falling back to Task.UserID.
Use NULLIF to convert 0 to NULL before the fallback.

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

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(o.UserID, t.UserID)
LEFT JOIN Users u ON u.ID = COALESCE(NULLIF(o.UserID, 0), t.UserID)
WHERE t.ID = ?
", [ { value = TaskID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>