Fix receipt showing processing fee for cash orders

Cash orders have no card processing fee. Now checks PaymentPaidInCash
to determine payment type and skips the Stripe fee calculation + display
for cash orders.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-03-08 11:24:23 -07:00
parent 6346ffdb02
commit 06adc1211e

View file

@ -16,10 +16,12 @@
<cfset cart_grand_total = 0> <cfset cart_grand_total = 0>
<cfquery name="get_order_info"> <cfquery name="get_order_info">
SELECT O.OrderTypeID, O.BusinessID, O.Remarks, O.ID, O.BalanceApplied, SELECT O.OrderTypeID, O.BusinessID, O.Remarks, O.ID, O.BalanceApplied, O.PaymentID,
B.Name, B.TaxRate, B.PayfritFee B.Name, B.TaxRate, B.PayfritFee,
COALESCE(P.PaymentPaidInCash, 0) AS PaymentPaidInCash
FROM Orders O FROM Orders O
JOIN Businesses B ON B.ID = O.BusinessID JOIN Businesses B ON B.ID = O.BusinessID
LEFT JOIN Payments P ON P.ID = O.PaymentID
WHERE O.UUID = <cfqueryparam value="#url.UUID#" cfsqltype="cf_sql_varchar"> WHERE O.UUID = <cfqueryparam value="#url.UUID#" cfsqltype="cf_sql_varchar">
</cfquery> </cfquery>
@ -304,21 +306,27 @@
<cfset PaymentDeliveryFee = calculated_delivery_fee> <cfset PaymentDeliveryFee = calculated_delivery_fee>
</cfif> </cfif>
<!--- Determine if this is a cash order --->
<cfset isCashOrder = val(get_order_info.PaymentPaidInCash) GT 0>
<!--- Calculate total BEFORE card fee (no rounding) ---> <!--- Calculate total BEFORE card fee (no rounding) --->
<cfset totalBeforeCardFee = cart_grand_total + tax_amount_raw + payfrit_fee_raw + PaymentDeliveryFee> <cfset totalBeforeCardFee = cart_grand_total + tax_amount_raw + payfrit_fee_raw + PaymentDeliveryFee>
<!--- Calculate final total with Stripe fees: (amount + $0.30) / (1 - 2.9%) ---> <cfif isCashOrder>
<cfset cardFeePercent = 0.029> <!--- Cash: no card processing fee --->
<cfset cardFeeFixed = 0.30> <cfset order_grand_total = round(totalBeforeCardFee * 100) / 100>
<cfset totalCustomerPays_raw = (totalBeforeCardFee + cardFeeFixed) / (1 - cardFeePercent)> <cfset tax_amount = round(tax_amount_raw * 100) / 100>
<cfset cardFee = 0>
<!--- Round ONLY the final total to cents (this is what Stripe charges) ---> <cfelse>
<cfset order_grand_total = round(totalCustomerPays_raw * 100) / 100> <!--- Card: add Stripe fees: (amount + $0.30) / (1 - 2.9%) --->
<cfset cardFeePercent = 0.029>
<!--- Work backwards to get displayed values that add up correctly ---> <cfset cardFeeFixed = 0.30>
<cfset tax_amount = round(tax_amount_raw * 100) / 100> <cfset totalCustomerPays_raw = (totalBeforeCardFee + cardFeeFixed) / (1 - cardFeePercent)>
<cfset cardFee = order_grand_total - cart_grand_total - tax_amount - round(payfrit_fee_raw * 100) / 100 - PaymentDeliveryFee> <cfset order_grand_total = round(totalCustomerPays_raw * 100) / 100>
<cfset cardFee = round(cardFee * 100) / 100> <cfset tax_amount = round(tax_amount_raw * 100) / 100>
<cfset cardFee = order_grand_total - cart_grand_total - tax_amount - round(payfrit_fee_raw * 100) / 100 - PaymentDeliveryFee>
<cfset cardFee = round(cardFee * 100) / 100>
</cfif>
<!--- Display fees ---> <!--- Display fees --->
<cfif tax_amount GT 0> <cfif tax_amount GT 0>
@ -342,10 +350,12 @@
</div> </div>
</cfif> </cfif>
<cfif cardFee GT 0>
<div class="total-row"> <div class="total-row">
<span>Processing fee</span> <span>Processing fee</span>
<span>#dollarFormat(cardFee)#</span> <span>#dollarFormat(cardFee)#</span>
</div> </div>
</cfif>
<cfset receiptBalanceApplied = val(get_order_info.BalanceApplied)> <cfset receiptBalanceApplied = val(get_order_info.BalanceApplied)>
<cfif receiptBalanceApplied GT 0> <cfif receiptBalanceApplied GT 0>