20 lines
535 B
TypeScript
20 lines
535 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;
|
|
defaultGPB: number;
|
|
defaultBalance: number;
|
|
prepaidAllowance: number;
|
|
}): number {
|
|
return newGPB - prepaidAllowance;
|
|
}
|