payservedb 7.0.3 → 7.0.6
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 +231 -1
- package/package.json +1 -1
- package/src/models/facilityInvoice.js +2 -2
- package/src/models/facilityInvoiceRecipient.js +7 -5
- package/src/models/powerMeterDailyReading.js +1 -1
- package/src/models/powerMeterSingleDayReading.js +1 -1
- package/src/models/powerMeters.js +4 -4
- package/src/models/power_meter_command_queue.js +33 -0
- package/src/models/power_meter_negative_balance.js +44 -0
- package/src/models/power_prepaid_credits.js +47 -0
- package/src/models/power_prepaid_debits.js +50 -0
- package/src/models/water_meter_communication_logs.js +12 -2
- package/src/models/water_meter_high_risk.js +37 -0
- package/src/models/water_meter_negative_amounts.js +6 -1
- package/src/models/facilityInvoicerecipientMD.js +0 -33
- package/src/models/power_prepaid_credts.js +0 -0
package/index.js
CHANGED
|
@@ -6,6 +6,236 @@ const connections = {};
|
|
|
6
6
|
|
|
7
7
|
// Utility function to connect to MongoDB
|
|
8
8
|
async function connectToMongoDB(
|
|
9
|
+
<<<<<<< HEAD
|
|
10
|
+
=======
|
|
11
|
+
dbName,
|
|
12
|
+
secured,
|
|
13
|
+
username,
|
|
14
|
+
password,
|
|
15
|
+
url,
|
|
16
|
+
port,
|
|
17
|
+
) {
|
|
18
|
+
try {
|
|
19
|
+
if (secured === false) {
|
|
20
|
+
const url_ = url + ":" + port;
|
|
21
|
+
const connectionString = `mongodb://${url_}/${dbName}`;
|
|
22
|
+
await mongoose.connect(connectionString, {
|
|
23
|
+
useNewUrlParser: true,
|
|
24
|
+
});
|
|
25
|
+
console.log("Connected to MongoDB");
|
|
26
|
+
} else {
|
|
27
|
+
const url_ = `${username}:${password}@${url}:${port}`;
|
|
28
|
+
const source = "?authSource=admin";
|
|
29
|
+
const connectionString = `mongodb://${url_}/${dbName}${source}`;
|
|
30
|
+
await mongoose.connect(connectionString, {
|
|
31
|
+
useNewUrlParser: true,
|
|
32
|
+
});
|
|
33
|
+
console.log("Connected to MongoDB");
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.error("Error connecting to MongoDB:", err);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Function to switch databases dynamically
|
|
42
|
+
async function switchDB(dbName) {
|
|
43
|
+
// Check if there's already a connection to the desired database
|
|
44
|
+
if (connections[dbName]) {
|
|
45
|
+
return connections[dbName]; // Return existing connection
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
// Use environment variables for connection parameters - same as in connectToMongoDB
|
|
50
|
+
const username = process.env.MONGODB_USER;
|
|
51
|
+
const password = process.env.MONGODB_PASSWORD;
|
|
52
|
+
const url = process.env.MONGODB_HOST;
|
|
53
|
+
const port = process.env.MONGODB_PORT;
|
|
54
|
+
const source = "?authSource=admin";
|
|
55
|
+
|
|
56
|
+
const connectionString = `mongodb://${username}:${password}@${url}:${port}/${dbName}${source}`;
|
|
57
|
+
const dbConnection = await mongoose.createConnection(connectionString, {
|
|
58
|
+
useNewUrlParser: true,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
connections[dbName] = dbConnection; // Store the connection for reuse
|
|
62
|
+
console.log(`Switched to database: ${dbName}`);
|
|
63
|
+
return dbConnection;
|
|
64
|
+
} catch (err) {
|
|
65
|
+
console.error(`Error switching to database: ${dbName}`, err);
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Importing all model files (Note: models may need to be re-registered for different connections)
|
|
71
|
+
// This maintains backward compatibility for existing services
|
|
72
|
+
const models = {
|
|
73
|
+
User: require("./src/models/user"),
|
|
74
|
+
Company: require("./src/models/company"),
|
|
75
|
+
Customer: require("./src/models/customer"),
|
|
76
|
+
FacilityEmailDetails: require("./src/models/email"),
|
|
77
|
+
Module: require("./src/models/module"),
|
|
78
|
+
Facility: require("./src/models/facility"),
|
|
79
|
+
RefreshToken: require("./src/models/refresh_token"),
|
|
80
|
+
ApiLog: require("./src/models/apilog"),
|
|
81
|
+
ArchivedApiLog: require("./src/models/archivedapilog"),
|
|
82
|
+
FacilityAsset: require("./src/models/facilityasset"),
|
|
83
|
+
Unit: require("./src/models/units"),
|
|
84
|
+
FAQ: require("./src/models/faq"),
|
|
85
|
+
UnitAsset: require("./src/models/unitasset"),
|
|
86
|
+
CombinedUnit: require("./src/models/combinedUnits"),
|
|
87
|
+
Message: require("./src/models/message"),
|
|
88
|
+
SMSAfricastalking: require("./src/models/sms_africastalking"),
|
|
89
|
+
SMSMeliora: require("./src/models/sms_meliora"),
|
|
90
|
+
EntryExit: require("./src/models/entry_exit"),
|
|
91
|
+
Guard: require("./src/models/guard"),
|
|
92
|
+
Visitor: require("./src/models/visitor"),
|
|
93
|
+
VisitLog: require("./src/models/visitLog"),
|
|
94
|
+
Settings: require("./src/models/settings"),
|
|
95
|
+
Levy: require("./src/models/levy"),
|
|
96
|
+
LevyType: require("./src/models/levytype"),
|
|
97
|
+
LevyContract: require("./src/models/levycontract"),
|
|
98
|
+
Invoice: require("./src/models/invoice"),
|
|
99
|
+
Reminder: require("./src/models/reminder"),
|
|
100
|
+
Penalty: require("./src/models/penalty"),
|
|
101
|
+
Notifiaction: require("./src/models/notification"),
|
|
102
|
+
Resident: require("./src/models/resident"),
|
|
103
|
+
Asset: require("./src/models/asset"),
|
|
104
|
+
DutyRoster: require("./src/models/dutyroster"),
|
|
105
|
+
LeaseTemplate: require("./src/models/leasetemplate"),
|
|
106
|
+
Report: require("./src/models/report"),
|
|
107
|
+
Ticket: require("./src/models/tickets"),
|
|
108
|
+
Stocksandspare: require("./src/models/stocksandspare"),
|
|
109
|
+
ServiceVendor: require("./src/models/maintenance_service_vendor"),
|
|
110
|
+
MaintenanceServices: require("./src/models/maintenance_services"),
|
|
111
|
+
StockRequisition: require("./src/models/maintenancerequisition"),
|
|
112
|
+
LeaseAgreement: require("./src/models/leaseagreement"),
|
|
113
|
+
WorkOrder: require("./src/models/workorder"),
|
|
114
|
+
ValueAddedService: require("./src/models/valueaddedservices"),
|
|
115
|
+
VasInvoice: require("./src/models/vasinvoice"),
|
|
116
|
+
VasVendor: require("./src/models/vasvendor"),
|
|
117
|
+
Staff: require("./src/models/staff"),
|
|
118
|
+
ServiceRequest: require("./src/models/servicerequest"),
|
|
119
|
+
CountryTaxRate: require("./src/models/country_tax"),
|
|
120
|
+
WaterMeter: require("./src/models/water_meters"),
|
|
121
|
+
DailyConsumption: require("./src/models/smart_meter_daily_consumption"),
|
|
122
|
+
WaterMeterSettings: require("./src/models/water_meter_settings"),
|
|
123
|
+
AnalogBilling: require("./src/models/water_meter_billing"),
|
|
124
|
+
MeterSize: require("./src/models/water_meter_size"),
|
|
125
|
+
WaterInvoice: require("./src/models/water_invoice"),
|
|
126
|
+
MeterProtocol: require("./src/models/water_meter_communication"),
|
|
127
|
+
MeterManufacturer: require("./src/models/water_meter_manufacturer"),
|
|
128
|
+
MeterIotCard: require("./src/models/water_meter_iot_cards"),
|
|
129
|
+
MetersDelivery: require("./src/models/water_meters_delivery"),
|
|
130
|
+
Notification: require("./src/models/notification"),
|
|
131
|
+
Concentrator: require("./src/models/water_meter_concentrator"),
|
|
132
|
+
Handover: require("./src/models/handover"),
|
|
133
|
+
Budget: require("./src/models/budget"),
|
|
134
|
+
BudgetCategory: require("./src/models/budgetCategory"),
|
|
135
|
+
Expense: require("./src/models/expense"),
|
|
136
|
+
ExpenseCategory: require("./src/models/expense_category"),
|
|
137
|
+
InvoiceSettings: require("./src/models/levy_invoice_settings"),
|
|
138
|
+
Account: require("./src/models/account"),
|
|
139
|
+
FacilityPaymentDetails: require("./src/models/facility_payment_details"),
|
|
140
|
+
DefaultPaymentDetails: require("./src/models/default_payment_details"),
|
|
141
|
+
Currency: require("./src/models/currency_settings"),
|
|
142
|
+
WaterMeterAccount: require("./src/models/water_meter_account"),
|
|
143
|
+
SingleDayWaterMeterHistory: require("./src/models/water_meter_single_day_history"),
|
|
144
|
+
DailyWaterMeterHistory: require("./src/models/water_meter_daily_history"),
|
|
145
|
+
MonthlyWaterMeterHistory: require("./src/models/water_meter_monthly_history"),
|
|
146
|
+
WaterPrepaidCredit: require("./src/models/water_prepaid_credit"),
|
|
147
|
+
WaterPrepaidDebit: require("./src/models/water_prepaid_debit"),
|
|
148
|
+
MeterLog: require("./src/models/water_meter_communication_logs"),
|
|
149
|
+
CashPayment: require("./src/models/cashpayment"),
|
|
150
|
+
VasPayment: require("./src/models/vas_payments"),
|
|
151
|
+
VasInvoicesQuickBooks: require("./src/models/vas_invoices_upload"),
|
|
152
|
+
ServiceChargePayment: require("./src/models/service_charge_payments"),
|
|
153
|
+
ServiceChargeInvoiceUpload: require("./src/models/service_charge_invoice_upload"),
|
|
154
|
+
Campaign: require("./src/models/campaigns"),
|
|
155
|
+
InspectionItem: require("./src/models/item_inspection"),
|
|
156
|
+
Supplier: require("./src/models/suppliers"),
|
|
157
|
+
PurchaseRequest: require("./src/models/purchase_request"),
|
|
158
|
+
PurchaseOrder: require("./src/models/purchase_order"),
|
|
159
|
+
PaymentTermMark: require("./src/models/paymentTermsMarks"),
|
|
160
|
+
DeliveryTimeMark: require("./src/models/deliveryTimeMarks"),
|
|
161
|
+
RFQDetails: require("./src/models/rfq_details"),
|
|
162
|
+
RFQResponse: require("./src/models/rfq_response"),
|
|
163
|
+
ApprovalWorkflow: require("./src/models/approvalsWorkflows"),
|
|
164
|
+
CommonAreaElectricityReading: require("./src/models/common_area_electricity"),
|
|
165
|
+
CommonAreaWaterReading: require("./src/models/common_area_water"),
|
|
166
|
+
CommonAreaGeneratorReading: require("./src/models/common_area_generator"),
|
|
167
|
+
CommonAreaUtilityAlert: require("./src/models/common_area_utility_alert"),
|
|
168
|
+
BookingProperty: require("./src/models/bookingproperty"),
|
|
169
|
+
BookingReservation: require("./src/models/bookingreservation"),
|
|
170
|
+
BookingConfig: require("./src/models/bookingconfig"),
|
|
171
|
+
BookingAnalytics: require("./src/models/bookinganalytics"),
|
|
172
|
+
BookingInvoice: require("./src/models/booking_invoice"),
|
|
173
|
+
BankDetails: require("./src/models/bankdetails"),
|
|
174
|
+
RevenueRecord: require("./src/models/bookingrevenuerecord"),
|
|
175
|
+
GLAccount: require("./src/models/gl_accounts"),
|
|
176
|
+
GLEntry: require("./src/models/gl_entries"),
|
|
177
|
+
GLAccountDoubleEntries: require("./src/models/gl_account_double_entries"),
|
|
178
|
+
PendingCredential: require("./src/models/pendingCredentials"),
|
|
179
|
+
UnitManagementTemplate: require("./src/models/unitManagementTemplate"),
|
|
180
|
+
PropertyManagerRevenue: require("./src/models/propertyManagerRevenue"),
|
|
181
|
+
PropertyManagerContract: require("./src/models/propertyManagerContract"),
|
|
182
|
+
BillerAddress: require("./src/models/billerAddress"),
|
|
183
|
+
AssetAssignment: require("./src/models/assetsAssignment"),
|
|
184
|
+
Wallet: require("./src/models/wallet"),
|
|
185
|
+
WalletTransaction: require("./src/models/wallet_transactions"),
|
|
186
|
+
GoodsReceivedNote: require("./src/models/goodsReceivedNotes"),
|
|
187
|
+
CommunicationStatus: require("./src/models/communication_status"),
|
|
188
|
+
MeterCommandQueue: require("./src/models/water_meter_Command_Queue"),
|
|
189
|
+
FacilityDepartment: require("./src/models/facility_departements"),
|
|
190
|
+
EmailSmsQueue: require("./src/models/email_sms_queue"),
|
|
191
|
+
PurchaseOrderInvoice: require("./src/models/purchaseOrderInvoice"),
|
|
192
|
+
PowerMeterCustomerBand: require("./src/models/powerMeterCustomerBand"),
|
|
193
|
+
PowerMeterCommunicationProtocol: require("./src/models/powerMeterCommunicationProtocol"),
|
|
194
|
+
PowerMeterDailyReading: require("./src/models/powerMeterDailyReading"),
|
|
195
|
+
PowerMeterPowerCharge: require("./src/models/powerMeterPowerCharges"),
|
|
196
|
+
PowerMeterGateway: require("./src/models/powerMeterGateways"),
|
|
197
|
+
PowerMeters: require("./src/models/powerMeters"),
|
|
198
|
+
PowerMeterSingleDayReading: require("./src/models/powerMeterSingleDayReading"),
|
|
199
|
+
PowerMeterAccount: require("./src/models/power_meter_account"),
|
|
200
|
+
PowerMeterLog: require("./src/models/power_meter_command_logs"),
|
|
201
|
+
PowerMeterManufacturer: require("./src/models/powerMetersManufacturer"),
|
|
202
|
+
PowerMeterMonthlyReading: require("./src/models/powerMeterMonthlyReading"),
|
|
203
|
+
PowerMeterSettings: require("./src/models/powerMeterSettings"),
|
|
204
|
+
FacilityWalletTransactionsMetadata: require("./src/models/facilityWalletTransactionsMetadata"),
|
|
205
|
+
PowerMeterCustomerAccount: require("./src/models/powerMeterCustomerAccount"),
|
|
206
|
+
PowerPrepaidCredit: require("./src/models/power_prepaid_credits"),
|
|
207
|
+
PowerPrepaidDebit: require("./src/models/power_prepaid_debits"),
|
|
208
|
+
PowerNegativeBalance: require("./src/models/power_meter_negative_balance"),
|
|
209
|
+
PowerCommandQueue: require("./src/models/power_meter_command_queue"),
|
|
210
|
+
SmsNotification: require("./src/models/sms_balance_notification"),
|
|
211
|
+
NegativeBalance: require("./src/models/water_meter_negative_amounts"),
|
|
212
|
+
MasterWorkplan: require("./src/models/master_workplan"),
|
|
213
|
+
MasterWorkplanChild: require("./src/models/master_workplan_child"),
|
|
214
|
+
DutyRosterChecklist: require("./src/models/dutyRosterChecklist"),
|
|
215
|
+
AuditTrail: require("./src/models/auditTrail"),
|
|
216
|
+
DailyChecklist: require("./src/models/dailyChecklist"),
|
|
217
|
+
CoreInvoiceSettings: require("./src/models/coreInvoiceSettings"),
|
|
218
|
+
FacilityInvoice: require("./src/models/facilityInvoice"),
|
|
219
|
+
CoreBaseSettings: require("./src/models/coreBaseSettings"),
|
|
220
|
+
FacilityContractPricing: require("./src/models/facilityContractPricing"),
|
|
221
|
+
FacilityContract: require("./src/models/facilityInvoiceContract"),
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// Function to get models dynamically from a specific database connection
|
|
225
|
+
async function getModelFromDB(dbConnection, modelName, schema) {
|
|
226
|
+
if (!dbConnection.models[modelName]) {
|
|
227
|
+
return dbConnection.model(modelName, schema); // Register the model in the db connection
|
|
228
|
+
}
|
|
229
|
+
return dbConnection.models[modelName]; // Return existing model if already registered
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Function to initialize service with specific models - NEW FEATURE
|
|
233
|
+
function initializeService(modelNames = []) {
|
|
234
|
+
let currentConnection = null;
|
|
235
|
+
|
|
236
|
+
// Enhanced connect function that only registers specified models
|
|
237
|
+
async function connectWithModels(
|
|
238
|
+
>>>>>>> eefef4ffbdd0b8bf99ffc02da539bd5eba17f820
|
|
9
239
|
dbName,
|
|
10
240
|
secured,
|
|
11
241
|
username,
|
|
@@ -211,7 +441,7 @@ const models = {
|
|
|
211
441
|
CoreInvoiceSettings: require("./src/models/coreInvoiceSettings"),
|
|
212
442
|
FacilityInvoice: require("./src/models/facilityInvoice"),
|
|
213
443
|
CoreBaseSettings: require("./src/models/coreBaseSettings"),
|
|
214
|
-
|
|
444
|
+
Recipient: require("./src/models/facilityInvoiceRecipient")
|
|
215
445
|
};
|
|
216
446
|
|
|
217
447
|
// Function to get models dynamically from a specific database connection
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
|
-
const {
|
|
2
|
+
const {RecipientSchema} = require("./facilityInvoiceRecipient")
|
|
3
3
|
|
|
4
4
|
const FacilityInvoiceSchema = new mongoose.Schema(
|
|
5
5
|
{
|
|
@@ -14,7 +14,7 @@ const FacilityInvoiceSchema = new mongoose.Schema(
|
|
|
14
14
|
required: true,
|
|
15
15
|
},
|
|
16
16
|
recipient: {
|
|
17
|
-
type:
|
|
17
|
+
type: RecipientSchema,
|
|
18
18
|
required: true,
|
|
19
19
|
},
|
|
20
20
|
invoiceNumber: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const RecipientSchema = new mongoose.Schema(
|
|
4
4
|
{
|
|
5
5
|
facilityId: {
|
|
6
6
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -24,8 +24,10 @@ const Recipient = new mongoose.Schema(
|
|
|
24
24
|
}
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
+
// Create the model
|
|
28
|
+
const Recipient = mongoose.model("Recipient", RecipientSchema);
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
module.exports =
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// Export the model as default and the schema as a named export
|
|
31
|
+
module.exports = Recipient;
|
|
32
|
+
module.exports.RecipientSchema = RecipientSchema;
|
|
33
|
+
module.exports.schema = RecipientSchema; // For compatibility with getModel if needed
|
|
@@ -81,13 +81,13 @@ const powerMeterSchema = new mongoose.Schema({
|
|
|
81
81
|
},
|
|
82
82
|
liveStatus: {
|
|
83
83
|
type: String,
|
|
84
|
-
enum: ['
|
|
85
|
-
default: '
|
|
84
|
+
enum: ['Off', 'On', 'Maintenance', 'Faulty'],
|
|
85
|
+
default: 'On'
|
|
86
86
|
},
|
|
87
87
|
gatewayLiveStatus: {
|
|
88
88
|
type: String,
|
|
89
|
-
enum: ['
|
|
90
|
-
default: '
|
|
89
|
+
enum: ['on', 'off'],
|
|
90
|
+
default: 'off'
|
|
91
91
|
},
|
|
92
92
|
meterStatus: {
|
|
93
93
|
type: String,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const powerCommandQueueSchema = new mongoose.Schema({
|
|
4
|
+
deviceId: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true
|
|
7
|
+
},
|
|
8
|
+
gatewayId: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: true
|
|
11
|
+
},
|
|
12
|
+
commandType: {
|
|
13
|
+
type: String,
|
|
14
|
+
enum: ['On', 'Off', 'Read'],
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
status: {
|
|
18
|
+
type: String,
|
|
19
|
+
enum: ['pending', 'sent', 'acknowledged', 'failed'],
|
|
20
|
+
default: 'pending'
|
|
21
|
+
},
|
|
22
|
+
retryCount: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: 0
|
|
25
|
+
},
|
|
26
|
+
sentAt: {
|
|
27
|
+
type: Date
|
|
28
|
+
}
|
|
29
|
+
}, { timestamps: true });
|
|
30
|
+
|
|
31
|
+
const PowerCommandQueue = mongoose.model('PowerCommandQueue', powerCommandQueueSchema);
|
|
32
|
+
|
|
33
|
+
module.exports = PowerCommandQueue;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const powerNegativeBalanceSchema = new mongoose.Schema({
|
|
4
|
+
customerId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Customer',
|
|
7
|
+
required: true
|
|
8
|
+
},
|
|
9
|
+
accountId: {
|
|
10
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
11
|
+
ref: 'PowerMeterCustomerAccount',
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
customerName: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
trim: true
|
|
18
|
+
},
|
|
19
|
+
meterNumber: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true,
|
|
22
|
+
trim: true
|
|
23
|
+
},
|
|
24
|
+
amount: {
|
|
25
|
+
type: Number,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
type: {
|
|
29
|
+
type: String,
|
|
30
|
+
enum: ['Credit', 'Debit'],
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
dateRecorded: {
|
|
34
|
+
type: Date,
|
|
35
|
+
required: true,
|
|
36
|
+
default: Date.now
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
timestamps: true
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const PowerNegativeBalance = mongoose.model('PowerNegativeBalance', powerNegativeBalanceSchema);
|
|
43
|
+
|
|
44
|
+
module.exports = PowerNegativeBalance;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const powerPrepaidCreditSchema = new mongoose.Schema({
|
|
4
|
+
accountId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'PowerMeterCustomerAccount',
|
|
7
|
+
required: true,
|
|
8
|
+
},
|
|
9
|
+
meterId: {
|
|
10
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
11
|
+
ref: 'PowerMeters',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
ref: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
amount: {
|
|
19
|
+
type: Number,
|
|
20
|
+
required: true,
|
|
21
|
+
default: 0
|
|
22
|
+
},
|
|
23
|
+
time: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
addedOn: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
reason: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
type: {
|
|
36
|
+
type: String,
|
|
37
|
+
enum: ['Mobile Money', 'Bank', 'Manual'],
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
}, {
|
|
42
|
+
timestamps: true
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const PowerPrepaidCredit = mongoose.model('PowerPrepaidCredit', powerPrepaidCreditSchema);
|
|
46
|
+
|
|
47
|
+
module.exports = PowerPrepaidCredit;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const powerPrepaidDebitSchema = new mongoose.Schema({
|
|
4
|
+
accountId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'PowerMeterCustomerAccount',
|
|
7
|
+
required: true,
|
|
8
|
+
},
|
|
9
|
+
meterId: {
|
|
10
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
11
|
+
ref: 'PowerMeters',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
prev_reading: {
|
|
15
|
+
type: Number,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
current_reading: {
|
|
19
|
+
type: Number,
|
|
20
|
+
required: true,
|
|
21
|
+
default: 0
|
|
22
|
+
},
|
|
23
|
+
consumption: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
rate: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
totalAmount: {
|
|
32
|
+
type: Number,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
date: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true
|
|
38
|
+
},
|
|
39
|
+
time: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: true
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
}, {
|
|
45
|
+
timestamps: true
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const PowerPrepaidDebit = mongoose.model('PowerPrepaidDebit', powerPrepaidDebitSchema);
|
|
49
|
+
|
|
50
|
+
module.exports = PowerPrepaidDebit;
|
|
@@ -17,14 +17,24 @@ const meterLogSchema = new mongoose.Schema({
|
|
|
17
17
|
required: true,
|
|
18
18
|
trim: true
|
|
19
19
|
},
|
|
20
|
+
reason: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
trim: true
|
|
24
|
+
},
|
|
25
|
+
actionBy: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true,
|
|
28
|
+
trim: true
|
|
29
|
+
},
|
|
20
30
|
timestamp: {
|
|
21
31
|
type: Date,
|
|
22
32
|
default: Date.now
|
|
23
33
|
}
|
|
24
34
|
}, {
|
|
25
|
-
timestamps: true
|
|
35
|
+
timestamps: true
|
|
26
36
|
});
|
|
27
37
|
|
|
28
38
|
const MeterLog = mongoose.model('MeterLog', meterLogSchema);
|
|
29
39
|
|
|
30
|
-
module.exports = MeterLog;
|
|
40
|
+
module.exports = MeterLog;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const highRiskMeterSchema = new mongoose.Schema({
|
|
4
|
+
meterNumber: {
|
|
5
|
+
type: String,
|
|
6
|
+
required: true,
|
|
7
|
+
unique: true,
|
|
8
|
+
trim: true,
|
|
9
|
+
index: true
|
|
10
|
+
},
|
|
11
|
+
concentratorSerialNumber: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
trim: true
|
|
15
|
+
},
|
|
16
|
+
customerName: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
trim: true
|
|
20
|
+
},
|
|
21
|
+
facilityName: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true,
|
|
24
|
+
trim: true
|
|
25
|
+
},
|
|
26
|
+
unitName: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
trim: true
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
timestamps: true
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const HighRiskMeter = mongoose.model('HighRiskMeter', highRiskMeterSchema);
|
|
36
|
+
|
|
37
|
+
module.exports = HighRiskMeter;
|
|
@@ -25,6 +25,11 @@ const negativeBalanceSchema = new mongoose.Schema({
|
|
|
25
25
|
type: Number,
|
|
26
26
|
required: true
|
|
27
27
|
},
|
|
28
|
+
type: {
|
|
29
|
+
type: String,
|
|
30
|
+
enum: ['Credit', 'Debit'],
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
28
33
|
dateRecorded: {
|
|
29
34
|
type: Date,
|
|
30
35
|
required: true,
|
|
@@ -36,4 +41,4 @@ const negativeBalanceSchema = new mongoose.Schema({
|
|
|
36
41
|
|
|
37
42
|
const NegativeBalance = mongoose.model('NegativeBalance', negativeBalanceSchema);
|
|
38
43
|
|
|
39
|
-
module.exports = NegativeBalance;
|
|
44
|
+
module.exports = NegativeBalance;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
|
|
3
|
-
const Recipient = new mongoose.Schema(
|
|
4
|
-
{
|
|
5
|
-
facilityId: {
|
|
6
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
-
ref: "Facility",
|
|
8
|
-
required: true,
|
|
9
|
-
},
|
|
10
|
-
phoneNumber: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: true
|
|
13
|
-
},
|
|
14
|
-
email: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true,
|
|
17
|
-
lowercase: true,
|
|
18
|
-
trim: true,
|
|
19
|
-
match: [/^\S+@\S+\.\S+$/, "Please enter a valid email address"]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
timestamps: true,
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const RecipientSchema = mongoose.model("RecipientSchema", Recipient);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
module.exports = {
|
|
32
|
-
RecipientSchema,
|
|
33
|
-
};
|
|
File without changes
|