gemcap-be-common 1.3.128 → 1.3.129
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/compliance-borrowers.service.d.ts +1 -1
- package/services/loan-payments.service.d.ts +3 -1
- package/services/loan-payments.service.js +6 -6
- package/services/loan-payments.service.ts +6 -7
- package/services/nodemailer.service.js +0 -1
- package/services/nodemailer.service.ts +0 -1
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -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, "items" | "borrower" | "fundingStatus"> | {
|
|
49
49
|
items: {
|
|
50
50
|
instances: any[];
|
|
51
51
|
item: import("../models/ComplianceItem.model").IComplianceItemDocument;
|
|
@@ -90,7 +90,9 @@ export declare class LoanPaymentsService {
|
|
|
90
90
|
}[];
|
|
91
91
|
isCalculated: boolean;
|
|
92
92
|
}>;
|
|
93
|
-
payExpectedPayments(userId: string,
|
|
93
|
+
payExpectedPayments(userId: string, borrowers: {
|
|
94
|
+
[borrowerId: string]: boolean;
|
|
95
|
+
}): Promise<{
|
|
94
96
|
message: string;
|
|
95
97
|
}>;
|
|
96
98
|
}
|
|
@@ -421,20 +421,20 @@ class LoanPaymentsService {
|
|
|
421
421
|
}));
|
|
422
422
|
return { borrowers: borrowersData, isCalculated: !!isCalculated };
|
|
423
423
|
}
|
|
424
|
-
async payExpectedPayments(userId,
|
|
424
|
+
async payExpectedPayments(userId, borrowers) {
|
|
425
425
|
const arrayOfStringsSchema = joi_1.default.array().items(joi_1.default.string()).required();
|
|
426
|
+
const borrowerIds = Object.keys(borrowers);
|
|
426
427
|
const { error } = arrayOfStringsSchema.validate(borrowerIds, { abortEarly: false });
|
|
427
428
|
if (error) {
|
|
428
429
|
return { message: 'Incorrect list of borrowers IDs' };
|
|
429
430
|
}
|
|
430
|
-
const addToRevolver = true;
|
|
431
431
|
await this.redisClient.set(CALCULATION_VAR, 1);
|
|
432
432
|
const user = await User_model_1.UserModel.findById(userId).lean();
|
|
433
433
|
if (!user) {
|
|
434
434
|
return { message: 'Cannot find user with this id' };
|
|
435
435
|
}
|
|
436
|
-
const
|
|
437
|
-
const paymentPromises =
|
|
436
|
+
const allowedBorrowers = await this.borrowersDB.getAllowedBorrowers(user);
|
|
437
|
+
const paymentPromises = allowedBorrowers.map(async (borrower) => {
|
|
438
438
|
if (borrowerIds.includes(borrower._id.toString())) {
|
|
439
439
|
try {
|
|
440
440
|
const loanStatementService = this.getLoanStatementService();
|
|
@@ -449,13 +449,13 @@ class LoanPaymentsService {
|
|
|
449
449
|
return {
|
|
450
450
|
productId: productId,
|
|
451
451
|
payableSum: amount,
|
|
452
|
-
settlementCode:
|
|
452
|
+
settlementCode: borrowers[borrower._id.toString()] ? product.code : product.settlementCode,
|
|
453
453
|
paymentOrder: null,
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
456
|
}));
|
|
457
457
|
const combinedPayment = {
|
|
458
|
-
addToRevolver,
|
|
458
|
+
addToRevolver: borrowers[borrower._id.toString()],
|
|
459
459
|
borrowerId: borrower._id.toString(),
|
|
460
460
|
date: new Date(),
|
|
461
461
|
linkedProducts: [],
|
|
@@ -470,23 +470,22 @@ export class LoanPaymentsService {
|
|
|
470
470
|
return { borrowers: borrowersData, isCalculated: !!isCalculated };
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
async payExpectedPayments(userId: string,
|
|
473
|
+
async payExpectedPayments(userId: string, borrowers: { [borrowerId: string]: boolean }) {
|
|
474
474
|
|
|
475
475
|
const arrayOfStringsSchema = Joi.array().items(Joi.string()).required();
|
|
476
|
+
const borrowerIds = Object.keys(borrowers);
|
|
476
477
|
const { error } = arrayOfStringsSchema.validate(borrowerIds, { abortEarly: false });
|
|
477
478
|
if (error) {
|
|
478
479
|
return { message: 'Incorrect list of borrowers IDs' };
|
|
479
480
|
}
|
|
480
481
|
|
|
481
|
-
const addToRevolver = true;
|
|
482
|
-
|
|
483
482
|
await this.redisClient.set(CALCULATION_VAR, 1);
|
|
484
483
|
const user = await UserModel.findById(userId).lean();
|
|
485
484
|
if (!user) {
|
|
486
485
|
return { message: 'Cannot find user with this id' };
|
|
487
486
|
}
|
|
488
|
-
const
|
|
489
|
-
const paymentPromises =
|
|
487
|
+
const allowedBorrowers = await this.borrowersDB.getAllowedBorrowers(user);
|
|
488
|
+
const paymentPromises = allowedBorrowers.map(async (borrower) => {
|
|
490
489
|
if (borrowerIds.includes(borrower._id.toString())) {
|
|
491
490
|
try {
|
|
492
491
|
const loanStatementService = this.getLoanStatementService();
|
|
@@ -502,7 +501,7 @@ export class LoanPaymentsService {
|
|
|
502
501
|
return {
|
|
503
502
|
productId: productId,
|
|
504
503
|
payableSum: amount,
|
|
505
|
-
settlementCode:
|
|
504
|
+
settlementCode: borrowers[borrower._id.toString()] ? product.code : product.settlementCode,
|
|
506
505
|
paymentOrder: null,
|
|
507
506
|
};
|
|
508
507
|
}
|
|
@@ -510,7 +509,7 @@ export class LoanPaymentsService {
|
|
|
510
509
|
);
|
|
511
510
|
|
|
512
511
|
const combinedPayment: ICombinedPayment = {
|
|
513
|
-
addToRevolver,
|
|
512
|
+
addToRevolver: borrowers[borrower._id.toString()],
|
|
514
513
|
borrowerId: borrower._id.toString(),
|
|
515
514
|
date: new Date(),
|
|
516
515
|
linkedProducts: [],
|
|
@@ -98,7 +98,6 @@ class NodemailerService {
|
|
|
98
98
|
this.transporter = nodemailer_1.default.createTransport(this.config.mailerConfig);
|
|
99
99
|
}
|
|
100
100
|
getSender(senderType, senderExtraName) {
|
|
101
|
-
console.log({ senderExtraName, typeof: typeof senderExtraName });
|
|
102
101
|
switch (senderType) {
|
|
103
102
|
case ESenderType.REGULAR:
|
|
104
103
|
return `${this.senders[senderType].senderName} <${this.senders[senderType].senderEmail}>`;
|
|
@@ -111,7 +111,6 @@ export class NodemailerService {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
private getSender(senderType: ESenderType, senderExtraName?: string) {
|
|
114
|
-
console.log({ senderExtraName, typeof: typeof senderExtraName });
|
|
115
114
|
switch (senderType) {
|
|
116
115
|
case ESenderType.REGULAR:
|
|
117
116
|
return `${this.senders[senderType].senderName} <${this.senders[senderType].senderEmail}>`;
|