feat: add-account-details

This commit is contained in:
Abdalhamid Alhamad
2025-07-31 14:07:01 +03:00
parent a245545811
commit 7e63abb2fb
9 changed files with 94 additions and 8 deletions

View File

@ -1,4 +1,5 @@
import { Injectable, UnprocessableEntityException } from '@nestjs/common';
import { CreateApplicationResponse } from '~/common/modules/neoleap/dtos/response';
import { Account } from '../entities/account.entity';
import { AccountRepository } from '../repositories/account.repository';
@ -6,8 +7,8 @@ import { AccountRepository } from '../repositories/account.repository';
export class AccountService {
constructor(private readonly accountRepository: AccountRepository) {}
createAccount(accountId: string): Promise<Account> {
return this.accountRepository.createAccount(accountId);
createAccount(data: CreateApplicationResponse): Promise<Account> {
return this.accountRepository.createAccount(data);
}
async getAccountByReferenceNumber(accountReference: string): Promise<Account> {
@ -18,6 +19,14 @@ export class AccountService {
return account;
}
async getAccountByAccountNumber(accountNumber: string): Promise<Account> {
const account = await this.accountRepository.getAccountByAccountNumber(accountNumber);
if (!account) {
throw new UnprocessableEntityException('ACCOUNT.NOT_FOUND');
}
return account;
}
async creditAccountBalance(accountReference: string, amount: number) {
return this.accountRepository.topUpAccountBalance(accountReference, amount);
}