payservedb 4.3.1 → 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 +3 -1
- package/package.json +1 -1
- package/src/models/campaigns.js +73 -0
- package/src/models/item_inspection.js +68 -0
package/index.js
CHANGED
|
@@ -131,7 +131,9 @@ const models = {
|
|
|
131
131
|
VasPayment: require('./src/models/vas_payments'),
|
|
132
132
|
VasInvoicesQuickBooks: require('./src/models/vas_invoices_upload'),
|
|
133
133
|
ServiceChargePayment: require('./src/models/service_charge_payments'),
|
|
134
|
-
ServiceChargeInvoiceUpload: require('./src/models/service_charge_invoice_upload')
|
|
134
|
+
ServiceChargeInvoiceUpload: require('./src/models/service_charge_invoice_upload'),
|
|
135
|
+
Campaign: require('./src/models/campaigns'),
|
|
136
|
+
InspectionItem: require('./src/models/item_inspection')
|
|
135
137
|
|
|
136
138
|
};
|
|
137
139
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const CampaignSchema = new mongoose.Schema({
|
|
4
|
+
facilityId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Facility',
|
|
7
|
+
required: true,
|
|
8
|
+
},
|
|
9
|
+
name: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
trim: true,
|
|
13
|
+
maxlength: 100
|
|
14
|
+
},
|
|
15
|
+
objective: {
|
|
16
|
+
type: String,
|
|
17
|
+
enum: ['Brand Awareness', 'Lead Generation', 'Sales', 'Engagement'],
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
startDate: {
|
|
21
|
+
type: Date,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
endDate: {
|
|
25
|
+
type: Date,
|
|
26
|
+
required: true,
|
|
27
|
+
validate: {
|
|
28
|
+
validator: function (value) {
|
|
29
|
+
return this.startDate <= value;
|
|
30
|
+
},
|
|
31
|
+
message: 'End date must be after or equal to start date'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
targetAudience: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: true,
|
|
37
|
+
trim: true,
|
|
38
|
+
maxlength: 200
|
|
39
|
+
},
|
|
40
|
+
channels: [{
|
|
41
|
+
type: String,
|
|
42
|
+
enum: ['Email', 'Social Media', 'SMS', 'Ads'],
|
|
43
|
+
required: true
|
|
44
|
+
}],
|
|
45
|
+
status: {
|
|
46
|
+
type: String,
|
|
47
|
+
enum: ['Draft', 'Ongoing', 'Completed'],
|
|
48
|
+
default: 'Draft'
|
|
49
|
+
}, description: {
|
|
50
|
+
type: String,
|
|
51
|
+
trim: true,
|
|
52
|
+
maxlength: 500
|
|
53
|
+
},
|
|
54
|
+
createdAt: {
|
|
55
|
+
type: Date,
|
|
56
|
+
default: Date.now
|
|
57
|
+
},
|
|
58
|
+
updatedAt: {
|
|
59
|
+
type: Date,
|
|
60
|
+
default: Date.now
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
timestamps: true
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Ensure at least one channel is selected
|
|
67
|
+
CampaignSchema.path('channels').validate(function (value) {
|
|
68
|
+
return value.length > 0;
|
|
69
|
+
}, 'At least one channel must be selected');
|
|
70
|
+
|
|
71
|
+
const Campaign = mongoose.model('Campaign', CampaignSchema);
|
|
72
|
+
|
|
73
|
+
module.exports =Campaign;
|
|
@@ -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;
|