payservedb 6.1.5 → 6.1.7
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 +1 -1
- package/package.json +1 -1
- package/src/models/powerMeterSettings.js +139 -0
- package/src/models/powerMeters.js +14 -2
- package/src/models/user.js +2 -2
- package/src/models/powerMeterTariffs.js +0 -50
package/index.js
CHANGED
|
@@ -196,7 +196,7 @@ const models = {
|
|
|
196
196
|
PowerMeterSingleDayReading: require("./src/models/powerMeterSingleDayReading"),
|
|
197
197
|
PowerMeterManufacturer: require("./src/models/powerMetersManufacturer"),
|
|
198
198
|
PowerMeterMonthlyReading: require("./src/models/powerMeterMonthlyReading"),
|
|
199
|
-
|
|
199
|
+
PowerMeterSettings: require("./src/models/powerMeterSettings"),
|
|
200
200
|
};
|
|
201
201
|
|
|
202
202
|
// Function to get models dynamically from a specific database connection
|
package/package.json
CHANGED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const powerMeterSettingsSchema = new mongoose.Schema({
|
|
4
|
+
facilityId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Facility',
|
|
7
|
+
required: true,
|
|
8
|
+
unique: true // Ensure one settings record per facility
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
// Billing Amounts
|
|
12
|
+
minAmount: {
|
|
13
|
+
type: Number,
|
|
14
|
+
default: 0,
|
|
15
|
+
min: 0
|
|
16
|
+
},
|
|
17
|
+
maxAmount: {
|
|
18
|
+
type: Number,
|
|
19
|
+
default: 50000,
|
|
20
|
+
min: 0
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// Suspicious Meter Reading Thresholds
|
|
24
|
+
lowThreshold: {
|
|
25
|
+
type: Number,
|
|
26
|
+
default: 0,
|
|
27
|
+
min: 0
|
|
28
|
+
},
|
|
29
|
+
highThreshold: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 0,
|
|
32
|
+
min: 0
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// Billing Schedule
|
|
36
|
+
gracePeriod: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: 10,
|
|
39
|
+
min: 0
|
|
40
|
+
},
|
|
41
|
+
invoiceDay: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 3,
|
|
44
|
+
min: 0,
|
|
45
|
+
max: 30
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// Payment Enforcement
|
|
49
|
+
enforcePayment: {
|
|
50
|
+
type: String,
|
|
51
|
+
enum: ['yes', 'no', ''],
|
|
52
|
+
default: ''
|
|
53
|
+
},
|
|
54
|
+
minimumPaymentAmount: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 0,
|
|
57
|
+
min: 0
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
// Tariff Settings
|
|
61
|
+
tariff: {
|
|
62
|
+
type: String,
|
|
63
|
+
enum: ['yes', 'no', ''],
|
|
64
|
+
default: ''
|
|
65
|
+
},
|
|
66
|
+
tariffAmount: {
|
|
67
|
+
type: Number,
|
|
68
|
+
default: 0,
|
|
69
|
+
min: 0
|
|
70
|
+
},
|
|
71
|
+
fixedTariffAmount: {
|
|
72
|
+
type: Number,
|
|
73
|
+
default: 0,
|
|
74
|
+
min: 0
|
|
75
|
+
},
|
|
76
|
+
meterLoan: {
|
|
77
|
+
type: Number,
|
|
78
|
+
default: 0,
|
|
79
|
+
min: 0
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// GL Account Configuration (following your sample pattern)
|
|
83
|
+
glAccounts: {
|
|
84
|
+
invoice: {
|
|
85
|
+
debit: {
|
|
86
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
87
|
+
ref: "GLAccount",
|
|
88
|
+
required: false,
|
|
89
|
+
},
|
|
90
|
+
credit: {
|
|
91
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
92
|
+
ref: "GLAccount",
|
|
93
|
+
required: false,
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
payment: {
|
|
97
|
+
debit: {
|
|
98
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
99
|
+
ref: "GLAccount",
|
|
100
|
+
required: false,
|
|
101
|
+
},
|
|
102
|
+
credit: {
|
|
103
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
104
|
+
ref: "GLAccount",
|
|
105
|
+
required: false,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// Other Charges
|
|
111
|
+
otherCharges: {
|
|
112
|
+
type: String,
|
|
113
|
+
enum: ['yes', 'no', ''],
|
|
114
|
+
default: ''
|
|
115
|
+
},
|
|
116
|
+
// Notifications
|
|
117
|
+
notifications: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
default: false
|
|
120
|
+
},
|
|
121
|
+
dailyNotifications: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: false
|
|
124
|
+
},
|
|
125
|
+
weeklyNotifications: {
|
|
126
|
+
type: Boolean,
|
|
127
|
+
default: false
|
|
128
|
+
},
|
|
129
|
+
allNotifications: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: false
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
timestamps: true
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const PowerMeterSettings = mongoose.model('PowerMeterSettings', powerMeterSettingsSchema);
|
|
138
|
+
|
|
139
|
+
module.exports = PowerMeterSettings;
|
|
@@ -23,17 +23,29 @@ const powerMeterSchema = new mongoose.Schema({
|
|
|
23
23
|
meterReading: {
|
|
24
24
|
type: Number,
|
|
25
25
|
required: true,
|
|
26
|
-
|
|
26
|
+
default: 0,
|
|
27
|
+
},
|
|
28
|
+
currentMeterReading: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 0,
|
|
27
31
|
},
|
|
28
32
|
lastUpdated: {
|
|
29
33
|
type: Date,
|
|
30
34
|
required: true
|
|
31
|
-
|
|
32
35
|
},
|
|
33
36
|
manufacturer: {
|
|
34
37
|
type: String,
|
|
35
38
|
required: true
|
|
36
39
|
},
|
|
40
|
+
unitId: {
|
|
41
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
42
|
+
ref: 'Unit',
|
|
43
|
+
trim: true
|
|
44
|
+
},
|
|
45
|
+
unitName: {
|
|
46
|
+
type: String,
|
|
47
|
+
trim: true
|
|
48
|
+
},
|
|
37
49
|
type: {
|
|
38
50
|
type: String,
|
|
39
51
|
required: true,
|
package/src/models/user.js
CHANGED
|
@@ -22,11 +22,11 @@ const userSchema = new mongoose.Schema({
|
|
|
22
22
|
type: String,
|
|
23
23
|
required: false
|
|
24
24
|
},
|
|
25
|
-
type: {
|
|
25
|
+
type: [{
|
|
26
26
|
type: String,
|
|
27
27
|
required: [true, 'Type is required'],
|
|
28
28
|
enum: ['Company', 'Project Manager', 'Universal', 'Core', 'Resident', 'Landlord', 'Supplier'],
|
|
29
|
-
},
|
|
29
|
+
}],
|
|
30
30
|
department: {
|
|
31
31
|
type: mongoose.Schema.Types.ObjectId,
|
|
32
32
|
ref: 'FacilityDepartment',
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
const powerMeterTariffsSchema = new mongoose.Schema({
|
|
4
|
-
facilityId: {
|
|
5
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
-
ref: 'Facility',
|
|
7
|
-
required: true
|
|
8
|
-
},
|
|
9
|
-
meterSerialNumber: {
|
|
10
|
-
type: String,
|
|
11
|
-
required: true
|
|
12
|
-
},
|
|
13
|
-
deviceId: {
|
|
14
|
-
type: Number,
|
|
15
|
-
required: false
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
gatewayId: {
|
|
19
|
-
type: String,
|
|
20
|
-
required: true
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
meterReading: {
|
|
24
|
-
type: Number,
|
|
25
|
-
required: true,
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
lastUpdated: {
|
|
29
|
-
type: Date,
|
|
30
|
-
required: true
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
manufacturer: {
|
|
34
|
-
type: String,
|
|
35
|
-
required: true
|
|
36
|
-
},
|
|
37
|
-
type: {
|
|
38
|
-
type: String,
|
|
39
|
-
required: true,
|
|
40
|
-
enum: ['2 phase', '3 phase'],
|
|
41
|
-
default: '2 phase'
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
timestamps: true
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const PowerMeterTariffs = mongoose.model('PowerMeterTariffs', powerMeterTariffsSchema);
|
|
49
|
-
|
|
50
|
-
module.exports = PowerMeterTariffs;
|