@kipicore/dbcore 1.1.217 → 1.1.219

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.
@@ -31,14 +31,14 @@ class StudentFeeHistoryModel extends sequelize_1.Model {
31
31
  foreignKey: { name: 'bankAccountId', field: 'bank_account_id', allowNull: true },
32
32
  as: 'studentFeeHistoryHasAccount',
33
33
  });
34
- StudentFeeHistoryModel.belongsTo(StudentFeeHistoryModel, {
35
- foreignKey: { name: 'parentHistoryId', field: 'parent_history_id', allowNull: true },
36
- as: 'studentOldFeeHistory',
37
- });
38
- StudentFeeHistoryModel.hasMany(StudentFeeHistoryModel, {
39
- foreignKey: { name: 'parentHistoryId', field: 'parent_history_id', allowNull: true },
40
- as: 'feeHistoryHasOldFee',
41
- });
34
+ // StudentFeeHistoryModel.belongsTo(StudentFeeHistoryModel, {
35
+ // foreignKey: { name: 'parentHistoryId', field: 'parent_history_id', allowNull: true },
36
+ // as: 'studentOldFeeHistory',
37
+ // });
38
+ // StudentFeeHistoryModel.hasMany(StudentFeeHistoryModel, {
39
+ // foreignKey: { name: 'parentHistoryId', field: 'parent_history_id', allowNull: true },
40
+ // as: 'feeHistoryHasOldFee',
41
+ // });
42
42
  StudentFeeHistoryModel.belongsTo(InstituteModel, {
43
43
  foreignKey: { name: 'instituteId', field: 'institute_id' },
44
44
  as: 'studentFeeHistoryInstitute',
@@ -23,6 +23,5 @@ export declare class StudentFeeTypeCollectionModel extends Model<IStudentFeeType
23
23
  readonly updatedAt: Date;
24
24
  readonly deletedAt: string;
25
25
  static associate(models: any): void;
26
- static addHooks(models: any): void;
27
26
  }
28
27
  export default StudentFeeTypeCollectionModel;
@@ -15,14 +15,14 @@ class StudentFeeTypeCollectionModel extends sequelize_1.Model {
15
15
  foreignKey: { name: 'studentFeeCollectionId', field: 'student_fee_collection_id', allowNull: true },
16
16
  as: 'collectionHasFeeType',
17
17
  });
18
- StudentFeeTypeCollectionModel.belongsTo(StudentFeeTypeCollectionModel, {
19
- foreignKey: { name: 'oldId', field: 'old_id', allowNull: true },
20
- as: 'oldFeeTypeCollection',
21
- });
22
- StudentFeeTypeCollectionModel.hasMany(StudentFeeTypeCollectionModel, {
23
- foreignKey: { name: 'oldId', field: 'old_id', allowNull: true },
24
- as: 'feeTypeHasOldCollection',
25
- });
18
+ // StudentFeeTypeCollectionModel.belongsTo(StudentFeeTypeCollectionModel, {
19
+ // foreignKey: { name: 'oldId', field: 'old_id', allowNull: true },
20
+ // as: 'oldFeeTypeCollection',
21
+ // });
22
+ // StudentFeeTypeCollectionModel.hasMany(StudentFeeTypeCollectionModel, {
23
+ // foreignKey: { name: 'oldId', field: 'old_id', allowNull: true },
24
+ // as: 'feeTypeHasOldCollection',
25
+ // });
26
26
  StudentFeeTypeCollectionModel.belongsTo(InstituteModel, {
27
27
  foreignKey: { name: 'instituteId', field: 'institute_id' },
28
28
  as: 'feeTypeCollectionInstitute',
@@ -86,9 +86,6 @@ class StudentFeeTypeCollectionModel extends sequelize_1.Model {
86
86
  as: 'deletedByUser',
87
87
  });
88
88
  }
89
- static addHooks(models) {
90
- StudentFeeTypeCollectionModel.beforeCreate(async (feeCollection) => { });
91
- }
92
89
  }
93
90
  exports.StudentFeeTypeCollectionModel = StudentFeeTypeCollectionModel;
