gemcap-be-common 1.5.66 → 1.5.67
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/db/reports.db.js +1 -1
- package/models/LoanProducts.model.d.ts +21 -21
- package/models/LoanProducts.model.js +1 -1
- package/models/_index.d.ts +3 -3
- package/package.json +1 -1
- package/services/borrowers.service.d.ts +2 -2
- package/services/loan-charges.service.js +4 -2
- package/services/loan-charges.service.ts +3 -1
- package/services/loan-products.service.js +1 -1
- package/services/quickbooks.service.js +4 -4
- package/services/reports/investor-summary.service.js +1 -1
- package/services/reports.service.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/db/reports.db.js
CHANGED
|
@@ -207,7 +207,7 @@ const getLedgerData = async (params, options = defaultReportLedgerOptions) => {
|
|
|
207
207
|
};
|
|
208
208
|
}))
|
|
209
209
|
: statementTransactions.slice();
|
|
210
|
-
const isParticipant = group.product.
|
|
210
|
+
const isParticipant = group.product.masteredLoanProductId != null;
|
|
211
211
|
const groupedMappedStatementTransactions = await Promise.all(statementTransactionsWithBalance.map(async (statement) => {
|
|
212
212
|
const transactions = [];
|
|
213
213
|
if (statement.amountPaid > 0) {
|
|
@@ -40,7 +40,7 @@ export interface ILoanProduct {
|
|
|
40
40
|
isBalanceActual: boolean;
|
|
41
41
|
isFloatedBalanceActual: boolean;
|
|
42
42
|
isParticipant?: boolean;
|
|
43
|
-
|
|
43
|
+
masteredLoanProductId: mongoose.Types.ObjectId;
|
|
44
44
|
minPercent: number;
|
|
45
45
|
maxPercent: number;
|
|
46
46
|
prepaymentDate?: Date;
|
|
@@ -60,10 +60,10 @@ export interface ILoanProductLean extends ILoanProduct {
|
|
|
60
60
|
createdAt: Date;
|
|
61
61
|
updatedAt: Date;
|
|
62
62
|
}
|
|
63
|
-
export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId' | '
|
|
63
|
+
export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId' | 'masteredLoanProductId'> {
|
|
64
64
|
_id: string;
|
|
65
65
|
borrowerId: string;
|
|
66
|
-
|
|
66
|
+
masteredLoanProductId: string;
|
|
67
67
|
}
|
|
68
68
|
export interface ILoanProductWithId extends ILoanProduct {
|
|
69
69
|
_id: mongoose.Types.ObjectId;
|
|
@@ -83,21 +83,19 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
83
83
|
createdAt: NativeDate;
|
|
84
84
|
updatedAt: NativeDate;
|
|
85
85
|
} & {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
87
|
+
masteredLoanProductId: mongoose.Types.ObjectId;
|
|
88
88
|
order: number;
|
|
89
89
|
active: boolean;
|
|
90
|
-
borrowerId: mongoose.Types.ObjectId;
|
|
91
90
|
code: string;
|
|
91
|
+
name: string;
|
|
92
|
+
type: string;
|
|
92
93
|
startDate: Date;
|
|
93
94
|
maturityDate: Date;
|
|
94
95
|
commitment: number;
|
|
95
96
|
isBalanceActual: boolean;
|
|
96
97
|
isFloatedBalanceActual: boolean;
|
|
97
|
-
masterLoanProductId: mongoose.Types.ObjectId;
|
|
98
98
|
isDefaultPaymentOrder: boolean;
|
|
99
|
-
__v?: number;
|
|
100
|
-
settlementCode?: string;
|
|
101
99
|
masterCode?: string;
|
|
102
100
|
payoffDate?: Date;
|
|
103
101
|
isParticipant?: boolean;
|
|
@@ -105,26 +103,26 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
105
103
|
maxPercent?: number;
|
|
106
104
|
prepaymentDate?: Date;
|
|
107
105
|
prepaymentTerms?: string;
|
|
106
|
+
settlementCode?: string;
|
|
108
107
|
deactivationDate?: Date;
|
|
108
|
+
__v?: number;
|
|
109
109
|
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
110
110
|
createdAt: NativeDate;
|
|
111
111
|
updatedAt: NativeDate;
|
|
112
112
|
} & {
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
114
|
+
masteredLoanProductId: mongoose.Types.ObjectId;
|
|
115
115
|
order: number;
|
|
116
116
|
active: boolean;
|
|
117
|
-
borrowerId: mongoose.Types.ObjectId;
|
|
118
117
|
code: string;
|
|
118
|
+
name: string;
|
|
119
|
+
type: string;
|
|
119
120
|
startDate: Date;
|
|
120
121
|
maturityDate: Date;
|
|
121
122
|
commitment: number;
|
|
122
123
|
isBalanceActual: boolean;
|
|
123
124
|
isFloatedBalanceActual: boolean;
|
|
124
|
-
masterLoanProductId: mongoose.Types.ObjectId;
|
|
125
125
|
isDefaultPaymentOrder: boolean;
|
|
126
|
-
__v?: number;
|
|
127
|
-
settlementCode?: string;
|
|
128
126
|
masterCode?: string;
|
|
129
127
|
payoffDate?: Date;
|
|
130
128
|
isParticipant?: boolean;
|
|
@@ -132,26 +130,26 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
132
130
|
maxPercent?: number;
|
|
133
131
|
prepaymentDate?: Date;
|
|
134
132
|
prepaymentTerms?: string;
|
|
133
|
+
settlementCode?: string;
|
|
135
134
|
deactivationDate?: Date;
|
|
135
|
+
__v?: number;
|
|
136
136
|
}>> & mongoose.FlatRecord<{
|
|
137
137
|
createdAt: NativeDate;
|
|
138
138
|
updatedAt: NativeDate;
|
|
139
139
|
} & {
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
141
|
+
masteredLoanProductId: mongoose.Types.ObjectId;
|
|
142
142
|
order: number;
|
|
143
143
|
active: boolean;
|
|
144
|
-
borrowerId: mongoose.Types.ObjectId;
|
|
145
144
|
code: string;
|
|
145
|
+
name: string;
|
|
146
|
+
type: string;
|
|
146
147
|
startDate: Date;
|
|
147
148
|
maturityDate: Date;
|
|
148
149
|
commitment: number;
|
|
149
150
|
isBalanceActual: boolean;
|
|
150
151
|
isFloatedBalanceActual: boolean;
|
|
151
|
-
masterLoanProductId: mongoose.Types.ObjectId;
|
|
152
152
|
isDefaultPaymentOrder: boolean;
|
|
153
|
-
__v?: number;
|
|
154
|
-
settlementCode?: string;
|
|
155
153
|
masterCode?: string;
|
|
156
154
|
payoffDate?: Date;
|
|
157
155
|
isParticipant?: boolean;
|
|
@@ -159,7 +157,9 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
159
157
|
maxPercent?: number;
|
|
160
158
|
prepaymentDate?: Date;
|
|
161
159
|
prepaymentTerms?: string;
|
|
160
|
+
settlementCode?: string;
|
|
162
161
|
deactivationDate?: Date;
|
|
162
|
+
__v?: number;
|
|
163
163
|
}> & {
|
|
164
164
|
_id: mongoose.Types.ObjectId;
|
|
165
165
|
}>;
|
|
@@ -68,7 +68,7 @@ exports.LoanProductSchema = new mongoose_1.default.Schema({
|
|
|
68
68
|
type: Boolean,
|
|
69
69
|
required: false,
|
|
70
70
|
},
|
|
71
|
-
|
|
71
|
+
masteredLoanProductId: {
|
|
72
72
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
73
73
|
ref: _models_1.MODEL_NAMES.loanProducts,
|
|
74
74
|
default: null,
|
package/models/_index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare const allSchemas: {
|
|
|
31
31
|
createdAt: NativeDate;
|
|
32
32
|
updatedAt: NativeDate;
|
|
33
33
|
} & {
|
|
34
|
-
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
35
34
|
order: number;
|
|
35
|
+
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
36
36
|
apDate: Date;
|
|
37
37
|
amount: number;
|
|
38
38
|
__v?: number;
|
|
@@ -45,8 +45,8 @@ export declare const allSchemas: {
|
|
|
45
45
|
createdAt: NativeDate;
|
|
46
46
|
updatedAt: NativeDate;
|
|
47
47
|
} & {
|
|
48
|
-
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
49
48
|
order: number;
|
|
49
|
+
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
50
50
|
apDate: Date;
|
|
51
51
|
amount: number;
|
|
52
52
|
__v?: number;
|
|
@@ -59,8 +59,8 @@ export declare const allSchemas: {
|
|
|
59
59
|
createdAt: NativeDate;
|
|
60
60
|
updatedAt: NativeDate;
|
|
61
61
|
} & {
|
|
62
|
-
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
63
62
|
order: number;
|
|
63
|
+
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
64
64
|
apDate: Date;
|
|
65
65
|
amount: number;
|
|
66
66
|
__v?: number;
|
package/package.json
CHANGED
|
@@ -84,10 +84,10 @@ export declare class BorrowerService {
|
|
|
84
84
|
getBorrowerCodesMap(): Promise<Map<string, string>>;
|
|
85
85
|
getBorrowerStatementDetails(borrowers: IBorrowerDoc[]): Promise<{
|
|
86
86
|
[x: string]: {
|
|
87
|
+
SELECTED_PERIOD?: boolean;
|
|
88
|
+
ENTIRE_LOAN?: boolean;
|
|
87
89
|
LAST_MONTH?: boolean;
|
|
88
90
|
CURRENT_MONTH?: boolean;
|
|
89
|
-
ENTIRE_LOAN?: boolean;
|
|
90
|
-
SELECTED_PERIOD?: boolean;
|
|
91
91
|
TERM_LOAN?: boolean;
|
|
92
92
|
};
|
|
93
93
|
}>;
|
|
@@ -85,7 +85,7 @@ class LoanChargesService {
|
|
|
85
85
|
if (!masterProduct) {
|
|
86
86
|
return 0;
|
|
87
87
|
}
|
|
88
|
-
const participationProduct = await LoanProducts_model_1.LoanProduct.findOne({
|
|
88
|
+
const participationProduct = await LoanProducts_model_1.LoanProduct.findOne({ masteredLoanProductId: masterProduct._id }).lean();
|
|
89
89
|
if (!participationProduct) {
|
|
90
90
|
return 0;
|
|
91
91
|
}
|
|
@@ -155,7 +155,9 @@ class LoanChargesService {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
else {
|
|
158
|
-
|
|
158
|
+
console.debug({ product });
|
|
159
|
+
const updated = await LoanProducts_model_1.LoanProduct.findByIdAndUpdate(product._id, product, { new: true });
|
|
160
|
+
console.debug({ updated });
|
|
159
161
|
if (updateChargesForProduct) {
|
|
160
162
|
await this.updatedChargeCodes(product._id.toString());
|
|
161
163
|
}
|
|
@@ -184,7 +184,9 @@ export class LoanChargesService {
|
|
|
184
184
|
await this.saveLoanCharges(borrowerId, charges, true);
|
|
185
185
|
}
|
|
186
186
|
} else {
|
|
187
|
-
|
|
187
|
+
console.debug({ product });
|
|
188
|
+
const updated = await LoanProduct.findByIdAndUpdate(product._id, product, { new: true });
|
|
189
|
+
console.debug({ updated });
|
|
188
190
|
if (updateChargesForProduct) {
|
|
189
191
|
await this.updatedChargeCodes(product._id.toString());
|
|
190
192
|
}
|
|
@@ -25,7 +25,7 @@ class LoanProductsService {
|
|
|
25
25
|
const masterProducts = await LoanProducts_model_1.LoanProduct.find({ code: { $in: codes } });
|
|
26
26
|
const masterProductIds = masterProducts.map((product) => product._id);
|
|
27
27
|
const loanProducts = await LoanProducts_model_1.LoanProduct
|
|
28
|
-
.find({
|
|
28
|
+
.find({ masteredLoanProductId: { $in: masterProductIds } })
|
|
29
29
|
.sort({ code: 1 })
|
|
30
30
|
.lean();
|
|
31
31
|
return loanProducts.reduce((acc, loanProduct) => ({ ...acc, [loanProduct.code]: loanProduct._id.toString() }), {});
|
|
@@ -357,7 +357,7 @@ class QuickbooksService {
|
|
|
357
357
|
if (totalAmountValue === 0) {
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
360
|
-
let totalAmount = product.
|
|
360
|
+
let totalAmount = product.masteredLoanProductId != null ? -totalAmountValue : totalAmountValue;
|
|
361
361
|
totalAmount = isAccrual ? totalAmount : -totalAmount;
|
|
362
362
|
const quickbooksAccountBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: charge.code, ...companyFilter }).lean();
|
|
363
363
|
const quickbooksAccountPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: PLCode, ...companyFilter }).lean();
|
|
@@ -374,7 +374,7 @@ class QuickbooksService {
|
|
|
374
374
|
...trTemplate,
|
|
375
375
|
productId,
|
|
376
376
|
class: borrower.code,
|
|
377
|
-
memo: `${borrower.code} ${product.
|
|
377
|
+
memo: `${borrower.code} ${product.masteredLoanProductId != null ? 'PARTICIPANT' : ''} ${reports_db_1.EChargeType[charge.chargeType].toUpperCase()} ${product.type.toUpperCase()} - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
|
|
378
378
|
};
|
|
379
379
|
tr.account = quickbooksAccountBS.fullName;
|
|
380
380
|
tr.amount = totalAmount;
|
|
@@ -429,8 +429,8 @@ class QuickbooksService {
|
|
|
429
429
|
...trTemplate,
|
|
430
430
|
productId,
|
|
431
431
|
class: borrower.code,
|
|
432
|
-
amount: product.
|
|
433
|
-
memo: `${borrower.code} ${product.
|
|
432
|
+
amount: product.masteredLoanProductId != null ? +amount : -+amount,
|
|
433
|
+
memo: `${borrower.code} ${product.masteredLoanProductId != null ? 'PARTICIPANT' : ''} PRINCIPAL PAID TERM - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
|
|
434
434
|
};
|
|
435
435
|
if (settlementCode === 'null') {
|
|
436
436
|
const products = await this.loanChargesService.getLoanProducts(borrower._id.toString());
|
|
@@ -76,7 +76,7 @@ class InvestorSummaryService {
|
|
|
76
76
|
await Promise.all(borrowerIds.map(async (borrowerId) => {
|
|
77
77
|
const borrower = await Borrower_model_1.BorrowerModel.findById(borrowerId).lean();
|
|
78
78
|
const borrowerProducts = await this.loanChargesService.getLoanProducts(borrowerId);
|
|
79
|
-
await Promise.all(borrowerProducts.filter((product) => product.
|
|
79
|
+
await Promise.all(borrowerProducts.filter((product) => product.masteredLoanProductId == null).map(async (product) => {
|
|
80
80
|
const productId = product._id.toString();
|
|
81
81
|
const isRevolver = product.type === loan_types_enum_1.ELoanTypes.REVOLVER;
|
|
82
82
|
const { balance: balanceEnd } = await this.loanChargesService.getLoanProductBalance(productId, end);
|
|
@@ -323,7 +323,7 @@ class ReportsService {
|
|
|
323
323
|
const hasTermProduct = products.some((product) => product.type === loan_types_enum_1.ELoanTypes.TERM);
|
|
324
324
|
const manyTermProduct = products.filter((product) => product.type === loan_types_enum_1.ELoanTypes.TERM).length > 1;
|
|
325
325
|
return await Promise.all(products.map(async (product) => {
|
|
326
|
-
if (product.
|
|
326
|
+
if (product.masteredLoanProductId != null) {
|
|
327
327
|
return null;
|
|
328
328
|
}
|
|
329
329
|
if ((0, dayjs_1.default)(product.deactivationDate).isBefore((0, dayjs_1.default)(date))) {
|