gemcap-be-common 1.2.1 → 1.2.3
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/index.d.ts +4 -1
- package/db/index.js +4 -1
- package/db/index.ts +4 -1
- package/db/inventory-availability.db.d.ts +1 -2
- package/db/inventory-availability.db.js +2 -3
- package/db/inventory-availability.db.ts +7 -2
- package/db/inventory-seasonal-rates.db.d.ts +1 -1
- package/db/inventory-seasonal-rates.db.js +5 -5
- package/db/inventory-seasonal-rates.db.ts +1 -1
- package/db/loan-products.db.d.ts +33 -0
- package/db/loan-products.db.js +139 -0
- package/db/loan-products.db.ts +146 -0
- package/db/loan-statement.db.d.ts +2 -0
- package/db/loan-statement.db.js +59 -0
- package/db/loan-statement.db.ts +53 -0
- package/db/microservice-tasks.db.d.ts +1 -1
- package/db/microservice-tasks.db.ts +1 -2
- package/db/{receivables.ts → receivables.db.ts} +2 -1
- package/db/user-logs.db.d.ts +36 -0
- package/db/user-logs.db.js +41 -0
- package/db/user-logs.db.ts +48 -0
- package/enums/index.d.ts +2 -1
- package/enums/index.js +2 -1
- package/enums/index.ts +2 -1
- package/interfaces/collaterals.interface.d.ts +1 -3
- package/interfaces/collaterals.interface.ts +3 -5
- package/interfaces/index.d.ts +1 -0
- package/interfaces/index.js +1 -0
- package/interfaces/index.ts +1 -0
- package/models/AvailabilitySigns.model.ts +1 -0
- package/models/Banks.model.d.ts +45 -0
- package/models/Banks.model.js +39 -0
- package/models/Banks.model.ts +55 -0
- package/models/DeletedRecords.model.d.ts +35 -0
- package/models/DeletedRecords.model.js +21 -0
- package/models/DeletedRecords.model.ts +28 -0
- package/models/InventoryManualEntry.model.d.ts +2 -0
- package/models/InventorySeasonalRates.model.d.ts +3 -0
- package/models/LoanCharges.model.d.ts +58 -0
- package/models/LoanCharges.model.js +207 -0
- package/models/LoanCharges.model.ts +238 -0
- package/models/LoanProducts.model.d.ts +60 -0
- package/models/LoanProducts.model.js +93 -0
- package/models/LoanProducts.model.ts +130 -0
- package/models/LoanStatementTransaction.model.d.ts +50 -0
- package/models/LoanStatementTransaction.model.js +64 -0
- package/models/LoanStatementTransaction.model.ts +94 -0
- package/models/LoanTransaction.model.d.ts +76 -0
- package/models/LoanTransaction.model.js +160 -0
- package/models/LoanTransaction.model.ts +218 -0
- package/models/MicroserviceTask.model.d.ts +1 -2
- package/models/MicroserviceTask.model.ts +1 -2
- package/models/PostponedTransactions.model.d.ts +39 -0
- package/models/PostponedTransactions.model.js +28 -0
- package/models/PostponedTransactions.model.ts +42 -0
- package/models/UserLog.model.d.ts +55 -0
- package/models/UserLog.model.js +55 -0
- package/models/UserLog.model.ts +72 -0
- package/models/Yield.model.d.ts +46 -0
- package/models/Yield.model.js +48 -0
- package/models/Yield.model.ts +76 -0
- package/models/_models.d.ts +1 -0
- package/models/_models.js +2 -1
- package/models/_models.ts +2 -1
- package/models/index.d.ts +9 -0
- package/models/index.js +9 -0
- package/models/index.ts +9 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/db/{receivables.d.ts → receivables.db.d.ts} +0 -0
- package/db/{receivables.js → receivables.db.js} +1 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import mongoose, { Document, Model } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
import { ILoanProductDoc } from './LoanProducts.model';
|
|
4
|
+
import { MODEL_NAMES } from './_models';
|
|
5
|
+
import { ELogActionType, ELogType } from './UserLog.model';
|
|
6
|
+
import { IBankDoc } from './Banks.model';
|
|
7
|
+
import { DeletedRecord } from './DeletedRecords.model';
|
|
8
|
+
import { createLog, getLogChanges } from '../db';
|
|
9
|
+
|
|
10
|
+
export enum ELoanTransactionTypes {
|
|
11
|
+
COLLECTION = 'COLLECTION',
|
|
12
|
+
DISBURSEMENT = 'DISBURSEMENT',
|
|
13
|
+
ADJUSTMENT = 'ADJUSTMENT'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const LOAN_TRANSACTION_DOWNLOAD_FIELDS = [
|
|
17
|
+
'date',
|
|
18
|
+
'amount',
|
|
19
|
+
'description',
|
|
20
|
+
'reference',
|
|
21
|
+
'customerId',
|
|
22
|
+
'transactionType',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const LOAN_TRANSACTION_FIELDS = [
|
|
26
|
+
'_id',
|
|
27
|
+
'date',
|
|
28
|
+
'effectiveDate',
|
|
29
|
+
'productId',
|
|
30
|
+
'amount',
|
|
31
|
+
'description',
|
|
32
|
+
'reference',
|
|
33
|
+
'customerId',
|
|
34
|
+
'bankId',
|
|
35
|
+
'transactionType',
|
|
36
|
+
'balance',
|
|
37
|
+
'floatedBalance',
|
|
38
|
+
'loanPaymentId',
|
|
39
|
+
'userId',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export interface ILoanTransactionUpload {
|
|
43
|
+
date: Date;
|
|
44
|
+
ledgerAccountCode: string;
|
|
45
|
+
amount: number;
|
|
46
|
+
description: string;
|
|
47
|
+
reference: string;
|
|
48
|
+
customerId: string;
|
|
49
|
+
bankAccountNumber: string;
|
|
50
|
+
transactionType: ELoanTransactionTypes;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ILoanTransaction {
|
|
54
|
+
order?: number;
|
|
55
|
+
date: Date;
|
|
56
|
+
effectiveDate: Date,
|
|
57
|
+
productId: mongoose.Types.ObjectId;
|
|
58
|
+
amount: number;
|
|
59
|
+
description: string;
|
|
60
|
+
reference: string;
|
|
61
|
+
customerId: string;
|
|
62
|
+
bankId: mongoose.Types.ObjectId;
|
|
63
|
+
transactionType: ELoanTransactionTypes;
|
|
64
|
+
balance: number;
|
|
65
|
+
floatedBalance: number;
|
|
66
|
+
loanPaymentId?: mongoose.Types.ObjectId;
|
|
67
|
+
userId?: mongoose.Types.ObjectId;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface ILoanTransactionDocWithProduct extends ILoanTransactionDoc {
|
|
71
|
+
product: ILoanProductDoc;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ILoanTransactionWithId extends ILoanTransaction {
|
|
75
|
+
_id: mongoose.Types.ObjectId;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type ILoanTransactionView = Omit<ILoanTransactionWithId, 'order'>;
|
|
79
|
+
|
|
80
|
+
export type ILoanTransactionViewWithBank = ILoanTransactionView & { bank: IBankDoc };
|
|
81
|
+
|
|
82
|
+
export interface ILoanTransactionDoc extends ILoanTransaction, Document {
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface ILoanTransactionModel extends Model<ILoanTransaction> {
|
|
86
|
+
findByIdAndDeleteWithUserId(id: string, userId: string): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const LoanTransactionSchema = new mongoose.Schema<ILoanTransaction, ILoanTransactionModel>(
|
|
90
|
+
{
|
|
91
|
+
userId: {
|
|
92
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
93
|
+
ref: MODEL_NAMES.users,
|
|
94
|
+
required: false,
|
|
95
|
+
},
|
|
96
|
+
order: {
|
|
97
|
+
type: Number,
|
|
98
|
+
required: true,
|
|
99
|
+
default: 0,
|
|
100
|
+
},
|
|
101
|
+
date: {
|
|
102
|
+
type: Date,
|
|
103
|
+
required: true,
|
|
104
|
+
},
|
|
105
|
+
effectiveDate: {
|
|
106
|
+
type: Date,
|
|
107
|
+
required: true,
|
|
108
|
+
},
|
|
109
|
+
productId: {
|
|
110
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
111
|
+
ref: 'loan_products',
|
|
112
|
+
required: true,
|
|
113
|
+
},
|
|
114
|
+
amount: {
|
|
115
|
+
type: Number,
|
|
116
|
+
required: true,
|
|
117
|
+
},
|
|
118
|
+
description: {
|
|
119
|
+
type: String,
|
|
120
|
+
trim: true,
|
|
121
|
+
},
|
|
122
|
+
reference: {
|
|
123
|
+
type: String,
|
|
124
|
+
trim: true,
|
|
125
|
+
},
|
|
126
|
+
customerId: {
|
|
127
|
+
type: String,
|
|
128
|
+
trim: true,
|
|
129
|
+
},
|
|
130
|
+
bankId: {
|
|
131
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
132
|
+
ref: 'banks',
|
|
133
|
+
required: false,
|
|
134
|
+
},
|
|
135
|
+
transactionType: {
|
|
136
|
+
type: String,
|
|
137
|
+
enum: Object.values(ELoanTransactionTypes),
|
|
138
|
+
required: true,
|
|
139
|
+
},
|
|
140
|
+
balance: {
|
|
141
|
+
type: Number,
|
|
142
|
+
},
|
|
143
|
+
floatedBalance: {
|
|
144
|
+
type: Number,
|
|
145
|
+
},
|
|
146
|
+
loanPaymentId: {
|
|
147
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
148
|
+
ref: 'loan_payments',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{ timestamps: true },
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
LoanTransactionSchema.statics.findByIdAndDeleteWithUserId = async function(id, userId) {
|
|
155
|
+
const foundDoc = await this.findById(id).lean();
|
|
156
|
+
if (!foundDoc) {
|
|
157
|
+
return this.findByIdAndDelete(id);
|
|
158
|
+
}
|
|
159
|
+
const deletedRecord = new DeletedRecord({
|
|
160
|
+
collection: 'loan_transactions',
|
|
161
|
+
recordId: id,
|
|
162
|
+
record: foundDoc,
|
|
163
|
+
});
|
|
164
|
+
await deletedRecord.save();
|
|
165
|
+
|
|
166
|
+
await createLog({
|
|
167
|
+
action: ELogActionType.DELETE,
|
|
168
|
+
logType: ELogType.LOAN_TRANSACTION,
|
|
169
|
+
userId: userId,
|
|
170
|
+
recordCollection: 'loan_transactions',
|
|
171
|
+
recordId: id,
|
|
172
|
+
details: {},
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
return this.findByIdAndDelete(id);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
LoanTransactionSchema.pre(/^(save)/, async function() {
|
|
180
|
+
const myDoc: any = this;
|
|
181
|
+
await createLog({
|
|
182
|
+
action: ELogActionType.CREATE,
|
|
183
|
+
logType: ELogType.LOAN_TRANSACTION,
|
|
184
|
+
userId: myDoc.userId,
|
|
185
|
+
recordCollection: 'loan_transactions',
|
|
186
|
+
recordId: myDoc._id,
|
|
187
|
+
details: {},
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
LoanTransactionSchema.pre(/^(updateOne|updateMany|findOneAndUpdate)/, async function() {
|
|
192
|
+
const myDoc: any = this;
|
|
193
|
+
const update = myDoc._update;
|
|
194
|
+
const conditions = myDoc._conditions;
|
|
195
|
+
if (update
|
|
196
|
+
&& update.hasOwnProperty('userId')
|
|
197
|
+
&& conditions
|
|
198
|
+
&& conditions.hasOwnProperty('_id')
|
|
199
|
+
) {
|
|
200
|
+
const oldDoc = await myDoc.model.findById(conditions._id);
|
|
201
|
+
let changes = {};
|
|
202
|
+
if (oldDoc) {
|
|
203
|
+
changes = getLogChanges(oldDoc, update);
|
|
204
|
+
}
|
|
205
|
+
await createLog({
|
|
206
|
+
action: ELogActionType.EDIT,
|
|
207
|
+
logType: ELogType.LOAN_TRANSACTION,
|
|
208
|
+
userId: update.userId,
|
|
209
|
+
recordCollection: 'loan_transactions',
|
|
210
|
+
recordId: conditions._id,
|
|
211
|
+
details: {
|
|
212
|
+
changes,
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
export const LoanTransaction: ILoanTransactionModel = mongoose.model<ILoanTransactionDoc, ILoanTransactionModel>('loan_transactions', LoanTransactionSchema);
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from 'mongoose';
|
|
26
|
-
import { EMicroserviceTaskStatuses } from '../enums';
|
|
27
|
-
import { EMicroserviceTask } from '../enums/microservice-task.enum';
|
|
26
|
+
import { EMicroserviceTask, EMicroserviceTaskStatuses } from '../enums';
|
|
28
27
|
export interface IMicroserviceTask {
|
|
29
28
|
cmd: EMicroserviceTask;
|
|
30
29
|
params: any;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import mongoose, { Document } from 'mongoose';
|
|
2
2
|
|
|
3
|
-
import { EMicroserviceTaskStatuses } from '../enums';
|
|
4
|
-
import { EMicroserviceTask } from '../enums/microservice-task.enum';
|
|
3
|
+
import { EMicroserviceTask, EMicroserviceTaskStatuses } from '../enums';
|
|
5
4
|
|
|
6
5
|
const mongooseLeanId = require('../plugins/id.plugin');
|
|
7
6
|
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import { ILoanTransactionDoc } from './LoanTransaction.model';
|
|
27
|
+
export interface IPostponedTransaction {
|
|
28
|
+
postponedToDate: string;
|
|
29
|
+
transactionId: mongoose.Types.ObjectId;
|
|
30
|
+
productId: mongoose.Types.ObjectId;
|
|
31
|
+
}
|
|
32
|
+
export interface IPostponedTransactionDoc extends Document, IPostponedTransaction {
|
|
33
|
+
}
|
|
34
|
+
export interface IPostponedTransactionWithTransaction extends IPostponedTransactionDoc {
|
|
35
|
+
transaction: ILoanTransactionDoc;
|
|
36
|
+
}
|
|
37
|
+
export declare const PostponedTransaction: mongoose.Model<IPostponedTransactionDoc, {}, {}, {}, mongoose.Document<unknown, {}, IPostponedTransactionDoc> & IPostponedTransactionDoc & {
|
|
38
|
+
_id: mongoose.Types.ObjectId;
|
|
39
|
+
}, any>;
|
|
@@ -0,0 +1,28 @@
|
|
|
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.PostponedTransaction = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const PostponedTransactionSchema = new mongoose_1.default.Schema({
|
|
9
|
+
postponedToDate: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
transactionId: {
|
|
14
|
+
type: mongoose_1.default.Types.ObjectId,
|
|
15
|
+
ref: 'loan_transactions',
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
productId: {
|
|
19
|
+
type: mongoose_1.default.Types.ObjectId,
|
|
20
|
+
ref: 'loan_products',
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
__v: {
|
|
24
|
+
type: Number,
|
|
25
|
+
select: false
|
|
26
|
+
},
|
|
27
|
+
}, { timestamps: false });
|
|
28
|
+
exports.PostponedTransaction = mongoose_1.default.model('postponed_transactions', PostponedTransactionSchema);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import mongoose, { Document } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
import { ILoanTransactionDoc } from './LoanTransaction.model';
|
|
4
|
+
|
|
5
|
+
export interface IPostponedTransaction {
|
|
6
|
+
postponedToDate: string;
|
|
7
|
+
transactionId: mongoose.Types.ObjectId;
|
|
8
|
+
productId: mongoose.Types.ObjectId;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface IPostponedTransactionDoc extends Document, IPostponedTransaction {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IPostponedTransactionWithTransaction extends IPostponedTransactionDoc {
|
|
15
|
+
transaction: ILoanTransactionDoc
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const PostponedTransactionSchema = new mongoose.Schema(
|
|
19
|
+
{
|
|
20
|
+
postponedToDate: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
transactionId: {
|
|
25
|
+
type: mongoose.Types.ObjectId,
|
|
26
|
+
ref: 'loan_transactions',
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
productId: {
|
|
30
|
+
type: mongoose.Types.ObjectId,
|
|
31
|
+
ref: 'loan_products',
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
__v: {
|
|
35
|
+
type: Number,
|
|
36
|
+
select: false
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{ timestamps: false }
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export const PostponedTransaction = mongoose.model<IPostponedTransactionDoc>('postponed_transactions', PostponedTransactionSchema);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/types" />
|
|
2
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
3
|
+
/// <reference types="mongoose/types/models" />
|
|
4
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
5
|
+
/// <reference types="mongoose/types/callback" />
|
|
6
|
+
/// <reference types="mongoose/types/collection" />
|
|
7
|
+
/// <reference types="mongoose/types/connection" />
|
|
8
|
+
/// <reference types="mongoose/types/cursor" />
|
|
9
|
+
/// <reference types="mongoose/types/document" />
|
|
10
|
+
/// <reference types="mongoose/types/error" />
|
|
11
|
+
/// <reference types="mongoose/types/expressions" />
|
|
12
|
+
/// <reference types="mongoose/types/helpers" />
|
|
13
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
14
|
+
/// <reference types="mongoose/types/indexes" />
|
|
15
|
+
/// <reference types="mongoose/types/models" />
|
|
16
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
17
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
18
|
+
/// <reference types="mongoose/types/populate" />
|
|
19
|
+
/// <reference types="mongoose/types/query" />
|
|
20
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
21
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
22
|
+
/// <reference types="mongoose/types/session" />
|
|
23
|
+
/// <reference types="mongoose/types/types" />
|
|
24
|
+
/// <reference types="mongoose/types/utility" />
|
|
25
|
+
/// <reference types="mongoose/types/validation" />
|
|
26
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
27
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
28
|
+
import mongoose, { Model } from 'mongoose';
|
|
29
|
+
export declare enum ELogType {
|
|
30
|
+
TRANSACTIONS_UPLOAD = "TRANSACTIONS_UPLOAD",
|
|
31
|
+
COLLATERAL_UPLOAD = "COLLATERAL_UPLOAD",
|
|
32
|
+
LOAN_TRANSACTION = "LOAN_TRANSACTION"
|
|
33
|
+
}
|
|
34
|
+
export declare enum ELogActionType {
|
|
35
|
+
UPLOAD = "UPLOAD",
|
|
36
|
+
CREATE = "CREATE",
|
|
37
|
+
EDIT = "EDIT",
|
|
38
|
+
DELETE = "DELETE"
|
|
39
|
+
}
|
|
40
|
+
export interface IUserLog {
|
|
41
|
+
_id?: mongoose.Types.ObjectId;
|
|
42
|
+
logType: ELogType;
|
|
43
|
+
userId: mongoose.Types.ObjectId;
|
|
44
|
+
timestamp: Date;
|
|
45
|
+
action: ELogActionType;
|
|
46
|
+
recordId: mongoose.Schema.Types.ObjectId;
|
|
47
|
+
recordCollection: string;
|
|
48
|
+
details: any;
|
|
49
|
+
}
|
|
50
|
+
export interface IUserLogWithLookup extends IUserLog {
|
|
51
|
+
record?: any;
|
|
52
|
+
}
|
|
53
|
+
type UserLogModel = Model<IUserLog, {}, {}>;
|
|
54
|
+
export declare const UserLog: UserLogModel;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
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.UserLog = exports.ELogActionType = exports.ELogType = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const _models_1 = require("./_models");
|
|
9
|
+
var ELogType;
|
|
10
|
+
(function (ELogType) {
|
|
11
|
+
ELogType["TRANSACTIONS_UPLOAD"] = "TRANSACTIONS_UPLOAD";
|
|
12
|
+
ELogType["COLLATERAL_UPLOAD"] = "COLLATERAL_UPLOAD";
|
|
13
|
+
ELogType["LOAN_TRANSACTION"] = "LOAN_TRANSACTION";
|
|
14
|
+
})(ELogType || (exports.ELogType = ELogType = {}));
|
|
15
|
+
var ELogActionType;
|
|
16
|
+
(function (ELogActionType) {
|
|
17
|
+
ELogActionType["UPLOAD"] = "UPLOAD";
|
|
18
|
+
ELogActionType["CREATE"] = "CREATE";
|
|
19
|
+
ELogActionType["EDIT"] = "EDIT";
|
|
20
|
+
ELogActionType["DELETE"] = "DELETE";
|
|
21
|
+
})(ELogActionType || (exports.ELogActionType = ELogActionType = {}));
|
|
22
|
+
const UserLogSchema = new mongoose_1.default.Schema({
|
|
23
|
+
logType: {
|
|
24
|
+
type: String,
|
|
25
|
+
enum: Object.values(ELogType),
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
userId: {
|
|
29
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
30
|
+
ref: _models_1.MODEL_NAMES.users,
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
timestamp: {
|
|
34
|
+
type: Date,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
action: {
|
|
38
|
+
type: String,
|
|
39
|
+
enum: Object.values(ELogActionType),
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
recordId: {
|
|
43
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
44
|
+
},
|
|
45
|
+
recordCollection: {
|
|
46
|
+
type: String,
|
|
47
|
+
},
|
|
48
|
+
details: {
|
|
49
|
+
type: mongoose_1.default.Schema.Types.Mixed,
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
52
|
+
}, {
|
|
53
|
+
timestamps: { createdAt: true, updatedAt: false },
|
|
54
|
+
});
|
|
55
|
+
exports.UserLog = mongoose_1.default.model('user_logs', UserLogSchema);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import mongoose, { Model } from 'mongoose';
|
|
2
|
+
|
|
3
|
+
import { MODEL_NAMES } from './_models';
|
|
4
|
+
|
|
5
|
+
export enum ELogType {
|
|
6
|
+
TRANSACTIONS_UPLOAD = 'TRANSACTIONS_UPLOAD',
|
|
7
|
+
COLLATERAL_UPLOAD = 'COLLATERAL_UPLOAD',
|
|
8
|
+
LOAN_TRANSACTION = 'LOAN_TRANSACTION',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export enum ELogActionType {
|
|
12
|
+
UPLOAD = 'UPLOAD',
|
|
13
|
+
CREATE = 'CREATE',
|
|
14
|
+
EDIT = 'EDIT',
|
|
15
|
+
DELETE = 'DELETE',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface IUserLog {
|
|
19
|
+
_id?: mongoose.Types.ObjectId;
|
|
20
|
+
logType: ELogType;
|
|
21
|
+
userId: mongoose.Types.ObjectId;
|
|
22
|
+
timestamp: Date;
|
|
23
|
+
action: ELogActionType;
|
|
24
|
+
recordId: mongoose.Schema.Types.ObjectId;
|
|
25
|
+
recordCollection: string;
|
|
26
|
+
details: any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface IUserLogWithLookup extends IUserLog {
|
|
30
|
+
record?: any;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type UserLogModel = Model<IUserLog, {}, {}>;
|
|
34
|
+
|
|
35
|
+
const UserLogSchema = new mongoose.Schema<IUserLog, UserLogModel>(
|
|
36
|
+
{
|
|
37
|
+
logType: {
|
|
38
|
+
type: String,
|
|
39
|
+
enum: Object.values(ELogType),
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
userId: {
|
|
43
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
44
|
+
ref: MODEL_NAMES.users,
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
timestamp: {
|
|
48
|
+
type: Date,
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
action: {
|
|
52
|
+
type: String,
|
|
53
|
+
enum: Object.values(ELogActionType),
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
56
|
+
recordId: {
|
|
57
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
58
|
+
},
|
|
59
|
+
recordCollection: {
|
|
60
|
+
type: String,
|
|
61
|
+
},
|
|
62
|
+
details: {
|
|
63
|
+
type: mongoose.Schema.Types.Mixed,
|
|
64
|
+
required: true,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
timestamps: { createdAt: true, updatedAt: false },
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
export const UserLog = mongoose.model<IUserLog, UserLogModel>('user_logs', UserLogSchema);
|
|
@@ -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 Joi from 'joi';
|
|
26
|
+
import mongoose, { Model } from 'mongoose';
|
|
27
|
+
import { ISelectedMonth } from '../helpers';
|
|
28
|
+
export declare const yieldParamsValidationSchema: Joi.ObjectSchema<IYieldParams>;
|
|
29
|
+
export interface IYieldParams {
|
|
30
|
+
periodStart?: ISelectedMonth;
|
|
31
|
+
periodEnd?: ISelectedMonth;
|
|
32
|
+
forLifetime?: boolean;
|
|
33
|
+
ignoreOldData?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface IYieldData {
|
|
36
|
+
_id?: mongoose.Types.ObjectId;
|
|
37
|
+
chargeId: mongoose.Types.ObjectId;
|
|
38
|
+
year: number;
|
|
39
|
+
month: number;
|
|
40
|
+
total: number;
|
|
41
|
+
averageBalance: number;
|
|
42
|
+
percent: number;
|
|
43
|
+
}
|
|
44
|
+
type IYieldDataModel = Model<IYieldData, {}, {}>;
|
|
45
|
+
export declare const YieldData: IYieldDataModel;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
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.YieldData = exports.yieldParamsValidationSchema = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
9
|
+
const _models_1 = require("./_models");
|
|
10
|
+
exports.yieldParamsValidationSchema = joi_1.default.object({
|
|
11
|
+
periodStart: joi_1.default.object({
|
|
12
|
+
month: joi_1.default.number().integer().min(1).max(12),
|
|
13
|
+
year: joi_1.default.number().integer().min(1900).max(9999),
|
|
14
|
+
}),
|
|
15
|
+
periodEnd: joi_1.default.object({
|
|
16
|
+
month: joi_1.default.number().integer().min(1).max(12),
|
|
17
|
+
year: joi_1.default.number().integer().min(1900).max(9999),
|
|
18
|
+
}),
|
|
19
|
+
forLifetime: joi_1.default.boolean(),
|
|
20
|
+
ignoreOldData: joi_1.default.boolean(),
|
|
21
|
+
});
|
|
22
|
+
const YieldDataSchema = new mongoose_1.default.Schema({
|
|
23
|
+
chargeId: {
|
|
24
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
25
|
+
ref: _models_1.MODEL_NAMES.loanCharges,
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
year: {
|
|
29
|
+
type: Number,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
month: {
|
|
33
|
+
type: Number,
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
total: {
|
|
37
|
+
type: Number,
|
|
38
|
+
},
|
|
39
|
+
averageBalance: {
|
|
40
|
+
type: Number,
|
|
41
|
+
},
|
|
42
|
+
percent: {
|
|
43
|
+
type: Number,
|
|
44
|
+
},
|
|
45
|
+
}, {
|
|
46
|
+
timestamps: { createdAt: true, updatedAt: true },
|
|
47
|
+
});
|
|
48
|
+
exports.YieldData = mongoose_1.default.model(_models_1.MODEL_NAMES.yieldData, YieldDataSchema);
|