gemcap-be-common 1.3.185 → 1.3.186
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
|
@@ -14,6 +14,7 @@ export declare class TermLoanService {
|
|
|
14
14
|
private readonly getUploadsService;
|
|
15
15
|
constructor(financialIndexesService: FinancialIndexesService, loanChargesService: LoanChargesService, getLoanStatementStatusService: () => LoanStatementStatusService, getLoanTransactionsService: () => LoanTransactionsService, getUploadsService: () => UploadsService);
|
|
16
16
|
private createTermLoan;
|
|
17
|
+
private refreshChargeSettings;
|
|
17
18
|
private createTermLoanSettings;
|
|
18
19
|
private getCreateTermLoan;
|
|
19
20
|
getTermLoan(productId: string, actual: boolean): Promise<ITermLoanView & {
|
|
@@ -61,6 +61,27 @@ class TermLoanService {
|
|
|
61
61
|
};
|
|
62
62
|
return TermLoan_model_1.TermLoanModel.findOneAndUpdate({ productId, actual }, newEmptyTerm, { upsert: true, new: true });
|
|
63
63
|
}
|
|
64
|
+
async refreshChargeSettings(productId, actual) {
|
|
65
|
+
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
66
|
+
const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
67
|
+
if (charges.length === 0) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const adminCharge = charges.find((charge) => charge.chargeType === loan_charge_type_enum_1.ELoanChargeType.ADMIN_FEE);
|
|
71
|
+
const interestCharge = charges.find((charge) => charge.chargeType === loan_charge_type_enum_1.ELoanChargeType.INTEREST_FEE);
|
|
72
|
+
if (!adminCharge || !interestCharge) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const newEmptyTerm = {
|
|
76
|
+
productId: new mongoose_1.default.Types.ObjectId(String(product._id)),
|
|
77
|
+
initialBalance: product.commitment,
|
|
78
|
+
adminRate: adminCharge.percent,
|
|
79
|
+
interestRate: interestCharge.percent,
|
|
80
|
+
loanStartDate: product.startDate,
|
|
81
|
+
actual,
|
|
82
|
+
};
|
|
83
|
+
return TermLoan_model_1.TermLoanModel.findOneAndUpdate({ productId, actual }, newEmptyTerm, { upsert: true, new: true });
|
|
84
|
+
}
|
|
64
85
|
async createTermLoanSettings(termLoanId) {
|
|
65
86
|
return TermLoanSettings_model_1.TermLoanSettingsModel.findOneAndUpdate({ termLoanId }, { termLoanId, ...newEmptySettings }, {
|
|
66
87
|
upsert: true,
|
|
@@ -82,6 +82,29 @@ export class TermLoanService {
|
|
|
82
82
|
return TermLoanModel.findOneAndUpdate({ productId, actual }, newEmptyTerm, { upsert: true, new: true });
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
private async refreshChargeSettings(productId: string, actual: boolean) {
|
|
86
|
+
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
87
|
+
const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
88
|
+
if (charges.length === 0) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const adminCharge = charges.find((charge) => charge.chargeType === ELoanChargeType.ADMIN_FEE);
|
|
92
|
+
const interestCharge = charges.find((charge) => charge.chargeType === ELoanChargeType.INTEREST_FEE);
|
|
93
|
+
if (!adminCharge || !interestCharge) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const newEmptyTerm: Partial<ITermLoan> = {
|
|
98
|
+
productId: new mongoose.Types.ObjectId(String(product._id)),
|
|
99
|
+
initialBalance: product.commitment,
|
|
100
|
+
adminRate: adminCharge.percent,
|
|
101
|
+
interestRate: interestCharge.percent,
|
|
102
|
+
loanStartDate: product.startDate,
|
|
103
|
+
actual,
|
|
104
|
+
};
|
|
105
|
+
return TermLoanModel.findOneAndUpdate({ productId, actual }, newEmptyTerm, { upsert: true, new: true });
|
|
106
|
+
}
|
|
107
|
+
|
|
85
108
|
private async createTermLoanSettings(termLoanId: string) {
|
|
86
109
|
return TermLoanSettingsModel.findOneAndUpdate({ termLoanId }, { termLoanId, ...newEmptySettings }, {
|
|
87
110
|
upsert: true,
|