From d6fb5f48d9ebe1806aab76c07629306bc7463a89 Mon Sep 17 00:00:00 2001 From: Abdalhamid Alhamad Date: Sun, 2 Nov 2025 12:34:41 +0300 Subject: [PATCH] add more loggs --- src/card/services/card.service.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/card/services/card.service.ts b/src/card/services/card.service.ts index 5c2dc4e..4cb0a51 100644 --- a/src/card/services/card.service.ts +++ b/src/card/services/card.service.ts @@ -148,11 +148,18 @@ export class CardService { async transferToChild(juniorId: string, amount: number) { const card = await this.getCardByCustomerId(juniorId); + this.logger.debug(`Transfer to child - juniorId: ${juniorId}, parentId: ${card.parentId}, cardId: ${card.id}`); + this.logger.debug(`Card account - balance: ${card.account.balance}, reserved: ${card.account.reservedBalance}`); + const fundingAccount = card.parentId ? await this.accountService.getAccountByCustomerId(card.parentId) : card.account; + this.logger.debug(`Funding account - balance: ${fundingAccount.balance}, reserved: ${fundingAccount.reservedBalance}, available: ${fundingAccount.balance - fundingAccount.reservedBalance}`); + this.logger.debug(`Amount requested: ${amount}`); + if (amount > fundingAccount.balance - fundingAccount.reservedBalance) { + this.logger.error(`Insufficient balance - requested: ${amount}, available: ${fundingAccount.balance - fundingAccount.reservedBalance}`); throw new BadRequestException('CARD.INSUFFICIENT_BALANCE'); }