Skip to content

Commit

Permalink
Fix: Get Credit Account endpoint when the Account is closed (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
praju-aot authored Jul 11, 2024
1 parent 4ad095c commit dbe8e4b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vehicles/src/modules/credit-account/credit-account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class CreditAccountService {
}

@LogAsyncMethodExecution()
async getCreditAccount(currentUser: IUserJWT, companyId: number) {
async getCreditAccount(currentUser: IUserJWT, companyId: number) {
let creditAccount = await this.creditAccountRepository.findOne({
where: {
company: { companyId },
Expand All @@ -259,7 +259,7 @@ export class CreditAccountService {
creditAccount?.creditAccountStatusType ===
CreditAccountStatus.ACCOUNT_CLOSED
) {
creditAccount = await this.creditAccountRepository.findOne({
const accountDetailsForUser = await this.creditAccountRepository.findOne({
where: {
creditAccountUsers: { company: { companyId }, isActive: true },
},
Expand All @@ -269,7 +269,11 @@ export class CreditAccountService {
creditAccountActivities: { idirUser: true },
},
});
if (accountDetailsForUser) {
creditAccount = accountDetailsForUser;
}
}

if (!creditAccount) {
throw new DataNotFoundException();
}
Expand Down

0 comments on commit dbe8e4b

Please sign in to comment.