gemcap-be-common 1.5.66 → 1.5.68
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.ts +1 -1
- package/models/LoanProducts.model.d.ts +18 -18
- package/models/LoanProducts.model.ts +4 -4
- 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.ts +1 -1
- package/services/loan-products.service.ts +1 -1
- package/services/quickbooks.service.ts +4 -4
- package/services/reports/investor-summary.service.ts +1 -1
- package/services/reports.service.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/db/reports.db.ts
CHANGED
|
@@ -285,7 +285,7 @@ const getLedgerData = async (params: ReportLedgerParams, options = defaultReport
|
|
|
285
285
|
}))
|
|
286
286
|
: statementTransactions.slice();
|
|
287
287
|
|
|
288
|
-
const isParticipant = group.product.
|
|
288
|
+
const isParticipant = group.product.masterLoanProductId != null;
|
|
289
289
|
const groupedMappedStatementTransactions = await Promise.all(statementTransactionsWithBalance.map(async (statement) => {
|
|
290
290
|
|
|
291
291
|
const transactions = [];
|
|
@@ -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
|
+
masterLoanProductId: 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
|
+
masterLoanProductId: 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
|
+
masterLoanProductId: 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
|
}>;
|
|
@@ -19,7 +19,7 @@ export interface ILoanProduct {
|
|
|
19
19
|
isBalanceActual: boolean;
|
|
20
20
|
isFloatedBalanceActual: boolean;
|
|
21
21
|
isParticipant?: boolean;
|
|
22
|
-
|
|
22
|
+
masterLoanProductId: mongoose.Types.ObjectId;
|
|
23
23
|
minPercent: number;
|
|
24
24
|
maxPercent: number;
|
|
25
25
|
prepaymentDate?: Date;
|
|
@@ -42,10 +42,10 @@ export interface ILoanProductLean extends ILoanProduct {
|
|
|
42
42
|
updatedAt: Date;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId' | '
|
|
45
|
+
export interface ILoanProductPlain extends Omit<ILoanProduct, 'borrowerId' | 'masterLoanProductId'> {
|
|
46
46
|
_id: string;
|
|
47
47
|
borrowerId: string;
|
|
48
|
-
|
|
48
|
+
masterLoanProductId: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface ILoanProductWithId extends ILoanProduct {
|
|
@@ -128,7 +128,7 @@ export const LoanProductSchema = new mongoose.Schema(
|
|
|
128
128
|
type: Boolean,
|
|
129
129
|
required: false,
|
|
130
130
|
},
|
|
131
|
-
|
|
131
|
+
masterLoanProductId: {
|
|
132
132
|
type: mongoose.Schema.Types.ObjectId,
|
|
133
133
|
ref: MODEL_NAMES.loanProducts,
|
|
134
134
|
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
|
}>;
|
|
@@ -112,7 +112,7 @@ export class LoanChargesService {
|
|
|
112
112
|
if (!masterProduct) {
|
|
113
113
|
return 0;
|
|
114
114
|
}
|
|
115
|
-
const participationProduct = await LoanProduct.findOne({
|
|
115
|
+
const participationProduct = await LoanProduct.findOne({ masterLoanProductId: masterProduct._id }).lean();
|
|
116
116
|
if (!participationProduct) {
|
|
117
117
|
return 0;
|
|
118
118
|
}
|
|
@@ -29,7 +29,7 @@ export class LoanProductsService {
|
|
|
29
29
|
const masterProducts = await LoanProduct.find({ code: { $in: codes } });
|
|
30
30
|
const masterProductIds = masterProducts.map((product) => product._id);
|
|
31
31
|
const loanProducts = await LoanProduct
|
|
32
|
-
.find({
|
|
32
|
+
.find({ masterLoanProductId: { $in: masterProductIds } })
|
|
33
33
|
.sort({ code: 1 })
|
|
34
34
|
.lean();
|
|
35
35
|
return loanProducts.reduce((acc, loanProduct) => ({ ...acc, [loanProduct.code]: loanProduct._id.toString() }), {});
|
|
@@ -416,7 +416,7 @@ export class QuickbooksService {
|
|
|
416
416
|
if (totalAmountValue === 0) {
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
|
-
let totalAmount = product.
|
|
419
|
+
let totalAmount = product.masterLoanProductId != null ? -totalAmountValue : totalAmountValue;
|
|
420
420
|
totalAmount = isAccrual ? totalAmount : -totalAmount;
|
|
421
421
|
const quickbooksAccountBS = await QuickbooksAccount.findOne({ accountCode: charge.code, ...companyFilter }).lean();
|
|
422
422
|
const quickbooksAccountPL = await QuickbooksAccount.findOne({ accountCode: PLCode, ...companyFilter }).lean();
|
|
@@ -433,7 +433,7 @@ export class QuickbooksService {
|
|
|
433
433
|
...trTemplate,
|
|
434
434
|
productId,
|
|
435
435
|
class: borrower.code,
|
|
436
|
-
memo: `${borrower.code} ${product.
|
|
436
|
+
memo: `${borrower.code} ${product.masterLoanProductId != null ? 'PARTICIPANT' : ''} ${EChargeType[charge.chargeType].toUpperCase()} ${product.type.toUpperCase()} - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
|
|
437
437
|
};
|
|
438
438
|
|
|
439
439
|
tr.account = quickbooksAccountBS.fullName;
|
|
@@ -500,8 +500,8 @@ export class QuickbooksService {
|
|
|
500
500
|
...trTemplate,
|
|
501
501
|
productId,
|
|
502
502
|
class: borrower.code,
|
|
503
|
-
amount: product.
|
|
504
|
-
memo: `${borrower.code} ${product.
|
|
503
|
+
amount: product.masterLoanProductId != null ? +amount : -+amount,
|
|
504
|
+
memo: `${borrower.code} ${product.masterLoanProductId != null ? 'PARTICIPANT' : ''} PRINCIPAL PAID TERM - TRANS: ${reportDateTrFormatted} - POST: ${currentDateTrFormatted}`,
|
|
505
505
|
};
|
|
506
506
|
|
|
507
507
|
if (settlementCode === 'null') {
|
|
@@ -100,7 +100,7 @@ export class InvestorSummaryService {
|
|
|
100
100
|
await Promise.all(borrowerIds.map(async (borrowerId) => {
|
|
101
101
|
const borrower = await BorrowerModel.findById(borrowerId).lean();
|
|
102
102
|
const borrowerProducts = await this.loanChargesService.getLoanProducts(borrowerId);
|
|
103
|
-
await Promise.all(borrowerProducts.filter((product) => product.
|
|
103
|
+
await Promise.all(borrowerProducts.filter((product) => product.masterLoanProductId == null).map(async (product) => {
|
|
104
104
|
const productId = product._id.toString();
|
|
105
105
|
const isRevolver = product.type === ELoanTypes.REVOLVER;
|
|
106
106
|
const { balance: balanceEnd } = await this.loanChargesService.getLoanProductBalance(productId, end);
|
|
@@ -426,7 +426,7 @@ export class ReportsService {
|
|
|
426
426
|
const manyTermProduct = products.filter((product) => product.type === ELoanTypes.TERM).length > 1;
|
|
427
427
|
|
|
428
428
|
return await Promise.all(products.map(async (product) => {
|
|
429
|
-
if (product.
|
|
429
|
+
if (product.masterLoanProductId != null) {
|
|
430
430
|
return null as IBankReportData;
|
|
431
431
|
}
|
|
432
432
|
if (dayjs(product.deactivationDate).isBefore(dayjs(date))) {
|