@kipicore/dbcore 1.1.218 → 1.1.220

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.
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any): Promise<void>;
@@ -0,0 +1,191 @@
1
+ 'use strict';
2
+ const up = async (queryInterface, Sequelize) => {
3
+ const tableName = 'fee_type1';
4
+ const tableExists = await queryInterface
5
+ .describeTable(tableName)
6
+ .then(() => true)
7
+ .catch(() => false);
8
+ if (!tableExists) {
9
+ await queryInterface.createTable(tableName, {
10
+ id: {
11
+ type: Sequelize.UUID,
12
+ defaultValue: Sequelize.UUIDV4,
13
+ allowNull: false,
14
+ primaryKey: true,
15
+ },
16
+ typeManagementId: {
17
+ type: Sequelize.UUID,
18
+ allowNull: true,
19
+ field: 'type_management_id',
20
+ },
21
+ instituteId: {
22
+ type: Sequelize.UUID,
23
+ allowNull: true,
24
+ field: 'institute_id',
25
+ },
26
+ account: {
27
+ type: Sequelize.ARRAY(Sequelize.UUID),
28
+ allowNull: true,
29
+ defaultValue: [],
30
+ },
31
+ status: {
32
+ type: Sequelize.STRING,
33
+ allowNull: true,
34
+ },
35
+ module: {
36
+ type: Sequelize.STRING,
37
+ allowNull: true,
38
+ },
39
+ isDefault: {
40
+ type: Sequelize.STRING,
41
+ allowNull: true,
42
+ field: 'is_default',
43
+ },
44
+ isCreditAllowed: {
45
+ type: Sequelize.BOOLEAN,
46
+ allowNull: true,
47
+ field: 'is_credit_allowed',
48
+ defaultValue: false,
49
+ },
50
+ isRefundable: {
51
+ type: Sequelize.BOOLEAN,
52
+ allowNull: true,
53
+ field: 'is_refundable',
54
+ defaultValue: false,
55
+ },
56
+ isRequired: {
57
+ type: Sequelize.BOOLEAN,
58
+ allowNull: true,
59
+ field: 'is_required',
60
+ defaultValue: false,
61
+ },
62
+ isTaxable: {
63
+ type: Sequelize.BOOLEAN,
64
+ allowNull: true,
65
+ field: 'is_taxable',
66
+ defaultValue: false,
67
+ },
68
+ defaultAccount: {
69
+ type: Sequelize.UUID,
70
+ allowNull: true,
71
+ field: 'default_account',
72
+ },
73
+ feeType: {
74
+ type: Sequelize.STRING,
75
+ allowNull: true,
76
+ field: 'fee_type',
77
+ },
78
+ frequency: {
79
+ type: Sequelize.STRING,
80
+ allowNull: true,
81
+ },
82
+ academicCalendarId: {
83
+ type: Sequelize.UUID,
84
+ allowNull: true,
85
+ field: 'academic_calendar_id',
86
+ },
87
+ createdAt: {
88
+ type: Sequelize.DATE,
89
+ allowNull: false,
90
+ defaultValue: Sequelize.NOW,
91
+ field: 'created_at',
92
+ },
93
+ updatedAt: {
94
+ type: Sequelize.DATE,
95
+ allowNull: false,
96
+ defaultValue: Sequelize.NOW,
97
+ field: 'updated_at',
98
+ },
99
+ deletedAt: {
100
+ type: Sequelize.DATE,
101
+ allowNull: true,
102
+ field: 'deleted_at',
103
+ },
104
+ createdBy: {
105
+ type: Sequelize.UUID,
106
+ allowNull: true,
107
+ field: 'created_by',
108
+ },
109
+ updatedBy: {
110
+ type: Sequelize.UUID,
111
+ allowNull: true,
112
+ field: 'updated_by',
113
+ },
114
+ deletedBy: {
115
+ type: Sequelize.UUID,
116
+ allowNull: true,
117
+ field: 'deleted_by',
118
+ },
119
+ paymentType: {
120
+ type: Sequelize.ARRAY(Sequelize.STRING),
121
+ allowNull: true,
122
+ field: 'payment_type',
123
+ defaultValue: [],
124
+ },
125
+ });
126
+ }
127
+ else {
128
+ const tableDefinition = await queryInterface.describeTable(tableName);
129
+ const columnsToAdd = {
130
+ typeManagementId: { type: Sequelize.UUID, allowNull: true, field: 'type_management_id' },
131
+ instituteId: { type: Sequelize.UUID, allowNull: true, field: 'institute_id' },
132
+ account: { type: Sequelize.ARRAY(Sequelize.UUID), allowNull: true, defaultValue: [] },
133
+ status: { type: Sequelize.STRING, allowNull: true },
134
+ module: { type: Sequelize.STRING, allowNull: true },
135
+ isDefault: { type: Sequelize.STRING, allowNull: true, field: 'is_default' },
136
+ isCreditAllowed: { type: Sequelize.BOOLEAN, allowNull: true, field: 'is_credit_allowed', defaultValue: false },
137
+ isRefundable: { type: Sequelize.BOOLEAN, allowNull: true, field: 'is_refundable', defaultValue: false },
138
+ isRequired: { type: Sequelize.BOOLEAN, allowNull: true, field: 'is_required', defaultValue: false },
139
+ isTaxable: { type: Sequelize.BOOLEAN, allowNull: true, field: 'is_taxable', defaultValue: false },
140
+ defaultAccount: { type: Sequelize.UUID, allowNull: true, field: 'default_account' },
141
+ feeType: { type: Sequelize.STRING, allowNull: true, field: 'fee_type' },
142
+ frequency: { type: Sequelize.STRING, allowNull: true },
143
+ academicCalendarId: { type: Sequelize.UUID, allowNull: true, field: 'academic_calendar_id' },
144
+ createdAt: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.NOW, field: 'created_at' },
145
+ updatedAt: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.NOW, field: 'updated_at' },
146
+ deletedAt: { type: Sequelize.DATE, allowNull: true, field: 'deleted_at' },
147
+ createdBy: {
148
+ type: Sequelize.UUID,
149
+ allowNull: true,
150
+ field: 'created_by',
151
+ },
152
+ updatedBy: {
153
+ type: Sequelize.UUID,
154
+ allowNull: true,
155
+ field: 'updated_by',
156
+ },
157
+ deletedBy: {
158
+ type: Sequelize.UUID,
159
+ allowNull: true,
160
+ field: 'deleted_by',
161
+ },
162
+ paymentType: {
163
+ type: Sequelize.ARRAY(Sequelize.STRING),
164
+ allowNull: true,
165
+ field: 'payment_type',
166
+ defaultValue: [],
167
+ },
168
+ };
169
+ for (const key of Object.keys(columnsToAdd)) {
170
+ const column = columnsToAdd[key];
171
+ const columnName = column.field || key;
172
+ if (!tableDefinition[columnName]) {
173
+ await queryInterface.addColumn(tableName, columnName, column);
174
+ }
175
+ }
176
+ }
177
+ };
178
+ const down = async (queryInterface) => {
179
+ const tableName = 'fee_type1';
180
+ const tableExists = await queryInterface
181
+ .describeTable(tableName)
182
+ .then(() => true)
183
+ .catch(() => false);
184
+ if (tableExists) {
185
+ await queryInterface.dropTable(tableName);
186
+ }
187
+ };
188
+ module.exports = {
189
+ up,
190
+ down,
191
+ };
@@ -1,4 +1,4 @@
1
- import { FEE_TYPE, COMMAN_STATUS, FEE_TYPE_FREQUENCY, BOOLEAN_STATUS } from '../constants/app';
1
+ import { FEE_TYPE, COMMAN_STATUS, FEE_TYPE_FREQUENCY, BOOLEAN_STATUS, PAYMENT_TYPE } from '../constants/app';
2
2
  import { IDefaultAttributes } from './commonInterface';
