Use business PayfritFee instead of hardcoded 5% in task order totals

Fixed complete.cfm, getDetails.cfm, listMine.cfm, listPending.cfm to pull
PayfritFee from Businesses table with 0.05 fallback if not set.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-02-17 09:20:18 -08:00
parent 0a08b1da3e
commit eb92042de5
4 changed files with 12 additions and 7 deletions

View file

@ -138,7 +138,7 @@
</cfif>
<cfset qOrderTotal = queryTimed("
SELECT SUM(oli.Price * oli.Quantity) AS Subtotal, o.TipAmount, o.DeliveryFee, o.OrderTypeID, b.TaxRate
SELECT SUM(oli.Price * oli.Quantity) AS Subtotal, o.TipAmount, o.DeliveryFee, o.OrderTypeID, b.TaxRate, b.PayfritFee
FROM Orders o
INNER JOIN Businesses b ON b.ID = o.BusinessID
LEFT JOIN OrderLineItems oli ON oli.OrderID = o.ID AND oli.IsDeleted = b'0'
@ -154,7 +154,8 @@
<cfset cashTax = cashSubtotal * val(qOrderTotal.TaxRate)>
<cfset cashTip = val(qOrderTotal.TipAmount)>
<cfset cashDeliveryFee = (val(qOrderTotal.OrderTypeID) EQ 3) ? val(qOrderTotal.DeliveryFee) : 0>
<cfset cashPlatformFee = cashSubtotal * 0.05>
<cfset cashPayfritFee = (isNumeric(qOrderTotal.PayfritFee) AND val(qOrderTotal.PayfritFee) GT 0) ? val(qOrderTotal.PayfritFee) : 0.05>
<cfset cashPlatformFee = cashSubtotal * cashPayfritFee>
<cfset orderTotalCents = round((cashSubtotal + cashTax + cashTip + cashDeliveryFee + cashPlatformFee) * 100)>
<cfif CashReceivedCents LT orderTotalCents>

View file

@ -57,6 +57,7 @@
o.TipAmount,
o.DeliveryFee,
b.TaxRate,
b.PayfritFee,
COALESCE(sp.Name, tsp.Name) AS ServicePointName,
COALESCE(sp.TypeID, tsp.TypeID) AS ServicePointTypeID,
COALESCE(sp.ID, tsp.ID) AS ServicePointID,
@ -193,7 +194,8 @@
<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 feeRate = (isNumeric(qTask.PayfritFee) AND val(qTask.PayfritFee) GT 0) ? val(qTask.PayfritFee) : 0.05>
<cfset platformFee = subtotal * feeRate>
<cfset totalAmount = subtotal + taxAmount + tipAmount + deliveryFee + platformFee>
<cfset result.OrderTotal = numberFormat(totalAmount, "0.00")>
<cfset result.OrderTotalCents = round(totalAmount * 100)>

View file

@ -148,7 +148,7 @@
<cfloop from="1" to="#arrayLen(tasks)#" index="i">
<cfif val(tasks[i].SourceID) GT 0>
<cfset qOT = queryTimed("
SELECT SUM(oli.Price * oli.Quantity) AS Subtotal, o.TipAmount, o.DeliveryFee, o.OrderTypeID, b.TaxRate
SELECT SUM(oli.Price * oli.Quantity) AS Subtotal, o.TipAmount, o.DeliveryFee, o.OrderTypeID, b.TaxRate, b.PayfritFee
FROM Orders o
INNER JOIN Businesses b ON b.ID = o.BusinessID
LEFT JOIN OrderLineItems oli ON oli.OrderID = o.ID AND oli.IsDeleted = b'0'
@ -157,7 +157,8 @@
", [{ value = tasks[i].SourceID, cfsqltype = "cf_sql_integer" }], { datasource = "payfrit" })>
<cfif qOT.recordCount GT 0>
<cfset sub = val(qOT.Subtotal)>
<cfset tasks[i]["OrderTotal"] = numberFormat(sub + (sub * val(qOT.TaxRate)) + val(qOT.TipAmount) + ((val(qOT.OrderTypeID) EQ 3) ? val(qOT.DeliveryFee) : 0) + (sub * 0.05), "0.00")>
<cfset feeRate = (isNumeric(qOT.PayfritFee) AND val(qOT.PayfritFee) GT 0) ? val(qOT.PayfritFee) : 0.05>
<cfset tasks[i]["OrderTotal"] = numberFormat(sub + (sub * val(qOT.TaxRate)) + val(qOT.TipAmount) + ((val(qOT.OrderTypeID) EQ 3) ? val(qOT.DeliveryFee) : 0) + (sub * feeRate), "0.00")>
<cfelse>
<cfset tasks[i]["OrderTotal"] = 0>
</cfif>

View file

@ -128,7 +128,7 @@
<cfloop from="1" to="#arrayLen(tasks)#" index="i">
<cfif val(tasks[i].SourceID) GT 0>
<cfset qOT = queryTimed("
SELECT SUM(oli.Price * oli.Quantity) AS Subtotal, o.TipAmount, o.DeliveryFee, o.OrderTypeID, b.TaxRate
SELECT SUM(oli.Price * oli.Quantity) AS Subtotal, o.TipAmount, o.DeliveryFee, o.OrderTypeID, b.TaxRate, b.PayfritFee
FROM Orders o
INNER JOIN Businesses b ON b.ID = o.BusinessID
LEFT JOIN OrderLineItems oli ON oli.OrderID = o.ID AND oli.IsDeleted = b'0'
@ -137,7 +137,8 @@
", [{ value = tasks[i].SourceID, cfsqltype = "cf_sql_integer" }], { datasource = "payfrit" })>
<cfif qOT.recordCount GT 0>
<cfset sub = val(qOT.Subtotal)>
<cfset tasks[i]["OrderTotal"] = numberFormat(sub + (sub * val(qOT.TaxRate)) + val(qOT.TipAmount) + ((val(qOT.OrderTypeID) EQ 3) ? val(qOT.DeliveryFee) : 0) + (sub * 0.05), "0.00")>
<cfset feeRate = (isNumeric(qOT.PayfritFee) AND val(qOT.PayfritFee) GT 0) ? val(qOT.PayfritFee) : 0.05>
<cfset tasks[i]["OrderTotal"] = numberFormat(sub + (sub * val(qOT.TaxRate)) + val(qOT.TipAmount) + ((val(qOT.OrderTypeID) EQ 3) ? val(qOT.DeliveryFee) : 0) + (sub * feeRate), "0.00")>
<cfelse>
<cfset tasks[i]["OrderTotal"] = 0>
</cfif>