payservedb 3.1.3 → 3.1.4

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 CHANGED
@@ -108,7 +108,12 @@ const models = {
108
108
  ServiceRequest:require('./src/models/servicerequest'),
109
109
  CountryTaxRate:require('./src/models/country_tax'),
110
110
  Meter:require('./src/models/water_meter'),
111
- Concentrator:require('./src/models/water_meters_concentrator')
111
+ Concentrator:require('./src/models/water_meters_concentrator'),
112
+ HandoverChecklist:require('./src/models/handover_checklist'),
113
+ HandoverNotification:require('./src/models/handover_notification'),
114
+ HandoverSchedule:require('./src/models/handover_schedule'),
115
+ Handover:require('./src/models/handover'),
116
+ WelcomePack:require('./src/models/welcome_pack')
112
117
 
113
118
 
114
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,144 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const handoverSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true
8
+ },
9
+ unitNumber: {
10
+ type: mongoose.Schema.Types.ObjectId,
11
+ ref: 'Unit',
12
+ required: true
13
+ },
14
+ type: {
15
+ type: String,
16
+ enum: ['Initial', 'MoveOut'],
17
+ required: true
18
+ },
19
+ tenant: {
20
+ type: mongoose.Schema.Types.ObjectId,
21
+ ref: 'Customer',
22
+ required: true
23
+ },
24
+ status: {
25
+ type: String,
26
+ enum: ['Pending', 'InProgress', 'Completed', 'Cancelled'],
27
+ default: 'Pending'
28
+ },
29
+ startDate: {
30
+ type: Date,
31
+ required: true
32
+ },
33
+ completionDate: {
34
+ type: Date
35
+ },
36
+ preHandoverInspection: {
37
+ scheduled: { type: Date },
38
+ completed: { type: Date },
39
+ inspector: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
40
+ status: {
41
+ type: String,
42
+ enum: ['Pending', 'Scheduled', 'Completed'],
43
+ default: 'Pending'
44
+ },
45
+ checklist: { type: mongoose.Schema.Types.ObjectId, ref: 'HandoverChecklist' }
46
+ },
47
+ finalInspection: {
48
+ scheduled: { type: Date },
49
+ completed: { type: Date },
50
+ inspector: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
51
+ status: {
52
+ type: String,
53
+ enum: ['Pending', 'Scheduled', 'Completed'],
54
+ default: 'Pending'
55
+ },
56
+ checklist: { type: mongoose.Schema.Types.ObjectId, ref: 'HandoverChecklist' }
57
+ },
58
+ utilities: [{
59
+ type: { type: String, enum: ['Water', 'Electricity', 'Gas', 'Internet'] },
60
+ meterNumber: String,
61
+ initialReading: Number,
62
+ finalReading: Number,
63
+ transferStatus: {
64
+ type: String,
65
+ enum: ['Pending', 'InProgress', 'Completed'],
66
+ default: 'Pending'
67
+ },
68
+ transferDate: Date
69
+ }],
70
+ securityDeposit: {
71
+ amount: { type: Number },
72
+ deductions: [{
73
+ reason: String,
74
+ amount: Number,
75
+ description: String
76
+ }],
77
+ refundAmount: { type: Number },
78
+ refundStatus: {
79
+ type: String,
80
+ enum: ['Pending', 'Processed', 'Completed'],
81
+ default: 'Pending'
82
+ },
83
+ refundDate: Date
84
+ },
85
+ documents: [{
86
+ type: {
87
+ type: String,
88
+ enum: ['Inspection', 'Utility', 'Welcome', 'Handover', 'Other']
89
+ },
90
+ title: String,
91
+ fileName: String,
92
+ fileUrl: String,
93
+ uploadedAt: { type: Date, default: Date.now }
94
+ }],
95
+ welcomePack: {
96
+ status: {
97
+ type: String,
98
+ enum: ['Pending', 'Prepared', 'Delivered'],
99
+ default: 'Pending'
100
+ },
101
+ deliveredDate: Date,
102
+ contents: [{
103
+ itemType: String,
104
+ description: String,
105
+ quantity: Number
106
+ }]
107
+ },
108
+ feedback: {
109
+ submitted: { type: Boolean, default: false },
110
+ submissionDate: Date,
111
+ ratings: {
112
+ overallExperience: { type: Number, min: 1, max: 5 },
113
+ processEfficiency: { type: Number, min: 1, max: 5 },
114
+ staffProfessionalism: { type: Number, min: 1, max: 5 }
115
+ },
116
+ comments: String
117
+ },
118
+ maintenanceRequests: [{
119
+ type: { type: String },
120
+ description: String,
121
+ status: {
122
+ type: String,
123
+ enum: ['Pending', 'Scheduled', 'InProgress', 'Completed'],
124
+ default: 'Pending'
125
+ },
126
+ scheduledDate: Date,
127
+ completionDate: Date,
128
+ cost: Number
129
+ }],
130
+ notes: [{
131
+ content: String,
132
+ addedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
133
+ addedAt: { type: Date, default: Date.now }
134
+ }],
135
+ createdBy: {
136
+ type: mongoose.Schema.Types.ObjectId,
137
+ ref: 'User'
138
+ }
139
+ }, {
140
+ timestamps: true
141
+ });
142
+ const Handover = mongoose.model('Handover', handoverSchema);
143
+
144
+ module.exports = Handover;
@@ -0,0 +1,73 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const handoverChecklistSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true
8
+ },
9
+ type: {
10
+ type: String,
11
+ enum: ['PreHandover', 'MoveOut', 'FinalInspection'],
12
+ required: true
13
+ },
14
+ sections: [{
15
+ name: { type: String, required: true },
16
+ items: [{
17
+ itemName: { type: String, required: true },
18
+ condition: {
19
+ type: String,
20
+ enum: ['Excellent', 'Good', 'Fair', 'Poor', 'Damaged', 'Missing', 'NA']
21
+ },
22
+ photos: [{
23
+ url: String,
24
+ description: String,
25
+ uploadedAt: { type: Date, default: Date.now }
26
+ }],
27
+ notes: String,
28
+ actionRequired: {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ actionDetails: {
33
+ description: String,
34
+ estimatedCost: Number,
35
+ deadline: Date,
36
+ status: {
37
+ type: String,
38
+ enum: ['Pending', 'InProgress', 'Completed'],
39
+ default: 'Pending'
40
+ }
41
+ }
42
+ }]
43
+ }],
44
+ completedBy: {
45
+ type: mongoose.Schema.Types.ObjectId,
46
+ ref: 'User'
47
+ },
48
+ signoffs: [{
49
+ role: {
50
+ type: String,
51
+ enum: ['Inspector', 'Tenant', 'PropertyManager'],
52
+ required: true
53
+ },
54
+ user: {
55
+ type: mongoose.Schema.Types.ObjectId,
56
+ ref: 'User'
57
+ },
58
+ signature: String,
59
+ signedAt: Date,
60
+ comments: String
61
+ }],
62
+ status: {
63
+ type: String,
64
+ enum: ['Draft', 'InProgress', 'Completed', 'Rejected'],
65
+ default: 'Draft'
66
+ }
67
+ }, {
68
+ timestamps: true
69
+ });
70
+
71
+ const HandoverChecklist = mongoose.model('HandoverChecklist', handoverChecklistSchema);
72
+
73
+ module.exports = HandoverChecklist;
@@ -0,0 +1,119 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const handoverNotificationSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true
8
+ },
9
+ handoverId: {
10
+ type: mongoose.Schema.Types.ObjectId,
11
+ ref: 'Handover',
12
+ required: true
13
+ },
14
+ tenant: {
15
+ type: mongoose.Schema.Types.ObjectId,
16
+ ref: 'Customer',
17
+ required: true
18
+ },
19
+ type: {
20
+ type: String,
21
+ enum: ['MoveOutNotice', 'InspectionSchedule', 'DocumentRequest', 'WelcomePackReady', 'UtilityTransfer'],
22
+ required: true
23
+ },
24
+ noticeDate: {
25
+ type: Date,
26
+ required: true
27
+ },
28
+ plannedMoveOutDate: Date,
29
+ // Reference to main Notification schema
30
+ notifications: [{
31
+ type: mongoose.Schema.Types.ObjectId,
32
+ ref: 'Notification'
33
+ }],
34
+ // Reference to main Reminder schema
35
+ reminders: [{
36
+ type: mongoose.Schema.Types.ObjectId,
37
+ ref: 'Reminder'
38
+ }],
39
+ status: {
40
+ type: String,
41
+ enum: ['Pending', 'InProgress', 'Completed', 'Cancelled'],
42
+ default: 'Pending'
43
+ },
44
+ acknowledgement: {
45
+ acknowledgedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
46
+ acknowledgedAt: Date,
47
+ comments: String
48
+ },
49
+ notificationConfig: {
50
+ methods: [{
51
+ type: String,
52
+ enum: ['Email', 'SMS', 'System', 'Letter'],
53
+ required: true
54
+ }],
55
+ reminderFrequency: {
56
+ type: String,
57
+ enum: ['daily', 'weekly', 'biweekly', 'monthly'],
58
+ required: true
59
+ },
60
+ messageTemplate: {
61
+ type: String,
62
+ required: true
63
+ }
64
+ }
65
+ }, {
66
+ timestamps: true
67
+ });
68
+
69
+ // Pre-save middleware to create notifications and reminders
70
+ handoverNotificationSchema.pre('save', async function(next) {
71
+ if (this.isNew) {
72
+ try {
73
+ // Create base notification
74
+ const notification = new Notification({
75
+ userId: this.tenant,
76
+ message: this.notificationConfig.messageTemplate,
77
+ dateSent: new Date()
78
+ });
79
+ await notification.save();
80
+ this.notifications.push(notification._id);
81
+
82
+ // Create reminder
83
+ const reminder = new Reminder({
84
+ name: `Handover_${this.type}_${this.handoverId}`,
85
+ type: 'recurring',
86
+ frequency: this.notificationConfig.reminderFrequency,
87
+ time: '09:00', // Default time
88
+ module: 'Handover',
89
+ isActive: true,
90
+ notificationTypes: this.notificationConfig.methods,
91
+ message: this.notificationConfig.messageTemplate,
92
+ facilityId: this.facilityId
93
+ });
94
+ await reminder.save();
95
+ this.reminders.push(reminder._id);
96
+
97
+ next();
98
+ } catch (error) {
99
+ next(error);
100
+ }
101
+ } else {
102
+ next();
103
+ }
104
+ });
105
+
106
+ // Clean up related notifications and reminders when deleted
107
+ handoverNotificationSchema.pre('remove', async function(next) {
108
+ try {
109
+ await Notification.deleteMany({ _id: { $in: this.notifications } });
110
+ await Reminder.deleteMany({ _id: { $in: this.reminders } });
111
+ next();
112
+ } catch (error) {
113
+ next(error);
114
+ }
115
+ });
116
+
117
+ const HandoverNotification = mongoose.model('HandoverNotification', handoverNotificationSchema);
118
+
119
+ module.exports = HandoverNotification;
@@ -0,0 +1,71 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const handoverScheduleSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true
8
+ },
9
+ handoverId: {
10
+ type: mongoose.Schema.Types.ObjectId,
11
+ ref: 'Handover',
12
+ required: true
13
+ },
14
+ inspectionType: {
15
+ type: String,
16
+ enum: ['PreHandover', 'MoveOut', 'Final'],
17
+ required: true
18
+ },
19
+ scheduledDate: {
20
+ type: Date,
21
+ required: true
22
+ },
23
+ duration: {
24
+ type: Number, // in minutes
25
+ required: true
26
+ },
27
+ inspector: {
28
+ type: mongoose.Schema.Types.ObjectId,
29
+ ref: 'User',
30
+ required: true
31
+ },
32
+ participants: [{
33
+ role: {
34
+ type: String,
35
+ enum: ['Tenant', 'PropertyManager', 'Contractor', 'Other'],
36
+ required: true
37
+ },
38
+ user: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
39
+ confirmed: { type: Boolean, default: false },
40
+ confirmationDate: Date
41
+ }],
42
+ status: {
43
+ type: String,
44
+ enum: ['Scheduled', 'Confirmed', 'InProgress', 'Completed', 'Cancelled', 'Rescheduled'],
45
+ default: 'Scheduled'
46
+ },
47
+ rescheduledFrom: {
48
+ date: Date,
49
+ reason: String
50
+ },
51
+ checklist: {
52
+ type: mongoose.Schema.Types.ObjectId,
53
+ ref: 'HandoverChecklist'
54
+ },
55
+ notes: String,
56
+ reminders: [{
57
+ recipientType: {
58
+ type: String,
59
+ enum: ['Inspector', 'Tenant', 'PropertyManager', 'All']
60
+ },
61
+ scheduledTime: Date,
62
+ sent: { type: Boolean, default: false },
63
+ sentAt: Date
64
+ }]
65
+ }, {
66
+ timestamps: true
67
+ });
68
+
69
+ const HandoverSchedule = mongoose.model('HandoverSchedule', handoverScheduleSchema);
70
+
71
+ module.exports = HandoverSchedule;
@@ -0,0 +1,63 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const welcomePackSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true
8
+ },
9
+ name: {
10
+ type: String,
11
+ required: true
12
+ },
13
+ type: {
14
+ type: String,
15
+ enum: ['Standard', 'Premium', 'Custom'],
16
+ default: 'Standard'
17
+ },
18
+ items: [{
19
+ category: {
20
+ type: String,
21
+ enum: ['Keys', 'Documents', 'Manuals', 'AccessCards', 'Other'],
22
+ required: true
23
+ },
24
+ itemName: { type: String, required: true },
25
+ quantity: { type: Number, default: 1 },
26
+ description: String,
27
+ isRequired: { type: Boolean, default: true }
28
+ }],
29
+ documents: [{
30
+ name: String,
31
+ type: {
32
+ type: String,
33
+ enum: ['Manual', 'Guide', 'Policy', 'Emergency', 'Other']
34
+ },
35
+ fileUrl: String,
36
+ isRequired: { type: Boolean, default: true }
37
+ }],
38
+ facilitiesInfo: {
39
+ emergencyContacts: [{
40
+ name: String,
41
+ role: String,
42
+ contact: String
43
+ }],
44
+ amenities: [{
45
+ name: String,
46
+ location: String,
47
+ accessInstructions: String
48
+ }],
49
+ rules: [String]
50
+ },
51
+ status: {
52
+ type: String,
53
+ enum: ['Active', 'Inactive', 'Draft'],
54
+ default: 'Active'
55
+ }
56
+ }, {
57
+ timestamps: true
58
+ });
59
+
60
+
61
+ const WelcomePack = mongoose.model('WelcomePack', welcomePackSchema);
62
+
63
+ module.exports = WelcomePack;