payservedb 5.2.6 → 5.2.7
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 +1 -1
- package/src/models/dutyroster.js +42 -64
- package/src/models/rfq_response.js +31 -4
package/package.json
CHANGED
package/src/models/dutyroster.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
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
|
+
|
|
3
14
|
const dutyRosterSchema = new mongoose.Schema({
|
|
4
15
|
facilityId: {
|
|
5
16
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -22,71 +33,15 @@ const dutyRosterSchema = new mongoose.Schema({
|
|
|
22
33
|
}
|
|
23
34
|
},
|
|
24
35
|
|
|
25
|
-
// Regular weekly schedule
|
|
36
|
+
// Regular weekly schedule - now array of time slots for each day
|
|
26
37
|
weeklySchedule: {
|
|
27
|
-
monday:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
}
|
|
38
|
+
monday: [timeSlotSchema],
|
|
39
|
+
tuesday: [timeSlotSchema],
|
|
40
|
+
wednesday: [timeSlotSchema],
|
|
41
|
+
thursday: [timeSlotSchema],
|
|
42
|
+
friday: [timeSlotSchema],
|
|
43
|
+
saturday: [timeSlotSchema],
|
|
44
|
+
sunday: [timeSlotSchema]
|
|
90
45
|
},
|
|
91
46
|
|
|
92
47
|
// For exceptions to the regular schedule
|
|
@@ -127,4 +82,27 @@ dutyRosterSchema.statics.STATUS_CODES = {
|
|
|
127
82
|
UI: 'Unplanned Issues'
|
|
128
83
|
};
|
|
129
84
|
|
|
85
|
+
// Pre-save middleware to handle backward compatibility with old format
|
|
86
|
+
dutyRosterSchema.pre('save', function (next) {
|
|
87
|
+
const schedule = this.weeklySchedule;
|
|
88
|
+
|
|
89
|
+
// 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']) {
|
|
91
|
+
if (schedule[day] && !Array.isArray(schedule[day])) {
|
|
92
|
+
schedule[day] = [schedule[day]];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Ensure each day has at least one time slot
|
|
96
|
+
if (!schedule[day] || schedule[day].length === 0) {
|
|
97
|
+
schedule[day] = [{
|
|
98
|
+
startTime: "",
|
|
99
|
+
endTime: "",
|
|
100
|
+
status: "ON"
|
|
101
|
+
}];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
next();
|
|
106
|
+
});
|
|
107
|
+
|
|
130
108
|
module.exports = mongoose.model('DutyRoster', dutyRosterSchema);
|
|
@@ -19,7 +19,7 @@ const rfqResponseSchema = new mongoose.Schema({
|
|
|
19
19
|
required: true,
|
|
20
20
|
index: true,
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
items: [{
|
|
24
24
|
itemId: {
|
|
25
25
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -40,15 +40,42 @@ const rfqResponseSchema = new mongoose.Schema({
|
|
|
40
40
|
required: true,
|
|
41
41
|
min: 0,
|
|
42
42
|
},
|
|
43
|
+
notes: {
|
|
44
|
+
type: String,
|
|
45
|
+
trim: true,
|
|
46
|
+
default: '',
|
|
47
|
+
}
|
|
43
48
|
}],
|
|
44
|
-
|
|
49
|
+
|
|
50
|
+
notes: {
|
|
51
|
+
type: String,
|
|
52
|
+
trim: true,
|
|
53
|
+
default: '',
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
attachments: [{
|
|
57
|
+
fileName: {
|
|
58
|
+
type: String,
|
|
59
|
+
required: true,
|
|
60
|
+
trim: true,
|
|
61
|
+
},
|
|
62
|
+
filePath: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: true,
|
|
65
|
+
},
|
|
66
|
+
uploadedAt: {
|
|
67
|
+
type: Date,
|
|
68
|
+
default: Date.now,
|
|
69
|
+
}
|
|
70
|
+
}],
|
|
71
|
+
|
|
45
72
|
status: {
|
|
46
73
|
type: String,
|
|
47
74
|
enum: ['pending', 'submitted', 'evaluated', 'awarded'],
|
|
48
75
|
default: 'pending',
|
|
49
76
|
index: true,
|
|
50
77
|
},
|
|
51
|
-
|
|
78
|
+
|
|
52
79
|
evaluation: {
|
|
53
80
|
score: {
|
|
54
81
|
type: Number,
|
|
@@ -69,4 +96,4 @@ const rfqResponseSchema = new mongoose.Schema({
|
|
|
69
96
|
// Unique response per supplier per RFQ
|
|
70
97
|
rfqResponseSchema.index({ rfqId: 1, supplierId: 1 }, { unique: true });
|
|
71
98
|
|
|
72
|
-
module.exports = mongoose.model('RFQResponse', rfqResponseSchema);
|
|
99
|
+
module.exports = mongoose.model('RFQResponse', rfqResponseSchema);
|