payservedb 5.0.3 → 5.0.5
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/.env +2 -2
- package/index.js +172 -172
- package/package.json +17 -17
- package/src/models/account.js +35 -35
- package/src/models/analog_water_billing.js +58 -58
- package/src/models/apilog.js +18 -18
- package/src/models/approvalsWorkflows.js +49 -49
- package/src/models/archivedapilog.js +18 -18
- package/src/models/archivedauditlog.js +83 -83
- package/src/models/asset.js +34 -34
- package/src/models/auditlog.js +83 -83
- package/src/models/bankdetails.js +40 -40
- package/src/models/bookinganalytics.js +63 -63
- package/src/models/bookingconfig.js +45 -45
- package/src/models/bookingproperty.js +112 -112
- package/src/models/bookingreservation.js +192 -192
- package/src/models/bookingrevenuerecord.js +84 -84
- package/src/models/budget.js +33 -33
- package/src/models/budgetCategory.js +19 -19
- package/src/models/campaigns.js +72 -72
- package/src/models/cashpayment.js +262 -262
- package/src/models/combinedUnits.js +62 -62
- package/src/models/common_area_electricity.js +38 -38
- package/src/models/common_area_generator.js +38 -38
- package/src/models/common_area_utility_alert.js +37 -37
- package/src/models/common_area_water.js +39 -39
- package/src/models/company.js +53 -53
- package/src/models/country_tax.js +42 -42
- package/src/models/currency_settings.js +39 -39
- package/src/models/customer.js +200 -200
- package/src/models/default_payment_details.js +17 -17
- package/src/models/dutyroster.js +129 -129
- package/src/models/email.js +24 -24
- package/src/models/entry_exit.js +53 -53
- package/src/models/expense.js +55 -55
- package/src/models/facility.js +61 -61
- package/src/models/facility_payment_details.js +20 -20
- package/src/models/facilityasset.js +25 -25
- package/src/models/faq.js +18 -18
- package/src/models/gl_account_double_entries.js +25 -25
- package/src/models/gl_accounts.js +56 -56
- package/src/models/gl_entries.js +52 -45
- package/src/models/guard.js +47 -47
- package/src/models/handover.js +241 -241
- package/src/models/invoice.js +291 -291
- package/src/models/item_inspection.js +67 -67
- package/src/models/leaseagreement.js +169 -168
- package/src/models/leasetemplate.js +17 -17
- package/src/models/levy.js +84 -84
- package/src/models/levy_invoice_settings.js +26 -26
- package/src/models/levycontract.js +77 -77
- package/src/models/levytype.js +23 -23
- package/src/models/maintenance_service_vendor.js +38 -38
- package/src/models/maintenance_services.js +17 -17
- package/src/models/maintenancerequisition.js +31 -31
- package/src/models/message.js +38 -38
- package/src/models/module.js +21 -21
- package/src/models/notification.js +24 -24
- package/src/models/penalty.js +76 -76
- package/src/models/purchase_order.js +190 -190
- package/src/models/purchase_request.js +65 -65
- package/src/models/refresh_token.js +23 -23
- package/src/models/reminder.js +161 -161
- package/src/models/report.js +13 -13
- package/src/models/resident.js +121 -121
- package/src/models/rfq_details.js +87 -87
- package/src/models/rfq_response.js +109 -109
- package/src/models/service_charge_invoice_upload.js +42 -42
- package/src/models/service_charge_payments.js +27 -27
- package/src/models/servicerequest.js +55 -55
- package/src/models/settings.js +62 -62
- package/src/models/smart_meter_daily_consumption.js +44 -44
- package/src/models/sms_africastalking.js +20 -20
- package/src/models/sms_meliora.js +16 -16
- package/src/models/staff.js +36 -36
- package/src/models/stocksandspare.js +34 -34
- package/src/models/suppliers.js +68 -68
- package/src/models/tickets.js +109 -109
- package/src/models/unitasset.js +25 -25
- package/src/models/units.js +86 -86
- package/src/models/user.js +187 -187
- package/src/models/valueaddedservices.js +36 -36
- package/src/models/vas_invoices_upload.js +50 -50
- package/src/models/vas_payments.js +24 -24
- package/src/models/vasinvoice.js +159 -159
- package/src/models/vasvendor.js +57 -57
- package/src/models/visitLog.js +86 -86
- package/src/models/visitor.js +63 -63
- package/src/models/waitlist.js +45 -45
- package/src/models/water_invoice.js +192 -192
- package/src/models/water_meter_account.js +74 -74
- package/src/models/water_meter_communication.js +17 -17
- package/src/models/water_meter_concentrator.js +59 -59
- package/src/models/water_meter_daily_history.js +31 -31
- package/src/models/water_meter_iot_cards.js +34 -34
- package/src/models/water_meter_manufacturer.js +35 -35
- package/src/models/water_meter_monthly_history.js +37 -37
- package/src/models/water_meter_settings.js +88 -88
- package/src/models/water_meter_single_day_history.js +31 -31
- package/src/models/water_meter_size.js +15 -15
- package/src/models/water_meters.js +106 -106
- package/src/models/water_meters_delivery.js +76 -76
- package/src/models/workorder.js +49 -49
package/src/models/resident.js
CHANGED
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for Resident
|
|
4
|
-
const residentSchema = new mongoose.Schema({
|
|
5
|
-
residentId: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: true,
|
|
8
|
-
unique: true
|
|
9
|
-
},
|
|
10
|
-
name: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: true
|
|
13
|
-
},
|
|
14
|
-
email: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true
|
|
17
|
-
},
|
|
18
|
-
phone: {
|
|
19
|
-
type: String,
|
|
20
|
-
required: true
|
|
21
|
-
},
|
|
22
|
-
nationalId: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: true
|
|
25
|
-
},
|
|
26
|
-
unitId: {
|
|
27
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
28
|
-
ref: 'Unit',
|
|
29
|
-
required: true
|
|
30
|
-
},
|
|
31
|
-
unitName: {
|
|
32
|
-
type: String,
|
|
33
|
-
required: true
|
|
34
|
-
},
|
|
35
|
-
facilityId: {
|
|
36
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
-
ref: 'Facility',
|
|
38
|
-
required: true
|
|
39
|
-
},
|
|
40
|
-
contracts: [{
|
|
41
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
42
|
-
ref: 'LevyContract'
|
|
43
|
-
}],
|
|
44
|
-
levies: [{
|
|
45
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
46
|
-
ref: 'Levy'
|
|
47
|
-
}],
|
|
48
|
-
invoices: [{
|
|
49
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
50
|
-
ref: 'Invoice'
|
|
51
|
-
}],
|
|
52
|
-
paymentHistory: [{
|
|
53
|
-
paymentDate: {
|
|
54
|
-
type: Date,
|
|
55
|
-
required: true
|
|
56
|
-
},
|
|
57
|
-
amount: {
|
|
58
|
-
type: Number,
|
|
59
|
-
required: true
|
|
60
|
-
},
|
|
61
|
-
paymentMethod: {
|
|
62
|
-
type: String
|
|
63
|
-
},
|
|
64
|
-
transactionId: {
|
|
65
|
-
type: String
|
|
66
|
-
}
|
|
67
|
-
}],
|
|
68
|
-
status: {
|
|
69
|
-
type: String,
|
|
70
|
-
enum: ['Active', 'Inactive'],
|
|
71
|
-
default: 'Active'
|
|
72
|
-
},
|
|
73
|
-
registrationDate: {
|
|
74
|
-
type: Date,
|
|
75
|
-
default: Date.now
|
|
76
|
-
},
|
|
77
|
-
paymentFrequency: {
|
|
78
|
-
type: String,
|
|
79
|
-
enum: ['Monthly', 'Quarterly', 'Annually']
|
|
80
|
-
},
|
|
81
|
-
notificationPreferences: {
|
|
82
|
-
email: {
|
|
83
|
-
type: Boolean,
|
|
84
|
-
default: true
|
|
85
|
-
},
|
|
86
|
-
sms: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: true
|
|
89
|
-
},
|
|
90
|
-
push: {
|
|
91
|
-
type: Boolean,
|
|
92
|
-
default: true
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
reminders: [{
|
|
96
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
97
|
-
ref: 'Reminder'
|
|
98
|
-
}],
|
|
99
|
-
notifications: [{
|
|
100
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
101
|
-
ref: 'Notification'
|
|
102
|
-
}],
|
|
103
|
-
penalties: [{
|
|
104
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
105
|
-
ref: 'Penalty'
|
|
106
|
-
}],
|
|
107
|
-
penaltyStatus: {
|
|
108
|
-
type: String,
|
|
109
|
-
enum: ['Pending', 'Paid', 'Waived'],
|
|
110
|
-
default: 'Pending'
|
|
111
|
-
},
|
|
112
|
-
notes: {
|
|
113
|
-
type: String
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
timestamps: true
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const Resident = mongoose.model('Resident', residentSchema);
|
|
120
|
-
|
|
121
|
-
module.exports = Resident;
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Resident
|
|
4
|
+
const residentSchema = new mongoose.Schema({
|
|
5
|
+
residentId: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
unique: true
|
|
9
|
+
},
|
|
10
|
+
name: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
email: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
phone: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
nationalId: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
unitId: {
|
|
27
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
28
|
+
ref: 'Unit',
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
unitName: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true
|
|
34
|
+
},
|
|
35
|
+
facilityId: {
|
|
36
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
+
ref: 'Facility',
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
contracts: [{
|
|
41
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
42
|
+
ref: 'LevyContract'
|
|
43
|
+
}],
|
|
44
|
+
levies: [{
|
|
45
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
46
|
+
ref: 'Levy'
|
|
47
|
+
}],
|
|
48
|
+
invoices: [{
|
|
49
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
50
|
+
ref: 'Invoice'
|
|
51
|
+
}],
|
|
52
|
+
paymentHistory: [{
|
|
53
|
+
paymentDate: {
|
|
54
|
+
type: Date,
|
|
55
|
+
required: true
|
|
56
|
+
},
|
|
57
|
+
amount: {
|
|
58
|
+
type: Number,
|
|
59
|
+
required: true
|
|
60
|
+
},
|
|
61
|
+
paymentMethod: {
|
|
62
|
+
type: String
|
|
63
|
+
},
|
|
64
|
+
transactionId: {
|
|
65
|
+
type: String
|
|
66
|
+
}
|
|
67
|
+
}],
|
|
68
|
+
status: {
|
|
69
|
+
type: String,
|
|
70
|
+
enum: ['Active', 'Inactive'],
|
|
71
|
+
default: 'Active'
|
|
72
|
+
},
|
|
73
|
+
registrationDate: {
|
|
74
|
+
type: Date,
|
|
75
|
+
default: Date.now
|
|
76
|
+
},
|
|
77
|
+
paymentFrequency: {
|
|
78
|
+
type: String,
|
|
79
|
+
enum: ['Monthly', 'Quarterly', 'Annually']
|
|
80
|
+
},
|
|
81
|
+
notificationPreferences: {
|
|
82
|
+
email: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: true
|
|
85
|
+
},
|
|
86
|
+
sms: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: true
|
|
89
|
+
},
|
|
90
|
+
push: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
reminders: [{
|
|
96
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
97
|
+
ref: 'Reminder'
|
|
98
|
+
}],
|
|
99
|
+
notifications: [{
|
|
100
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
101
|
+
ref: 'Notification'
|
|
102
|
+
}],
|
|
103
|
+
penalties: [{
|
|
104
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
105
|
+
ref: 'Penalty'
|
|
106
|
+
}],
|
|
107
|
+
penaltyStatus: {
|
|
108
|
+
type: String,
|
|
109
|
+
enum: ['Pending', 'Paid', 'Waived'],
|
|
110
|
+
default: 'Pending'
|
|
111
|
+
},
|
|
112
|
+
notes: {
|
|
113
|
+
type: String
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
timestamps: true
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const Resident = mongoose.model('Resident', residentSchema);
|
|
120
|
+
|
|
121
|
+
module.exports = Resident;
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
const rfqDetailsSchema = new mongoose.Schema({
|
|
4
|
-
facilityId: {
|
|
5
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
-
ref: 'Facility',
|
|
7
|
-
required: true,
|
|
8
|
-
index: true,
|
|
9
|
-
},
|
|
10
|
-
name: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: true,
|
|
13
|
-
trim: true,
|
|
14
|
-
index: true,
|
|
15
|
-
},
|
|
16
|
-
rfqNumber: {
|
|
17
|
-
type: String,
|
|
18
|
-
required: true,
|
|
19
|
-
unique: true,
|
|
20
|
-
trim: true,
|
|
21
|
-
index: true,
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
startDate: {
|
|
25
|
-
type: Date,
|
|
26
|
-
required: true,
|
|
27
|
-
},
|
|
28
|
-
closingDate: {
|
|
29
|
-
type: Date,
|
|
30
|
-
required: true,
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
currency: {
|
|
34
|
-
type: String,
|
|
35
|
-
required: true,
|
|
36
|
-
enum: ['KES', 'USD', 'EUR', 'GBP'],
|
|
37
|
-
default: 'KES',
|
|
38
|
-
},
|
|
39
|
-
rfqType: {
|
|
40
|
-
type: String,
|
|
41
|
-
required: true,
|
|
42
|
-
enum: ['open', 'closed'],
|
|
43
|
-
default: 'closed',
|
|
44
|
-
},
|
|
45
|
-
rfqFee: {
|
|
46
|
-
type: Number,
|
|
47
|
-
default: 0,
|
|
48
|
-
},
|
|
49
|
-
rfqEvaluationType: {
|
|
50
|
-
type: String,
|
|
51
|
-
required: true,
|
|
52
|
-
enum: ['automatic', 'approvers'],
|
|
53
|
-
default: 'automatic',
|
|
54
|
-
},
|
|
55
|
-
notes: {
|
|
56
|
-
type: String,
|
|
57
|
-
trim: true,
|
|
58
|
-
},
|
|
59
|
-
category: {
|
|
60
|
-
type: String,
|
|
61
|
-
trim: true,
|
|
62
|
-
},
|
|
63
|
-
status: {
|
|
64
|
-
type: String,
|
|
65
|
-
enum: ['Pending', 'Active', 'Closed'],
|
|
66
|
-
default: 'Pending',
|
|
67
|
-
trim: true,
|
|
68
|
-
},
|
|
69
|
-
suppliers: [{
|
|
70
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
71
|
-
ref: 'Supplier',
|
|
72
|
-
}],
|
|
73
|
-
items: [{
|
|
74
|
-
itemName: { type: String, required: true, trim: true },
|
|
75
|
-
description: { type: String, trim: true },
|
|
76
|
-
quantity: { type: Number, required: true, min: 1 },
|
|
77
|
-
unitOfMeasure: { type: String, trim: true },
|
|
78
|
-
specifications: { type: String, trim: true },
|
|
79
|
-
}],
|
|
80
|
-
|
|
81
|
-
}, {
|
|
82
|
-
timestamps: true,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const RFQDetails = mongoose.model('RFQDetails', rfqDetailsSchema);
|
|
86
|
-
|
|
87
|
-
module.exports = RFQDetails;
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const rfqDetailsSchema = new mongoose.Schema({
|
|
4
|
+
facilityId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Facility',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true,
|
|
9
|
+
},
|
|
10
|
+
name: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
trim: true,
|
|
14
|
+
index: true,
|
|
15
|
+
},
|
|
16
|
+
rfqNumber: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
unique: true,
|
|
20
|
+
trim: true,
|
|
21
|
+
index: true,
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
startDate: {
|
|
25
|
+
type: Date,
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
closingDate: {
|
|
29
|
+
type: Date,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
currency: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
enum: ['KES', 'USD', 'EUR', 'GBP'],
|
|
37
|
+
default: 'KES',
|
|
38
|
+
},
|
|
39
|
+
rfqType: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: true,
|
|
42
|
+
enum: ['open', 'closed'],
|
|
43
|
+
default: 'closed',
|
|
44
|
+
},
|
|
45
|
+
rfqFee: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 0,
|
|
48
|
+
},
|
|
49
|
+
rfqEvaluationType: {
|
|
50
|
+
type: String,
|
|
51
|
+
required: true,
|
|
52
|
+
enum: ['automatic', 'approvers'],
|
|
53
|
+
default: 'automatic',
|
|
54
|
+
},
|
|
55
|
+
notes: {
|
|
56
|
+
type: String,
|
|
57
|
+
trim: true,
|
|
58
|
+
},
|
|
59
|
+
category: {
|
|
60
|
+
type: String,
|
|
61
|
+
trim: true,
|
|
62
|
+
},
|
|
63
|
+
status: {
|
|
64
|
+
type: String,
|
|
65
|
+
enum: ['Pending', 'Active', 'Closed'],
|
|
66
|
+
default: 'Pending',
|
|
67
|
+
trim: true,
|
|
68
|
+
},
|
|
69
|
+
suppliers: [{
|
|
70
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
71
|
+
ref: 'Supplier',
|
|
72
|
+
}],
|
|
73
|
+
items: [{
|
|
74
|
+
itemName: { type: String, required: true, trim: true },
|
|
75
|
+
description: { type: String, trim: true },
|
|
76
|
+
quantity: { type: Number, required: true, min: 1 },
|
|
77
|
+
unitOfMeasure: { type: String, trim: true },
|
|
78
|
+
specifications: { type: String, trim: true },
|
|
79
|
+
}],
|
|
80
|
+
|
|
81
|
+
}, {
|
|
82
|
+
timestamps: true,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const RFQDetails = mongoose.model('RFQDetails', rfqDetailsSchema);
|
|
86
|
+
|
|
87
|
+
module.exports = RFQDetails;
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
const rfqResponseSchema = new mongoose.Schema({
|
|
4
|
-
facilityId: {
|
|
5
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
-
ref: 'Facility',
|
|
7
|
-
required: true,
|
|
8
|
-
index: true,
|
|
9
|
-
},
|
|
10
|
-
rfqId: {
|
|
11
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
-
ref: 'RFQDetails',
|
|
13
|
-
required: true,
|
|
14
|
-
unique: true,
|
|
15
|
-
index: true,
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
// track each supplier’s progress & quotation
|
|
19
|
-
suppliers: [{
|
|
20
|
-
supplierId: {
|
|
21
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
-
ref: 'Supplier',
|
|
23
|
-
required: true,
|
|
24
|
-
},
|
|
25
|
-
invitationStatus: {
|
|
26
|
-
type: String,
|
|
27
|
-
enum: ['pending', 'accepted', 'declined', 'no-response'],
|
|
28
|
-
default: 'pending',
|
|
29
|
-
},
|
|
30
|
-
invitationDate: {
|
|
31
|
-
type: Date,
|
|
32
|
-
default: Date.now,
|
|
33
|
-
},
|
|
34
|
-
responseDate: Date,
|
|
35
|
-
quotationSubmitted: {
|
|
36
|
-
type: Boolean,
|
|
37
|
-
default: false,
|
|
38
|
-
},
|
|
39
|
-
quotationDetails: {
|
|
40
|
-
submissionDate: Date,
|
|
41
|
-
totalAmount: Number,
|
|
42
|
-
items: [{
|
|
43
|
-
// tie back to the Details’ item index or category
|
|
44
|
-
categoryId: { type: mongoose.Schema.Types.ObjectId, required: true },
|
|
45
|
-
itemId: { type: mongoose.Schema.Types.ObjectId, required: true },
|
|
46
|
-
unitPrice: { type: Number, required: true },
|
|
47
|
-
quantity: { type: Number, required: true },
|
|
48
|
-
totalPrice: { type: Number, required: true },
|
|
49
|
-
notes: { type: String, trim: true },
|
|
50
|
-
}],
|
|
51
|
-
attachments: [{
|
|
52
|
-
name: { type: String, required: true },
|
|
53
|
-
fileType: { type: String, required: true },
|
|
54
|
-
filePath: { type: String, required: true },
|
|
55
|
-
uploadDate: { type: Date, default: Date.now },
|
|
56
|
-
}],
|
|
57
|
-
notes: { type: String, trim: true },
|
|
58
|
-
},
|
|
59
|
-
evaluationScore: { type: Number, min: 0, max: 100 },
|
|
60
|
-
evaluationNotes: { type: String, trim: true },
|
|
61
|
-
}],
|
|
62
|
-
|
|
63
|
-
// overall lifecycle & award
|
|
64
|
-
status: {
|
|
65
|
-
type: String,
|
|
66
|
-
enum: ['open', 'closed', 'awarded', 'canceled'],
|
|
67
|
-
default: 'open',
|
|
68
|
-
index: true,
|
|
69
|
-
},
|
|
70
|
-
awardDetails: {
|
|
71
|
-
awarded: {
|
|
72
|
-
type: Boolean,
|
|
73
|
-
default: false,
|
|
74
|
-
},
|
|
75
|
-
awardedSupplierId: {
|
|
76
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
77
|
-
ref: 'Supplier',
|
|
78
|
-
},
|
|
79
|
-
awardedSupplierName: {
|
|
80
|
-
type: String,
|
|
81
|
-
trim: true,
|
|
82
|
-
},
|
|
83
|
-
awardDate: Date,
|
|
84
|
-
awardNotes: { type: String, trim: true },
|
|
85
|
-
|
|
86
|
-
purchaseOrderCreated: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: false,
|
|
89
|
-
},
|
|
90
|
-
purchaseOrderId: {
|
|
91
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
92
|
-
ref: 'PurchaseOrder',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
}, {
|
|
97
|
-
timestamps: true,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// participation rate virtual
|
|
101
|
-
rfqResponseSchema.virtual('participationRate').get(function () {
|
|
102
|
-
if (!this.suppliers.length) return 0;
|
|
103
|
-
const responded = this.suppliers.filter(s => s.quotationSubmitted).length;
|
|
104
|
-
return (responded / this.suppliers.length) * 100;
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
const RFQResponse = mongoose.model('RFQResponse', rfqResponseSchema);
|
|
108
|
-
|
|
109
|
-
module.exports = RFQResponse;
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const rfqResponseSchema = new mongoose.Schema({
|
|
4
|
+
facilityId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Facility',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true,
|
|
9
|
+
},
|
|
10
|
+
rfqId: {
|
|
11
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'RFQDetails',
|
|
13
|
+
required: true,
|
|
14
|
+
unique: true,
|
|
15
|
+
index: true,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
// track each supplier’s progress & quotation
|
|
19
|
+
suppliers: [{
|
|
20
|
+
supplierId: {
|
|
21
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
+
ref: 'Supplier',
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
invitationStatus: {
|
|
26
|
+
type: String,
|
|
27
|
+
enum: ['pending', 'accepted', 'declined', 'no-response'],
|
|
28
|
+
default: 'pending',
|
|
29
|
+
},
|
|
30
|
+
invitationDate: {
|
|
31
|
+
type: Date,
|
|
32
|
+
default: Date.now,
|
|
33
|
+
},
|
|
34
|
+
responseDate: Date,
|
|
35
|
+
quotationSubmitted: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
quotationDetails: {
|
|
40
|
+
submissionDate: Date,
|
|
41
|
+
totalAmount: Number,
|
|
42
|
+
items: [{
|
|
43
|
+
// tie back to the Details’ item index or category
|
|
44
|
+
categoryId: { type: mongoose.Schema.Types.ObjectId, required: true },
|
|
45
|
+
itemId: { type: mongoose.Schema.Types.ObjectId, required: true },
|
|
46
|
+
unitPrice: { type: Number, required: true },
|
|
47
|
+
quantity: { type: Number, required: true },
|
|
48
|
+
totalPrice: { type: Number, required: true },
|
|
49
|
+
notes: { type: String, trim: true },
|
|
50
|
+
}],
|
|
51
|
+
attachments: [{
|
|
52
|
+
name: { type: String, required: true },
|
|
53
|
+
fileType: { type: String, required: true },
|
|
54
|
+
filePath: { type: String, required: true },
|
|
55
|
+
uploadDate: { type: Date, default: Date.now },
|
|
56
|
+
}],
|
|
57
|
+
notes: { type: String, trim: true },
|
|
58
|
+
},
|
|
59
|
+
evaluationScore: { type: Number, min: 0, max: 100 },
|
|
60
|
+
evaluationNotes: { type: String, trim: true },
|
|
61
|
+
}],
|
|
62
|
+
|
|
63
|
+
// overall lifecycle & award
|
|
64
|
+
status: {
|
|
65
|
+
type: String,
|
|
66
|
+
enum: ['open', 'closed', 'awarded', 'canceled'],
|
|
67
|
+
default: 'open',
|
|
68
|
+
index: true,
|
|
69
|
+
},
|
|
70
|
+
awardDetails: {
|
|
71
|
+
awarded: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false,
|
|
74
|
+
},
|
|
75
|
+
awardedSupplierId: {
|
|
76
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
77
|
+
ref: 'Supplier',
|
|
78
|
+
},
|
|
79
|
+
awardedSupplierName: {
|
|
80
|
+
type: String,
|
|
81
|
+
trim: true,
|
|
82
|
+
},
|
|
83
|
+
awardDate: Date,
|
|
84
|
+
awardNotes: { type: String, trim: true },
|
|
85
|
+
|
|
86
|
+
purchaseOrderCreated: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
},
|
|
90
|
+
purchaseOrderId: {
|
|
91
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
92
|
+
ref: 'PurchaseOrder',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
}, {
|
|
97
|
+
timestamps: true,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// participation rate virtual
|
|
101
|
+
rfqResponseSchema.virtual('participationRate').get(function () {
|
|
102
|
+
if (!this.suppliers.length) return 0;
|
|
103
|
+
const responded = this.suppliers.filter(s => s.quotationSubmitted).length;
|
|
104
|
+
return (responded / this.suppliers.length) * 100;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const RFQResponse = mongoose.model('RFQResponse', rfqResponseSchema);
|
|
108
|
+
|
|
109
|
+
module.exports = RFQResponse;
|