payservedb 6.3.3 → 6.3.5

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
@@ -200,7 +200,9 @@ const models = {
200
200
  FacilityWalletTransactionsMetadata: require("./src/models/facilityWalletTransactionsMetadata"),
201
201
  PowerMeterCustomerAccount: require("./src/models/powerMeterCustomerAccount"),
202
202
  SmsNotification: require("./src/models/sms_balance_notification"),
203
- NegativeBalance: require("./src/models/water_meter_negative_amounts")
203
+ NegativeBalance: require("./src/models/water_meter_negative_amounts"),
204
+ MasterWorkplan: require("./src/models/master_workplan"),
205
+ MasterWorkplanChild: require("./src/models/master_workplan_child"),
204
206
  };
205
207
 
206
208
  // Function to get models dynamically from a specific database connection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "6.3.3",
3
+ "version": "6.3.5",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,108 +1,126 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require("mongoose");
2
2
 
3
3
  // Time slot schema for reuse
4
- const timeSlotSchema = new mongoose.Schema({
5
- startTime: String,
6
- endTime: String,
7
- status: {
8
- type: String,
9
- enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
10
- default: 'ON'
11
- }
12
- }, { _id: false });
13
-
14
- const dutyRosterSchema = new mongoose.Schema({
15
- facilityId: {
16
- type: mongoose.Schema.Types.ObjectId,
17
- ref: 'Facility',
18
- required: true,
19
- },
20
- staffDetails: {
21
- name: {
4
+ const timeSlotSchema = new mongoose.Schema(
5
+ {
6
+ startTime: String,
7
+ endTime: String,
8
+ status: {
22
9
  type: String,
10
+ enum: ["ON", "OFF", "AL", "CL", "ML/PL", "PH", "UI"],
11
+ default: "ON",
12
+ },
13
+ },
14
+ { _id: false },
15
+ );
16
+
17
+ const dutyRosterSchema = new mongoose.Schema(
18
+ {
19
+ facilityId: {
20
+ type: mongoose.Schema.Types.ObjectId,
21
+ ref: "Facility",
23
22
  required: true,
24
23
  },
25
- phone: {
26
- type: String,
24
+ staffId: {
25
+ type: mongoose.Schema.Types.ObjectId,
26
+ ref: "User",
27
27
  required: true,
28
28
  },
29
- role: {
29
+ staffPosition: {
30
30
  type: String,
31
+ enum: ["Head", "Deputy", "Assistant", "Normal"],
32
+ default: "Normal",
33
+ },
34
+ masterWorkplanId: {
35
+ type: mongoose.Schema.Types.ObjectId,
36
+ ref: "MasterWorkplanAssignment",
31
37
  required: true,
32
- // Examples: 'Site Manager', 'GRE', 'Site support staff', 'Plumber', etc.
33
- }
34
- },
35
-
36
- // Regular weekly schedule - now array of time slots for each day
37
- weeklySchedule: {
38
- monday: [timeSlotSchema],
39
- tuesday: [timeSlotSchema],
40
- wednesday: [timeSlotSchema],
41
- thursday: [timeSlotSchema],
42
- friday: [timeSlotSchema],
43
- saturday: [timeSlotSchema],
44
- sunday: [timeSlotSchema]
45
- },
46
-
47
- // For exceptions to the regular schedule
48
- exceptions: [{
49
- date: {
50
- type: Date,
51
- required: true
52
38
  },
53
- startTime: String,
54
- endTime: String,
55
- status: {
56
- type: String,
57
- enum: ['ON', 'OFF', 'AL', 'CL', 'ML/PL', 'PH', 'UI'],
58
- required: true
39
+
40
+ // Regular weekly schedule - now array of time slots for each day
41
+ weeklySchedule: {
42
+ monday: [timeSlotSchema],
43
+ tuesday: [timeSlotSchema],
44
+ wednesday: [timeSlotSchema],
45
+ thursday: [timeSlotSchema],
46
+ friday: [timeSlotSchema],
47
+ saturday: [timeSlotSchema],
48
+ sunday: [timeSlotSchema],
59
49
  },
60
- reason: String
61
- }],
62
50
 
63
- // Metadata
64
- metadata: {
65
- period: {
66
- startDate: Date,
67
- endDate: Date
68
- }
69
- }
70
- }, {
71
- timestamps: true
72
- });
51
+ // For exceptions to the regular schedule
52
+ exceptions: [
53
+ {
54
+ date: {
55
+ type: Date,
56
+ required: true,
57
+ },
58
+ startTime: String,
59
+ endTime: String,
60
+ status: {
61
+ type: String,
62
+ enum: ["ON", "OFF", "AL", "CL", "ML/PL", "PH", "UI"],
63
+ required: true,
64
+ },
65
+ reason: String,
66
+ },
67
+ ],
68
+
69
+ // Metadata
70
+ metadata: {
71
+ period: {
72
+ startDate: Date,
73
+ endDate: Date,
74
+ },
75
+ },
76
+ },
77
+ {
78
+ timestamps: true,
79
+ },
80
+ );
73
81
 
74
82
  // Status code definitions
75
83
  dutyRosterSchema.statics.STATUS_CODES = {
76
- ON: 'On Duty',
77
- OFF: 'Off Duty',
78
- AL: 'Annual Leave',
79
- CL: 'Casual Leave',
80
- 'ML/PL': 'Medical/Paternity Leave',
81
- PH: 'Public Holiday',
82
- UI: 'Unplanned Issues'
84
+ ON: "On Duty",
85
+ OFF: "Off Duty",
86
+ AL: "Annual Leave",
87
+ CL: "Casual Leave",
88
+ "ML/PL": "Medical/Paternity Leave",
89
+ PH: "Public Holiday",
90
+ UI: "Unplanned Issues",
83
91
  };
84
92
 
85
93
  // Pre-save middleware to handle backward compatibility with old format
86
- dutyRosterSchema.pre('save', function (next) {
94
+ dutyRosterSchema.pre("save", function (next) {
87
95
  const schedule = this.weeklySchedule;
88
96
 
89
97
  // Convert any day that's not an array to an array with a single element
90
- for (const day of ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']) {
98
+ for (const day of [
99
+ "monday",
100
+ "tuesday",
101
+ "wednesday",
102
+ "thursday",
103
+ "friday",
104
+ "saturday",
105
+ "sunday",
106
+ ]) {
91
107
  if (schedule[day] && !Array.isArray(schedule[day])) {
92
108
  schedule[day] = [schedule[day]];
93
109
  }
94
110
 
95
111
  // Ensure each day has at least one time slot
96
112
  if (!schedule[day] || schedule[day].length === 0) {
97
- schedule[day] = [{
98
- startTime: "",
99
- endTime: "",
100
- status: "ON"
101
- }];
113
+ schedule[day] = [
114
+ {
115
+ startTime: "",
116
+ endTime: "",
117
+ status: "ON",
118
+ },
119
+ ];
102
120
  }
103
121
  }
104
122
 
105
123
  next();
106
124
  });
107
125
 
108
- module.exports = mongoose.model('DutyRoster', dutyRosterSchema);
126
+ module.exports = mongoose.model("DutyRoster", dutyRosterSchema);
@@ -0,0 +1,30 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const masterWorkplanSchema = new mongoose.Schema({
4
+ facility: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: "Facility",
7
+ required: true,
8
+ },
9
+ title: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ description: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ life: {
18
+ type: String,
19
+ enum: ["Active", "Inactive"],
20
+ default: "Active",
21
+ },
22
+ status: {
23
+ type: Enum(["Approved", "Rejected", "Pending"]),
24
+ default: "Approved",
25
+ },
26
+ });
27
+
28
+ const MasterWorkplan = mongoose.model("MasterWorkplan", masterWorkplanSchema);
29
+
30
+ module.exports = MasterWorkplan;
@@ -0,0 +1,34 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const MasterWorkplanChildSchema = new mongoose.Schema(
4
+ {
5
+ name: {
6
+ type: String,
7
+ required: true,
8
+ },
9
+ description: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ parent: {
14
+ type: mongoose.Schema.Types.ObjectId,
15
+ ref: "MasterWorkplan",
16
+ required: true,
17
+ },
18
+ status: {
19
+ type: String,
20
+ enum: ["Completed", "Pending", "In Progress", "Undone"],
21
+ default: "Pending",
22
+ },
23
+ },
24
+ {
25
+ timestamps: true,
26
+ },
27
+ );
28
+
29
+ const MasterWorkplanChild = mongoose.model(
30
+ "ChildWorkplan",
31
+ MasterWorkplanChildSchema,
32
+ );
33
+
34
+ module.exports = MasterWorkplanChild;