gemcap-be-common 1.2.59 → 1.2.60

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.
Files changed (41) hide show
  1. package/db/brokers.db.d.ts +5 -0
  2. package/db/brokers.db.js +62 -0
  3. package/db/brokers.db.ts +60 -0
  4. package/db/loan-charges.db.d.ts +2 -0
  5. package/db/loan-charges.db.js +26 -0
  6. package/db/loan-charges.db.ts +21 -0
  7. package/db/loan-payments.db.d.ts +2 -0
  8. package/db/loan-payments.db.js +23 -0
  9. package/db/loan-payments.db.ts +18 -0
  10. package/db/loan-products.db.d.ts +3 -0
  11. package/db/loan-products.db.js +22 -1
  12. package/db/loan-products.db.ts +23 -1
  13. package/db/loan-statement.db.d.ts +44 -0
  14. package/db/loan-statement.db.js +186 -1
  15. package/db/loan-statement.db.ts +203 -5
  16. package/db/loan-transactions.db.d.ts +2 -0
  17. package/db/loan-transactions.db.js +39 -0
  18. package/db/loan-transactions.db.ts +33 -0
  19. package/db/reports.db.d.ts +56 -0
  20. package/db/reports.db.js +295 -0
  21. package/db/reports.db.ts +354 -0
  22. package/models/Borrower.model.d.ts +46 -0
  23. package/models/Borrower.model.js +75 -0
  24. package/models/Borrower.model.ts +103 -0
  25. package/models/LoanPayment.model.d.ts +66 -0
  26. package/models/LoanPayment.model.js +62 -0
  27. package/models/LoanPayment.model.ts +97 -0
  28. package/models/TermLoan.model.d.ts +53 -0
  29. package/models/TermLoan.model.js +74 -0
  30. package/models/TermLoan.model.ts +97 -0
  31. package/models/TermLoanCalculated.model.d.ts +54 -0
  32. package/models/TermLoanCalculated.model.js +98 -0
  33. package/models/TermLoanCalculated.model.ts +128 -0
  34. package/models/TermLoanSettings.model.d.ts +38 -0
  35. package/models/TermLoanSettings.model.js +39 -0
  36. package/models/TermLoanSettings.model.ts +53 -0
  37. package/models/_models.d.ts +3 -0
  38. package/models/_models.js +3 -0
  39. package/models/_models.ts +3 -0
  40. package/package.json +1 -1
  41. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,354 @@
