mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 00:24:54 +00:00
Refactor balance check in increaseReservedBalance method to delegate validation to the caller, improving clarity and responsibility separation.
This commit is contained in:
@ -64,9 +64,8 @@ export class AccountService {
|
||||
}
|
||||
|
||||
increaseReservedBalance(account: Account, amount: number) {
|
||||
if (account.balance < account.reservedBalance + amount) {
|
||||
throw new UnprocessableEntityException('CARD.INSUFFICIENT_BALANCE');
|
||||
}
|
||||
// Balance check is performed by the caller (e.g., transferToChild)
|
||||
// to ensure correct account (guardian vs child) is validated
|
||||
return this.accountRepository.increaseReservedBalance(account.id, amount);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user