gemcap-be-common 1.1.102 → 1.2.2

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 (71) hide show
  1. package/db/index.d.ts +4 -1
  2. package/db/index.js +4 -1
  3. package/db/index.ts +4 -1
  4. package/db/inventory-availability.db.d.ts +1 -2
  5. package/db/inventory-availability.db.js +2 -3
  6. package/db/inventory-availability.db.ts +7 -2
  7. package/db/inventory-seasonal-rates.db.d.ts +1 -1
  8. package/db/inventory-seasonal-rates.db.js +5 -5
  9. package/db/inventory-seasonal-rates.db.ts +1 -1
  10. package/db/loan-products.db.d.ts +33 -0
  11. package/db/loan-products.db.js +139 -0
  12. package/db/loan-products.db.ts +146 -0
  13. package/db/loan-statement.db.d.ts +2 -0
  14. package/db/loan-statement.db.js +59 -0
  15. package/db/loan-statement.db.ts +53 -0
  16. package/db/microservice-tasks.db.d.ts +1 -1
  17. package/db/microservice-tasks.db.ts +1 -2
  18. package/db/{receivables.ts → receivables.db.ts} +2 -1
  19. package/db/user-logs.db.d.ts +36 -0
  20. package/db/user-logs.db.js +41 -0
  21. package/db/user-logs.db.ts +48 -0
  22. package/enums/index.d.ts +2 -1
  23. package/enums/index.js +2 -1
  24. package/enums/index.ts +2 -1
  25. package/interfaces/collaterals.interface.d.ts +1 -3
  26. package/interfaces/collaterals.interface.ts +3 -5
  27. package/interfaces/index.d.ts +1 -0
  28. package/interfaces/index.js +1 -0
  29. package/interfaces/index.ts +1 -0
  30. package/models/AvailabilitySigns.model.ts +1 -0
  31. package/models/Banks.model.d.ts +45 -0
  32. package/models/Banks.model.js +39 -0
  33. package/models/Banks.model.ts +55 -0
  34. package/models/DeletedRecords.model.d.ts +35 -0
  35. package/models/DeletedRecords.model.js +21 -0
  36. package/models/DeletedRecords.model.ts +28 -0
  37. package/models/InventoryManualEntry.model.d.ts +2 -0
  38. package/models/InventorySeasonalRates.model.d.ts +3 -0
  39. package/models/LoanCharges.model.d.ts +58 -0
  40. package/models/LoanCharges.model.js +207 -0
  41. package/models/LoanCharges.model.ts +238 -0
  42. package/models/LoanProducts.model.d.ts +60 -0
  43. package/models/LoanProducts.model.js +93 -0
  44. package/models/LoanProducts.model.ts +130 -0
  45. package/models/LoanStatementTransaction.model.d.ts +50 -0
  46. package/models/LoanStatementTransaction.model.js +64 -0
  47. package/models/LoanStatementTransaction.model.ts +94 -0
  48. package/models/LoanTransaction.model.d.ts +76 -0
  49. package/models/LoanTransaction.model.js +160 -0
  50. package/models/LoanTransaction.model.ts +218 -0
  51. package/models/MicroserviceTask.model.d.ts +1 -2
  52. package/models/MicroserviceTask.model.ts +1 -2
  53. package/models/PostponedTransactions.model.d.ts +39 -0
  54. package/models/PostponedTransactions.model.js +28 -0
  55. package/models/PostponedTransactions.model.ts +42 -0
  56. package/models/UserLog.model.d.ts +55 -0
  57. package/models/UserLog.model.js +55 -0
  58. package/models/UserLog.model.ts +72 -0
  59. package/models/Yield.model.d.ts +46 -0
  60. package/models/Yield.model.js +48 -0
  61. package/models/Yield.model.ts +76 -0
  62. package/models/_models.d.ts +1 -0
  63. package/models/_models.js +1 -0
  64. package/models/_models.ts +1 -0
  65. package/models/index.d.ts +9 -0
  66. package/models/index.js +9 -0
  67. package/models/index.ts +9 -0
  68. package/package.json +3 -3
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/db/{receivables.d.ts → receivables.db.d.ts} +0 -0
  71. package/db/{receivables.js → receivables.db.js} +1 -1
