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:
parent
6346ffdb02
commit
06adc1211e
1 changed files with 24 additions and 14 deletions
|
|
@ -16,10 +16,12 @@
|
|||
<cfset cart_grand_total = 0>
|
||||
|
||||
<cfquery name="get_order_info">
|
||||
SELECT O.OrderTypeID, O.BusinessID, O.Remarks, O.ID, O.BalanceApplied,
|
||||
B.Name, B.TaxRate, B.PayfritFee
|
||||
SELECT O.OrderTypeID, O.BusinessID, O.Remarks, O.ID, O.BalanceApplied, O.PaymentID,
|
||||
B.Name, B.TaxRate, B.PayfritFee,
|
||||
COALESCE(P.PaymentPaidInCash, 0) AS PaymentPaidInCash
|
||||
FROM Orders O
|
||||
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">
|
||||
</cfquery>
|
||||
|
||||
|
|
@ -304,21 +306,27 @@
|
|||
<cfset PaymentDeliveryFee = calculated_delivery_fee>
|
||||
</cfif>
|
||||
|
||||
<!--- Determine if this is a cash order --->
|
||||
<cfset isCashOrder = val(get_order_info.PaymentPaidInCash) GT 0>
|
||||
|
||||
<!--- Calculate total BEFORE card fee (no rounding) --->
|
||||
<cfset totalBeforeCardFee = cart_grand_total + tax_amount_raw + payfrit_fee_raw + PaymentDeliveryFee>
|
||||
|
||||
<!--- Calculate final total with Stripe fees: (amount + $0.30) / (1 - 2.9%) --->
|
||||
<cfset cardFeePercent = 0.029>
|
||||
<cfset cardFeeFixed = 0.30>
|
||||
<cfset totalCustomerPays_raw = (totalBeforeCardFee + cardFeeFixed) / (1 - cardFeePercent)>
|
||||
|
||||
<!--- Round ONLY the final total to cents (this is what Stripe charges) --->
|
||||
<cfset order_grand_total = round(totalCustomerPays_raw * 100) / 100>
|
||||
|
||||
<!--- Work backwards to get displayed values that add up correctly --->
|
||||
<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 isCashOrder>
|
||||
<!--- Cash: no card processing fee --->
|
||||
<cfset order_grand_total = round(totalBeforeCardFee * 100) / 100>
|
||||
<cfset tax_amount = round(tax_amount_raw * 100) / 100>
|
||||
<cfset cardFee = 0>
|
||||
<cfelse>
|
||||
<!--- Card: add Stripe fees: (amount + $0.30) / (1 - 2.9%) --->
|
||||
<cfset cardFeePercent = 0.029>
|
||||
<cfset cardFeeFixed = 0.30>
|
||||
<cfset totalCustomerPays_raw = (totalBeforeCardFee + cardFeeFixed) / (1 - cardFeePercent)>
|
||||
<cfset order_grand_total = round(totalCustomerPays_raw * 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 --->
|
||||
<cfif tax_amount GT 0>
|
||||
|
|
@ -342,10 +350,12 @@
|
|||
</div>
|
||||
</cfif>
|
||||
|
||||
<cfif cardFee GT 0>
|
||||
<div class="total-row">
|
||||
<span>Processing fee</span>
|
||||
<span>#dollarFormat(cardFee)#</span>
|
||||
</div>
|
||||
</cfif>
|
||||
|
||||
<cfset receiptBalanceApplied = val(get_order_info.BalanceApplied)>
|
||||
<cfif receiptBalanceApplied GT 0>
|
||||
|
|
|
|||
Reference in a new issue