mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 00:24:54 +00:00
Merge pull request #58 from HamzaSha1/money-request-to-use-the-parint-account
add more loggs
This commit is contained in:
@ -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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user