Fix delivery task creation when other tasks exist for order

The duplicate check was preventing delivery task creation if ANY task
existed for the order (e.g., Cash or Chat tasks). Now only checks for
TaskTypeID=1 (delivery/pickup tasks) to allow proper task creation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-02-16 19:24:59 -08:00
parent aeeba3c6e5
commit 7caf4d60b0

View file

@ -90,9 +90,10 @@
<cfset cashTaskCreated = false> <cfset cashTaskCreated = false>
<cfif NewStatusID EQ 3 AND oldStatusID NEQ 3> <cfif NewStatusID EQ 3 AND oldStatusID NEQ 3>
<cftry> <cftry>
<!--- Check if task already exists for this order to prevent duplicates ---> <!--- Check if delivery/pickup task already exists for this order (TaskTypeID=1) to prevent duplicates --->
<!--- Note: Other tasks like Cash or Chat may already exist for this order, so we only check for TaskTypeID=1 --->
<cfset qExisting = queryExecute(" <cfset qExisting = queryExecute("
SELECT ID FROM Tasks WHERE OrderID = ? LIMIT 1 SELECT ID FROM Tasks WHERE OrderID = ? AND TaskTypeID = 1 LIMIT 1
", [ { value = OrderID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })> ", [ { value = OrderID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
<cfif qExisting.recordCount EQ 0> <cfif qExisting.recordCount EQ 0>