Skip to content

Commit 7942245

Browse files
authored
feat: ORV2-2530 Get endpoint to handle Credit account users (#1461)
1 parent 05d5023 commit 7942245

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

vehicles/src/modules/credit-account/credit-account.service.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,8 @@ export class CreditAccountService {
242242
}
243243

244244
@LogAsyncMethodExecution()
245-
async getCreditAccount(currentUser: IUserJWT, companyId: number) {
246-
//TODO handle where company is Credit Account User.
247-
const creditAccount = await this.creditAccountRepository.findOne({
245+
async getCreditAccount(currentUser: IUserJWT, companyId: number) {
246+
let creditAccount = await this.creditAccountRepository.findOne({
248247
where: {
249248
company: { companyId },
250249
},
@@ -254,6 +253,23 @@ export class CreditAccountService {
254253
creditAccountActivities: { idirUser: true },
255254
},
256255
});
256+
257+
if (
258+
!creditAccount ||
259+
creditAccount?.creditAccountStatusType ===
260+
CreditAccountStatus.ACCOUNT_CLOSED
261+
) {
262+
creditAccount = await this.creditAccountRepository.findOne({
263+
where: {
264+
creditAccountUsers: { company: { companyId }, isActive: true },
265+
},
266+
relations: {
267+
company: true,
268+
creditAccountUsers: { company: true },
269+
creditAccountActivities: { idirUser: true },
270+
},
271+
});
272+
}
257273
if (!creditAccount) {
258274
throw new DataNotFoundException();
259275
}

0 commit comments

Comments
 (0)