Merge pull request #58 from HamzaSha1/money-request-to-use-the-parint-account

add more loggs
This commit is contained in:
abdalhamid99
2025-11-02 12:35:31 +03:00
committed by GitHub

View File

@ -148,11 +148,18 @@ export class CardService {
async transferToChild(juniorId: string, amount: number) { async transferToChild(juniorId: string, amount: number) {
const card = await this.getCardByCustomerId(juniorId); 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 const fundingAccount = card.parentId
? await this.accountService.getAccountByCustomerId(card.parentId) ? await this.accountService.getAccountByCustomerId(card.parentId)
: card.account; : 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) { if (amount > fundingAccount.balance - fundingAccount.reservedBalance) {
this.logger.error(`Insufficient balance - requested: ${amount}, available: ${fundingAccount.balance - fundingAccount.reservedBalance}`);
throw new BadRequestException('CARD.INSUFFICIENT_BALANCE'); throw new BadRequestException('CARD.INSUFFICIENT_BALANCE');
} }