payservedb 2.3.10 → 2.3.12
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/index.js +2 -1
- package/package.json +1 -1
- package/src/models/facility.js +8 -1
- package/src/models/resident.js +121 -0
package/index.js
CHANGED
|
@@ -75,7 +75,8 @@ const models = {
|
|
|
75
75
|
Invoice:require('./src/models/invoice'),
|
|
76
76
|
Reminder:require('./src/models/reminder'),
|
|
77
77
|
Penalty:require('./src/models/penalty'),
|
|
78
|
-
Notifiaction:require('./src/models/notification')
|
|
78
|
+
Notifiaction:require('./src/models/notification'),
|
|
79
|
+
Resident:require('./src/models/resident')
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
// Function to get models dynamically from a specific database connection
|
package/package.json
CHANGED
package/src/models/facility.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
-
// Define the schema for
|
|
3
|
+
// Define the schema for facilities
|
|
4
4
|
const facilitySchema = new mongoose.Schema({
|
|
5
5
|
name: {
|
|
6
6
|
type: String,
|
|
@@ -24,6 +24,12 @@ const facilitySchema = new mongoose.Schema({
|
|
|
24
24
|
type: String,
|
|
25
25
|
trim: false,
|
|
26
26
|
default: null
|
|
27
|
+
},
|
|
28
|
+
dbName: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: [true, 'Database name is required'],
|
|
31
|
+
unique: true,
|
|
32
|
+
trim: true
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
}, {
|
|
@@ -32,6 +38,7 @@ const facilitySchema = new mongoose.Schema({
|
|
|
32
38
|
|
|
33
39
|
// Indexes for improved performance
|
|
34
40
|
facilitySchema.index({ name: 1 });
|
|
41
|
+
facilitySchema.index({ dbName: 1 });
|
|
35
42
|
|
|
36
43
|
// Compile the model from the schema
|
|
37
44
|
const Facility = mongoose.model('Facility', facilitySchema);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Resident
|
|
4
|
+
const residentSchema = new mongoose.Schema({
|
|
5
|
+
residentId: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
unique: true
|
|
9
|
+
},
|
|
10
|
+
name: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
email: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
phone: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
nationalId: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
unitId: {
|
|
27
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
28
|
+
ref: 'Unit',
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
unitName: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true
|
|
34
|
+
},
|
|
35
|
+
facilityId: {
|
|
36
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
+
ref: 'Facility',
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
contracts: [{
|
|
41
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
42
|
+
ref: 'LevyContract'
|
|
43
|
+
}],
|
|
44
|
+
levies: [{
|
|
45
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
46
|
+
ref: 'Levy'
|
|
47
|
+
}],
|
|
48
|
+
invoices: [{
|
|
49
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
50
|
+
ref: 'Invoice'
|
|
51
|
+
}],
|
|
52
|
+
paymentHistory: [{
|
|
53
|
+
paymentDate: {
|
|
54
|
+
type: Date,
|
|
55
|
+
required: true
|
|
56
|
+
},
|
|
57
|
+
amount: {
|
|
58
|
+
type: Number,
|
|
59
|
+
required: true
|
|
60
|
+
},
|
|
61
|
+
paymentMethod: {
|
|
62
|
+
type: String
|
|
63
|
+
},
|
|
64
|
+
transactionId: {
|
|
65
|
+
type: String
|
|
66
|
+
}
|
|
67
|
+
}],
|
|
68
|
+
status: {
|
|
69
|
+
type: String,
|
|
70
|
+
enum: ['Active', 'Inactive'],
|
|
71
|
+
default: 'Active'
|
|
72
|
+
},
|
|
73
|
+
registrationDate: {
|
|
74
|
+
type: Date,
|
|
75
|
+
default: Date.now
|
|
76
|
+
},
|
|
77
|
+
paymentFrequency: {
|
|
78
|
+
type: String,
|
|
79
|
+
enum: ['Monthly', 'Quarterly', 'Annually']
|
|
80
|
+
},
|
|
81
|
+
notificationPreferences: {
|
|
82
|
+
email: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: true
|
|
85
|
+
},
|
|
86
|
+
sms: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: true
|
|
89
|
+
},
|
|
90
|
+
push: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
reminders: [{
|
|
96
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
97
|
+
ref: 'Reminder'
|
|
98
|
+
}],
|
|
99
|
+
notifications: [{
|
|
100
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
101
|
+
ref: 'Notification'
|
|
102
|
+
}],
|
|
103
|
+
penalties: [{
|
|
104
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
105
|
+
ref: 'Penalty'
|
|
106
|
+
}],
|
|
107
|
+
penaltyStatus: {
|
|
108
|
+
type: String,
|
|
109
|
+
enum: ['Pending', 'Paid', 'Waived'],
|
|
110
|
+
default: 'Pending'
|
|
111
|
+
},
|
|
112
|
+
notes: {
|
|
113
|
+
type: String
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
timestamps: true
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const Resident = mongoose.model('Resident', residentSchema);
|
|
120
|
+
|
|
121
|
+
module.exports = Resident;
|