Files
cfw-autumn/shared/utils/cusEntUtils/balanceUtils/computeGrantedBalanceInput.ts
Ayush Rodrigues 1d9a1b96dd Replace info box with toggle for granted balance in balance edit sheet
Swap the static "both will be updated" info box with a ConfigRow + Switch
toggle so users can control whether adding to balance also updates the
granted balance. Remove the overly restrictive included_grant validation
on the server and clean up dead params in computeGrantedBalanceInput.

Made-with: Cursor
2026-04-17 15:03:15 +01:00

18 lines
489 B
TypeScript

/**
* Computes the granted_balance value to send to the balance update API
* when the BalanceEditSheet "set" mode submits.
*
* The form displays grantedAndPurchasedBalance (GPB) as an editable field.
* To derive the actual granted_balance, we subtract the prepaid allowance
* from the user's new GPB value.
*/
export function computeGrantedBalanceInput({
newGPB,
prepaidAllowance,
}: {
newGPB: number;
prepaidAllowance: number;
}): number {
return newGPB - prepaidAllowance;
}