1
+ import _ from 'lodash';
2
+ import Decimal from 'decimal.js';
3
+
4
+ import { ILoanProductDoc, LoanProduct } from '../models/LoanProducts.model';
5
+ import { ELedgerReportType, ledgerHeadersMap } from './loan-statement.db';
6
+ import mongoose from 'mongoose';
7
+ import { BorrowerModel } from '../models/Borrower.model';
8
+ import {
9
+ ELoanTransactionTypes,
10
+ ILoanTransactionDocWithProduct,
11
+ LoanTransaction,
12
+ } from '../models/LoanTransaction.model';
13
+ import { ELoanTypes } from '../enums/loan-types.enum';
14
+ import {
15
+ ILoanStatementTransactionDocWithCharge,
16
+ LoanStatementTransactionModel,
17
+ } from '../models/LoanStatementTransaction.model';
18
+ import { defaultDateFormat, formatDate } from '../helpers/date.helper';
19
+ import dayjs from 'dayjs';
20
+ import { getLoanChargeForProduct } from './loan-charges.db';
21
+ import { getLoanProductBalance } from './loan-products.db';
22
+ import { getPaymentForTransaction } from './loan-payments.db';
23
+ import { enrichWithBrokers } from './brokers.db';
24
+ import { TermLoanModel } from '../models/TermLoan.model';
25
+ import { TermLoanCalculatedModel } from '../models/TermLoanCalculated.model';
26
+
27
+ export enum EChargeType {
28
+ INTEREST_FEE = 'INTEREST',
29
+ ADMIN_FEE = 'ADMIN FEE',
30
+ UNUSED_LINE_FEE = 'UNUSED LINE FEE',
31
+ ANNUAL_LINE_FEE = 'ANNUAL LINE FEE',
32
+ WIRE_FEE = 'WIRE FEE',
33
+ RECOVERABLE = 'RECOVERABLE',
34
+ OTHER = 'OTHER',
35
+ DISBURSEMENT = 'DISBURSEMENT',
36
+ PRINCIPAL = 'PRINCIPAL',
37
+ COLLECTION = 'COLLECTION',
38
+ ADJUSTMENT = 'ADJUSTMENT',
39
+ EXPECTED_PRINCIPAL = 'EXPECTED PRINCIPAL ACCRUED',
40
+ EXPECTED_PRINCIPAL_PAID = 'EXPECTED PRINCIPAL PAID',
41
+ }
42
+
43
+ export interface ILedgerReportRow {
44
+ borrowerCode: string;
45
+ date: string;
46
+ type: string;
47
+ chargeCode: string;
48
+ PLCode: string;
49
+ productCode: string;
50
+ productName: string;
51
+ amount: number;
52
+ statementAmount: number;
53
+ title: string;
54
+ balance: number;
55
+ floatedBalance: number;
56
+ info: string;
57
+ paymentDate: string;
58
+ }
59
+
60
+ export interface ILedgerDataRow {
61
+ typeOrder: number;
62
+ order: number;
63
+ date: Date;
64
+ type: EChargeType;
65
+ amount: number;
66
+ statementAmount: number;
67
+ title: string;
68
+ chargeCode: string;
69
+ PLCode: string;
70
+ productCode: string;
71
+ productName: string;
72
+ balance: number;
73
+ floatedBalance: number;
74
+ createdAt: Date;
75
+ info: string;
76
+ paymentDate: Date;
77
+ isBrokerFee?: boolean;
78
+ }
79
+
80
+ export const getLedger = async (productId: string, startDate: Date, endDate: Date, reportType: ELedgerReportType, showFloatedBalance = true) => {
81
+ const product: ILoanProductDoc = await LoanProduct.findById(productId).lean();
82
+
83
+ const emptyWorkBook = { [`${product.code} - ${product.name}`]: [['']] };
84
+ if (startDate === null || endDate === null) {
85
+ return emptyWorkBook;
86
+ }
87
+ const fullTransactions = await getLedgerData(productId, startDate, endDate);
88
+
89
+ const header = ledgerHeadersMap[reportType];
90
+ const headerKeys = showFloatedBalance
91
+ ? Object.keys(header).filter((key) => key !== 'floatedBalance')
92
+ : Object.keys(header);
93
+
94
+ const sumKeys = ['amount', 'statementAmount'];
95
+ const groupKeys = headerKeys.filter((key) => !sumKeys.includes(key));
96
+ const finalTransactions = reportType === ELedgerReportType.SHORT
97
+ ? mergeLedgerData(fullTransactions, groupKeys, sumKeys)
98
+ : fullTransactions;
99
+
100
+ const mappedArray = _.map([header, ...finalTransactions], (obj) => _.pick(obj, headerKeys));
101
+ const sheetName = `${product.code} - ${product.name}`;
102
+ return { [sheetName]: mappedArray };
103
+ };
104
+
105
+ const getLedgerData = async (productId: string, startDate: Date, endDate: Date): Promise<ILedgerReportRow[]> => {
106
+ const addBrokers = true;
107
+ const product: ILoanProductDoc = await LoanProduct.findById(productId).lean();
108
+ const borrower = await BorrowerModel.findById(product.borrowerId).lean();
109
+ const transactions = await LoanTransaction.aggregate<ILoanTransactionDocWithProduct>([
110
+ {
111
+ $match: {
112
+ $and: [
113
+ { 'date': { $gte: startDate } },
114
+ { 'date': { $lte: dayjs(endDate).endOf('day').toDate() } },
115
+ { 'productId': new mongoose.Types.ObjectId(productId) },
116
+ ],
117
+ },
118
+ }, {
119
+ $lookup: {
120
+ from: 'loan_products',
121
+ localField: 'productId',
122
+ foreignField: '_id',
123
+ as: 'product',
124
+ },
125
+ }, {
126
+ $unwind: {
127
+ path: '$product',
128
+ },
129
+ }, {
130
+ $sort: {
131
+ 'date': 1,
132
+ 'order': 1,
133
+ },
134
+ },
135
+ ]);
136
+ const convertTypes = (transactionType: ELoanTransactionTypes) => {
137
+ if (product.type === ELoanTypes.TERM && transactionType === ELoanTransactionTypes.COLLECTION) {
138
+ return 'PRINCIPAL';
139
+ }
140
+ return transactionType;
141
+ };
142
+ const mappedTransactions = transactions.map((transaction) => {
143
+ return <ILedgerDataRow>{
144
+ typeOrder: 0,
145
+ order: transaction.order,
146
+ date: transaction.date,
147
+ type: convertTypes(transaction.transactionType),
148
+ amount: transaction.amount,
149
+ statementAmount: null,
150
+ title: convertTypes(transaction.transactionType),
151
+ balance: transaction.balance,
152
+ floatedBalance: transaction.floatedBalance,
153
+ chargeCode: transaction.product.code,
154
+ PLCode: null,
155
+ productCode: transaction.product.code,
156
+ productName: transaction.product.name,
157
+ createdAt: transaction['createdAt'],
158
+ info: transaction.reference,
159
+ paymentDate: null,
160
+ };
161
+ });
162
+
163
+ const loanCharges = await getLoanChargeForProduct(productId);
164
+ const chargesIds = loanCharges.map((charge) => charge._id);
165
+ const statementTransactions = await LoanStatementTransactionModel.aggregate<ILoanStatementTransactionDocWithCharge>([
166
+ {
167
+ $match: {
168
+ $and: [
169
+ { 'date': { $gte: startDate } },
170
+ { 'date': { $lte: dayjs(endDate).endOf('day').toDate() } },
171
+ { 'chargeId': { '$in': chargesIds } },
172
+ ],
173
+ },
174
+ }, {
175
+ $lookup: {
176
+ from: 'loan_charges',
177
+ localField: 'chargeId',
178
+ foreignField: '_id',
179
+ as: 'charge',
180
+ },
181
+ }, {
182
+ $unwind: {
183
+ path: '$charge',
184
+ },
185
+ }, {
186
+ $sort: {
187
+ 'date': 1,
188
+ 'createdAt': 1,
189
+ 'order': 1,
190
+ },
191
+ },
192
+ ]);
193
+
194
+ const statementTransactionsWithBalance = await Promise.all(statementTransactions.map(async (statement) => {
195
+ const balances = await getLoanProductBalance(productId, statement.date);
196
+ return {
197
+ ...statement,
198
+ balance: balances.balance,
199
+ floatedBalance: balances.floatedBalance,
200
+ };
201
+ }));
202
+
203
+ const isParticipant = product.isParticipant;
204
+ const groupedMappedStatementTransactions = await Promise.all(statementTransactionsWithBalance.map(async (statement) => {
205
+
206
+ const transactions = [];
207
+
208
+ if (statement.amountPaid > 0) {
209
+ const payments = await getPaymentForTransaction(productId, statement._id.toString());
210
+ for (const payment of payments) {
211
+ transactions.push({
212
+ typeOrder: 1,
213
+ order: statement.order,
214
+ date: statement.date,
215
+ type: statement.charge.chargeType,
216
+ amount: null,
217
+ statementAmount: isParticipant ? statement.amountPaid : -statement.amountPaid,
218
+ title: `${statement.charge.name} PAID`,
219
+ chargeCode: statement.charge.code,
220
+ PLCode: statement.charge.PLCode,
221
+ productCode: product.code,
222
+ productName: product.name,
223
+ balance: statement.balance,
224
+ floatedBalance: statement.floatedBalance,
225
+ createdAt: statement['createdAt'],
226
+ info: statement.memo,
227
+ paymentDate: dayjs(payment.date).format(defaultDateFormat),
228
+ });
229
+ }
230
+ }
231
+ return [...transactions, {
232
+ typeOrder: 1,
233
+ order: statement.order,
234
+ date: statement.date,
235
+ type: statement.charge.chargeType,
236
+ amount: null,
237
+ statementAmount: isParticipant ? -statement.amount : statement.amount,
238
+ title: `${statement.charge.name} ACCRUED`,
239
+ chargeCode: statement.charge.code,
240
+ PLCode: statement.charge.PLCode,
241
+ productCode: product.code,
242
+ productName: product.name,
243
+ balance: statement.balance,
244
+ floatedBalance: statement.floatedBalance,
245
+ createdAt: statement['createdAt'],
246
+ info: statement.memo,
247
+ paymentDate: null,
248
+ }];
249
+ }));
250
+ const mappedStatementTransactions: ILedgerDataRow[] = groupedMappedStatementTransactions
251
+ .reduce((acc, group) => [...acc, ...group], []);
252
+ const statementTransactionsWithBrokers = addBrokers
253
+ ? await enrichWithBrokers(mappedStatementTransactions, product)
254
+ : mappedStatementTransactions;
255
+ const sortedTransactions = [...statementTransactionsWithBrokers, ...mappedTransactions]
256
+ .sort((a, b) => {
257
+ if (a.date.valueOf() !== b.date.valueOf()) {
258
+ return b.date.valueOf() - a.date.valueOf();
259
+ }
260
+ if (a.typeOrder !== b.typeOrder) {
261
+ return b.typeOrder - a.typeOrder;
262
+ }
263
+ return b.createdAt.valueOf() - a.createdAt.valueOf();
264
+ });
265
+
266
+ const fullTransactions = sortedTransactions
267
+ .map((row): ILedgerReportRow => ({
268
+ borrowerCode: borrower.code,
269
+ date: formatDate(row.date),
270
+ type: !!row.isBrokerFee ? `${EChargeType[row.type]} BROKER` : EChargeType[row.type],
271
+ chargeCode: row.chargeCode,
272
+ PLCode: row.PLCode,
273
+ productCode: row.productCode,
274
+ productName: row.productName,
275
+ amount: row.amount,
276
+ statementAmount: row.statementAmount,
277
+ title: row.title,
278
+ balance: row.balance,
279
+ floatedBalance: row.floatedBalance,
280
+ info: row.info,
281
+ paymentDate: row.paymentDate ? formatDate(row.paymentDate) : '',
282
+ }));
283
+
284
+ const termLoan = await TermLoanModel.findOne({ productId, actual: true });
285
+ if (termLoan) {
286
+ const calculatedTermLoan = await TermLoanCalculatedModel.findOne({
287
+ termLoanId: termLoan._id.toString(),
288
+ relevantStatement: dayjs(endDate).format('YYYY-MM-DD'),
289
+ });
290
+ if (calculatedTermLoan) {
291
+ const expectedPayment = <ILedgerReportRow>{
292
+ borrowerCode: borrower.code,
293
+ date: formatDate(endDate),
294
+ type: EChargeType.EXPECTED_PRINCIPAL,
295
+ chargeCode: null,
296
+ PLCode: null,
297
+ productCode: product.code,
298
+ amount: isParticipant ? -calculatedTermLoan.monthlyPrincipal : calculatedTermLoan.monthlyPrincipal,
299
+ statementAmount: null,
300
+ title: EChargeType.EXPECTED_PRINCIPAL,
301
+ balance: null,
302
+ floatedBalance: null,
303
+ info: EChargeType.EXPECTED_PRINCIPAL,
304
+ paymentDate: null,
305
+ };
306
+ fullTransactions.unshift(expectedPayment);
307
+ if (calculatedTermLoan.payments && calculatedTermLoan.payments.length > 0) {
308
+ for (const payment of calculatedTermLoan.payments) {
309
+ const paymentDoc = await LoanTransaction.findById(payment.paymentId).lean();
310
+ if (paymentDoc) {
311
+ const expectedPayment = <ILedgerReportRow>{
312
+ borrowerCode: borrower.code,
313
+ date: formatDate(endDate),
314
+ type: EChargeType.EXPECTED_PRINCIPAL_PAID,
315
+ chargeCode: null,
316
+ PLCode: null,
317
+ productCode: product.code,
318
+ amount: isParticipant ? -payment.amount : payment.amount,
319
+ statementAmount: null,
320
+ title: EChargeType.EXPECTED_PRINCIPAL_PAID,
321
+ balance: null,
322
+ floatedBalance: null,
323
+ info: EChargeType.EXPECTED_PRINCIPAL_PAID,
324
+ paymentDate: formatDate(paymentDoc.date),
325
+ };
326
+ fullTransactions.unshift(expectedPayment);
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+ return fullTransactions;
333
+ };
334
+
335
+ const mergeLedgerData = (transactions: ILedgerReportRow[], groupKeys: string[], sumKeys: string[]) => {
336
+ const groupedObjects = _.groupBy(
337
+ transactions,
338
+ (obj) => groupKeys.reduce((acc, key) => `${acc}${obj[key]}`, ''),
339
+ );
340
+
341
+ const mergedObjects = _.mapValues(groupedObjects, group =>
342
+ _.reduce(group, (result: any, obj) => {
343
+ sumKeys.forEach((key) => {
344
+ result[key] = new Decimal(result[key] || 0).plus(obj[key] || 0).toNumber();
345
+ });
346
+ groupKeys.forEach((key) => {
347
+ result[key] = obj[key];
348
+ });
349
+ return result;
350
+ }, {}),
351
+ );
352
+
353
+ return _.values(mergedObjects);
354
+ };
@@ -0,0 +1,46 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose, { Document } from 'mongoose';
26
+ interface ISchemaItem {
27
+ column: string;
28
+ databaseTitle: string;
29
+ }
30
+ interface IMapSchema {
31
+ data: ISchemaItem[];
32
+ name: string;
33
+ type: string;
34
+ }
35
+ export interface IBorrower {
36
+ code: string;
37
+ name: string;
38
+ title: string;
39
+ active: boolean;
40
+ accrualStatus: boolean;
41
+ schemas: IMapSchema[];
42
+ }
43
+ export interface IBorrowerDocument extends IBorrower, Document {
44
+ }
45
+ export declare const BorrowerModel: mongoose.Model<IBorrowerDocument>;
46
+ export {};
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BorrowerModel = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const _models_1 = require("./_models");
9
+ const mongooseLeanId = require('gemcap-be-common/plugins/id.plugin');
10
+ const BorrowerSchema = new mongoose_1.default.Schema({
11
+ code: {
12
+ type: String,
13
+ trim: true,
14
+ required: true,
15
+ },
16
+ name: {
17
+ type: String,
18
+ trim: true,
19
+ required: true,
20
+ },
21
+ title: {
22
+ type: String,
23
+ trim: true,
24
+ required: true,
25
+ },
26
+ active: {
27
+ type: Boolean,
28
+ default: true,
29
+ },
30
+ accrualStatus: {
31
+ type: Boolean,
32
+ default: false,
33
+ },
34
+ schemas: {
35
+ required: false,
36
+ type: [
37
+ {
38
+ name: {
39
+ type: String,
40
+ trim: true,
41
+ required: true,
42
+ },
43
+ type: {
44
+ type: String,
45
+ trim: true,
46
+ required: true,
47
+ },
48
+ data: [
49
+ {
50
+ column: {
51
+ type: String,
52
+ trim: true,
53
+ required: true,
54
+ },
55
+ databaseTitle: {
56
+ type: String,
57
+ trim: true,
58
+ required: true,
59
+ },
60
+ },
61
+ ],
62
+ },
63
+ ],
64
+ default: [],
65
+ },
66
+ __v: { type: Number, select: false },
67
+ }, { timestamps: true });
68
+ BorrowerSchema.pre(/^(save)/, async function () {
69
+ });
70
+ BorrowerSchema.pre(/^(updateOne|updateMany|findOneAndUpdate)/, async function () {
71
+ });
72
+ BorrowerSchema.pre(/^(findOneAndDelete|deleteOne|deleteMany)/, async function () {
73
+ });
74
+ BorrowerSchema.plugin(mongooseLeanId);
75
+ exports.BorrowerModel = mongoose_1.default.model(_models_1.MODEL_NAMES.borrowers, BorrowerSchema);
@@ -0,0 +1,103 @@
1
+ import mongoose, { Document } from 'mongoose';
2
+ import { MODEL_NAMES } from './_models';
3
+
4
+ const mongooseLeanId = require('gemcap-be-common/plugins/id.plugin');
5
+
6
+ interface ISchemaItem {
7
+ column: string;
8
+ databaseTitle: string;
9
+ }
10
+
11
+ interface IMapSchema {
12
+ data: ISchemaItem[];
13
+ name: string;
14
+ type: string;
15
+ }
16
+
17
+ export interface IBorrower {
18
+ code: string;
19
+ name: string;
20
+ title: string;
21
+ active: boolean;
22
+ accrualStatus: boolean;
23
+ schemas: IMapSchema[];
24
+ }
25
+
26
+ export interface IBorrowerDocument extends IBorrower, Document {
27
+ }
28
+
29
+ const BorrowerSchema = new mongoose.Schema(
30
+ {
31
+ code: {
32
+ type: String,
33
+ trim: true,
34
+ required: true,
35
+ },
36
+ name: {
37
+ type: String,
38
+ trim: true,
39
+ required: true,
40
+ },
41
+ title: {
42
+ type: String,
43
+ trim: true,
44
+ required: true,
45
+ },
46
+ active: {
47
+ type: Boolean,
48
+ default: true,
49
+ },
50
+ accrualStatus: {
51
+ type: Boolean,
52
+ default: false,
53
+ },
54
+ schemas: {
55
+ required: false,
56
+ type: [
57
+ {
58
+ name: {
59
+ type: String,
60
+ trim: true,
61
+ required: true,
62
+ },
63
+ type: {
64
+ type: String,
65
+ trim: true,
66
+ required: true,
67
+ },
68
+ data: [
69
+ {
70
+ column: {
71
+ type: String,
72
+ trim: true,
73
+ required: true,
74
+ },
75
+ databaseTitle: {
76
+ type: String,
77
+ trim: true,
78
+ required: true,
79
+ },
80
+ },
81
+ ],
82
+ },
83
+ ],
84
+ default: [],
85
+ },
86
+ __v: { type: Number, select: false },
87
+ },
88
+ { timestamps: true },
89
+ );
90
+
91
+ BorrowerSchema.pre(/^(save)/, async function() {
92
+
93
+ });
94
+
95
+ BorrowerSchema.pre(/^(updateOne|updateMany|findOneAndUpdate)/, async function() {
96
+ });
97
+
98
+ BorrowerSchema.pre(/^(findOneAndDelete|deleteOne|deleteMany)/, async function() {
99
+ });
100
+
101
+ BorrowerSchema.plugin(mongooseLeanId);
102
+
103
+ export const BorrowerModel: mongoose.Model<IBorrowerDocument> = mongoose.model<IBorrowerDocument>(MODEL_NAMES.borrowers, BorrowerSchema);
@@ -0,0 +1,66 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose, { Document } from 'mongoose';
26
+ export declare const LOAN_PAYMENT_FIELDS: string[];
27
+ export interface ICombinedPayment {
28
+ borrowerId: string;
29
+ date: Date;
30
+ payment: number;
31
+ addToRevolver: boolean;
32
+ products: {
33
+ productId: string;
34
+ payableSum: number;
35
+ settlementCode: string;
36
+ paymentOrder: string[];
37
+ }[];
38
+ linkedProducts: {
39
+ productId: string;
40
+ payableSum: number;
41
+ settlementCode: string;
42
+ }[];
43
+ }
44
+ export interface ILoanPayment {
45
+ date: Date;
46
+ productId: mongoose.Types.ObjectId;
47
+ amount: number;
48
+ paid: {
49
+ _id?: mongoose.Types.ObjectId;
50
+ statementId: mongoose.Types.ObjectId;
51
+ amount: number;
52
+ }[];
53
+ loanTransactions: {
54
+ _id?: mongoose.Types.ObjectId;
55
+ transactionId: mongoose.Types.ObjectId;
56
+ amount: number;
57
+ }[];
58
+ settlementCode?: string;
59
+ paymentOrder?: string[];
60
+ }
61
+ export interface ILoanPaymentWithId extends ILoanPayment {
62
+ _id: mongoose.Types.ObjectId;
63
+ }
64
+ export interface ILoanPaymentDoc extends ILoanPayment, Document {
65
+ }
66
+ export declare const LoanPaymentModel: mongoose.Model<ILoanPaymentDoc>;