payservedb 5.7.1 → 5.7.2
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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const assetAssignmentSchema = new mongoose.Schema({
|
|
4
|
+
assetId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Asset',
|
|
7
|
+
required: true,
|
|
8
|
+
},
|
|
9
|
+
serviceVendorId: {
|
|
10
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
11
|
+
ref: 'ServiceVendor',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
facilityId: {
|
|
15
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
16
|
+
ref: 'Facility',
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
assignedDate: {
|
|
20
|
+
type: Date,
|
|
21
|
+
default: Date.now,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
unassignedDate: {
|
|
25
|
+
type: Date,
|
|
26
|
+
},
|
|
27
|
+
status: {
|
|
28
|
+
type: String,
|
|
29
|
+
enum: ['Active', 'Inactive', 'Completed'],
|
|
30
|
+
default: 'Active',
|
|
31
|
+
},
|
|
32
|
+
notes: {
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
priority: {
|
|
36
|
+
type: String,
|
|
37
|
+
enum: ['Low', 'Medium', 'High', 'Critical'],
|
|
38
|
+
default: 'Medium',
|
|
39
|
+
},
|
|
40
|
+
serviceType: {
|
|
41
|
+
type: String,
|
|
42
|
+
enum: ['Maintenance', 'Repair', 'Installation', 'Inspection', 'Other'],
|
|
43
|
+
},
|
|
44
|
+
estimatedCompletionDate: {
|
|
45
|
+
type: Date,
|
|
46
|
+
},
|
|
47
|
+
actualCompletionDate: {
|
|
48
|
+
type: Date,
|
|
49
|
+
},
|
|
50
|
+
cost: {
|
|
51
|
+
type: Number,
|
|
52
|
+
min: 0,
|
|
53
|
+
},
|
|
54
|
+
}, {
|
|
55
|
+
timestamps: true,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Compound index to ensure unique active assignments per asset-vendor pair
|
|
59
|
+
assetAssignmentSchema.index(
|
|
60
|
+
{ assetId: 1, serviceVendorId: 1, status: 1 },
|
|
61
|
+
{
|
|
62
|
+
unique: true,
|
|
63
|
+
partialFilterExpression: { status: 'Active' }
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Index for efficient querying by facility
|
|
68
|
+
assetAssignmentSchema.index({ facilityId: 1 });
|
|
69
|
+
|
|
70
|
+
// Index for date-based queries
|
|
71
|
+
assetAssignmentSchema.index({ assignedDate: 1 });
|
|
72
|
+
assetAssignmentSchema.index({ estimatedCompletionDate: 1 });
|
|
73
|
+
|
|
74
|
+
module.exports = mongoose.model('AssetAssignment', assetAssignmentSchema);
|
package/src/models/tickets.js
CHANGED
|
@@ -37,7 +37,7 @@ const ticketSchema = new mongoose.Schema({
|
|
|
37
37
|
},
|
|
38
38
|
status: {
|
|
39
39
|
type: String,
|
|
40
|
-
enum: ['open', '
|
|
40
|
+
enum: ['open', 'under review', 'ongoing', 'resolved', 'cancelled', 'closed'],
|
|
41
41
|
required: true,
|
|
42
42
|
default: 'open',
|
|
43
43
|
},
|