94
91
  StudentFeeTypeCollectionModel.init({
@@ -64,8 +64,9 @@ class TestimonialModel extends sequelize_1.Model {
64
64
  static addHooks(models) {
65
65
  const { InstituteModel, UserModel, InstituteEntityModel } = models;
66
66
  const beforeCreateOrUpdateHook = async (testimonial) => {
67
+ let institute = null;
67
68
  if (testimonial.instituteId) {
68
- const institute = await InstituteModel.findByPk(testimonial.instituteId);
69
+ institute = await InstituteModel.findByPk(testimonial.instituteId);
69
70
  if (!institute) {
70
71
  throw new Error(errorMessages_1.INSTITUTE_ERROR_MESSAGES.NOT_FOUND);
71
72
  }
@@ -80,11 +81,18 @@ class TestimonialModel extends sequelize_1.Model {
80
81
  }
81
82
  testimonial.class = `${(0, utils_1.fromSnakeCaseToNormalText)(testimonial.userType)}`;
82
83
  if (testimonial.userId && testimonial.instituteId && testimonial.userType !== app_1.USER_TYPES.PARENTS) {
83
- const meta = await userInstituteMetaModel_1.default.findOne({
84
+ const userInstituteMetaWhere = {
84
85
  userId: testimonial.userId,
85
86
  instituteId: testimonial.instituteId,
86
- status: app_1.USER_INSTITUTE_META_STATUS.ACCEPTED,
87
- });
87
+ status: { $in: [app_1.USER_INSTITUTE_META_STATUS.ACCEPTED] },
88
+ };
89
+ if (testimonial.academicCalendarId)
90
+ userInstituteMetaWhere.academicCalendarId = testimonial.academicCalendarId;
91
+ if (institute?.type !== null || institute?.subType !== null) {
92
+ userInstituteMetaWhere.status = { $in: [app_1.USER_INSTITUTE_META_STATUS.ACCEPTED, app_1.USER_INSTITUTE_META_STATUS.PENDING] };
93
+ // userInstituteMetaWhere.details = BOOLEAN_STATUS.YES;
94
+ }
95
+ const meta = await userInstituteMetaModel_1.default.findOne(userInstituteMetaWhere);
88
96
  if (!meta) {
89
97
  throw new Error(errorMessages_1.USER_INSTITUTE_META_ERROR_MESSAGES.NOT_FOUND);
90
98
  }
@@ -97,10 +105,7 @@ class TestimonialModel extends sequelize_1.Model {
97
105
  association: 'entityType',
98
106
  required: true,
99
107
  where: {
100
- [sequelize_1.Op.or]: [
101
- { title: { [sequelize_1.Op.iLike]: 'STANDARD' } },
102
- { title: { [sequelize_1.Op.iLike]: 'MEDIUM' } },
103
- ],
108
+ [sequelize_1.Op.or]: [{ title: { [sequelize_1.Op.iLike]: 'STANDARD' } }, { title: { [sequelize_1.Op.iLike]: 'MEDIUM' } }],
104
109
  },
105
110
  },
106
111
  });
@@ -71,20 +71,20 @@ class UserHasPenaltyModel extends sequelize_1.Model {
71
71
  },
72
72
  as: 'userHPenaltyUser',
73
73
  });
74
- UserHasPenaltyModel.belongsTo(StudentFeeCollectionModel, {
75
- foreignKey: {
76
- name: 'studentFeeCollectionId',
77
- field: 'student_fee_collection_id',
78
- },
79
- as: 'userHPenaltyStudentFee',
80
- });
81
- StudentFeeCollectionModel.hasMany(UserHasPenaltyModel, {
82
- foreignKey: {
83
- name: 'studentFeeCollectionId',
84
- field: 'student_fee_collection_id',
85
- },
86
- as: 'studentFeeUHPenalty',
87
- });
74
+ // UserHasPenaltyModel.belongsTo(StudentFeeCollectionModel, {
75
+ // foreignKey: {
76
+ // name: 'studentFeeCollectionId',
77
+ // field: 'student_fee_collection_id',
78
+ // },
79
+ // as: 'userHPenaltyStudentFee',
80
+ // });
81
+ // StudentFeeCollectionModel.hasMany(UserHasPenaltyModel, {
82
+ // foreignKey: {
83
+ // name: 'studentFeeCollectionId',
84
+ // field: 'student_fee_collection_id',
85
+ // },
86
+ // as: 'studentFeeUHPenalty',
87
+ // });
88
88
  UserHasPenaltyModel.belongsTo(PenaltiesModel, {
89
89
  foreignKey: {
90
90
  name: 'penaltyId',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.217",
3
+ "version": "1.1.219",
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",