Fix getDetails customer info

This commit is contained in:
John Mizerek 2026-02-06 18:22:45 -08:00
parent 407f68655e
commit 14c9336025

View file

@ -47,6 +47,7 @@
t.ServicePointID AS TaskServicePointID, t.ServicePointID AS TaskServicePointID,
tc.Name AS CategoryName, tc.Name AS CategoryName,
tc.Color AS CategoryColor, tc.Color AS CategoryColor,
tt.Name AS TaskTypeName,
o.ID AS OID, o.ID AS OID,
o.UUID AS OrderUUID, o.UUID AS OrderUUID,
o.UserID AS OrderUserID, o.UserID AS OrderUserID,
@ -55,6 +56,9 @@
o.ServicePointID AS OrderServicePointID, o.ServicePointID AS OrderServicePointID,
o.Remarks, o.Remarks,
o.SubmittedOn, o.SubmittedOn,
o.TipAmount,
o.DeliveryFee,
b.TaxRate,
COALESCE(sp.Name, tsp.Name) AS ServicePointName, COALESCE(sp.Name, tsp.Name) AS ServicePointName,
COALESCE(sp.TypeID, tsp.TypeID) AS ServicePointTypeID, COALESCE(sp.TypeID, tsp.TypeID) AS ServicePointTypeID,
COALESCE(sp.ID, tsp.ID) AS ServicePointID, COALESCE(sp.ID, tsp.ID) AS ServicePointID,
@ -65,10 +69,12 @@
u.ImageExtension AS CustomerImageExtension u.ImageExtension AS CustomerImageExtension
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 Orders o ON o.ID = t.OrderID LEFT JOIN Orders o ON o.ID = t.OrderID
LEFT JOIN Businesses b ON b.ID = t.BusinessID
LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID LEFT JOIN ServicePoints sp ON sp.ID = o.ServicePointID
LEFT JOIN ServicePoints tsp ON tsp.ID = t.ServicePointID LEFT JOIN ServicePoints tsp ON tsp.ID = t.ServicePointID
LEFT JOIN Users u ON u.ID = o.UserID LEFT JOIN Users u ON u.ID = COALESCE(t.UserID, o.UserID)
WHERE t.ID = ? WHERE t.ID = ?
", [ { value = TaskID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })> ", [ { value = TaskID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
@ -103,6 +109,7 @@
"TaskBusinessID": qTask.BusinessID, "TaskBusinessID": qTask.BusinessID,
"TaskCategoryID": qTask.CategoryID, "TaskCategoryID": qTask.CategoryID,
"TaskTypeID": qTask.TaskTypeID ?: 1, "TaskTypeID": qTask.TaskTypeID ?: 1,
"TaskTypeName": qTask.TaskTypeName ?: "",
"TaskTitle": taskTitle, "TaskTitle": taskTitle,
"TaskCreatedOn": dateFormat(qTask.CreatedOn, "yyyy-mm-dd") & "T" & timeFormat(qTask.CreatedOn, "HH:mm:ss"), "TaskCreatedOn": dateFormat(qTask.CreatedOn, "yyyy-mm-dd") & "T" & timeFormat(qTask.CreatedOn, "HH:mm:ss"),
"TaskStatusID": qTask.ClaimedByUserID GT 0 ? 1 : 0, "TaskStatusID": qTask.ClaimedByUserID GT 0 ? 1 : 0,
@ -111,6 +118,7 @@
"OrderID": qTask.OrderID ?: 0, "OrderID": qTask.OrderID ?: 0,
"OrderRemarks": qTask.Remarks ?: "", "OrderRemarks": qTask.Remarks ?: "",
"OrderSubmittedOn": isDate(qTask.SubmittedOn) ? (dateFormat(qTask.SubmittedOn, "yyyy-mm-dd") & "T" & timeFormat(qTask.SubmittedOn, "HH:mm:ss")) : "", "OrderSubmittedOn": isDate(qTask.SubmittedOn) ? (dateFormat(qTask.SubmittedOn, "yyyy-mm-dd") & "T" & timeFormat(qTask.SubmittedOn, "HH:mm:ss")) : "",
"OrderTotal": 0,
"ServicePointID": qTask.ServicePointID ?: 0, "ServicePointID": qTask.ServicePointID ?: 0,
"ServicePointName": qTask.ServicePointName ?: "", "ServicePointName": qTask.ServicePointName ?: "",
"ServicePointTypeID": qTask.ServicePointTypeID ?: 0, "ServicePointTypeID": qTask.ServicePointTypeID ?: 0,
@ -164,7 +172,9 @@
ORDER BY oli.ID ORDER BY oli.ID
", [ { value = qTask.OrderID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })> ", [ { value = qTask.OrderID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
<cfset subtotal = 0>
<cfloop query="qLineItems"> <cfloop query="qLineItems">
<cfset subtotal = subtotal + (qLineItems.LineItemPrice * qLineItems.Quantity)>
<cfset arrayAppend(result.LineItems, { <cfset arrayAppend(result.LineItems, {
"LineItemID": qLineItems.OrderLineItemID, "LineItemID": qLineItems.OrderLineItemID,
"ParentLineItemID": qLineItems.ParentOrderLineItemID, "ParentLineItemID": qLineItems.ParentOrderLineItemID,
@ -176,6 +186,13 @@
"IsModifier": qLineItems.ParentOrderLineItemID GT 0 "IsModifier": qLineItems.ParentOrderLineItemID GT 0
})> })>
</cfloop> </cfloop>
<!--- Calculate order total: subtotal + tax + tip + delivery (if delivery) + platform fee --->
<cfset taxAmount = subtotal * val(qTask.TaxRate)>
<cfset tipAmount = val(qTask.TipAmount)>
<cfset deliveryFee = (val(qTask.OrderTypeID) EQ 3) ? val(qTask.DeliveryFee) : 0>
<cfset platformFee = subtotal * 0.05>
<cfset result.OrderTotal = numberFormat(subtotal + taxAmount + tipAmount + deliveryFee + platformFee, "0.00")>
</cfif> </cfif>
<cfset apiAbort({ <cfset apiAbort({