mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
Merge pull request #59 from HamzaSha1/money-request-to-use-the-parint-account
Refactor balance check in increaseReservedBalance method to delegate …
This commit is contained in:
@ -64,9 +64,8 @@ export class AccountService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
increaseReservedBalance(account: Account, amount: number) {
|
increaseReservedBalance(account: Account, amount: number) {
|
||||||
if (account.balance < account.reservedBalance + amount) {
|
// Balance check is performed by the caller (e.g., transferToChild)
|
||||||
throw new UnprocessableEntityException('CARD.INSUFFICIENT_BALANCE');
|
// to ensure correct account (guardian vs child) is validated
|
||||||
}
|
|
||||||
return this.accountRepository.increaseReservedBalance(account.id, amount);
|
return this.accountRepository.increaseReservedBalance(account.id, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user