gemcap-be-common 1.3.0 → 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 +1 -1
- package/services/borrowers.service.d.ts +5 -5
- package/services/borrowers.service.js +17 -13
- package/services/borrowers.service.ts +12 -8
- package/services/compliance-borrowers.service.d.ts +1 -1
- package/services/reports/investor-summary.service.d.ts +2 -2
- package/services/reports/investor-summary.service.js +6 -5
- package/services/reports/investor-summary.service.ts +4 -3
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -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
|
|
39
|
-
private readonly
|
|
40
|
-
private readonly
|
|
41
|
-
private readonly
|
|
42
|
-
constructor(
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
constructor(
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
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
|
|
162
|
-
const
|
|
163
|
-
const
|
|
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
|
|
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
|
|
47
|
-
private readonly
|
|
48
|
-
private readonly
|
|
49
|
-
private readonly
|
|
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
|
|
183
|
-
const
|
|
184
|
-
const
|
|
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
|
|
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, "
|
|
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;
|
|
@@ -22,7 +22,7 @@ export interface IInvestorSummaryDataRow {
|
|
|
22
22
|
}
|
|
23
23
|
export declare class InvestorSummaryService {
|
|
24
24
|
private readonly loanChargesService;
|
|
25
|
-
private readonly
|
|
26
|
-
constructor(loanChargesService: LoanChargesService,
|
|
25
|
+
private readonly getReportsService;
|
|
26
|
+
constructor(loanChargesService: LoanChargesService, getReportsService: () => ReportsService);
|
|
27
27
|
getInvestorSummaryData(borrowerIds: string[], start: Date, end: Date): Promise<IInvestorSummaryDataRow[]>;
|
|
28
28
|
}
|
|
@@ -64,14 +64,15 @@ const emptySummary = {
|
|
|
64
64
|
};
|
|
65
65
|
class InvestorSummaryService {
|
|
66
66
|
loanChargesService;
|
|
67
|
-
|
|
68
|
-
constructor(loanChargesService,
|
|
67
|
+
getReportsService;
|
|
68
|
+
constructor(loanChargesService, getReportsService) {
|
|
69
69
|
this.loanChargesService = loanChargesService;
|
|
70
|
-
this.
|
|
70
|
+
this.getReportsService = getReportsService;
|
|
71
71
|
}
|
|
72
72
|
async getInvestorSummaryData(borrowerIds, start, end) {
|
|
73
73
|
const data = [];
|
|
74
|
-
const
|
|
74
|
+
const reportsService = this.getReportsService();
|
|
75
|
+
const borrowerSummaries = await reportsService.generateBankPortfolioSummary(borrowerIds, end);
|
|
75
76
|
await Promise.all(borrowerIds.map(async (borrowerId) => {
|
|
76
77
|
const borrower = await Borrower_model_1.BorrowerModel.findById(borrowerId).lean();
|
|
77
78
|
const borrowerProducts = await this.loanChargesService.getLoanProducts(borrowerId);
|
|
@@ -93,7 +94,7 @@ class InvestorSummaryService {
|
|
|
93
94
|
const inventoryNet = productSummary.inventoryNet;
|
|
94
95
|
const otherCollateral = new decimal_js_1.default(productSummary.equipmentCollateral).add(productSummary.intellectualProperty).add(productSummary.realEstate).add(productSummary.bootCollateral).toNumber();
|
|
95
96
|
const otherReserves = isRevolver ? productSummary.otherReserves : 0;
|
|
96
|
-
const collateralAdjustments = isRevolver ? await
|
|
97
|
+
const collateralAdjustments = isRevolver ? await reportsService.getCollateralAdjustmentsForLastSignedBBC(borrowerId, end) : 0;
|
|
97
98
|
const otherReservesAndAdjustments = new decimal_js_1.default(otherReserves).add(collateralAdjustments).toNumber();
|
|
98
99
|
const totalRevolver = new decimal_js_1.default(productSummary.totalCollateral).add(productSummary.equipmentCollateral).add(productSummary.intellectualProperty).toNumber();
|
|
99
100
|
const netAvailable = new decimal_js_1.default(inventoryNet).add(ARNet).add(otherCollateral).add(otherReservesAndAdjustments).minus(balanceEnd).toNumber();
|
|
@@ -89,13 +89,14 @@ export class InvestorSummaryService {
|
|
|
89
89
|
|
|
90
90
|
constructor(
|
|
91
91
|
private readonly loanChargesService: LoanChargesService,
|
|
92
|
-
private readonly
|
|
92
|
+
private readonly getReportsService: () => ReportsService,
|
|
93
93
|
) {
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
async getInvestorSummaryData(borrowerIds: string[], start: Date, end: Date) {
|
|
97
97
|
const data: IInvestorSummaryDataRow[] = [];
|
|
98
|
-
const
|
|
98
|
+
const reportsService = this.getReportsService();
|
|
99
|
+
const borrowerSummaries = await reportsService.generateBankPortfolioSummary(borrowerIds, end);
|
|
99
100
|
await Promise.all(borrowerIds.map(async (borrowerId) => {
|
|
100
101
|
const borrower = await BorrowerModel.findById(borrowerId).lean();
|
|
101
102
|
const borrowerProducts = await this.loanChargesService.getLoanProducts(borrowerId);
|
|
@@ -118,7 +119,7 @@ export class InvestorSummaryService {
|
|
|
118
119
|
const inventoryNet = productSummary.inventoryNet;
|
|
119
120
|
const otherCollateral = new Decimal(productSummary.equipmentCollateral).add(productSummary.intellectualProperty).add(productSummary.realEstate).add(productSummary.bootCollateral).toNumber();
|
|
120
121
|
const otherReserves = isRevolver ? productSummary.otherReserves : 0;
|
|
121
|
-
const collateralAdjustments = isRevolver ? await
|
|
122
|
+
const collateralAdjustments = isRevolver ? await reportsService.getCollateralAdjustmentsForLastSignedBBC(borrowerId, end) : 0;
|
|
122
123
|
const otherReservesAndAdjustments = new Decimal(otherReserves).add(collateralAdjustments).toNumber();
|
|
123
124
|
const totalRevolver = new Decimal(productSummary.totalCollateral).add(productSummary.equipmentCollateral).add(productSummary.intellectualProperty).toNumber();
|
|
124
125
|
const netAvailable = new Decimal(inventoryNet).add(ARNet).add(otherCollateral).add(otherReservesAndAdjustments).minus(balanceEnd).toNumber();
|