Commit 7942245 1 parent 05d5023 commit 7942245 Copy full SHA for 7942245
File tree 1 file changed +19
-3
lines changed
vehicles/src/modules/credit-account
1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -242,9 +242,8 @@ export class CreditAccountService {
242
242
}
243
243
244
244
@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 ( {
248
247
where : {
249
248
company : { companyId } ,
250
249
} ,
@@ -254,6 +253,23 @@ export class CreditAccountService {
254
253
creditAccountActivities : { idirUser : true } ,
255
254
} ,
256
255
} ) ;
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
+ }
257
273
if ( ! creditAccount ) {
258
274
throw new DataNotFoundException ( ) ;
259
275
}
You can’t perform that action at this time.
0 commit comments