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:
parent
0a08b1da3e
commit
eb92042de5
4 changed files with 12 additions and 7 deletions
|
|
@ -138,7 +138,7 @@
|
||||||
</cfif>
|
</cfif>
|
||||||
|
|
||||||
<cfset qOrderTotal = queryTimed("
|
<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
|
FROM Orders o
|
||||||
INNER JOIN Businesses b ON b.ID = o.BusinessID
|
INNER JOIN Businesses b ON b.ID = o.BusinessID
|
||||||
LEFT JOIN OrderLineItems oli ON oli.OrderID = o.ID AND oli.IsDeleted = b'0'
|
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 cashTax = cashSubtotal * val(qOrderTotal.TaxRate)>
|
||||||
<cfset cashTip = val(qOrderTotal.TipAmount)>
|
<cfset cashTip = val(qOrderTotal.TipAmount)>
|
||||||
<cfset cashDeliveryFee = (val(qOrderTotal.OrderTypeID) EQ 3) ? val(qOrderTotal.DeliveryFee) : 0>
|
<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)>
|
<cfset orderTotalCents = round((cashSubtotal + cashTax + cashTip + cashDeliveryFee + cashPlatformFee) * 100)>
|
||||||
|
|
||||||
<cfif CashReceivedCents LT orderTotalCents>
|
<cfif CashReceivedCents LT orderTotalCents>
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@
|
||||||
o.TipAmount,
|
o.TipAmount,
|
||||||
o.DeliveryFee,
|
o.DeliveryFee,
|
||||||
b.TaxRate,
|
b.TaxRate,
|
||||||
|
b.PayfritFee,
|
||||||
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,
|
||||||
|
|
@ -193,7 +194,8 @@
|
||||||
<cfset taxAmount = subtotal * val(qTask.TaxRate)>
|
<cfset taxAmount = subtotal * val(qTask.TaxRate)>
|
||||||
<cfset tipAmount = val(qTask.TipAmount)>
|
<cfset tipAmount = val(qTask.TipAmount)>
|
||||||
<cfset deliveryFee = (val(qTask.OrderTypeID) EQ 3) ? val(qTask.DeliveryFee) : 0>
|
<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 totalAmount = subtotal + taxAmount + tipAmount + deliveryFee + platformFee>
|
||||||
<cfset result.OrderTotal = numberFormat(totalAmount, "0.00")>
|
<cfset result.OrderTotal = numberFormat(totalAmount, "0.00")>
|
||||||
<cfset result.OrderTotalCents = round(totalAmount * 100)>
|
<cfset result.OrderTotalCents = round(totalAmount * 100)>
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@
|
||||||
<cfloop from="1" to="#arrayLen(tasks)#" index="i">
|
<cfloop from="1" to="#arrayLen(tasks)#" index="i">
|
||||||
<cfif val(tasks[i].SourceID) GT 0>
|
<cfif val(tasks[i].SourceID) GT 0>
|
||||||
<cfset qOT = queryTimed("
|
<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
|
FROM Orders o
|
||||||
INNER JOIN Businesses b ON b.ID = o.BusinessID
|
INNER JOIN Businesses b ON b.ID = o.BusinessID
|
||||||
LEFT JOIN OrderLineItems oli ON oli.OrderID = o.ID AND oli.IsDeleted = b'0'
|
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" })>
|
", [{ value = tasks[i].SourceID, cfsqltype = "cf_sql_integer" }], { datasource = "payfrit" })>
|
||||||
<cfif qOT.recordCount GT 0>
|
<cfif qOT.recordCount GT 0>
|
||||||
<cfset sub = val(qOT.Subtotal)>
|
<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>
|
<cfelse>
|
||||||
<cfset tasks[i]["OrderTotal"] = 0>
|
<cfset tasks[i]["OrderTotal"] = 0>
|
||||||
</cfif>
|
</cfif>
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@
|
||||||
<cfloop from="1" to="#arrayLen(tasks)#" index="i">
|
<cfloop from="1" to="#arrayLen(tasks)#" index="i">
|
||||||
<cfif val(tasks[i].SourceID) GT 0>
|
<cfif val(tasks[i].SourceID) GT 0>
|
||||||
<cfset qOT = queryTimed("
|
<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
|
FROM Orders o
|
||||||
INNER JOIN Businesses b ON b.ID = o.BusinessID
|
INNER JOIN Businesses b ON b.ID = o.BusinessID
|
||||||
LEFT JOIN OrderLineItems oli ON oli.OrderID = o.ID AND oli.IsDeleted = b'0'
|
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" })>
|
", [{ value = tasks[i].SourceID, cfsqltype = "cf_sql_integer" }], { datasource = "payfrit" })>
|
||||||
<cfif qOT.recordCount GT 0>
|
<cfif qOT.recordCount GT 0>
|
||||||
<cfset sub = val(qOT.Subtotal)>
|
<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>
|
<cfelse>
|
||||||
<cfset tasks[i]["OrderTotal"] = 0>
|
<cfset tasks[i]["OrderTotal"] = 0>
|
||||||
</cfif>
|
</cfif>
|
||||||
|
|
|
||||||
Reference in a new issue