payservedb 4.7.5 → 4.7.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "4.7.5",
3
+ "version": "4.7.8",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,38 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const alertSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true,
8
+ index: true
9
+ },
10
+ date: {
11
+ type: Date,
12
+ required: true
13
+ },
14
+ utilityType: {
15
+ type: String,
16
+ required: true,
17
+ enum: ['Generator', 'Water', 'Electricity']
18
+ },
19
+ description: {
20
+ type: String,
21
+ required: true
22
+ },
23
+ status: {
24
+ type: String,
25
+ required: true,
26
+ enum: ['Open', 'Resolved', 'Ignored'],
27
+ default: 'Open'
28
+ },
29
+ resolvedDate: {
30
+ type: Date
31
+ }
32
+ }, { timestamps: true });
33
+
34
+ // Compound index for efficient querying
35
+ alertSchema.index({ facilityId: 1, date: 1, utilityType: 1 });
36
+
37
+ const Alert = mongoose.model('Alert', alertSchema);
38
+ module.exports = Alert;
@@ -6,47 +6,125 @@ const dutyRosterSchema = new mongoose.Schema({
6
6
  ref: 'Facility',
7
7
  required: true,
8
8
  },
9
- name: {
10
- type: String,
11
- required: true,
12
- },
13
- phone: {
14
- type: String,
15
- required: true,
16
- },
17
- activity: {
18
- type: String,
19
- required: true,
20
- },
21
- startTime: {
22
- type: String,
23
- required: true
24
- },
25
- endTime: {
26
- type: String,
27
- required: true
28
- },
29
- approved: {
30
- type: Boolean,
31
- default: false
9
+ staffDetails: {
10
+ name: {
11
+ type: String,
12
+ required: true,
13
+ },
14
+ phone: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ role: {
19
+ type: String,
20
+ required: true,
21
+ // Examples: 'Site Manager', 'GRE', 'Site support staff', 'Plumber', etc.
22
+ }
32
23
  },
33
- approvedBy: {
34
- type: mongoose.Schema.Types.ObjectId,
35
- ref: 'User'
24
+
25
+ // Regular weekly schedule
26
+ weeklySchedule: {
27
+ monday: {
28
+ startTime: String,
29
+ endTime: String,
30
+ status: {
31
+ type: String,
32
+ enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
33
+ default: 'ON'
34
+ }
35
+ },
36
+ tuesday: {
37
+ startTime: String,
38
+ endTime: String,
39
+ status: {
40
+ type: String,
41
+ enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
42
+ default: 'ON'
43
+ }
44
+ },
45
+ wednesday: {
46
+ startTime: String,
47
+ endTime: String,
48
+ status: {
49
+ type: String,
50
+ enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
51
+ default: 'ON'
52
+ }
53
+ },
54
+ thursday: {
55
+ startTime: String,
56
+ endTime: String,
57
+ status: {
58
+ type: String,
59
+ enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
60
+ default: 'ON'
61
+ }
62
+ },
63
+ friday: {
64
+ startTime: String,
65
+ endTime: String,
66
+ status: {
67
+ type: String,
68
+ enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
69
+ default: 'ON'
70
+ }
71
+ },
72
+ saturday: {
73
+ startTime: String,
74
+ endTime: String,
75
+ status: {
76
+ type: String,
77
+ enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
78
+ default: 'ON'
79
+ }
80
+ },
81
+ sunday: {
82
+ startTime: String,
83
+ endTime: String,
84
+ status: {
85
+ type: String,
86
+ enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
87
+ default: 'ON'
88
+ }
89
+ }
36
90
  },
37
- schedule: [{
91
+
92
+ // For exceptions to the regular schedule
93
+ exceptions: [{
38
94
  date: {
39
95
  type: Date,
40
96
  required: true
41
97
  },
98
+ startTime: String,
99
+ endTime: String,
42
100
  status: {
43
101
  type: String,
44
- enum: ['pending', 'completed', 'missed', 'rescheduled'],
45
- default: 'pending'
102
+ enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
103
+ required: true
104
+ },
105
+ reason: String
106
+ }],
107
+
108
+ // Metadata
109
+ metadata: {
110
+ period: {
111
+ startDate: Date,
112
+ endDate: Date
46
113
  }
47
- }]
114
+ }
48
115
  }, {
49
116
  timestamps: true
50
117
  });
51
118
 
119
+ // Status code definitions
120
+ dutyRosterSchema.statics.STATUS_CODES = {
121
+ ON: 'On Duty',
122
+ OFF: 'Off Duty',
123
+ AL: 'Annual Leave',
124
+ CL: 'Casual Leave',
125
+ 'ML/PL': 'Medical/Paternity Leave',
126
+ PH: 'Public Holiday',
127
+ UI: 'Unplanned Issues'
128
+ };
129
+
52
130
  module.exports = mongoose.model('DutyRoster', dutyRosterSchema);