mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
fix: validate card spending limit before transfering to child
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user