payservedb 4.3.2 → 4.3.3

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
@@ -132,7 +132,8 @@ const models = {
132
132
  VasInvoicesQuickBooks: require('./src/models/vas_invoices_upload'),
133
133
  ServiceChargePayment: require('./src/models/service_charge_payments'),
134
134
  ServiceChargeInvoiceUpload: require('./src/models/service_charge_invoice_upload'),
135
- Campaign: require('./src/models/campaigns')
135
+ Campaign: require('./src/models/campaigns'),
136
+ InspectionItem: require('./src/models/item_inspection')
136
137
 
137
138
  };
138
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "4.3.2",
3
+ "version": "4.3.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,68 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ // Define the schema for inspection items
4
+ const inspectionItemSchema = new mongoose.Schema({
5
+ name: {
6
+ type: String,
7
+ required: [true, 'Item name is required'],
8
+ trim: true
9
+ },
10
+ category: {
11
+ type: String,
12
+ required: [true, 'Category is required'],
13
+ trim: true
14
+ },
15
+ subcategory: {
16
+ type: String,
17
+ trim: true,
18
+ default: null
19
+ },
20
+ description: {
21
+ type: String,
22
+ trim: true
23
+ },
24
+ possibleConditions: {
25
+ type: [String],
26
+ default: ['Excellent', 'Good', 'Fair', 'Poor', 'Damaged', 'Non-functional'],
27
+ validate: {
28
+ validator: function(v) {
29
+ return v.length > 0;
30
+ },
31
+ message: 'At least one possible condition is required'
32
+ }
33
+ },
34
+ defaultCondition: {
35
+ type: String,
36
+ default: 'Good'
37
+ },
38
+ isRequired: {
39
+ type: Boolean,
40
+ default: true
41
+ },
42
+ defaultQuantity: {
43
+ type: Number,
44
+ default: 1,
45
+ min: [1, 'Default quantity must be at least 1']
46
+ },
47
+ active: {
48
+ type: Boolean,
49
+ default: true
50
+ },
51
+ facilityId: {
52
+ type: mongoose.Schema.Types.ObjectId,
53
+ ref: 'Facility',
54
+ required: true
55
+ }
56
+ }, {
57
+ timestamps: true
58
+ });
59
+
60
+ // Add indexes for common queries
61
+ inspectionItemSchema.index({ facilityId: 1 });
62
+ inspectionItemSchema.index({ facilityId: 1, category: 1 });
63
+ inspectionItemSchema.index({ facilityId: 1, active: 1 });
64
+
65
+ // Create InspectionItem model
66
+ const InspectionItem = mongoose.model('InspectionItem', inspectionItemSchema);
67
+
68
+ module.exports = InspectionItem;