From 21720510932fcaaab3b5895e4082af275ab64626 Mon Sep 17 00:00:00 2001 From: Abdalhamid Alhamad Date: Sun, 2 Nov 2025 12:41:16 +0300 Subject: [PATCH] Refactor balance check in increaseReservedBalance method to delegate validation to the caller, improving clarity and responsibility separation. --- src/card/services/account.service.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/card/services/account.service.ts b/src/card/services/account.service.ts index e6ac155..aefff7a 100644 --- a/src/card/services/account.service.ts +++ b/src/card/services/account.service.ts @@ -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); }