@kipicore/dbcore 1.1.272 → 1.1.274

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.
@@ -56,4 +56,6 @@ export interface IUserInstituteMetaAttributes extends IDefaultAttributes, Docume
56
56
  studentFeeService?: IStudentFeeService[];
57
57
  studentFeeType?: FEE_COLLECTION_TYPE;
58
58
  isSchoolMeta?: boolean;
59
+ isFeeCarryForward: boolean;
60
+ isFeeCollectionCreated: boolean;
59
61
  }
@@ -148,6 +148,7 @@ const examGroupModelSchema = new mongoose_1.Schema({
148
148
  });
149
149
  const createOrUpdateHook = async (examGroup) => {
150
150
  try {
151
+ await validateStandardDateConflict(examGroup);
151
152
  if (examGroup.instituteId) {
152
153
  const institute = await instituteModel_1.default.findOne({
153
154
  where: {
@@ -267,10 +268,22 @@ const createOrUpdateHook = async (examGroup) => {
267
268
  throw err;
268
269
  }
269
270
  };
271
+ const validateStandardDateConflict = async (examGroup) => {
272
+ const conflict = await ExamGroupModel.findOne({
273
+ instituteId: examGroup.instituteId,
274
+ ...(examGroup.id && { id: { $ne: examGroup.id } }),
275
+ standards: { $in: examGroup.standards },
276
+ startDate: { $lte: examGroup.endDate },
277
+ endDate: { $gte: examGroup.startDate },
278
+ }).lean();
279
+ if (conflict) {
280
+ throw new Error(`Another exam group "${conflict.title}" already exists for selected standard(s) in this date range`);
281
+ }
282
+ };
270
283
  examGroupModelSchema.pre('save', async function (next) {
271
- const subjectIndex = this;
284
+ const examGroup = this;
272
285
  try {
273
- await createOrUpdateHook(subjectIndex);
286
+ await createOrUpdateHook(examGroup);
274
287
  next();
275
288
  }
276
289
  catch (error) {
@@ -278,9 +291,9 @@ examGroupModelSchema.pre('save', async function (next) {
278
291
  }
279
292
  });
280
293
  examGroupModelSchema.pre('updateMany', async function (next) {
281
- const subjectIndex = this.getUpdate();
294
+ const examGroup = this.getUpdate();
282
295
  try {
283
- await createOrUpdateHook(subjectIndex);
296
+ await createOrUpdateHook(examGroup);
284
297
  next();
285
298
  }
286
299
  catch (error) {
@@ -227,6 +227,14 @@ const userInstituteMetaSchema = new mongoose_1.Schema({
227
227
  type: Boolean,
228
228
  default: true,
229
229
  },
230
+ isFeeCarryForward: {
231
+ type: Boolean,
232
+ default: false,
233
+ },
234
+ isFeeCollectionCreated: {
235
+ type: Boolean,
236
+ default: false,
237
+ },
230
238
  }, {
231
239
  timestamps: true,
232
240
  versionKey: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.272",
3
+ "version": "1.1.274",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",