Fix cash debit: attribute to business owner for admin/manager roles

Staff cash_debit goes to the worker (they keep the cash).
Admin/Manager cash_debit goes to the business owner (restaurant has it).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-02-28 12:10:59 -08:00
parent d1910a7d34
commit 698d31f62c

View file

@ -305,16 +305,18 @@
}, { datasource = "payfrit" })> }, { datasource = "payfrit" })>
</cfif> </cfif>
<!--- Debit worker (received physical cash, debit digitally) ---> <!--- Debit for physical cash received --->
<!--- Skip for admin/manager — they collected cash on behalf of the restaurant ---> <!--- Staff: debit the worker (they pocketed the cash) --->
<cfif workerUserID_for_payout GT 0 AND NOT isAdminRole> <!--- Admin/Manager: debit the business owner (restaurant has the cash) --->
<cfset cashDebitUserID = isAdminRole ? businessOwnerUserID : workerUserID_for_payout>
<cfif cashDebitUserID GT 0>
<cfset queryTimed(" <cfset queryTimed("
INSERT INTO WorkPayoutLedgers INSERT INTO WorkPayoutLedgers
(UserID, TaskID, GrossEarningsCents, ActivationWithheldCents, NetTransferCents, Status) (UserID, TaskID, GrossEarningsCents, ActivationWithheldCents, NetTransferCents, Status)
VALUES VALUES
(:userID, :taskID, :gross, 0, :net, 'cash_debit') (:userID, :taskID, :gross, 0, :net, 'cash_debit')
", { ", {
userID: workerUserID_for_payout, userID: cashDebitUserID,
taskID: TaskID, taskID: TaskID,
gross: -CashReceivedCents, gross: -CashReceivedCents,
net: -CashReceivedCents net: -CashReceivedCents