fix: validate card spending limit before transfering to child

This commit is contained in:
Abdalhameed Ahmad
2025-09-07 21:18:49 +03:00
parent d768da70f2
commit 15a48e4884
10 changed files with 75 additions and 2 deletions

View File

@ -27,6 +27,14 @@ export class AccountService {
return account;
}
async getAccountByIban(iban: string): Promise<Account> {
const account = await this.accountRepository.getAccountByIban(iban);
if (!account) {
throw new UnprocessableEntityException('ACCOUNT.NOT_FOUND');
}
return account;
}
creditAccountBalance(accountReference: string, amount: number) {
return this.accountRepository.topUpAccountBalance(accountReference, amount);
}
@ -52,4 +60,10 @@ export class AccountService {
return this.accountRepository.decreaseAccountBalance(accountReference, amount);
}
//THIS IS A MOCK FUNCTION FOR TESTING PURPOSES ONLY
async fundIban(iban: string, amount: number) {
const account = await this.getAccountByIban(iban);
return this.accountRepository.topUpAccountBalance(account.accountReference, amount);
}
}