@kipicore/dbcore 1.1.5 → 1.1.8
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/README.md +1 -1
- package/dist/constants/app.js +0 -1
- package/dist/db/mongodb.js +4 -4
- package/dist/db/postgres.d.ts +1 -1
- package/dist/db/postgres.js +5 -5
- package/dist/index.d.ts +419 -415
- package/dist/index.js +748 -428
- package/dist/models/mongodb/attendanceModel.d.ts +2 -2
- package/dist/models/mongodb/attendanceModel.js +7 -8
- package/dist/models/mongodb/eventModel.d.ts +2 -2
- package/dist/models/mongodb/eventModel.js +3 -3
- package/dist/models/mongodb/examGroupModel.d.ts +2 -2
- package/dist/models/mongodb/examGroupModel.js +22 -28
- package/dist/models/mongodb/examHasAnswerSheetModel.d.ts +2 -2
- package/dist/models/mongodb/examHasAnswerSheetModel.js +5 -6
- package/dist/models/mongodb/examModel.d.ts +2 -2
- package/dist/models/mongodb/examModel.js +7 -10
- package/dist/models/mongodb/holidayModel.d.ts +2 -2
- package/dist/models/mongodb/holidayModel.js +4 -6
- package/dist/models/mongodb/inquiryModel.d.ts +2 -2
- package/dist/models/mongodb/inquiryModel.js +3 -4
- package/dist/models/mongodb/plugin/transformIdInResponsePlugin.d.ts +1 -1
- package/dist/models/mongodb/plugin/transformIdInResponsePlugin.js +4 -6
- package/dist/models/mongodb/schoolFeeModel.d.ts +2 -2
- package/dist/models/mongodb/schoolFeeModel.js +3 -3
- package/dist/models/mongodb/subjectIndexModel.d.ts +2 -2
- package/dist/models/mongodb/subjectIndexModel.js +66 -108
- package/dist/models/mongodb/subscriptionPlanModel.d.ts +2 -2
- package/dist/models/mongodb/subscriptionPlanModel.js +1 -1
- package/dist/models/mongodb/taskManagementModel.d.ts +2 -2
- package/dist/models/mongodb/taskManagementModel.js +3 -3
- package/dist/models/mongodb/userDoc.d.ts +1 -1
- package/dist/models/mongodb/userDoc.js +1 -1
- package/dist/models/mongodb/userSchoolMetaModel.d.ts +1 -1
- package/dist/models/mongodb/userSchoolMetaModel.js +8 -8
- package/dist/models/psql/announcementModel.d.ts +4 -4
- package/dist/models/psql/announcementModel.js +25 -25
- package/dist/models/psql/batchModel.d.ts +4 -4
- package/dist/models/psql/batchModel.js +51 -51
- package/dist/models/psql/driverModel.d.ts +4 -4
- package/dist/models/psql/driverModel.js +28 -28
- package/dist/models/psql/facilityModel.d.ts +4 -4
- package/dist/models/psql/facilityModel.js +23 -23
- package/dist/models/psql/feeHistoryModel.d.ts +4 -4
- package/dist/models/psql/feeHistoryModel.js +64 -65
- package/dist/models/psql/feeReminderModel.d.ts +3 -3
- package/dist/models/psql/feeReminderModel.js +32 -32
- package/dist/models/psql/feesCollectionModel.d.ts +4 -4
- package/dist/models/psql/feesCollectionModel.js +36 -37
- package/dist/models/psql/index.d.ts +1 -1
- package/dist/models/psql/index.js +12 -12
- package/dist/models/psql/lectureModel.d.ts +4 -4
- package/dist/models/psql/lectureModel.js +75 -84
- package/dist/models/psql/masterLeaveModel.d.ts +4 -4
- package/dist/models/psql/masterLeaveModel.js +22 -23
- package/dist/models/psql/testimonialModel.d.ts +4 -4
- package/dist/models/psql/testimonialModel.js +25 -27
- package/dist/models/psql/toDoModel.d.ts +4 -4
- package/dist/models/psql/toDoModel.js +23 -23
- package/dist/models/psql/typeManagementModel.d.ts +4 -4
- package/dist/models/psql/typeManagementModel.js +19 -19
- package/dist/models/psql/userModel.d.ts +4 -4
- package/dist/models/psql/userModel.js +47 -48
- package/dist/models/psql/userPayoutModel.d.ts +4 -4
- package/dist/models/psql/userPayoutModel.js +55 -70
- package/dist/services/Concrete/mongooseCommonService.d.ts +4 -4
- package/dist/services/Concrete/mongooseCommonService.js +2 -4
- package/dist/services/Contracts/IMongooseCommonService.d.ts +2 -2
- package/dist/services/Contracts/ISequelizeCommonService.d.ts +12 -12
- package/dist/types/generateIdCardType.d.ts +2 -2
- package/package.json +49 -47
- /package/dist/services/Concrete/{sequelizeCommanService.d.ts → sequelizeCommonService.d.ts} +0 -0
- /package/dist/services/Concrete/{sequelizeCommanService.js → sequelizeCommonService.js} +0 -0
|
@@ -28,49 +28,49 @@ FeeHistoryModel.init({
|
|
|
28
28
|
},
|
|
29
29
|
instituteId: {
|
|
30
30
|
type: sequelize_1.DataTypes.UUID,
|
|
31
|
-
field:
|
|
31
|
+
field: 'institute_id',
|
|
32
32
|
allowNull: false,
|
|
33
33
|
},
|
|
34
34
|
pdfId: {
|
|
35
35
|
type: sequelize_1.DataTypes.UUID,
|
|
36
|
-
field:
|
|
36
|
+
field: 'pdf_id',
|
|
37
37
|
allowNull: true,
|
|
38
38
|
},
|
|
39
39
|
invoiceId: {
|
|
40
40
|
type: sequelize_1.DataTypes.INTEGER,
|
|
41
|
-
field:
|
|
41
|
+
field: 'invoice_id',
|
|
42
42
|
defaultValue: null,
|
|
43
43
|
allowNull: true,
|
|
44
44
|
},
|
|
45
45
|
userId: {
|
|
46
46
|
type: sequelize_1.DataTypes.UUID,
|
|
47
|
-
field:
|
|
47
|
+
field: 'user_id',
|
|
48
48
|
allowNull: false,
|
|
49
49
|
},
|
|
50
50
|
feeCollectionId: {
|
|
51
51
|
type: sequelize_1.DataTypes.UUID,
|
|
52
|
-
field:
|
|
52
|
+
field: 'fee_collection_id',
|
|
53
53
|
allowNull: true,
|
|
54
54
|
},
|
|
55
55
|
parentHistoryId: {
|
|
56
56
|
type: sequelize_1.DataTypes.UUID,
|
|
57
|
-
field:
|
|
57
|
+
field: 'parent_history_id',
|
|
58
58
|
allowNull: true,
|
|
59
59
|
},
|
|
60
60
|
bankAccountId: {
|
|
61
61
|
type: sequelize_1.DataTypes.UUID,
|
|
62
|
-
field:
|
|
62
|
+
field: 'bank_account_id',
|
|
63
63
|
allowNull: true,
|
|
64
64
|
},
|
|
65
65
|
feeTypeId: {
|
|
66
66
|
type: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.STRING),
|
|
67
67
|
defaultValue: [],
|
|
68
|
-
field:
|
|
68
|
+
field: 'fee_type_id',
|
|
69
69
|
allowNull: true,
|
|
70
70
|
},
|
|
71
71
|
schoolFeeCollectionId: {
|
|
72
72
|
type: sequelize_1.DataTypes.UUID,
|
|
73
|
-
field:
|
|
73
|
+
field: 'school_fee_collection_id',
|
|
74
74
|
allowNull: true,
|
|
75
75
|
},
|
|
76
76
|
// academicCalendarId: {
|
|
@@ -112,136 +112,136 @@ FeeHistoryModel.init({
|
|
|
112
112
|
allowNull: true,
|
|
113
113
|
},
|
|
114
114
|
}, {
|
|
115
|
-
modelName:
|
|
116
|
-
tableName:
|
|
115
|
+
modelName: 'FeeHistoryModel',
|
|
116
|
+
tableName: 'fee_history',
|
|
117
117
|
timestamps: true,
|
|
118
118
|
sequelize: index_js_1.sequelize,
|
|
119
119
|
});
|
|
120
120
|
FeeHistoryModel.belongsTo(feesCollectionModel_js_1.default, {
|
|
121
121
|
foreignKey: {
|
|
122
|
-
name:
|
|
123
|
-
field:
|
|
122
|
+
name: 'feeCollectionId',
|
|
123
|
+
field: 'fee_collection_id',
|
|
124
124
|
allowNull: true,
|
|
125
125
|
},
|
|
126
|
-
as:
|
|
126
|
+
as: 'feeHistoryFeeCollection',
|
|
127
127
|
});
|
|
128
128
|
feesCollectionModel_js_1.default.hasMany(FeeHistoryModel, {
|
|
129
129
|
foreignKey: {
|
|
130
|
-
name:
|
|
131
|
-
field:
|
|
130
|
+
name: 'feeCollectionId',
|
|
131
|
+
field: 'fee_collection_id',
|
|
132
132
|
allowNull: true,
|
|
133
133
|
},
|
|
134
|
-
as:
|
|
134
|
+
as: 'feeCollectionHasFeeHistory',
|
|
135
135
|
});
|
|
136
136
|
FeeHistoryModel.belongsTo(fileStorageModel_js_1.default, {
|
|
137
137
|
foreignKey: {
|
|
138
|
-
name:
|
|
139
|
-
field:
|
|
138
|
+
name: 'pdfId',
|
|
139
|
+
field: 'pdf_id',
|
|
140
140
|
allowNull: true,
|
|
141
141
|
},
|
|
142
|
-
as:
|
|
142
|
+
as: 'feeHistoryFile',
|
|
143
143
|
});
|
|
144
144
|
fileStorageModel_js_1.default.hasMany(FeeHistoryModel, {
|
|
145
145
|
foreignKey: {
|
|
146
|
-
name:
|
|
147
|
-
field:
|
|
146
|
+
name: 'pdfId',
|
|
147
|
+
field: 'pdf_id',
|
|
148
148
|
allowNull: true,
|
|
149
149
|
},
|
|
150
|
-
as:
|
|
150
|
+
as: 'filesHasFeeHistory',
|
|
151
151
|
});
|
|
152
152
|
FeeHistoryModel.belongsTo(bankAccountDetailsModel_js_1.default, {
|
|
153
153
|
foreignKey: {
|
|
154
|
-
name:
|
|
155
|
-
field:
|
|
154
|
+
name: 'bankAccountId',
|
|
155
|
+
field: 'bank_account_id',
|
|
156
156
|
allowNull: true,
|
|
157
157
|
},
|
|
158
|
-
as:
|
|
158
|
+
as: 'feeHistoryAccount',
|
|
159
159
|
});
|
|
160
160
|
bankAccountDetailsModel_js_1.default.hasMany(FeeHistoryModel, {
|
|
161
161
|
foreignKey: {
|
|
162
|
-
name:
|
|
163
|
-
field:
|
|
162
|
+
name: 'bankAccountId',
|
|
163
|
+
field: 'bank_account_id',
|
|
164
164
|
allowNull: true,
|
|
165
165
|
},
|
|
166
|
-
as:
|
|
166
|
+
as: 'feeHistoryHasAccount',
|
|
167
167
|
});
|
|
168
168
|
FeeHistoryModel.belongsTo(FeeHistoryModel, {
|
|
169
169
|
foreignKey: {
|
|
170
|
-
name:
|
|
171
|
-
field:
|
|
170
|
+
name: 'parentHistoryId',
|
|
171
|
+
field: 'parent_history_id',
|
|
172
172
|
allowNull: true,
|
|
173
173
|
},
|
|
174
|
-
as:
|
|
174
|
+
as: 'feeHistory',
|
|
175
175
|
});
|
|
176
176
|
FeeHistoryModel.hasMany(FeeHistoryModel, {
|
|
177
177
|
foreignKey: {
|
|
178
|
-
name:
|
|
179
|
-
field:
|
|
178
|
+
name: 'parentHistoryId',
|
|
179
|
+
field: 'parent_history_id',
|
|
180
180
|
allowNull: true,
|
|
181
181
|
},
|
|
182
|
-
as:
|
|
182
|
+
as: 'feeHistoryHas',
|
|
183
183
|
});
|
|
184
184
|
FeeHistoryModel.belongsTo(schoolFeeCollectionModel_js_1.default, {
|
|
185
185
|
foreignKey: {
|
|
186
|
-
name:
|
|
187
|
-
field:
|
|
186
|
+
name: 'schoolFeeCollectionId',
|
|
187
|
+
field: 'school_fee_collection_id',
|
|
188
188
|
allowNull: true,
|
|
189
189
|
},
|
|
190
|
-
as:
|
|
190
|
+
as: 'feeHistorySchool',
|
|
191
191
|
});
|
|
192
192
|
schoolFeeCollectionModel_js_1.default.hasMany(FeeHistoryModel, {
|
|
193
193
|
foreignKey: {
|
|
194
|
-
name:
|
|
195
|
-
field:
|
|
194
|
+
name: 'schoolFeeCollectionId',
|
|
195
|
+
field: 'school_fee_collection_id',
|
|
196
196
|
allowNull: true,
|
|
197
197
|
},
|
|
198
|
-
as:
|
|
198
|
+
as: 'feeHistoryHasSchool',
|
|
199
199
|
});
|
|
200
200
|
FeeHistoryModel.belongsTo(instituteModel_js_1.default, {
|
|
201
201
|
foreignKey: {
|
|
202
|
-
name:
|
|
203
|
-
field:
|
|
202
|
+
name: 'instituteId',
|
|
203
|
+
field: 'institute_id',
|
|
204
204
|
},
|
|
205
|
-
as:
|
|
205
|
+
as: 'feeHistoryInstitute',
|
|
206
206
|
});
|
|
207
207
|
instituteModel_js_1.default.hasMany(FeeHistoryModel, {
|
|
208
|
-
foreignKey:
|
|
209
|
-
as:
|
|
208
|
+
foreignKey: 'instituteId',
|
|
209
|
+
as: 'instituteHasFeeHistory',
|
|
210
210
|
});
|
|
211
211
|
FeeHistoryModel.belongsTo(userModel_js_1.default, {
|
|
212
212
|
foreignKey: {
|
|
213
|
-
name:
|
|
214
|
-
field:
|
|
213
|
+
name: 'userId',
|
|
214
|
+
field: 'user_id',
|
|
215
215
|
},
|
|
216
|
-
as:
|
|
216
|
+
as: 'feeHistoryUser',
|
|
217
217
|
});
|
|
218
218
|
userModel_js_1.default.hasMany(FeeHistoryModel, {
|
|
219
|
-
foreignKey:
|
|
220
|
-
as:
|
|
219
|
+
foreignKey: 'userId',
|
|
220
|
+
as: 'userHasFeeHistory',
|
|
221
221
|
});
|
|
222
222
|
FeeHistoryModel.belongsTo(userModel_js_1.default, {
|
|
223
223
|
foreignKey: {
|
|
224
|
-
name:
|
|
224
|
+
name: 'createdBy',
|
|
225
225
|
allowNull: true,
|
|
226
|
-
field:
|
|
226
|
+
field: 'created_by',
|
|
227
227
|
},
|
|
228
|
-
as:
|
|
228
|
+
as: 'createdByUser',
|
|
229
229
|
});
|
|
230
230
|
FeeHistoryModel.belongsTo(userModel_js_1.default, {
|
|
231
231
|
foreignKey: {
|
|
232
|
-
name:
|
|
232
|
+
name: 'updatedBy',
|
|
233
233
|
allowNull: true,
|
|
234
|
-
field:
|
|
234
|
+
field: 'updated_by',
|
|
235
235
|
},
|
|
236
|
-
as:
|
|
236
|
+
as: 'updatedByUser',
|
|
237
237
|
});
|
|
238
238
|
FeeHistoryModel.belongsTo(userModel_js_1.default, {
|
|
239
239
|
foreignKey: {
|
|
240
|
-
name:
|
|
240
|
+
name: 'deletedBy',
|
|
241
241
|
allowNull: true,
|
|
242
|
-
field:
|
|
242
|
+
field: 'deleted_by',
|
|
243
243
|
},
|
|
244
|
-
as:
|
|
244
|
+
as: 'deletedByUser',
|
|
245
245
|
});
|
|
246
246
|
const subjectWiserFeePay = async (instituteId, feeCollectionId, paidFee, userId) => {
|
|
247
247
|
try {
|
|
@@ -259,12 +259,12 @@ const subjectWiserFeePay = async (instituteId, feeCollectionId, paidFee, userId)
|
|
|
259
259
|
},
|
|
260
260
|
include: [
|
|
261
261
|
{
|
|
262
|
-
association:
|
|
262
|
+
association: 'entityType',
|
|
263
263
|
where: { sequence: app_js_1.INSTITUTE_ENTITY_TYPE_SEQUENCE.LAST },
|
|
264
264
|
},
|
|
265
265
|
],
|
|
266
266
|
});
|
|
267
|
-
const subjectIds = subjects.map(
|
|
267
|
+
const subjectIds = subjects.map(subject => subject.id);
|
|
268
268
|
const fees = await userHasSubjectFeeModel_js_1.default.findAll({
|
|
269
269
|
where: {
|
|
270
270
|
subjectId: { [sequelize_1.Op.in]: subjectIds },
|
|
@@ -276,7 +276,7 @@ const subjectWiserFeePay = async (instituteId, feeCollectionId, paidFee, userId)
|
|
|
276
276
|
throw new Error(errorMessages_js_1.FEESCOLLECTION_ERROR_MESSAGES.NOT_FOUND);
|
|
277
277
|
}
|
|
278
278
|
// const totalFeeAmount = Number(fees.reduce((total, fee) => total + fee.fee, 0));
|
|
279
|
-
const feeDistribution = fees.map(
|
|
279
|
+
const feeDistribution = fees.map(fee => {
|
|
280
280
|
const subjectPaidFee = (fee.fee / (feeCollection.feeAmount || 0)) * paidFee;
|
|
281
281
|
return {
|
|
282
282
|
subjectId: fee.subjectId,
|
|
@@ -326,8 +326,7 @@ const beforeCreateOrUpdateHook = async (feeCollection) => {
|
|
|
326
326
|
throw new Error(errorMessages_js_1.FILE_STORAGE_ERROR_MESSAGES.NOT_FOUND);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
if ((!feeCollection.feeTypeId || feeCollection.feeTypeId.length === 0) &&
|
|
330
|
-
!feeCollection.bankAccountId)
|
|
329
|
+
if ((!feeCollection.feeTypeId || feeCollection.feeTypeId.length === 0) && !feeCollection.bankAccountId)
|
|
331
330
|
await subjectWiserFeePay(feeCollection.instituteId, feeCollection.feeCollectionId, feeCollection.paidFee, feeCollection.userId);
|
|
332
331
|
};
|
|
333
332
|
FeeHistoryModel.beforeCreate(beforeCreateOrUpdateHook);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IFeeReminderModelAttributes } from
|
|
3
|
-
import { TFeeReminderModelCreationAttributes } from
|
|
1
|
+
import { Model } from 'sequelize';
|
|
2
|
+
import { IFeeReminderModelAttributes } from '../../interfaces/feeReminderInterface.js';
|
|
3
|
+
import { TFeeReminderModelCreationAttributes } from '../../types/feeReminderType.js';
|
|
4
4
|
declare class FeeReminderModel extends Model<IFeeReminderModelAttributes, TFeeReminderModelCreationAttributes> {
|
|
5
5
|
id: string;
|
|
6
6
|
userId: string;
|
|
@@ -33,7 +33,7 @@ FeeReminderModel.init({
|
|
|
33
33
|
sendDate: {
|
|
34
34
|
type: sequelize_1.DataTypes.DATE,
|
|
35
35
|
allowNull: false,
|
|
36
|
-
defaultValue: sequelize_1.Sequelize.literal(
|
|
36
|
+
defaultValue: sequelize_1.Sequelize.literal('CURRENT_TIMESTAMP'),
|
|
37
37
|
},
|
|
38
38
|
dueDate: {
|
|
39
39
|
type: sequelize_1.DataTypes.DATE,
|
|
@@ -61,78 +61,78 @@ FeeReminderModel.init({
|
|
|
61
61
|
allowNull: false,
|
|
62
62
|
},
|
|
63
63
|
}, {
|
|
64
|
-
modelName:
|
|
65
|
-
tableName:
|
|
64
|
+
modelName: 'FeeReminderModel',
|
|
65
|
+
tableName: 'fee_reminders',
|
|
66
66
|
timestamps: true,
|
|
67
67
|
sequelize: index_js_1.sequelize,
|
|
68
68
|
});
|
|
69
69
|
FeeReminderModel.belongsTo(userModel_js_1.default, {
|
|
70
70
|
foreignKey: {
|
|
71
|
-
name:
|
|
72
|
-
field:
|
|
71
|
+
name: 'userId',
|
|
72
|
+
field: 'user_id',
|
|
73
73
|
},
|
|
74
|
-
as:
|
|
74
|
+
as: 'reminderUser',
|
|
75
75
|
});
|
|
76
76
|
userModel_js_1.default.hasMany(FeeReminderModel, {
|
|
77
|
-
foreignKey:
|
|
78
|
-
as:
|
|
77
|
+
foreignKey: 'userId',
|
|
78
|
+
as: 'userReminders',
|
|
79
79
|
});
|
|
80
80
|
FeeReminderModel.belongsTo(feeReminderSettingModel_js_1.default, {
|
|
81
81
|
foreignKey: {
|
|
82
|
-
name:
|
|
83
|
-
field:
|
|
82
|
+
name: 'templateId',
|
|
83
|
+
field: 'template_id',
|
|
84
84
|
},
|
|
85
|
-
as:
|
|
85
|
+
as: 'reminderTemplate',
|
|
86
86
|
});
|
|
87
87
|
feeReminderSettingModel_js_1.default.hasMany(FeeReminderModel, {
|
|
88
|
-
foreignKey:
|
|
89
|
-
as:
|
|
88
|
+
foreignKey: 'templateId',
|
|
89
|
+
as: 'TemplateReminders',
|
|
90
90
|
});
|
|
91
91
|
FeeReminderModel.belongsTo(instituteModel_js_1.default, {
|
|
92
92
|
foreignKey: {
|
|
93
|
-
name:
|
|
94
|
-
field:
|
|
93
|
+
name: 'instituteId',
|
|
94
|
+
field: 'institute_id',
|
|
95
95
|
},
|
|
96
|
-
as:
|
|
96
|
+
as: 'reminderInstitute',
|
|
97
97
|
});
|
|
98
98
|
instituteModel_js_1.default.hasMany(FeeReminderModel, {
|
|
99
|
-
foreignKey:
|
|
100
|
-
as:
|
|
99
|
+
foreignKey: 'instituteId',
|
|
100
|
+
as: 'instituteReminders',
|
|
101
101
|
});
|
|
102
102
|
FeeReminderModel.belongsTo(userModel_js_1.default, {
|
|
103
103
|
foreignKey: {
|
|
104
|
-
name:
|
|
104
|
+
name: 'createdBy',
|
|
105
105
|
allowNull: true,
|
|
106
|
-
field:
|
|
106
|
+
field: 'created_by',
|
|
107
107
|
},
|
|
108
|
-
as:
|
|
108
|
+
as: 'createdByUser',
|
|
109
109
|
});
|
|
110
110
|
FeeReminderModel.belongsTo(userModel_js_1.default, {
|
|
111
111
|
foreignKey: {
|
|
112
|
-
name:
|
|
112
|
+
name: 'updatedBy',
|
|
113
113
|
allowNull: true,
|
|
114
|
-
field:
|
|
114
|
+
field: 'updated_by',
|
|
115
115
|
},
|
|
116
|
-
as:
|
|
116
|
+
as: 'updatedByUser',
|
|
117
117
|
});
|
|
118
118
|
FeeReminderModel.belongsTo(userModel_js_1.default, {
|
|
119
119
|
foreignKey: {
|
|
120
|
-
name:
|
|
120
|
+
name: 'deletedBy',
|
|
121
121
|
allowNull: true,
|
|
122
|
-
field:
|
|
122
|
+
field: 'deleted_by',
|
|
123
123
|
},
|
|
124
|
-
as:
|
|
124
|
+
as: 'deletedByUser',
|
|
125
125
|
});
|
|
126
126
|
FeeReminderModel.belongsTo(feesCollectionModel_js_1.default, {
|
|
127
127
|
foreignKey: {
|
|
128
|
-
name:
|
|
129
|
-
field:
|
|
128
|
+
name: 'feeCollectionId',
|
|
129
|
+
field: 'fee_collection_id',
|
|
130
130
|
},
|
|
131
|
-
as:
|
|
131
|
+
as: 'feeCollection',
|
|
132
132
|
});
|
|
133
133
|
feesCollectionModel_js_1.default.hasMany(FeeReminderModel, {
|
|
134
|
-
foreignKey:
|
|
135
|
-
as:
|
|
134
|
+
foreignKey: 'feeCollectionId',
|
|
135
|
+
as: 'feeReminders',
|
|
136
136
|
});
|
|
137
137
|
const beforeCreateHook = async (feeReminder) => {
|
|
138
138
|
if (feeReminder.userId && feeReminder.batchId && feeReminder.instituteId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { IFeesCollectionModelAttributes } from
|
|
3
|
-
import { TFeesCollectionModelCreationAttributes } from
|
|
4
|
-
import { FEE_PAYMENT_STATUS, PAYMENT_TYPE } from
|
|
1
|
+
import { Model } from 'sequelize';
|
|
2
|
+
import { IFeesCollectionModelAttributes } from '../../interfaces/feesCollectionInterface.js';
|
|
3
|
+
import { TFeesCollectionModelCreationAttributes } from '../../types/feesCollectionType.js';
|
|
4
|
+
import { FEE_PAYMENT_STATUS, PAYMENT_TYPE } from '../../constants/app.js';
|
|
5
5
|
declare class FeesCollectionModel extends Model<IFeesCollectionModelAttributes, TFeesCollectionModelCreationAttributes> {
|
|
6
6
|
id: string;
|
|
7
7
|
date: Date;
|
|
@@ -22,7 +22,7 @@ FeesCollectionModel.init({
|
|
|
22
22
|
},
|
|
23
23
|
date: {
|
|
24
24
|
type: sequelize_1.DataTypes.DATE,
|
|
25
|
-
defaultValue: sequelize_1.Sequelize.literal(
|
|
25
|
+
defaultValue: sequelize_1.Sequelize.literal('CURRENT_TIMESTAMP'),
|
|
26
26
|
allowNull: true,
|
|
27
27
|
},
|
|
28
28
|
dueDate: {
|
|
@@ -69,7 +69,7 @@ FeesCollectionModel.init({
|
|
|
69
69
|
},
|
|
70
70
|
academicCalendarId: {
|
|
71
71
|
type: sequelize_1.DataTypes.UUID,
|
|
72
|
-
field:
|
|
72
|
+
field: 'academic_calendar_id',
|
|
73
73
|
allowNull: false,
|
|
74
74
|
},
|
|
75
75
|
userId: {
|
|
@@ -82,13 +82,13 @@ FeesCollectionModel.init({
|
|
|
82
82
|
},
|
|
83
83
|
isLeft: {
|
|
84
84
|
type: sequelize_1.DataTypes.BOOLEAN,
|
|
85
|
-
field:
|
|
85
|
+
field: 'is_left',
|
|
86
86
|
defaultValue: false,
|
|
87
87
|
allowNull: true,
|
|
88
88
|
},
|
|
89
89
|
}, {
|
|
90
|
-
modelName:
|
|
91
|
-
tableName:
|
|
90
|
+
modelName: 'FeesCollectionModel',
|
|
91
|
+
tableName: 'fees_collections',
|
|
92
92
|
timestamps: true,
|
|
93
93
|
sequelize: index_js_1.sequelize,
|
|
94
94
|
});
|
|
@@ -106,8 +106,7 @@ const beforeCreateOrUpdateHook = async (feeCollection) => {
|
|
|
106
106
|
else {
|
|
107
107
|
existingRecord = await FeesCollectionModel.findByPk(feeCollection.id);
|
|
108
108
|
}
|
|
109
|
-
if (existingRecord?.status === app_js_1.FEE_PAYMENT_STATUS.COMPLETED &&
|
|
110
|
-
feeCollection.paidFee) {
|
|
109
|
+
if (existingRecord?.status === app_js_1.FEE_PAYMENT_STATUS.COMPLETED && feeCollection.paidFee) {
|
|
111
110
|
throw new Error(errorMessages_js_1.FEESCOLLECTION_ERROR_MESSAGES.FEE_PAID);
|
|
112
111
|
}
|
|
113
112
|
}
|
|
@@ -158,75 +157,75 @@ FeesCollectionModel.beforeBulkUpdate(async (options) => {
|
|
|
158
157
|
});
|
|
159
158
|
FeesCollectionModel.belongsTo(instituteModel_js_1.default, {
|
|
160
159
|
foreignKey: {
|
|
161
|
-
name:
|
|
162
|
-
field:
|
|
160
|
+
name: 'instituteId',
|
|
161
|
+
field: 'institute_id',
|
|
163
162
|
},
|
|
164
|
-
as:
|
|
163
|
+
as: 'feeCollectionInstitute',
|
|
165
164
|
});
|
|
166
165
|
instituteModel_js_1.default.hasMany(FeesCollectionModel, {
|
|
167
|
-
foreignKey:
|
|
168
|
-
as:
|
|
166
|
+
foreignKey: 'instituteId',
|
|
167
|
+
as: 'instituteHasFeeCollection',
|
|
169
168
|
});
|
|
170
169
|
FeesCollectionModel.belongsTo(userModel_js_1.default, {
|
|
171
170
|
foreignKey: {
|
|
172
|
-
name:
|
|
173
|
-
field:
|
|
171
|
+
name: 'userId',
|
|
172
|
+
field: 'user_id',
|
|
174
173
|
},
|
|
175
|
-
as:
|
|
174
|
+
as: 'feeCollectionUser',
|
|
176
175
|
});
|
|
177
176
|
userModel_js_1.default.hasMany(FeesCollectionModel, {
|
|
178
|
-
foreignKey:
|
|
179
|
-
as:
|
|
177
|
+
foreignKey: 'userId',
|
|
178
|
+
as: 'userHasFeeCollection',
|
|
180
179
|
});
|
|
181
180
|
FeesCollectionModel.belongsTo(academicCalendarModel_js_1.default, {
|
|
182
181
|
foreignKey: {
|
|
183
|
-
name:
|
|
184
|
-
field:
|
|
182
|
+
name: 'academicCalendarId',
|
|
183
|
+
field: 'academic_calendar_id',
|
|
185
184
|
allowNull: true,
|
|
186
185
|
},
|
|
187
|
-
as:
|
|
186
|
+
as: 'CollectionCalendar',
|
|
188
187
|
});
|
|
189
188
|
academicCalendarModel_js_1.default.hasMany(FeesCollectionModel, {
|
|
190
189
|
foreignKey: {
|
|
191
|
-
name:
|
|
192
|
-
field:
|
|
190
|
+
name: 'academicCalendarId',
|
|
191
|
+
field: 'academic_calendar_id',
|
|
193
192
|
allowNull: true,
|
|
194
193
|
},
|
|
195
|
-
as:
|
|
194
|
+
as: 'CollectionHasCalendar',
|
|
196
195
|
});
|
|
197
196
|
FeesCollectionModel.belongsTo(userModel_js_1.default, {
|
|
198
197
|
foreignKey: {
|
|
199
|
-
name:
|
|
198
|
+
name: 'createdBy',
|
|
200
199
|
allowNull: true,
|
|
201
|
-
field:
|
|
200
|
+
field: 'created_by',
|
|
202
201
|
},
|
|
203
|
-
as:
|
|
202
|
+
as: 'createdByUser',
|
|
204
203
|
});
|
|
205
204
|
FeesCollectionModel.belongsTo(userModel_js_1.default, {
|
|
206
205
|
foreignKey: {
|
|
207
|
-
name:
|
|
206
|
+
name: 'updatedBy',
|
|
208
207
|
allowNull: true,
|
|
209
|
-
field:
|
|
208
|
+
field: 'updated_by',
|
|
210
209
|
},
|
|
211
|
-
as:
|
|
210
|
+
as: 'updatedByUser',
|
|
212
211
|
});
|
|
213
212
|
FeesCollectionModel.belongsTo(userModel_js_1.default, {
|
|
214
213
|
foreignKey: {
|
|
215
|
-
name:
|
|
214
|
+
name: 'deletedBy',
|
|
216
215
|
allowNull: true,
|
|
217
|
-
field:
|
|
216
|
+
field: 'deleted_by',
|
|
218
217
|
},
|
|
219
|
-
as:
|
|
218
|
+
as: 'deletedByUser',
|
|
220
219
|
});
|
|
221
220
|
paymentTermsModel_js_1.default.belongsTo(FeesCollectionModel, {
|
|
222
221
|
foreignKey: {
|
|
223
|
-
name:
|
|
224
|
-
field:
|
|
222
|
+
name: 'feeCollectionId',
|
|
223
|
+
field: 'fee_collection_id',
|
|
225
224
|
},
|
|
226
|
-
as:
|
|
225
|
+
as: 'feeCollection',
|
|
227
226
|
});
|
|
228
227
|
FeesCollectionModel.hasMany(paymentTermsModel_js_1.default, {
|
|
229
|
-
foreignKey:
|
|
230
|
-
as:
|
|
228
|
+
foreignKey: 'feeCollectionId',
|
|
229
|
+
as: 'feeCollectionHasPaymentTerms',
|
|
231
230
|
});
|
|
232
231
|
exports.default = FeesCollectionModel;
|
|
@@ -40,7 +40,7 @@ exports.Sequelize = exports.db = exports.sequelize = void 0;
|
|
|
40
40
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
41
41
|
const sequelize_1 = require("sequelize");
|
|
42
42
|
Object.defineProperty(exports, "Sequelize", { enumerable: true, get: function () { return sequelize_1.Sequelize; } });
|
|
43
|
-
const postgresConfig = require(
|
|
43
|
+
const postgresConfig = require('../../configs/postgresConfig.js');
|
|
44
44
|
const fs_1 = __importDefault(require("fs"));
|
|
45
45
|
const path_1 = __importDefault(require("path"));
|
|
46
46
|
const { database, username, password, host, port, dbLogging, dialectOptions } = postgresConfig;
|
|
@@ -51,7 +51,7 @@ const sequelize = new sequelize_1.Sequelize(database, username, password, {
|
|
|
51
51
|
host,
|
|
52
52
|
port,
|
|
53
53
|
logging: dbLogging,
|
|
54
|
-
dialect:
|
|
54
|
+
dialect: 'postgres',
|
|
55
55
|
define: {
|
|
56
56
|
timestamps: true,
|
|
57
57
|
underscored: true,
|
|
@@ -62,7 +62,7 @@ const sequelize = new sequelize_1.Sequelize(database, username, password, {
|
|
|
62
62
|
exports.sequelize = sequelize;
|
|
63
63
|
// add all models
|
|
64
64
|
fs_1.default.readdirSync(__dirname)
|
|
65
|
-
.filter(
|
|
65
|
+
.filter(file => file.indexOf('.') !== 0 && file !== 'index.js' && file.slice(-3) === '.ts')
|
|
66
66
|
.forEach(async (file) => {
|
|
67
67
|
const model = await Promise.resolve(`${path_1.default.join(__dirname, file)}`).then(s => __importStar(require(s)));
|
|
68
68
|
db[model?.default?.name] = model;
|
|
@@ -73,7 +73,7 @@ fs_1.default.readdirSync(__dirname)
|
|
|
73
73
|
// db[modelName].associate(db);
|
|
74
74
|
// }
|
|
75
75
|
// });
|
|
76
|
-
sequelize.addHook(
|
|
76
|
+
sequelize.addHook('beforeBulkDestroy', async (options) => {
|
|
77
77
|
const userId = options.userId; // Pass the user ID through options
|
|
78
78
|
if (userId) {
|
|
79
79
|
// Fetch all instances matching the delete condition
|
|
@@ -83,7 +83,7 @@ sequelize.addHook("beforeBulkDestroy", async (options) => {
|
|
|
83
83
|
raw: false,
|
|
84
84
|
});
|
|
85
85
|
for (const instance of instances) {
|
|
86
|
-
if (
|
|
86
|
+
if ('deletedBy' in instance || 'deleted_by' in instance) {
|
|
87
87
|
instance.deletedBy = userId;
|
|
88
88
|
// Save the updated instance without triggering additional hooks
|
|
89
89
|
await instance.save({ hooks: false });
|
|
@@ -91,30 +91,30 @@ sequelize.addHook("beforeBulkDestroy", async (options) => {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
|
-
sequelize.addHook(
|
|
94
|
+
sequelize.addHook('beforeCreate', async (instance, options) => {
|
|
95
95
|
const userId = options.userId; // Extract user ID
|
|
96
|
-
if (userId && (
|
|
96
|
+
if (userId && ('createdBy' in instance || 'created_by' in instance)) {
|
|
97
97
|
instance.createdBy = userId;
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
|
-
sequelize.addHook(
|
|
100
|
+
sequelize.addHook('beforeBulkCreate', async (instances, options) => {
|
|
101
101
|
const userId = options.userId; // Extract user ID
|
|
102
102
|
if (userId) {
|
|
103
103
|
for (const instance of instances) {
|
|
104
|
-
if (
|
|
104
|
+
if ('createdBy' in instance || 'created_by' in instance) {
|
|
105
105
|
instance.createdBy = userId;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
sequelize.addHook(
|
|
110
|
+
sequelize.addHook('beforeBulkUpdate', async (options) => {
|
|
111
111
|
const userId = options.userId; // Extract user ID from options
|
|
112
112
|
if (userId && options.attributes) {
|
|
113
113
|
// Update the 'updatedBy' or 'updated_by' attribute
|
|
114
|
-
options.attributes[
|
|
114
|
+
options.attributes['updatedBy'] = userId; // Adjust as per your column name
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
|
-
sequelize.addHook(
|
|
117
|
+
sequelize.addHook('beforeFind', async (options) => {
|
|
118
118
|
if (options.include) {
|
|
119
119
|
options.raw = false;
|
|
120
120
|
}
|