payservedb 6.3.2 → 6.3.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
|
@@ -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
package/src/models/dutyroster.js
CHANGED
|
@@ -1,108 +1,126 @@
|
|
|
1
|
-
const mongoose = require(
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
2
|
|
|
3
3
|
// Time slot schema for reuse
|
|
4
|
-
const timeSlotSchema = new mongoose.Schema(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
26
|
-
type:
|
|
24
|
+
staffId: {
|
|
25
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
26
|
+
ref: "User",
|
|
27
27
|
required: true,
|
|
28
28
|
},
|
|
29
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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:
|
|
77
|
-
OFF:
|
|
78
|
-
AL:
|
|
79
|
-
CL:
|
|
80
|
-
|
|
81
|
-
PH:
|
|
82
|
-
UI:
|
|
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(
|
|
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 [
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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(
|
|
126
|
+
module.exports = mongoose.model("DutyRoster", dutyRosterSchema);
|
|
@@ -115,7 +115,6 @@ const facilityWalletTransactionsMetadataSchema = new mongoose.Schema(
|
|
|
115
115
|
);
|
|
116
116
|
|
|
117
117
|
// Indexes for better query performance
|
|
118
|
-
facilityWalletTransactionsMetadataSchema.index({ invoiceId: 1 });
|
|
119
118
|
facilityWalletTransactionsMetadataSchema.index({ facility: 1, status: 1 });
|
|
120
119
|
facilityWalletTransactionsMetadataSchema.index({ walletId: 1, status: 1 });
|
|
121
120
|
facilityWalletTransactionsMetadataSchema.index({ status: 1, createdAt: -1 });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const masterWorkplanSchema = new Schema({
|
|
3
|
+
facility: {
|
|
4
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
5
|
+
ref: "Facility",
|
|
6
|
+
required: true,
|
|
7
|
+
},
|
|
8
|
+
title: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: true,
|
|
11
|
+
},
|
|
12
|
+
description: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
life: {
|
|
17
|
+
type: String,
|
|
18
|
+
enum: ["Active", "Inactive"],
|
|
19
|
+
default: "Active",
|
|
20
|
+
},
|
|
21
|
+
status: {
|
|
22
|
+
type: Enum(["Approved", "Rejected", "Pending"]),
|
|
23
|
+
default: "Approved",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const MasterWorkplan = mongoose.model("MasterWorkplan", masterWorkplanSchema);
|
|
28
|
+
|
|
29
|
+
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;
|