Fix task APIs to get ServicePointName from Task.ServicePointID

- Use COALESCE(t.ServicePointID, o.ServicePointID) in JOIN
- Add ServicePointID to JSON response
- Fixes service bell tasks showing table name

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-02-06 17:46:04 -08:00
parent 8c247eb000
commit b1a263bb36
2 changed files with 6 additions and 2 deletions

View file

@ -83,13 +83,14 @@
tt.Icon AS TaskTypeIcon, tt.Icon AS TaskTypeIcon,
tt.Color AS TaskTypeColor, tt.Color AS TaskTypeColor,
b.Name AS BusinessName, b.Name AS BusinessName,
t.ServicePointID,
sp.Name AS ServicePointName sp.Name AS ServicePointName
FROM Tasks t FROM Tasks t
LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID
LEFT JOIN tt_TaskTypes tt ON tt.ID = t.TaskTypeID LEFT JOIN tt_TaskTypes tt ON tt.ID = t.TaskTypeID
LEFT JOIN Businesses b ON b.ID = t.BusinessID LEFT JOIN Businesses b ON b.ID = t.BusinessID
LEFT JOIN Orders o ON o.ID = t.OrderID LEFT JOIN Orders o ON o.ID = t.OrderID
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID LEFT JOIN ServicePoints sp ON sp.ID = COALESCE(t.ServicePointID, o.ServicePointID)
WHERE #whereSQL# WHERE #whereSQL#
ORDER BY t.ClaimedOn DESC ORDER BY t.ClaimedOn DESC
", params, { datasource = "payfrit" })> ", params, { datasource = "payfrit" })>
@ -131,6 +132,7 @@
"TaskTypeName": len(trim(qTasks.TaskTypeName)) ? qTasks.TaskTypeName : "", "TaskTypeName": len(trim(qTasks.TaskTypeName)) ? qTasks.TaskTypeName : "",
"TaskTypeIcon": len(trim(qTasks.TaskTypeIcon)) ? qTasks.TaskTypeIcon : "notifications", "TaskTypeIcon": len(trim(qTasks.TaskTypeIcon)) ? qTasks.TaskTypeIcon : "notifications",
"TaskTypeColor": len(trim(qTasks.TaskTypeColor)) ? qTasks.TaskTypeColor : "##9C27B0", "TaskTypeColor": len(trim(qTasks.TaskTypeColor)) ? qTasks.TaskTypeColor : "##9C27B0",
"ServicePointID": val(qTasks.ServicePointID),
"ServicePointName": isNull(qTasks.ServicePointName) ? "" : qTasks.ServicePointName "ServicePointName": isNull(qTasks.ServicePointName) ? "" : qTasks.ServicePointName
})> })>
</cfloop> </cfloop>

View file

@ -70,12 +70,13 @@
tt.Name AS TaskTypeName, tt.Name AS TaskTypeName,
tt.Icon AS TaskTypeIcon, tt.Icon AS TaskTypeIcon,
tt.Color AS TaskTypeColor, tt.Color AS TaskTypeColor,
t.ServicePointID,
sp.Name AS ServicePointName sp.Name AS ServicePointName
FROM Tasks t FROM Tasks t
LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID LEFT JOIN TaskCategories tc ON tc.ID = t.CategoryID
LEFT JOIN tt_TaskTypes tt ON tt.ID = t.TaskTypeID LEFT JOIN tt_TaskTypes tt ON tt.ID = t.TaskTypeID
LEFT JOIN Orders o ON o.ID = t.OrderID LEFT JOIN Orders o ON o.ID = t.OrderID
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID LEFT JOIN ServicePoints sp ON sp.ID = COALESCE(t.ServicePointID, o.ServicePointID)
WHERE #whereSQL# WHERE #whereSQL#
ORDER BY t.CreatedOn ASC ORDER BY t.CreatedOn ASC
", params, { datasource = "payfrit" })> ", params, { datasource = "payfrit" })>
@ -111,6 +112,7 @@
"TaskTypeName": len(trim(qTasks.TaskTypeName)) ? qTasks.TaskTypeName : "", "TaskTypeName": len(trim(qTasks.TaskTypeName)) ? qTasks.TaskTypeName : "",
"TaskTypeIcon": len(trim(qTasks.TaskTypeIcon)) ? qTasks.TaskTypeIcon : "notifications", "TaskTypeIcon": len(trim(qTasks.TaskTypeIcon)) ? qTasks.TaskTypeIcon : "notifications",
"TaskTypeColor": len(trim(qTasks.TaskTypeColor)) ? qTasks.TaskTypeColor : "##9C27B0", "TaskTypeColor": len(trim(qTasks.TaskTypeColor)) ? qTasks.TaskTypeColor : "##9C27B0",
"ServicePointID": val(qTasks.ServicePointID),
"ServicePointName": isNull(qTasks.ServicePointName) ? "" : qTasks.ServicePointName "ServicePointName": isNull(qTasks.ServicePointName) ? "" : qTasks.ServicePointName
})> })>
</cfloop> </cfloop>