3
3
  export interface IFeeType1ModelAttributes extends IDefaultAttributes {
4
4
  id: string;
@@ -15,5 +15,6 @@ export interface IFeeType1ModelAttributes extends IDefaultAttributes {
15
15
  isRequired: boolean;
16
16
  instituteId: string;
17
17
  isDefault: BOOLEAN_STATUS;
18
+ paymentType: PAYMENT_TYPE[];
18
19
  academicCalendarId: string;
19
20
  }
@@ -11,6 +11,7 @@ declare class FeeType1Model extends Model<IFeeType1ModelAttributes, TFeeType1Mod
11
11
  module: COMMAN_STATUS;
12
12
  status: COMMAN_STATUS;
13
13
  account: string[];
14
+ paymentType: string[];
14
15
  isDefault: BOOLEAN_STATUS;
15
16
  academicCalendarId: string;
16
17
  isCreditAllowed: boolean;
@@ -133,6 +133,11 @@ FeeType1Model.init({
133
133
  field: 'academic_calendar_id',
134
134
  allowNull: true,
135
135
  },
136
+ paymentType: {
137
+ type: sequelize_1.DataTypes.ARRAY(sequelize_1.DataTypes.STRING),
138
+ allowNull: true,
139
+ defaultValue: [],
140
+ },
136
141
  }, {
137
142
  modelName: 'FeeType1Model',
138
143
  tableName: 'fee_type1',
@@ -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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.218",
3
+ "version": "1.1.220",
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",