@@ -0,0 +1,130 @@
1
+ import mongoose, { Document } from 'mongoose';
2
+
3
+ import { MODEL_NAMES } from './_models';
4
+ import { ELoanTypes } from '../enums';
5
+
6
+ export interface ILoanProduct {
7
+ borrowerId: mongoose.Types.ObjectId;
8
+ order: number;
9
+ active: boolean;
10
+ code: string;
11
+ masterCode: string;
12
+ name: string;
13
+ type: ELoanTypes;
14
+ startDate: Date;
15
+ maturityDate: Date;
16
+ commitment: number;
17
+ isBalanceActual: boolean;
18
+ isFloatedBalanceActual: boolean;
19
+ isParticipant: boolean;
20
+ minPercent: number;
21
+ maxPercent: number;
22
+ prepaymentDate?: Date;
23
+ prepaymentTerms?: string;
24
+ settlementCode: string;
25
+ isDefaultPaymentOrder: boolean;
26
+ }
27
+
28
+ export interface ILoanProductWithId extends ILoanProduct {
29
+ _id: mongoose.Types.ObjectId;
30
+ }
31
+
32
+ export type ILoanProductView = Omit<ILoanProductWithId, 'borrowerId' | 'order'>;
33
+
34
+ export interface ILoanProductViewWithBalances extends ILoanProductView {
35
+ balance: number;
36
+ floatedBalance: number;
37
+ }
38
+
39
+ export interface ILoanProductDoc extends ILoanProduct, Document {
40
+ }
41
+
42
+ const LoanProductSchema = new mongoose.Schema(
43
+ {
44
+ borrowerId: {
45
+ type: mongoose.Schema.Types.ObjectId,
46
+ ref: 'borrowers',
47
+ required: true,
48
+ },
49
+ order: {
50
+ type: Number,
51
+ required: true,
52
+ },
53
+ active: {
54
+ type: Boolean,
55
+ required: true,
56
+ },
57
+ code: {
58
+ type: String,
59
+ trim: true,
60
+ required: true,
61
+ },
62
+ masterCode: {
63
+ type: String,
64
+ trim: true,
65
+ },
66
+ name: {
67
+ type: String,
68
+ trim: true,
69
+ required: true,
70
+ },
71
+ type: {
72
+ type: String,
73
+ required: true,
74
+ trim: true,
75
+ },
76
+ startDate: {
77
+ type: Date,
78
+ required: true,
79
+ },
80
+ maturityDate: {
81
+ type: Date,
82
+ required: true,
83
+ },
84
+ commitment: {
85
+ type: Number,
86
+ required: true,
87
+ },
88
+ isBalanceActual: {
89
+ type: Boolean,
90
+ required: true,
91
+ default: true,
92
+ },
93
+ isFloatedBalanceActual: {
94
+ type: Boolean,
95
+ required: true,
96
+ default: true,
97
+ },
98
+ isParticipant: {
99
+ type: Boolean,
100
+ required: true,
101
+ },
102
+ minPercent: {
103
+ type: Number,
104
+ required: false,
105
+ },
106
+ maxPercent: {
107
+ type: Number,
108
+ required: false,
109
+ },
110
+ prepaymentDate: {
111
+ type: Date,
112
+ },
113
+ prepaymentTerms: {
114
+ type: String,
115
+ trim: true,
116
+ },
117
+ settlementCode: {
118
+ type: String,
119
+ trim: true,
120
+ },
121
+ isDefaultPaymentOrder: {
122
+ type: Boolean,
123
+ required: true,
124
+ },
125
+ __v: { type: Number, select: false },
126
+ },
127
+ { timestamps: true },
128
+ );
129
+
130
+ export const LoanProduct = mongoose.model<ILoanProductDoc>(MODEL_NAMES.loanProducts, LoanProductSchema);
@@ -0,0 +1,50 @@
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 { ILoanChargeDoc } from './LoanCharges.model';
27
+ export declare const LOAN_STATEMENT_TRANSACTION_FIELDS: string[];
28
+ export interface ILoanStatementTransaction {
29
+ order: number;
30
+ date: Date;
31
+ chargeId: mongoose.Types.ObjectId;
32
+ amount: number;
33
+ amountPaid?: number;
34
+ balance?: number;
35
+ isSystem: boolean;
36
+ memo: string;
37
+ settlementCode?: string;
38
+ userId?: mongoose.Types.ObjectId;
39
+ isEditable?: boolean;
40
+ }
41
+ export interface ILoanStatementTransactionWithId extends ILoanStatementTransaction {
42
+ _id: mongoose.Types.ObjectId;
43
+ }
44
+ export interface ILoanStatementTransactionDocWithCharge extends ILoanStatementTransactionDoc {
45
+ charge: ILoanChargeDoc;
46
+ }
47
+ export type ILoanStatementTransactionView = Omit<ILoanStatementTransactionWithId, 'order'>;
48
+ export interface ILoanStatementTransactionDoc extends ILoanStatementTransaction, Document {
49
+ }
50
+ export declare const LoanStatementTransactionModel: mongoose.Model<ILoanStatementTransactionDoc>;
@@ -0,0 +1,64 @@
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.LoanStatementTransactionModel = exports.LOAN_STATEMENT_TRANSACTION_FIELDS = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const _models_1 = require("./_models");
9
+ exports.LOAN_STATEMENT_TRANSACTION_FIELDS = [
10
+ '_id',
11
+ 'date',
12
+ 'chargeId',
13
+ 'amount',
14
+ 'amountPaid',
15
+ 'balance',
16
+ 'isSystem',
17
+ 'memo',
18
+ 'userId',
19
+ ];
20
+ const LoanStatementSchema = new mongoose_1.default.Schema({
21
+ order: {
22
+ type: Number,
23
+ required: true,
24
+ default: 0,
25
+ },
26
+ date: {
27
+ type: Date,
28
+ required: true,
29
+ },
30
+ chargeId: {
31
+ type: mongoose_1.default.Schema.Types.ObjectId,
32
+ ref: 'loan_charges',
33
+ required: true,
34
+ },
35
+ amount: {
36
+ type: Number,
37
+ required: true,
38
+ },
39
+ amountPaid: {
40
+ type: Number,
41
+ required: false,
42
+ },
43
+ balance: {
44
+ type: Number,
45
+ required: false,
46
+ },
47
+ isSystem: {
48
+ type: Boolean,
49
+ default: true,
50
+ },
51
+ memo: {
52
+ type: String,
53
+ },
54
+ settlementCode: {
55
+ type: String,
56
+ },
57
+ userId: {
58
+ type: mongoose_1.default.Schema.Types.ObjectId,
59
+ ref: _models_1.MODEL_NAMES.users,
60
+ required: false,
61
+ },
62
+ __v: { type: Number, select: false },
63
+ }, { timestamps: true });
64
+ exports.LoanStatementTransactionModel = mongoose_1.default.model('loan_statements', LoanStatementSchema);
@@ -0,0 +1,94 @@
1
+ import mongoose, { Document } from 'mongoose';
2
+
3
+ import { ILoanChargeDoc } from './LoanCharges.model';
4
+ import { MODEL_NAMES } from './_models';
5
+
6
+
7
+ export const LOAN_STATEMENT_TRANSACTION_FIELDS = [
8
+ '_id',
9
+ 'date',
10
+ 'chargeId',
11
+ 'amount',
12
+ 'amountPaid',
13
+ 'balance',
14
+ 'isSystem',
15
+ 'memo',
16
+ 'userId',
17
+ ];
18
+
19
+ export interface ILoanStatementTransaction {
20
+ order: number;
21
+ date: Date;
22
+ chargeId: mongoose.Types.ObjectId;
23
+ amount: number;
24
+ amountPaid?: number;
25
+ balance?: number;
26
+ isSystem: boolean;
27
+ memo: string;
28
+ settlementCode?: string;
29
+ userId?: mongoose.Types.ObjectId;
30
+ isEditable?: boolean;
31
+ }
32
+
33
+ export interface ILoanStatementTransactionWithId extends ILoanStatementTransaction {
34
+ _id: mongoose.Types.ObjectId;
35
+ }
36
+
37
+ export interface ILoanStatementTransactionDocWithCharge extends ILoanStatementTransactionDoc {
38
+ charge: ILoanChargeDoc;
39
+ }
40
+
41
+ export type ILoanStatementTransactionView = Omit<ILoanStatementTransactionWithId, 'order'>
42
+
43
+ export interface ILoanStatementTransactionDoc extends ILoanStatementTransaction, Document {
44
+ }
45
+
46
+ const LoanStatementSchema = new mongoose.Schema(
47
+ {
48
+ order: {
49
+ type: Number,
50
+ required: true,
51
+ default: 0,
52
+ },
53
+ date: {
54
+ type: Date,
55
+ required: true,
56
+ },
57
+ chargeId: {
58
+ type: mongoose.Schema.Types.ObjectId,
59
+ ref: 'loan_charges',
60
+ required: true,
61
+ },
62
+ amount: {
63
+ type: Number,
64
+ required: true,
65
+ },
66
+ amountPaid: {
67
+ type: Number,
68
+ required: false,
69
+ },
70
+ balance: {
71
+ type: Number,
72
+ required: false,
73
+ },
74
+ isSystem: {
75
+ type: Boolean,
76
+ default: true,
77
+ },
78
+ memo: {
79
+ type: String,
80
+ },
81
+ settlementCode: {
82
+ type: String,
83
+ },
84
+ userId: {
85
+ type: mongoose.Schema.Types.ObjectId,
86
+ ref: MODEL_NAMES.users,
87
+ required: false,
88
+ },
89
+ __v: { type: Number, select: false },
90
+ },
91
+ { timestamps: true },
92
+ );
93
+
94
+ export const LoanStatementTransactionModel: mongoose.Model<ILoanStatementTransactionDoc> = mongoose.model<ILoanStatementTransactionDoc>('loan_statements', LoanStatementSchema);
@@ -0,0 +1,76 @@
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, Model } from 'mongoose';
26
+ import { ILoanProductDoc } from './LoanProducts.model';
27
+ import { IBankDoc } from './Banks.model';
28
+ export declare enum ELoanTransactionTypes {
29
+ COLLECTION = "COLLECTION",
30
+ DISBURSEMENT = "DISBURSEMENT",
31
+ ADJUSTMENT = "ADJUSTMENT"
32
+ }
33
+ export declare const LOAN_TRANSACTION_DOWNLOAD_FIELDS: string[];
34
+ export declare const LOAN_TRANSACTION_FIELDS: string[];
35
+ export interface ILoanTransactionUpload {
36
+ date: Date;
37
+ ledgerAccountCode: string;
38
+ amount: number;
39
+ description: string;
40
+ reference: string;
41
+ customerId: string;
42
+ bankAccountNumber: string;
43
+ transactionType: ELoanTransactionTypes;
44
+ }
45
+ export interface ILoanTransaction {
46
+ order?: number;
47
+ date: Date;
48
+ effectiveDate: Date;
49
+ productId: mongoose.Types.ObjectId;
50
+ amount: number;
51
+ description: string;
52
+ reference: string;
53
+ customerId: string;
54
+ bankId: mongoose.Types.ObjectId;
55
+ transactionType: ELoanTransactionTypes;
56
+ balance: number;
57
+ floatedBalance: number;
58
+ loanPaymentId?: mongoose.Types.ObjectId;
59
+ userId?: mongoose.Types.ObjectId;
60
+ }
61
+ export interface ILoanTransactionDocWithProduct extends ILoanTransactionDoc {
62
+ product: ILoanProductDoc;
63
+ }
64
+ export interface ILoanTransactionWithId extends ILoanTransaction {
65
+ _id: mongoose.Types.ObjectId;
66
+ }
67
+ export type ILoanTransactionView = Omit<ILoanTransactionWithId, 'order'>;
68
+ export type ILoanTransactionViewWithBank = ILoanTransactionView & {
69
+ bank: IBankDoc;
70
+ };
71
+ export interface ILoanTransactionDoc extends ILoanTransaction, Document {
72
+ }
73
+ export interface ILoanTransactionModel extends Model<ILoanTransaction> {
74
+ findByIdAndDeleteWithUserId(id: string, userId: string): Promise<void>;
75
+ }
76
+ export declare const LoanTransaction: ILoanTransactionModel;
@@ -0,0 +1,160 @@
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.LoanTransaction = exports.LOAN_TRANSACTION_FIELDS = exports.LOAN_TRANSACTION_DOWNLOAD_FIELDS = exports.ELoanTransactionTypes = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const _models_1 = require("./_models");
9
+ const UserLog_model_1 = require("./UserLog.model");
10
+ const DeletedRecords_model_1 = require("./DeletedRecords.model");
11
+ const db_1 = require("../db");
12
+ var ELoanTransactionTypes;
13
+ (function (ELoanTransactionTypes) {
14
+ ELoanTransactionTypes["COLLECTION"] = "COLLECTION";
15
+ ELoanTransactionTypes["DISBURSEMENT"] = "DISBURSEMENT";
16
+ ELoanTransactionTypes["ADJUSTMENT"] = "ADJUSTMENT";
17
+ })(ELoanTransactionTypes || (exports.ELoanTransactionTypes = ELoanTransactionTypes = {}));
18
+ exports.LOAN_TRANSACTION_DOWNLOAD_FIELDS = [
19
+ 'date',
20
+ 'amount',
21
+ 'description',
22
+ 'reference',
23
+ 'customerId',
24
+ 'transactionType',
25
+ ];
26
+ exports.LOAN_TRANSACTION_FIELDS = [
27
+ '_id',
28
+ 'date',
29
+ 'effectiveDate',
30
+ 'productId',
31
+ 'amount',
32
+ 'description',
33
+ 'reference',
34
+ 'customerId',
35
+ 'bankId',
36
+ 'transactionType',
37
+ 'balance',
38
+ 'floatedBalance',
39
+ 'loanPaymentId',
40
+ 'userId',
41
+ ];
42
+ const LoanTransactionSchema = new mongoose_1.default.Schema({
43
+ userId: {
44
+ type: mongoose_1.default.Schema.Types.ObjectId,
45
+ ref: _models_1.MODEL_NAMES.users,
46
+ required: false,
47
+ },
48
+ order: {
49
+ type: Number,
50
+ required: true,
51
+ default: 0,
52
+ },
53
+ date: {
54
+ type: Date,
55
+ required: true,
56
+ },
57
+ effectiveDate: {
58
+ type: Date,
59
+ required: true,
60
+ },
61
+ productId: {
62
+ type: mongoose_1.default.Schema.Types.ObjectId,
63
+ ref: 'loan_products',
64
+ required: true,
65
+ },
66
+ amount: {
67
+ type: Number,
68
+ required: true,
69
+ },
70
+ description: {
71
+ type: String,
72
+ trim: true,
73
+ },
74
+ reference: {
75
+ type: String,
76
+ trim: true,
77
+ },
78
+ customerId: {
79
+ type: String,
80
+ trim: true,
81
+ },
82
+ bankId: {
83
+ type: mongoose_1.default.Schema.Types.ObjectId,
84
+ ref: 'banks',
85
+ required: false,
86
+ },
87
+ transactionType: {
88
+ type: String,
89
+ enum: Object.values(ELoanTransactionTypes),
90
+ required: true,
91
+ },
92
+ balance: {
93
+ type: Number,
94
+ },
95
+ floatedBalance: {
96
+ type: Number,
97
+ },
98
+ loanPaymentId: {
99
+ type: mongoose_1.default.Schema.Types.ObjectId,
100
+ ref: 'loan_payments',
101
+ },
102
+ }, { timestamps: true });
103
+ LoanTransactionSchema.statics.findByIdAndDeleteWithUserId = async function (id, userId) {
104
+ const foundDoc = await this.findById(id).lean();
105
+ if (!foundDoc) {
106
+ return this.findByIdAndDelete(id);
107
+ }
108
+ const deletedRecord = new DeletedRecords_model_1.DeletedRecord({
109
+ collection: 'loan_transactions',
110
+ recordId: id,
111
+ record: foundDoc,
112
+ });
113
+ await deletedRecord.save();
114
+ await (0, db_1.createLog)({
115
+ action: UserLog_model_1.ELogActionType.DELETE,
116
+ logType: UserLog_model_1.ELogType.LOAN_TRANSACTION,
117
+ userId: userId,
118
+ recordCollection: 'loan_transactions',
119
+ recordId: id,
120
+ details: {},
121
+ });
122
+ return this.findByIdAndDelete(id);
123
+ };
124
+ LoanTransactionSchema.pre(/^(save)/, async function () {
125
+ const myDoc = this;
126
+ await (0, db_1.createLog)({
127
+ action: UserLog_model_1.ELogActionType.CREATE,
128
+ logType: UserLog_model_1.ELogType.LOAN_TRANSACTION,
129
+ userId: myDoc.userId,
130
+ recordCollection: 'loan_transactions',
131
+ recordId: myDoc._id,
132
+ details: {},
133
+ });
134
+ });
135
+ LoanTransactionSchema.pre(/^(updateOne|updateMany|findOneAndUpdate)/, async function () {
136
+ const myDoc = this;
137
+ const update = myDoc._update;
138
+ const conditions = myDoc._conditions;
139
+ if (update
140
+ && update.hasOwnProperty('userId')
141
+ && conditions
142
+ && conditions.hasOwnProperty('_id')) {
143
+ const oldDoc = await myDoc.model.findById(conditions._id);
144
+ let changes = {};
145
+ if (oldDoc) {
146
+ changes = (0, db_1.getLogChanges)(oldDoc, update);
147
+ }
148
+ await (0, db_1.createLog)({
149
+ action: UserLog_model_1.ELogActionType.EDIT,
150
+ logType: UserLog_model_1.ELogType.LOAN_TRANSACTION,
151
+ userId: update.userId,
152
+ recordCollection: 'loan_transactions',
153
+ recordId: conditions._id,
154
+ details: {
155
+ changes,
156
+ },
157
+ });
158
+ }
159
+ });
160
+ exports.LoanTransaction = mongoose_1.default.model('loan_transactions', LoanTransactionSchema);