payservedb 4.6.6 → 4.6.9
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 +12 -1
- package/package.json +1 -1
- package/src/models/bookinganalytics.js +64 -0
- package/src/models/bookingconfig.js +46 -0
- package/src/models/bookingproperty.js +113 -0
- package/src/models/bookingreservation.js +193 -0
- package/src/models/bookingrevenuerecord.js +85 -0
- package/src/models/common_area_electricity.js +41 -0
- package/src/models/common_area_generator.js +38 -0
- package/src/models/common_area_water.js +39 -0
- package/src/models/dutyroster.js +15 -3
- package/src/models/water_meter_daily_history.js +32 -0
- package/src/models/water_meter_monthly_history.js +38 -0
- package/src/models/water_meter_single_day_history.js +32 -0
- package/src/models/water_meters.js +2 -12
package/index.js
CHANGED
|
@@ -127,6 +127,9 @@ const models = {
|
|
|
127
127
|
DefaultPaymentDetails: require('./src/models/default_payment_details'),
|
|
128
128
|
Currency: require('./src/models/currency_settings'),
|
|
129
129
|
WaterMeterAccount: require('./src/models/water_meter_account'),
|
|
130
|
+
SingleDayWaterMeterHistory: require('./src/models/water_meter_single_day_history'),
|
|
131
|
+
DailyWaterMeterHistory: require('./src/models/water_meter_daily_history'),
|
|
132
|
+
MonthlyWaterMeterHistory: require('./src/models/water_meter_monthly_history'),
|
|
130
133
|
CashPayment: require('./src/models/cashpayment'),
|
|
131
134
|
VasPayment: require('./src/models/vas_payments'),
|
|
132
135
|
VasInvoicesQuickBooks: require('./src/models/vas_invoices_upload'),
|
|
@@ -137,7 +140,15 @@ const models = {
|
|
|
137
140
|
Supplier: require('./src/models/suppliers'),
|
|
138
141
|
PurchaseRequest: require('./src/models/purchase_request'),
|
|
139
142
|
PurchaseOrder: require('./src/models/purchase_order'),
|
|
140
|
-
RFQ: require('./src/models/quotation')
|
|
143
|
+
RFQ: require('./src/models/quotation'),
|
|
144
|
+
CommonAreaElectricityReading: require('./src/models/common_area_electricity'),
|
|
145
|
+
CommonAreaWaterReading: require('./src/models/common_area_water'),
|
|
146
|
+
CommonAreaGeneratorReading: require('./src/models/common_area_generator'),
|
|
147
|
+
BookingProperty: require('./src/models/bookingproperty'),
|
|
148
|
+
BookingReservation: require('./src/models/bookingreservation'),
|
|
149
|
+
BookingConfig: require('./src/models/bookingconfig'),
|
|
150
|
+
BookingAnalytics: require('./src/models/bookinganalytics'),
|
|
151
|
+
RevenueRecord: require('./src/models/bookingrevenuerecord')
|
|
141
152
|
|
|
142
153
|
};
|
|
143
154
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define schema for Booking Analytics
|
|
4
|
+
const bookingAnalyticsSchema = new mongoose.Schema({
|
|
5
|
+
facilityId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: 'Facility',
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
date: {
|
|
11
|
+
type: Date,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
metrics: {
|
|
15
|
+
totalBookings: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: 0
|
|
18
|
+
},
|
|
19
|
+
totalRevenue: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default: 0
|
|
22
|
+
},
|
|
23
|
+
pmCommission: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 0
|
|
26
|
+
},
|
|
27
|
+
landlordRevenue: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 0
|
|
30
|
+
},
|
|
31
|
+
occupancyRate: {
|
|
32
|
+
type: Number,
|
|
33
|
+
default: 0
|
|
34
|
+
},
|
|
35
|
+
averageDailyRate: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 0
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
bookingsByStatus: {
|
|
41
|
+
new: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 0
|
|
44
|
+
},
|
|
45
|
+
confirmed: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 0
|
|
48
|
+
},
|
|
49
|
+
cancelled: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 0
|
|
52
|
+
},
|
|
53
|
+
completed: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 0
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
timestamps: true
|
|
60
|
+
});
|
|
61
|
+
// Create model from schema
|
|
62
|
+
const BookingAnalytics = mongoose.model('BookingAnalytics', bookingAnalyticsSchema);
|
|
63
|
+
|
|
64
|
+
module.exports = BookingAnalytics;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define schema for API Configuration (for Booking.com integration if needed)
|
|
4
|
+
const bookingConfigSchema = new mongoose.Schema({
|
|
5
|
+
facilityId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: 'Facility',
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
apiKey: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: false
|
|
13
|
+
},
|
|
14
|
+
apiSecret: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: false
|
|
17
|
+
},
|
|
18
|
+
isEnabled: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: false
|
|
21
|
+
},
|
|
22
|
+
lastConnected: {
|
|
23
|
+
type: Date
|
|
24
|
+
},
|
|
25
|
+
settings: {
|
|
26
|
+
autoAcceptBookings: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
syncCalendar: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: true
|
|
33
|
+
},
|
|
34
|
+
defaultCommission: {
|
|
35
|
+
type: Number,
|
|
36
|
+
default: 10
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
timestamps: true
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Create model from schema
|
|
44
|
+
const BookingConfig = mongoose.model('BookingConfig', bookingConfigSchema);
|
|
45
|
+
|
|
46
|
+
module.exports = BookingConfig;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Booking Properties (listing configuration)
|
|
4
|
+
const bookingPropertySchema = new mongoose.Schema({
|
|
5
|
+
facilityId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: 'Facility',
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
unitId: {
|
|
11
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'Unit',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
division: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: false
|
|
18
|
+
},
|
|
19
|
+
description: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: false
|
|
22
|
+
},
|
|
23
|
+
amenities: [{
|
|
24
|
+
type: String
|
|
25
|
+
}],
|
|
26
|
+
basePrice: {
|
|
27
|
+
type: Number,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
currencyId: {
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
32
|
+
ref: 'Currency',
|
|
33
|
+
required: true
|
|
34
|
+
},
|
|
35
|
+
weekendPriceAdjustment: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 0
|
|
38
|
+
},
|
|
39
|
+
minimumStay: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 1
|
|
42
|
+
},
|
|
43
|
+
maximumStay: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: 30
|
|
46
|
+
},
|
|
47
|
+
advanceBookingDays: {
|
|
48
|
+
type: Number,
|
|
49
|
+
default: 0
|
|
50
|
+
},
|
|
51
|
+
cancellationPolicy: {
|
|
52
|
+
type: String,
|
|
53
|
+
enum: ['Flexible', 'Moderate', 'Strict'],
|
|
54
|
+
default: 'Moderate'
|
|
55
|
+
},
|
|
56
|
+
isListed: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
commission: {
|
|
61
|
+
type: Number,
|
|
62
|
+
required: true,
|
|
63
|
+
default: 10 // Default commission percentage
|
|
64
|
+
},
|
|
65
|
+
blockedDates: [{
|
|
66
|
+
startDate: {
|
|
67
|
+
type: Date,
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
endDate: {
|
|
71
|
+
type: Date,
|
|
72
|
+
required: true
|
|
73
|
+
},
|
|
74
|
+
reason: {
|
|
75
|
+
type: String,
|
|
76
|
+
enum: ['Reservation', 'Renovation', 'Owner Use'],
|
|
77
|
+
required: true
|
|
78
|
+
},
|
|
79
|
+
notes: {
|
|
80
|
+
type: String
|
|
81
|
+
}
|
|
82
|
+
}],
|
|
83
|
+
// For seasonal pricing or custom date ranges
|
|
84
|
+
specialPricing: [{
|
|
85
|
+
startDate: {
|
|
86
|
+
type: Date,
|
|
87
|
+
required: true
|
|
88
|
+
},
|
|
89
|
+
endDate: {
|
|
90
|
+
type: Date,
|
|
91
|
+
required: true
|
|
92
|
+
},
|
|
93
|
+
price: {
|
|
94
|
+
type: Number,
|
|
95
|
+
required: true
|
|
96
|
+
},
|
|
97
|
+
name: {
|
|
98
|
+
type: String
|
|
99
|
+
}
|
|
100
|
+
}],
|
|
101
|
+
status: {
|
|
102
|
+
type: String,
|
|
103
|
+
enum: ['Active', 'Inactive', 'Pending Approval'],
|
|
104
|
+
default: 'Active'
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
timestamps: true
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Create model from schema
|
|
111
|
+
const BookingProperty = mongoose.model('BookingProperty', bookingPropertySchema);
|
|
112
|
+
|
|
113
|
+
module.exports = BookingProperty;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Booking Reservations
|
|
4
|
+
const bookingReservationSchema = new mongoose.Schema({
|
|
5
|
+
checkOutActual: {
|
|
6
|
+
type: Date
|
|
7
|
+
},
|
|
8
|
+
// Field for checkout notes
|
|
9
|
+
checkoutNotes: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: ''
|
|
12
|
+
},
|
|
13
|
+
// Field for the final amount paid (may differ from original totalAmount)
|
|
14
|
+
finalAmount: {
|
|
15
|
+
type: Number
|
|
16
|
+
},
|
|
17
|
+
// Field for additional charges at checkout
|
|
18
|
+
additionalCheckoutCharges: [{
|
|
19
|
+
description: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
amount: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
reason: {
|
|
28
|
+
type: String
|
|
29
|
+
},
|
|
30
|
+
addedAt: {
|
|
31
|
+
type: Date,
|
|
32
|
+
default: Date.now
|
|
33
|
+
}
|
|
34
|
+
}],
|
|
35
|
+
// Field to track if this reservation has been included in revenue calculations
|
|
36
|
+
revenueProcessed: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
// Field to store the checkout date
|
|
41
|
+
checkoutDate: {
|
|
42
|
+
type: Date
|
|
43
|
+
},
|
|
44
|
+
facilityId: {
|
|
45
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
46
|
+
ref: 'Facility',
|
|
47
|
+
required: true
|
|
48
|
+
},
|
|
49
|
+
bookingPropertyId: {
|
|
50
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
51
|
+
ref: 'BookingProperty',
|
|
52
|
+
required: true
|
|
53
|
+
},
|
|
54
|
+
unitId: {
|
|
55
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
56
|
+
ref: 'Unit',
|
|
57
|
+
required: true
|
|
58
|
+
},
|
|
59
|
+
bookingReservationId: {
|
|
60
|
+
type: String,
|
|
61
|
+
required: true,
|
|
62
|
+
unique: true
|
|
63
|
+
},
|
|
64
|
+
guestInfo: {
|
|
65
|
+
name: {
|
|
66
|
+
type: String,
|
|
67
|
+
required: true
|
|
68
|
+
},
|
|
69
|
+
email: {
|
|
70
|
+
type: String,
|
|
71
|
+
required: true
|
|
72
|
+
},
|
|
73
|
+
phone: {
|
|
74
|
+
type: String,
|
|
75
|
+
required: true
|
|
76
|
+
},
|
|
77
|
+
idNumber: {
|
|
78
|
+
type: String,
|
|
79
|
+
required: true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
checkIn: {
|
|
83
|
+
type: Date,
|
|
84
|
+
required: true
|
|
85
|
+
},
|
|
86
|
+
checkOut: {
|
|
87
|
+
type: Date,
|
|
88
|
+
required: true
|
|
89
|
+
},
|
|
90
|
+
guests: {
|
|
91
|
+
adults: {
|
|
92
|
+
type: Number,
|
|
93
|
+
default: 1
|
|
94
|
+
},
|
|
95
|
+
children: {
|
|
96
|
+
type: Number,
|
|
97
|
+
default: 0
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
basePrice: {
|
|
101
|
+
type: Number,
|
|
102
|
+
required: true
|
|
103
|
+
},
|
|
104
|
+
totalAmount: {
|
|
105
|
+
type: Number,
|
|
106
|
+
required: true
|
|
107
|
+
},
|
|
108
|
+
commission: {
|
|
109
|
+
type: Number,
|
|
110
|
+
required: true
|
|
111
|
+
},
|
|
112
|
+
landlordAmount: {
|
|
113
|
+
type: Number,
|
|
114
|
+
required: true
|
|
115
|
+
},
|
|
116
|
+
currencyId: {
|
|
117
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
118
|
+
ref: 'Currency',
|
|
119
|
+
required: true
|
|
120
|
+
},
|
|
121
|
+
paymentMethod: {
|
|
122
|
+
type: String,
|
|
123
|
+
enum: ['Cash', 'Card', 'Bank Transfer', 'Mobile Money', 'Other'],
|
|
124
|
+
required: true
|
|
125
|
+
},
|
|
126
|
+
paymentTiming: {
|
|
127
|
+
type: String,
|
|
128
|
+
enum: ['Before', 'After', 'Split'],
|
|
129
|
+
default: 'Before'
|
|
130
|
+
},
|
|
131
|
+
invoiceId: {
|
|
132
|
+
type: String
|
|
133
|
+
},
|
|
134
|
+
// For additional services
|
|
135
|
+
additionalServices: [{
|
|
136
|
+
serviceId: {
|
|
137
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
138
|
+
ref: 'ValueAddedService'
|
|
139
|
+
},
|
|
140
|
+
serviceName: {
|
|
141
|
+
type: String,
|
|
142
|
+
required: true
|
|
143
|
+
},
|
|
144
|
+
quantity: {
|
|
145
|
+
type: Number,
|
|
146
|
+
default: 1
|
|
147
|
+
},
|
|
148
|
+
price: {
|
|
149
|
+
type: Number,
|
|
150
|
+
required: true
|
|
151
|
+
}
|
|
152
|
+
}],
|
|
153
|
+
specialRequests: {
|
|
154
|
+
type: String
|
|
155
|
+
},
|
|
156
|
+
status: {
|
|
157
|
+
type: String,
|
|
158
|
+
enum: ['new', 'confirmed', 'cancelled', 'completed'],
|
|
159
|
+
default: 'new'
|
|
160
|
+
},
|
|
161
|
+
statusHistory: [{
|
|
162
|
+
status: {
|
|
163
|
+
type: String,
|
|
164
|
+
enum: ['new', 'confirmed', 'cancelled', 'completed'],
|
|
165
|
+
required: true
|
|
166
|
+
},
|
|
167
|
+
timestamp: {
|
|
168
|
+
type: Date,
|
|
169
|
+
default: Date.now
|
|
170
|
+
},
|
|
171
|
+
updatedBy: mongoose.Schema.Types.ObjectId
|
|
172
|
+
}],
|
|
173
|
+
cancellationDetails: {
|
|
174
|
+
date: Date,
|
|
175
|
+
reason: String,
|
|
176
|
+
refundAmount: Number
|
|
177
|
+
},
|
|
178
|
+
createdBy: {
|
|
179
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
180
|
+
ref: 'User',
|
|
181
|
+
},
|
|
182
|
+
updatedBy: {
|
|
183
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
184
|
+
ref: 'User'
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
timestamps: true
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Create model from schema
|
|
191
|
+
const BookingReservation = mongoose.model('BookingReservation', bookingReservationSchema);
|
|
192
|
+
|
|
193
|
+
module.exports = BookingReservation;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Revenue Records
|
|
4
|
+
const revenueRecordSchema = new mongoose.Schema({
|
|
5
|
+
facilityId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
ref: 'Facility',
|
|
8
|
+
required: true,
|
|
9
|
+
index: true
|
|
10
|
+
},
|
|
11
|
+
reservationId: {
|
|
12
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'BookingReservation',
|
|
14
|
+
required: true,
|
|
15
|
+
index: true
|
|
16
|
+
},
|
|
17
|
+
bookingPropertyId: {
|
|
18
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
19
|
+
ref: 'BookingProperty',
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
unitId: {
|
|
23
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
24
|
+
ref: 'Unit',
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
checkoutDate: {
|
|
28
|
+
type: Date,
|
|
29
|
+
required: true,
|
|
30
|
+
index: true
|
|
31
|
+
},
|
|
32
|
+
baseAmount: {
|
|
33
|
+
type: Number,
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
finalAmount: {
|
|
37
|
+
type: Number,
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
additionalChargesAmount: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 0
|
|
43
|
+
},
|
|
44
|
+
currencyId: {
|
|
45
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
46
|
+
ref: 'Currency',
|
|
47
|
+
required: true
|
|
48
|
+
},
|
|
49
|
+
// For easier querying and aggregation
|
|
50
|
+
month: {
|
|
51
|
+
type: Number, // 1-12
|
|
52
|
+
required: true,
|
|
53
|
+
index: true
|
|
54
|
+
},
|
|
55
|
+
year: {
|
|
56
|
+
type: Number,
|
|
57
|
+
required: true,
|
|
58
|
+
index: true
|
|
59
|
+
},
|
|
60
|
+
quarter: {
|
|
61
|
+
type: Number, // 1-4
|
|
62
|
+
required: true,
|
|
63
|
+
index: true
|
|
64
|
+
},
|
|
65
|
+
bookingDuration: {
|
|
66
|
+
type: Number, // Number of days
|
|
67
|
+
default: 0
|
|
68
|
+
},
|
|
69
|
+
createdAt: {
|
|
70
|
+
type: Date,
|
|
71
|
+
default: Date.now
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
// Enable timestamps
|
|
75
|
+
timestamps: true
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Create compound indices for efficient querying
|
|
79
|
+
revenueRecordSchema.index({ facilityId: 1, year: 1, month: 1 });
|
|
80
|
+
revenueRecordSchema.index({ facilityId: 1, year: 1, quarter: 1 });
|
|
81
|
+
|
|
82
|
+
// Create model from schema
|
|
83
|
+
const RevenueRecord = mongoose.model('RevenueRecord', revenueRecordSchema);
|
|
84
|
+
|
|
85
|
+
module.exports = RevenueRecord;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const commonAreaElectricityReadingSchema = new mongoose.Schema({
|
|
4
|
+
facilityId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Facility',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
date: {
|
|
11
|
+
type: Date,
|
|
12
|
+
required: true,
|
|
13
|
+
default: Date.now
|
|
14
|
+
},
|
|
15
|
+
location: {
|
|
16
|
+
type: String,
|
|
17
|
+
enum: ['Common Area', 'Lift', 'Pumps'],
|
|
18
|
+
required: true,
|
|
19
|
+
trim: true
|
|
20
|
+
},
|
|
21
|
+
openingReadingKWh: {
|
|
22
|
+
type: Number,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
closingReadingKWh: {
|
|
26
|
+
type: Number,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
consumptionKWh: {
|
|
30
|
+
type: Number,
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
total: {
|
|
34
|
+
type: Number
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
timestamps: true
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const CommonAreaElectricityReading = mongoose.model('CommonAreaElectricityReading', commonAreaElectricityReadingSchema);
|
|
41
|
+
module.exports = CommonAreaElectricityReading;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const commonAreaGeneratorReadingSchema = new mongoose.Schema({
|
|
4
|
+
facilityId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Facility',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
date: {
|
|
11
|
+
type: Date,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
openingReadingHrs: {
|
|
15
|
+
type: Number,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
closingReadingHrs: {
|
|
19
|
+
type: Number,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
totalHrsRun: {
|
|
23
|
+
type: Number,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
fuelLevel: {
|
|
27
|
+
type: String,
|
|
28
|
+
trim: true
|
|
29
|
+
},
|
|
30
|
+
refillAmountLiters: {
|
|
31
|
+
type: Number
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
timestamps: true
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const CommonAreaGeneratorReading = mongoose.model('CommonAreaGeneratorReading', commonAreaGeneratorReadingSchema);
|
|
38
|
+
module.exports = CommonAreaGeneratorReading;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const commonAreaWaterReadingSchema = new mongoose.Schema({
|
|
4
|
+
facilityId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Facility',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
date: {
|
|
11
|
+
type: Date,
|
|
12
|
+
required: true,
|
|
13
|
+
default: Date.now
|
|
14
|
+
},
|
|
15
|
+
sourceType: {
|
|
16
|
+
type: String,
|
|
17
|
+
enum: ['City Council', 'Borehole'],
|
|
18
|
+
required: true,
|
|
19
|
+
trim: true
|
|
20
|
+
},
|
|
21
|
+
openingReadingM3: {
|
|
22
|
+
type: Number,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
closingReadingM3: {
|
|
26
|
+
type: Number,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
consumptionM3: {
|
|
30
|
+
type: Number,
|
|
31
|
+
required: true
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
timestamps: true
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const CommonAreaWaterReading = mongoose.model('CommonAreaWaterReading', commonAreaWaterReadingSchema);
|
|
38
|
+
module.exports = CommonAreaWaterReading;
|
|
39
|
+
|
package/src/models/dutyroster.js
CHANGED
|
@@ -3,7 +3,7 @@ const mongoose = require('mongoose');
|
|
|
3
3
|
const dutyRosterSchema = new mongoose.Schema({
|
|
4
4
|
facilityId: {
|
|
5
5
|
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
-
ref: 'Facility',
|
|
6
|
+
ref: 'Facility',
|
|
7
7
|
required: true,
|
|
8
8
|
},
|
|
9
9
|
name: {
|
|
@@ -18,10 +18,22 @@ const dutyRosterSchema = new mongoose.Schema({
|
|
|
18
18
|
type: String,
|
|
19
19
|
required: true,
|
|
20
20
|
},
|
|
21
|
-
|
|
22
|
-
type: String,
|
|
21
|
+
startTime: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
endTime: {
|
|
26
|
+
type: String,
|
|
23
27
|
required: true
|
|
24
28
|
},
|
|
29
|
+
approved: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
approvedBy: {
|
|
34
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
35
|
+
ref: 'User'
|
|
36
|
+
},
|
|
25
37
|
schedule: [{
|
|
26
38
|
date: {
|
|
27
39
|
type: Date,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const dailyWaterMeterHistorySchema = new mongoose.Schema({
|
|
4
|
+
meterId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'WaterMeter',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
date: {
|
|
11
|
+
type: Date,
|
|
12
|
+
required: true,
|
|
13
|
+
index: true
|
|
14
|
+
},
|
|
15
|
+
reading: {
|
|
16
|
+
type: Number,
|
|
17
|
+
required: true,
|
|
18
|
+
min: 0
|
|
19
|
+
},
|
|
20
|
+
timeStamps: {
|
|
21
|
+
type: [Date],
|
|
22
|
+
required: true
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
timestamps: true
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
dailyWaterMeterHistorySchema.index({ meterId: 1, date: 1 });
|
|
29
|
+
|
|
30
|
+
const DailyWaterMeterHistory = mongoose.model('DailyWaterMeterHistory', dailyWaterMeterHistorySchema);
|
|
31
|
+
|
|
32
|
+
module.exports = DailyWaterMeterHistory;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const monthlyWaterMeterHistorySchema = new mongoose.Schema({
|
|
4
|
+
meterId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'WaterMeter',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
yearMonth: {
|
|
11
|
+
type: Number,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
previousReading: {
|
|
15
|
+
type: Number,
|
|
16
|
+
required: true,
|
|
17
|
+
min: 0
|
|
18
|
+
},
|
|
19
|
+
currentReading: {
|
|
20
|
+
type: Number,
|
|
21
|
+
required: true,
|
|
22
|
+
min: 0
|
|
23
|
+
},
|
|
24
|
+
consumption: {
|
|
25
|
+
type: Number,
|
|
26
|
+
required: true,
|
|
27
|
+
min: 0,
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
timestamps: true
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
monthlyWaterMeterHistorySchema.index({ meterId: 1, yearMonth: 1 });
|
|
35
|
+
|
|
36
|
+
const MonthlyWaterMeterHistory = mongoose.model('MonthlyWaterMeterHistory', monthlyWaterMeterHistorySchema);
|
|
37
|
+
|
|
38
|
+
module.exports = MonthlyWaterMeterHistory;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const singleDayWaterMeterHistorySchema = new mongoose.Schema({
|
|
4
|
+
meterId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'WaterMeter',
|
|
7
|
+
required: true,
|
|
8
|
+
index: true
|
|
9
|
+
},
|
|
10
|
+
date: {
|
|
11
|
+
type: Date,
|
|
12
|
+
required: true,
|
|
13
|
+
index: true
|
|
14
|
+
},
|
|
15
|
+
reading: {
|
|
16
|
+
type: Number,
|
|
17
|
+
required: true,
|
|
18
|
+
min: 0
|
|
19
|
+
},
|
|
20
|
+
time: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
timestamps: true
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
singleDayWaterMeterHistorySchema.index({ meterId: 1, date: 1 });
|
|
29
|
+
|
|
30
|
+
const SingleDayWaterMeterHistory = mongoose.model('SingleDayWaterMeterHistory', singleDayWaterMeterHistorySchema);
|
|
31
|
+
|
|
32
|
+
module.exports = SingleDayWaterMeterHistory;
|
|
@@ -62,21 +62,11 @@ const waterMeterSchema = new mongoose.Schema({
|
|
|
62
62
|
type: Date,
|
|
63
63
|
default: Date.now
|
|
64
64
|
},
|
|
65
|
-
readingHistory: [{
|
|
66
|
-
previousReading: Number,
|
|
67
|
-
currentReading: Number,
|
|
68
|
-
readingDate: {
|
|
69
|
-
type: Date,
|
|
70
|
-
default: Date.now
|
|
71
|
-
},
|
|
72
|
-
readBy: String,
|
|
73
|
-
consumption: Number
|
|
74
|
-
}],
|
|
75
65
|
status: {
|
|
76
66
|
type: String,
|
|
77
67
|
required: true,
|
|
78
|
-
enum: ['
|
|
79
|
-
default: '
|
|
68
|
+
enum: ['Open', 'Closed', 'maintenance', 'faulty'],
|
|
69
|
+
default: 'Open',
|
|
80
70
|
},
|
|
81
71
|
customerType: {
|
|
82
72
|
type: String,
|