gemcap-be-common 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,11 +35,11 @@ export declare const borrowerDataModels: {
35
35
  [modelName: string]: mongoose.Model<any>;
36
36
  };
37
37
  export declare class BorrowerService {
38
- private readonly collateralsService;
39
- private readonly loanStatementStatusService;
40
- private readonly loanTransactionsService;
41
- private readonly signsService;
42
- constructor(collateralsService: CollateralsService, loanStatementStatusService: LoanStatementStatusService, loanTransactionsService: LoanTransactionsService, signsService: SignsService);
38
+ private readonly getCollateralsService;
39
+ private readonly getLoanStatementStatusService;
40
+ private readonly getLoanTransactionsService;
41
+ private readonly getSignsService;
42
+ constructor(getCollateralsService: () => CollateralsService, getLoanStatementStatusService: () => LoanStatementStatusService, getLoanTransactionsService: () => LoanTransactionsService, getSignsService: () => SignsService);
43
43
  isBorrowerAllowed(userAccess: any, requestedBorrowerId: string): boolean;
44
44
  checkBorrower(userAccess: any, requestedBorrowerId: string): boolean;
45
45
  getBorrowerById(borrowerId: string): Promise<mongoose.FlattenMaps<IBorrowerDocument> & {
@@ -29,15 +29,15 @@ exports.borrowerDataModels = {
29
29
  insurance: BorrowerDataInsurance_model_1.BorrowerDataInsuranceModel,
30
30
  };
31
31
  class BorrowerService {
32
- collateralsService;
33
- loanStatementStatusService;
34
- loanTransactionsService;
35
- signsService;
36
- constructor(collateralsService, loanStatementStatusService, loanTransactionsService, signsService) {
37
- this.collateralsService = collateralsService;
38
- this.loanStatementStatusService = loanStatementStatusService;
39
- this.loanTransactionsService = loanTransactionsService;
40
- this.signsService = signsService;
32
+ getCollateralsService;
33
+ getLoanStatementStatusService;
34
+ getLoanTransactionsService;
35
+ getSignsService;
36
+ constructor(getCollateralsService, getLoanStatementStatusService, getLoanTransactionsService, getSignsService) {
37
+ this.getCollateralsService = getCollateralsService;
38
+ this.getLoanStatementStatusService = getLoanStatementStatusService;
39
+ this.getLoanTransactionsService = getLoanTransactionsService;
40
+ this.getSignsService = getSignsService;
41
41
  }
42
42
  isBorrowerAllowed(userAccess, requestedBorrowerId) {
43
43
  if (userAccess.allBorrowers) {
@@ -158,9 +158,12 @@ class BorrowerService {
158
158
  return Borrower_model_1.BorrowerModel.findOne({ code });
159
159
  }
160
160
  async getExtraInfo(borrowerId) {
161
- const extraInfo = await this.loanTransactionsService.getLoanBalanceForBorrowerId(borrowerId);
162
- const { lastBBCDate, lastBBCId } = await this.collateralsService.getLatestBBCDate(borrowerId);
163
- const lastSignedBBCDate = await this.signsService.getLatestSignedBBCDate(borrowerId);
161
+ const loanTransactionsService = this.getLoanTransactionsService();
162
+ const collateralsService = this.getCollateralsService();
163
+ const signsService = this.getSignsService();
164
+ const extraInfo = await loanTransactionsService.getLoanBalanceForBorrowerId(borrowerId);
165
+ const { lastBBCDate, lastBBCId } = await collateralsService.getLatestBBCDate(borrowerId);
166
+ const lastSignedBBCDate = await signsService.getLatestSignedBBCDate(borrowerId);
164
167
  return {
165
168
  extraInfo,
166
169
  lastBBCDate,
@@ -253,7 +256,8 @@ class BorrowerService {
253
256
  async getBorrowerStatementDetails(borrowers) {
254
257
  const allBorrowersWithExtraInfo = await Promise.all(borrowers.map(async (borrower) => {
255
258
  const borrowerId = borrower._id.toString();
256
- const statementStatuses = await this.loanStatementStatusService.getBorrowerStatement(borrowerId);
259
+ const loanStatementStatusService = this.getLoanStatementStatusService();
260
+ const statementStatuses = await loanStatementStatusService.getBorrowerStatement(borrowerId);
257
261
  return { [borrowerId]: statementStatuses };
258
262
  }));
259
263
  return allBorrowersWithExtraInfo.reduce((acc, borrower) => {
@@ -43,10 +43,10 @@ export const borrowerDataModels: {
43
43
  export class BorrowerService {
44
44
 
45
45
  constructor(
46
- private readonly collateralsService: CollateralsService,
47
- private readonly loanStatementStatusService: LoanStatementStatusService,
48
- private readonly loanTransactionsService: LoanTransactionsService,
49
- private readonly signsService: SignsService,
46
+ private readonly getCollateralsService: () => CollateralsService,
47
+ private readonly getLoanStatementStatusService: () => LoanStatementStatusService,
48
+ private readonly getLoanTransactionsService: () => LoanTransactionsService,
49
+ private readonly getSignsService: () => SignsService,
50
50
  ) {
51
51
  }
52
52
 
@@ -179,9 +179,12 @@ export class BorrowerService {
179
179
  }
180
180
 
181
181
  async getExtraInfo(borrowerId: string) {
182
- const extraInfo = await this.loanTransactionsService.getLoanBalanceForBorrowerId(borrowerId);
183
- const { lastBBCDate, lastBBCId } = await this.collateralsService.getLatestBBCDate(borrowerId);
184
- const lastSignedBBCDate = await this.signsService.getLatestSignedBBCDate(borrowerId);
182
+ const loanTransactionsService = this.getLoanTransactionsService();
183
+ const collateralsService = this.getCollateralsService();
184
+ const signsService = this.getSignsService();
185
+ const extraInfo = await loanTransactionsService.getLoanBalanceForBorrowerId(borrowerId);
186
+ const { lastBBCDate, lastBBCId } = await collateralsService.getLatestBBCDate(borrowerId);
187
+ const lastSignedBBCDate = await signsService.getLatestSignedBBCDate(borrowerId);
185
188
  return {
186
189
  extraInfo,
187
190
  lastBBCDate,
@@ -287,7 +290,8 @@ export class BorrowerService {
287
290
  async getBorrowerStatementDetails(borrowers: IBorrowerDocument[]) {
288
291
  const allBorrowersWithExtraInfo = await Promise.all(borrowers.map(async (borrower) => {
289
292
  const borrowerId = borrower._id.toString();
290
- const statementStatuses = await this.loanStatementStatusService.getBorrowerStatement(borrowerId);
293
+ const loanStatementStatusService = this.getLoanStatementStatusService();
294
+ const statementStatuses = await loanStatementStatusService.getBorrowerStatement(borrowerId);
291
295
  return { [borrowerId]: statementStatuses };
292
296
  }));
293
297
  return allBorrowersWithExtraInfo.reduce((acc, borrower) => {
@@ -45,7 +45,7 @@ export declare class ComplianceBorrowersService {
45
45
  };
46
46
  };
47
47
  getFullComplianceBorrowerById(complianceBorrowerId: any): Promise<any>;
48
- getAllBorrowersShortened(userAccess: any): Promise<(Pick<IComplianceBorrowerDocument, "items" | "borrower" | "fundingStatus"> | {
48
+ getAllBorrowersShortened(userAccess: any): Promise<(Pick<IComplianceBorrowerDocument, "borrower" | "fundingStatus" | "items"> | {
49
49
  items: {
50
50
  instances: any[];
51
51
  item: import("../models/ComplianceItem.model").IComplianceItemDocument;