@churchsoln/dbms 1.0.27 → 1.0.30
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/constants/index.js +37 -1
- package/controllers/master.js +0 -89
- package/migrations/{common/20221226143349-create-province.js → church/20221226151615-create-province.js} +2 -0
- package/migrations/{common/20221226150238-create-city.js → church/20221226151616-create-city.js} +1 -0
- package/migrations/church/20221226151618-create-membership.js +68 -0
- package/migrations/church/20221226151619-create-member.js +140 -0
- package/migrations/church/20221227151615-create-user.js +50 -139
- package/migrations/church/20230826140644-create-eventsUpdates.js +1 -0
- package/migrations/church/20240918170620-create-donation.js +2 -0
- package/migrations/church/20240918170621-create-church.js +17 -2
- package/migrations/church/20240918170627-create-pledge.js +0 -2
- package/migrations/common/20221226140655-create-subscriptionPlan.js +2 -2
- package/migrations/common/20240815170619-create-permission.js +2 -0
- package/migrations/common/20240815170620-create-church.js +1 -29
- package/models/church/church.js +16 -2
- package/models/{common → church}/city.js +2 -1
- package/models/church/member.js +171 -0
- package/models/church/membership.js +81 -0
- package/models/{common → church}/province.js +3 -1
- package/models/church/user.js +43 -254
- package/package.json +1 -1
- package/public/swagger/church.json +18 -18
- package/public/swagger/master.json +0 -313
- package/routes/v1/master.js +0 -24
- package/seeders/church/20241005124245-province.js +101 -0
- package/seeders/church/20241005124547-city.js +87 -0
- package/services/church.js +2 -2
- package/services/master.js +0 -152
- package/validators/church.js +3 -3
- package/workers/seed.js +1 -1
- package/migrations/church/20221226150553-create-maritalStatus.js +0 -25
- package/migrations/church/20221226151615-create-relationship.js +0 -25
- package/migrations/church/20240918170624-create-membershipType.js +0 -24
- package/migrations/church/20240918170625-update-user.js +0 -24
- package/migrations/church/20240918170626-update-eventsUpdate.js +0 -12
- package/migrations/church/20240918170628-update-pledge.js +0 -12
- package/migrations/church/20240918170629-update-donation.js +0 -12
- package/migrations/church/20240918170630-update-donation.js +0 -12
- package/migrations/church/20240918170631-update-church.js +0 -12
- package/migrations/common/20240918170624-update-church.js +0 -23
- package/migrations/common/20240918170625-update-permission.js +0 -17
- package/migrations/common/20240918170626-update-subscriptionPlan.js +0 -20
- package/migrations/common/20240918170628-update-church.js +0 -12
- package/models/church/maritalStatus.js +0 -15
- package/models/church/membershipType.js +0 -16
- package/models/church/relationship.js +0 -15
- package/seeders/church/20241005131256-maritalStatus.js +0 -43
- package/seeders/church/20241005131416-relationship.js +0 -43
- package/seeders/church/20241005131417-membershipType.js +0 -39
- package/seeders/common/20241005124245-province.js +0 -42
- package/seeders/common/20241005124547-city.js +0 -55
|
@@ -11,20 +11,12 @@ module.exports = {
|
|
|
11
11
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
12
12
|
name: { type: DataTypes.STRING },
|
|
13
13
|
connectionUrl: { type: DataTypes.STRING },
|
|
14
|
-
address: { type: DataTypes.STRING },
|
|
15
|
-
cityId: { type: DataTypes.INTEGER },
|
|
16
|
-
provinceId: { type: DataTypes.INTEGER },
|
|
17
|
-
country: { type: DataTypes.STRING },
|
|
18
|
-
postalCode: { type: DataTypes.STRING },
|
|
19
14
|
email: { type: DataTypes.STRING },
|
|
20
15
|
phoneNumber: { type: DataTypes.STRING },
|
|
21
16
|
contactPerson: { type: DataTypes.STRING },
|
|
22
|
-
currency: { type: DataTypes.STRING },
|
|
23
|
-
charitable_reg_no: { type: DataTypes.STRING },
|
|
24
|
-
registration_agency: { type: DataTypes.STRING },
|
|
25
|
-
profile_image: { type: DataTypes.STRING },
|
|
26
17
|
registeredAt: { type: DataTypes.DATEONLY },
|
|
27
18
|
subscribedAt: { type: DataTypes.DATEONLY },
|
|
19
|
+
expiresAt: { type: DataTypes.DATEONLY },
|
|
28
20
|
subscriptionPlanId: { type: DataTypes.INTEGER },
|
|
29
21
|
dbCreationStatus: {
|
|
30
22
|
type: DataTypes.STRING,
|
|
@@ -56,26 +48,6 @@ module.exports = {
|
|
|
56
48
|
onDelete: "cascade",
|
|
57
49
|
onUpdate: "cascade",
|
|
58
50
|
})
|
|
59
|
-
)
|
|
60
|
-
.then(() =>
|
|
61
|
-
queryInterface.addConstraint("Church", {
|
|
62
|
-
fields: ["cityId"],
|
|
63
|
-
type: "foreign key",
|
|
64
|
-
name: "church_cityId_fk",
|
|
65
|
-
references: { table: "City", field: "id" },
|
|
66
|
-
onDelete: "cascade",
|
|
67
|
-
onUpdate: "cascade",
|
|
68
|
-
})
|
|
69
|
-
)
|
|
70
|
-
.then(() =>
|
|
71
|
-
queryInterface.addConstraint("Church", {
|
|
72
|
-
fields: ["provinceId"],
|
|
73
|
-
type: "foreign key",
|
|
74
|
-
name: "church_provinceId_fk",
|
|
75
|
-
references: { table: "Province", field: "id" },
|
|
76
|
-
onDelete: "cascade",
|
|
77
|
-
onUpdate: "cascade",
|
|
78
|
-
})
|
|
79
51
|
);
|
|
80
52
|
},
|
|
81
53
|
down: async (queryInterface) => {
|
package/models/church/church.js
CHANGED
|
@@ -7,8 +7,18 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
7
7
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
8
|
name: { type: DataTypes.STRING },
|
|
9
9
|
address: { type: DataTypes.STRING },
|
|
10
|
-
cityId: {
|
|
11
|
-
|
|
10
|
+
cityId: {
|
|
11
|
+
type: DataTypes.INTEGER,
|
|
12
|
+
set(cityId) {
|
|
13
|
+
this.setDataValue("cityId", cityId?.id || cityId);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
provinceId: {
|
|
17
|
+
type: DataTypes.INTEGER,
|
|
18
|
+
set(provinceId) {
|
|
19
|
+
this.setDataValue("provinceId", provinceId?.id || provinceId);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
12
22
|
country: { type: DataTypes.STRING },
|
|
13
23
|
postalCode: { type: DataTypes.STRING },
|
|
14
24
|
email: { type: DataTypes.STRING },
|
|
@@ -25,6 +35,10 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
25
35
|
},
|
|
26
36
|
{ freezeTableName: true, timestamps: false }
|
|
27
37
|
);
|
|
38
|
+
church.associate = function (models) {
|
|
39
|
+
church.belongsTo(models.province, { foreignKey: "provinceId", as: "province" });
|
|
40
|
+
church.belongsTo(models.city, { foreignKey: "cityId", as: "city" });
|
|
41
|
+
}
|
|
28
42
|
church.selectedFields = [
|
|
29
43
|
"id",
|
|
30
44
|
"name",
|
|
@@ -4,6 +4,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
4
4
|
{
|
|
5
5
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
6
|
provinceId: { type: DataTypes.INTEGER },
|
|
7
|
+
provinceCode: { type: DataTypes.STRING },
|
|
7
8
|
name: { type: DataTypes.STRING },
|
|
8
9
|
status: { type: DataTypes.BOOLEAN },
|
|
9
10
|
createdAt: { type: DataTypes.DATE },
|
|
@@ -17,6 +18,6 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
17
18
|
as: "province",
|
|
18
19
|
});
|
|
19
20
|
};
|
|
20
|
-
city.selectedFields = ["id", "name"];
|
|
21
|
+
city.selectedFields = ["id", "name", "provinceCode"];
|
|
21
22
|
return city;
|
|
22
23
|
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
const { MEMBER_STATUS, GENDER, RELATIONSHIP } = require("../../constants");
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize, DataTypes) => {
|
|
4
|
+
const member = sequelize.define(
|
|
5
|
+
"Member",
|
|
6
|
+
{
|
|
7
|
+
id: {
|
|
8
|
+
type: DataTypes.INTEGER,
|
|
9
|
+
primaryKey: true,
|
|
10
|
+
autoIncrement: true,
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
// Foreign Key to memberships
|
|
14
|
+
membershipId: {
|
|
15
|
+
type: DataTypes.INTEGER,
|
|
16
|
+
set(membershipId) {
|
|
17
|
+
this.setDataValue("membershipId", membershipId?.id || membershipId);
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
// Basic Identity
|
|
22
|
+
title: { type: DataTypes.STRING },
|
|
23
|
+
firstName: { type: DataTypes.STRING, allowNull: false },
|
|
24
|
+
middleName: { type: DataTypes.STRING },
|
|
25
|
+
lastName: { type: DataTypes.STRING, allowNull: false },
|
|
26
|
+
maidenName: { type: DataTypes.STRING },
|
|
27
|
+
suffix: { type: DataTypes.STRING },
|
|
28
|
+
salutation: { type: DataTypes.STRING },
|
|
29
|
+
preferredName: { type: DataTypes.STRING },
|
|
30
|
+
profileImage: { type: DataTypes.STRING },
|
|
31
|
+
|
|
32
|
+
// Contact Info
|
|
33
|
+
address: { type: DataTypes.TEXT },
|
|
34
|
+
cityId: {
|
|
35
|
+
type: DataTypes.INTEGER,
|
|
36
|
+
set(cityId) {
|
|
37
|
+
this.setDataValue("cityId", cityId?.id || cityId);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
provinceId: {
|
|
41
|
+
type: DataTypes.INTEGER,
|
|
42
|
+
set(provinceId) {
|
|
43
|
+
this.setDataValue("provinceId", provinceId?.id || provinceId);
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
zipCode: { type: DataTypes.STRING },
|
|
47
|
+
homePhone: { type: DataTypes.STRING },
|
|
48
|
+
cellPhone: { type: DataTypes.STRING },
|
|
49
|
+
workPhone: { type: DataTypes.STRING },
|
|
50
|
+
email: { type: DataTypes.STRING, validate: { isEmail: true } },
|
|
51
|
+
|
|
52
|
+
// Other Personal Info
|
|
53
|
+
occupation: { type: DataTypes.STRING },
|
|
54
|
+
employer: { type: DataTypes.STRING },
|
|
55
|
+
schoolGrade: { type: DataTypes.STRING },
|
|
56
|
+
emergencyContact: { type: DataTypes.STRING },
|
|
57
|
+
emergencyPhone: { type: DataTypes.STRING },
|
|
58
|
+
geographicArea: { type: DataTypes.STRING },
|
|
59
|
+
|
|
60
|
+
// Membership Status
|
|
61
|
+
memberStatus: {
|
|
62
|
+
type: DataTypes.STRING,
|
|
63
|
+
defaultValue: MEMBER_STATUS.ACTIVE,
|
|
64
|
+
validate: {
|
|
65
|
+
isIn: [
|
|
66
|
+
[
|
|
67
|
+
MEMBER_STATUS.ACTIVE,
|
|
68
|
+
MEMBER_STATUS.INACTIVE,
|
|
69
|
+
MEMBER_STATUS.DECEASED,
|
|
70
|
+
MEMBER_STATUS.PROSPECT,
|
|
71
|
+
MEMBER_STATUS.REGULAR_ATTENDEE,
|
|
72
|
+
MEMBER_STATUS.SINGLE_MEMBER,
|
|
73
|
+
MEMBER_STATUS.VISITOR,
|
|
74
|
+
],
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
envNumber: { type: DataTypes.STRING },
|
|
80
|
+
gender: {
|
|
81
|
+
type: DataTypes.STRING,
|
|
82
|
+
validate: {
|
|
83
|
+
isIn: [Object.values(GENDER)],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
relationship: {
|
|
87
|
+
type: DataTypes.STRING,
|
|
88
|
+
validate: {
|
|
89
|
+
isIn: [Object.values(RELATIONSHIP)],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// Dates
|
|
94
|
+
birthDate: { type: DataTypes.DATE },
|
|
95
|
+
weddingDate: { type: DataTypes.DATE },
|
|
96
|
+
baptizedDate: { type: DataTypes.DATE },
|
|
97
|
+
confessionDate: { type: DataTypes.DATE },
|
|
98
|
+
|
|
99
|
+
// Additional
|
|
100
|
+
notes: { type: DataTypes.TEXT },
|
|
101
|
+
otp: { type: DataTypes.INTEGER },
|
|
102
|
+
|
|
103
|
+
// Flags
|
|
104
|
+
enabledProfile: {
|
|
105
|
+
type: DataTypes.BOOLEAN,
|
|
106
|
+
defaultValue: true,
|
|
107
|
+
},
|
|
108
|
+
includeInDirectory: {
|
|
109
|
+
type: DataTypes.BOOLEAN,
|
|
110
|
+
defaultValue: true,
|
|
111
|
+
},
|
|
112
|
+
emailStatement: {
|
|
113
|
+
type: DataTypes.BOOLEAN,
|
|
114
|
+
defaultValue: false,
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// Metadata
|
|
118
|
+
createdAt: { type: DataTypes.DATE },
|
|
119
|
+
updatedAt: { type: DataTypes.DATE },
|
|
120
|
+
},
|
|
121
|
+
{ freezeTableName: true, timestamps: false }
|
|
122
|
+
);
|
|
123
|
+
member.associate = function (models) {
|
|
124
|
+
member.belongsTo(models.membership, { foreignKey: "membershipId", as: "membership" });
|
|
125
|
+
member.belongsTo(models.province, { foreignKey: "provinceId", as: "province" });
|
|
126
|
+
member.belongsTo(models.city, { foreignKey: "cityId", as: "city" });
|
|
127
|
+
}
|
|
128
|
+
member.selectedFields = [
|
|
129
|
+
"id",
|
|
130
|
+
"membershipId",
|
|
131
|
+
"title",
|
|
132
|
+
"firstName",
|
|
133
|
+
"middleName",
|
|
134
|
+
"lastName",
|
|
135
|
+
"maidenName",
|
|
136
|
+
"suffix",
|
|
137
|
+
"salutation",
|
|
138
|
+
"preferredName",
|
|
139
|
+
"profileImage",
|
|
140
|
+
"address",
|
|
141
|
+
"cityId",
|
|
142
|
+
"provinceId",
|
|
143
|
+
"zipCode",
|
|
144
|
+
"homePhone",
|
|
145
|
+
"cellPhone",
|
|
146
|
+
"workPhone",
|
|
147
|
+
"email",
|
|
148
|
+
"occupation",
|
|
149
|
+
"employer",
|
|
150
|
+
"schoolGrade",
|
|
151
|
+
"emergencyContact",
|
|
152
|
+
"emergencyPhone",
|
|
153
|
+
"geographicArea",
|
|
154
|
+
"memberStatus",
|
|
155
|
+
"envNumber",
|
|
156
|
+
"gender",
|
|
157
|
+
"relationship",
|
|
158
|
+
"birthDate",
|
|
159
|
+
"weddingDate",
|
|
160
|
+
"baptizedDate",
|
|
161
|
+
"confessionDate",
|
|
162
|
+
"notes",
|
|
163
|
+
"otp",
|
|
164
|
+
"enabledProfile",
|
|
165
|
+
"includeInDirectory",
|
|
166
|
+
"emailStatement",
|
|
167
|
+
"createdAt",
|
|
168
|
+
"updatedAt",
|
|
169
|
+
];
|
|
170
|
+
return member;
|
|
171
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const { MEMBER_STATUS } = require("../../constants");
|
|
2
|
+
|
|
3
|
+
module.exports = (sequelize, DataTypes) => {
|
|
4
|
+
const membership = sequelize.define(
|
|
5
|
+
"Membership",
|
|
6
|
+
{
|
|
7
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
8
|
+
|
|
9
|
+
// Family Profile Fields
|
|
10
|
+
directoryName: { type: DataTypes.STRING },
|
|
11
|
+
salutation: { type: DataTypes.STRING },
|
|
12
|
+
mailingName: { type: DataTypes.STRING },
|
|
13
|
+
address: { type: DataTypes.TEXT },
|
|
14
|
+
cityId: {
|
|
15
|
+
type: DataTypes.INTEGER,
|
|
16
|
+
set(cityId) {
|
|
17
|
+
this.setDataValue("cityId", cityId?.id || cityId);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
provinceId: {
|
|
21
|
+
type: DataTypes.INTEGER,
|
|
22
|
+
set(provinceId) {
|
|
23
|
+
this.setDataValue("provinceId", provinceId?.id || provinceId);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
zipCode: { type: DataTypes.STRING },
|
|
27
|
+
memberStatus: {
|
|
28
|
+
type: DataTypes.STRING,
|
|
29
|
+
defaultValue: MEMBER_STATUS.ACTIVE,
|
|
30
|
+
validate: {
|
|
31
|
+
isIn: [[MEMBER_STATUS.ACTIVE, MEMBER_STATUS.INACTIVE, MEMBER_STATUS.VISITOR]],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
phone: { type: DataTypes.STRING },
|
|
35
|
+
email: {
|
|
36
|
+
type: DataTypes.STRING,
|
|
37
|
+
validate: { isEmail: true },
|
|
38
|
+
},
|
|
39
|
+
geographicArea: { type: DataTypes.STRING },
|
|
40
|
+
notes: { type: DataTypes.TEXT },
|
|
41
|
+
|
|
42
|
+
// Mailing List & Settings Flags
|
|
43
|
+
enabledProfile: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
44
|
+
includeInDirectory: { type: DataTypes.BOOLEAN, defaultValue: true },
|
|
45
|
+
isOrganization: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
46
|
+
emailStatement: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
47
|
+
|
|
48
|
+
// Metadata
|
|
49
|
+
createdAt: { type: DataTypes.DATE },
|
|
50
|
+
updatedAt: { type: DataTypes.DATE },
|
|
51
|
+
},
|
|
52
|
+
{ freezeTableName: true, timestamps: false }
|
|
53
|
+
);
|
|
54
|
+
membership.associate = function (models) {
|
|
55
|
+
membership.belongsTo(models.province, { foreignKey: "provinceId", as: "province" });
|
|
56
|
+
membership.belongsTo(models.city, { foreignKey: "cityId", as: "city" });
|
|
57
|
+
}
|
|
58
|
+
membership.selectedFields = [
|
|
59
|
+
"id",
|
|
60
|
+
"directoryName",
|
|
61
|
+
"salutation",
|
|
62
|
+
"mailingName",
|
|
63
|
+
"address",
|
|
64
|
+
"cityId",
|
|
65
|
+
"provinceId",
|
|
66
|
+
"zipCode",
|
|
67
|
+
"memberStatus",
|
|
68
|
+
"phone",
|
|
69
|
+
"email",
|
|
70
|
+
"geographicArea",
|
|
71
|
+
"notes",
|
|
72
|
+
"enabledProfile",
|
|
73
|
+
"includeInDirectory",
|
|
74
|
+
"isOrganization",
|
|
75
|
+
"emailStatement",
|
|
76
|
+
"createdAt",
|
|
77
|
+
"updatedAt",
|
|
78
|
+
];
|
|
79
|
+
return membership;
|
|
80
|
+
}
|
|
81
|
+
|
|
@@ -3,6 +3,8 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
3
3
|
"Province",
|
|
4
4
|
{
|
|
5
5
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
6
|
+
country: { type: DataTypes.STRING },
|
|
7
|
+
code: { type: DataTypes.STRING },
|
|
6
8
|
name: { type: DataTypes.STRING },
|
|
7
9
|
status: { type: DataTypes.BOOLEAN },
|
|
8
10
|
createdAt: { type: DataTypes.DATE },
|
|
@@ -16,6 +18,6 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
16
18
|
as: "city",
|
|
17
19
|
});
|
|
18
20
|
};
|
|
19
|
-
province.selectedFields = ["id", "name"];
|
|
21
|
+
province.selectedFields = ["id", "name", "code", "country"];
|
|
20
22
|
return province;
|
|
21
23
|
};
|