gemcap-be-common 1.3.179 → 1.3.180
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
|
@@ -83,10 +83,10 @@ export declare class BorrowerService {
|
|
|
83
83
|
getBorrowerCodesMap(): Promise<Map<string, string>>;
|
|
84
84
|
getBorrowerStatementDetails(borrowers: IBorrowerDocument[]): Promise<{
|
|
85
85
|
[x: number]: {
|
|
86
|
+
SELECTED_PERIOD?: boolean;
|
|
87
|
+
ENTIRE_LOAN?: boolean;
|
|
86
88
|
LAST_MONTH?: boolean;
|
|
87
89
|
CURRENT_MONTH?: boolean;
|
|
88
|
-
ENTIRE_LOAN?: boolean;
|
|
89
|
-
SELECTED_PERIOD?: boolean;
|
|
90
90
|
TERM_LOAN?: boolean;
|
|
91
91
|
};
|
|
92
92
|
}>;
|
|
@@ -421,7 +421,7 @@ class LoanPaymentsService {
|
|
|
421
421
|
}));
|
|
422
422
|
return { borrowers: borrowersData, isCalculated: !!isCalculated };
|
|
423
423
|
}
|
|
424
|
-
async payExpectedPayments(userId, borrowers) {
|
|
424
|
+
async payExpectedPayments(userId, borrowers, selectedDate) {
|
|
425
425
|
const arrayOfStringsSchema = joi_1.default.array().items(joi_1.default.string()).required();
|
|
426
426
|
const borrowerIds = Object.keys(borrowers);
|
|
427
427
|
const { error } = arrayOfStringsSchema.validate(borrowerIds, { abortEarly: false });
|
|
@@ -437,6 +437,8 @@ class LoanPaymentsService {
|
|
|
437
437
|
const paymentPromises = allowedBorrowers.map(async (borrower) => {
|
|
438
438
|
if (borrowerIds.includes(borrower._id.toString())) {
|
|
439
439
|
try {
|
|
440
|
+
const borrowerProducts = await this.loanChargesService.getLoanProducts(borrower._id.toString());
|
|
441
|
+
const revolverProduct = borrowerProducts.find((product) => product.type === loan_types_enum_1.ELoanTypes.REVOLVER);
|
|
440
442
|
const loanStatementService = this.getLoanStatementService();
|
|
441
443
|
const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString());
|
|
442
444
|
if (dueAmounts.total === 0) {
|
|
@@ -449,7 +451,7 @@ class LoanPaymentsService {
|
|
|
449
451
|
return {
|
|
450
452
|
productId: productId,
|
|
451
453
|
payableSum: amount,
|
|
452
|
-
settlementCode: borrowers[borrower._id.toString()] ? product.code : product.settlementCode,
|
|
454
|
+
settlementCode: borrowers[borrower._id.toString()] ? (revolverProduct?.code ?? product.code) : product.settlementCode,
|
|
453
455
|
paymentOrder: null,
|
|
454
456
|
};
|
|
455
457
|
}
|
|
@@ -457,7 +459,7 @@ class LoanPaymentsService {
|
|
|
457
459
|
const combinedPayment = {
|
|
458
460
|
addToRevolver: borrowers[borrower._id.toString()],
|
|
459
461
|
borrowerId: borrower._id.toString(),
|
|
460
|
-
date:
|
|
462
|
+
date: selectedDate,
|
|
461
463
|
linkedProducts: [],
|
|
462
464
|
payment: dueAmounts.total,
|
|
463
465
|
products: products.filter((product) => !!product),
|
|
@@ -470,7 +470,7 @@ export class LoanPaymentsService {
|
|
|
470
470
|
return { borrowers: borrowersData, isCalculated: !!isCalculated };
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
async payExpectedPayments(userId: string, borrowers: { [borrowerId: string]: boolean }) {
|
|
473
|
+
async payExpectedPayments(userId: string, borrowers: { [borrowerId: string]: boolean }, selectedDate: Date) {
|
|
474
474
|
|
|
475
475
|
const arrayOfStringsSchema = Joi.array().items(Joi.string()).required();
|
|
476
476
|
const borrowerIds = Object.keys(borrowers);
|
|
@@ -488,6 +488,8 @@ export class LoanPaymentsService {
|
|
|
488
488
|
const paymentPromises = allowedBorrowers.map(async (borrower) => {
|
|
489
489
|
if (borrowerIds.includes(borrower._id.toString())) {
|
|
490
490
|
try {
|
|
491
|
+
const borrowerProducts = await this.loanChargesService.getLoanProducts(borrower._id.toString());
|
|
492
|
+
const revolverProduct = borrowerProducts.find((product) => product.type === ELoanTypes.REVOLVER);
|
|
491
493
|
const loanStatementService = this.getLoanStatementService();
|
|
492
494
|
const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString());
|
|
493
495
|
if (dueAmounts.total === 0) {
|
|
@@ -501,7 +503,7 @@ export class LoanPaymentsService {
|
|
|
501
503
|
return {
|
|
502
504
|
productId: productId,
|
|
503
505
|
payableSum: amount,
|
|
504
|
-
settlementCode: borrowers[borrower._id.toString()] ? product.code : product.settlementCode,
|
|
506
|
+
settlementCode: borrowers[borrower._id.toString()] ? (revolverProduct?.code ?? product.code) : product.settlementCode,
|
|
505
507
|
paymentOrder: null,
|
|
506
508
|
};
|
|
507
509
|
}
|
|
@@ -511,7 +513,7 @@ export class LoanPaymentsService {
|
|
|
511
513
|
const combinedPayment: ICombinedPayment = {
|
|
512
514
|
addToRevolver: borrowers[borrower._id.toString()],
|
|
513
515
|
borrowerId: borrower._id.toString(),
|
|
514
|
-
date:
|
|
516
|
+
date: selectedDate,
|
|
515
517
|
linkedProducts: [],
|
|
516
518
|
payment: dueAmounts.total,
|
|
517
519
|
products: products.filter((product) => !!product),
|