payservedb 5.2.6 → 5.2.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": "5.2.6",
3
+ "version": "5.2.8",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -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
- 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
- }
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,48 @@ 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
+ deliveryDays: {
50
+ type: Number,
51
+ required: true,
52
+ min: 1,
53
+ default: 7
54
+ },
55
+
56
+ notes: {
57
+ type: String,
58
+ trim: true,
59
+ default: '',
60
+ },
61
+
62
+ attachments: [{
63
+ fileName: {
64
+ type: String,
65
+ required: true,
66
+ trim: true,
67
+ },
68
+ filePath: {
69
+ type: String,
70
+ required: true,
71
+ },
72
+ uploadedAt: {
73
+ type: Date,
74
+ default: Date.now,
75
+ }
76
+ }],
77
+
45
78
  status: {
46
79
  type: String,
47
80
  enum: ['pending', 'submitted', 'evaluated', 'awarded'],
48
81
  default: 'pending',
49
82
  index: true,
50
83
  },
51
-
84
+
52
85
  evaluation: {
53
86
  score: {
54
87
  type: Number,
@@ -60,7 +93,7 @@ const rfqResponseSchema = new mongoose.Schema({
60
93
  type: String,
61
94
  trim: true,
62
95
  default: ''
63
- },
96
+ }
64
97
  },
65
98
  }, {
66
99
  timestamps: true,
@@ -69,4 +102,4 @@ const rfqResponseSchema = new mongoose.Schema({
69
102
  // Unique response per supplier per RFQ
70
103
  rfqResponseSchema.index({ rfqId: 1, supplierId: 1 }, { unique: true });
71
104
 
72
- module.exports = mongoose.model('RFQResponse', rfqResponseSchema);
105
+ module.exports = mongoose.model('RFQResponse', rfqResponseSchema);