payservedb 1.1.4 → 1.1.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/index.js +2 -5
- package/package.json +1 -1
- package/src/models/brian.js +6 -0
- package/src/models/customer.js +6 -83
- package/src/models/facility.js +1 -5
- package/src/models/units.js +27 -35
- package/src/models/waterMeterSetting.js +25 -0
- package/src/models/access.js +0 -38
- package/src/models/contract.js +0 -39
- package/src/models/guard.js +0 -54
- package/src/models/levy.js +0 -49
- package/src/models/unitasset.js +0 -25
- package/src/models/visitor.js +0 -73
package/index.js
CHANGED
|
@@ -63,11 +63,8 @@ const models = {
|
|
|
63
63
|
SMSAfricastalking: require('./src/models/sms_africastalking'),
|
|
64
64
|
SMSMeliora: require('./src/models/sms_meliora'),
|
|
65
65
|
WaterConcentrator:require('./src/models/waterConcentrator'),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Visitor: require('./src/models/visitor'),
|
|
69
|
-
Access: require('./src/models/access'),
|
|
70
|
-
Guard: require('./src/models/guard'),
|
|
66
|
+
WaterMeterSettings:require('./src/models/waterMeterSetting'),
|
|
67
|
+
Brian:require('./src/models/brian')
|
|
71
68
|
};
|
|
72
69
|
|
|
73
70
|
// Function to get models dynamically from a specific database connection
|
package/package.json
CHANGED
package/src/models/customer.js
CHANGED
|
@@ -30,93 +30,16 @@ const customerSchema = new mongoose.Schema({
|
|
|
30
30
|
required: [true, 'Phone number is required'],
|
|
31
31
|
trim: true
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
type: {
|
|
34
34
|
type: String,
|
|
35
|
-
required: [true, '
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
nextOfKinName: {
|
|
39
|
-
type: String,
|
|
40
|
-
required: [true, 'Next of kin name is required'],
|
|
41
|
-
trim: true
|
|
42
|
-
},
|
|
43
|
-
nextOfKinRelationship: {
|
|
44
|
-
type: String,
|
|
45
|
-
required: [true, 'Next of kin relationship is required'],
|
|
46
|
-
trim: true
|
|
47
|
-
},
|
|
48
|
-
nextOfKinContact: {
|
|
49
|
-
type: String,
|
|
50
|
-
required: [true, 'Next of kin contact is required'],
|
|
51
|
-
trim: true
|
|
35
|
+
required: [true, 'Type is required'],
|
|
36
|
+
enum: ['Tenant', 'Home Owner'],
|
|
52
37
|
},
|
|
53
38
|
units:[],
|
|
54
|
-
|
|
55
|
-
type: String,
|
|
56
|
-
required: [true, 'customerType is required'],
|
|
57
|
-
enum: ['home owner', 'tenant'],
|
|
58
|
-
},
|
|
59
|
-
residentType: {
|
|
60
|
-
type: String,
|
|
61
|
-
required: [true, 'residentType is required'],
|
|
62
|
-
enum: ['resident', 'non-resident'],
|
|
63
|
-
},
|
|
64
|
-
familyMembers: [{
|
|
65
|
-
name: {
|
|
66
|
-
type: String,
|
|
67
|
-
required: [true, 'Family member name is required'],
|
|
68
|
-
trim: true
|
|
69
|
-
},
|
|
70
|
-
phone: {
|
|
71
|
-
type: String,
|
|
72
|
-
required: [true, 'Family member phone number is required'],
|
|
73
|
-
trim: true
|
|
74
|
-
},
|
|
75
|
-
relation: {
|
|
76
|
-
type: String,
|
|
77
|
-
required: [true, 'Family member relation is required'],
|
|
78
|
-
trim: true
|
|
79
|
-
}
|
|
80
|
-
}],
|
|
81
|
-
vehicles: [{
|
|
82
|
-
name: {
|
|
83
|
-
type: String,
|
|
84
|
-
required: [true, 'Vehicle name is required'],
|
|
85
|
-
trim: true
|
|
86
|
-
},
|
|
87
|
-
model: {
|
|
88
|
-
type: String,
|
|
89
|
-
required: [true, 'Vehicle model is required'],
|
|
90
|
-
trim: true
|
|
91
|
-
},
|
|
92
|
-
plateNumber: {
|
|
93
|
-
type: String,
|
|
94
|
-
required: [true, 'Vehicle number is required'],
|
|
95
|
-
trim: true
|
|
96
|
-
}
|
|
97
|
-
}],
|
|
98
|
-
staff: [{
|
|
99
|
-
name: {
|
|
100
|
-
type: String,
|
|
101
|
-
required: [true, 'Staff member name is required'],
|
|
102
|
-
trim: true
|
|
103
|
-
},
|
|
104
|
-
phone: {
|
|
105
|
-
type: String,
|
|
106
|
-
required: [true, 'Staff member phone number is required'],
|
|
107
|
-
trim: true
|
|
108
|
-
},
|
|
109
|
-
job: {
|
|
110
|
-
type: String,
|
|
111
|
-
required: [true, 'Staff member name is required'],
|
|
112
|
-
trim: true
|
|
113
|
-
}
|
|
114
|
-
}],
|
|
115
|
-
isEnabled: { type: Boolean, default: false },
|
|
116
|
-
facilityId: {
|
|
39
|
+
projectId: {
|
|
117
40
|
type: mongoose.Schema.Types.ObjectId,
|
|
118
|
-
ref: '
|
|
119
|
-
required: [true, '
|
|
41
|
+
ref: 'Project',
|
|
42
|
+
required: [true, 'Project ID is required']
|
|
120
43
|
}
|
|
121
44
|
}, {
|
|
122
45
|
timestamps: true // Automatically add createdAt and updatedAt fields
|
package/src/models/facility.js
CHANGED
|
@@ -24,11 +24,7 @@ const facilitySchema = new mongoose.Schema({
|
|
|
24
24
|
type: String,
|
|
25
25
|
trim: false,
|
|
26
26
|
default: null
|
|
27
|
-
}
|
|
28
|
-
units: [{
|
|
29
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
30
|
-
ref: 'Unit' // Reference to the Unit model
|
|
31
|
-
}]
|
|
27
|
+
}
|
|
32
28
|
|
|
33
29
|
}, {
|
|
34
30
|
timestamps: true // Automatically add createdAt and updatedAt fields
|
package/src/models/units.js
CHANGED
|
@@ -6,52 +6,44 @@ const unitSchema = new mongoose.Schema({
|
|
|
6
6
|
type: String,
|
|
7
7
|
required: true
|
|
8
8
|
},
|
|
9
|
-
unitType:
|
|
10
|
-
type:
|
|
11
|
-
required:
|
|
9
|
+
unitType:{
|
|
10
|
+
type:String,
|
|
11
|
+
required:true
|
|
12
12
|
},
|
|
13
|
-
division:
|
|
14
|
-
type:
|
|
15
|
-
required:
|
|
13
|
+
division:{
|
|
14
|
+
type:String,
|
|
15
|
+
required:true
|
|
16
16
|
},
|
|
17
|
-
floorUnitNo:
|
|
18
|
-
type:
|
|
19
|
-
required:
|
|
17
|
+
floorUnitNo:{
|
|
18
|
+
type:String,
|
|
19
|
+
required:true
|
|
20
20
|
},
|
|
21
|
-
lettableFloorArea:
|
|
22
|
-
type:
|
|
23
|
-
required:
|
|
21
|
+
lettableFloorArea:{
|
|
22
|
+
type:String,
|
|
23
|
+
required:false
|
|
24
24
|
},
|
|
25
|
-
landRateNumber:
|
|
26
|
-
type:
|
|
27
|
-
required:
|
|
25
|
+
landRateNumber:{
|
|
26
|
+
type:String,
|
|
27
|
+
required:false
|
|
28
28
|
},
|
|
29
|
-
grossArea:
|
|
30
|
-
type:
|
|
31
|
-
required:
|
|
29
|
+
grossArea:{
|
|
30
|
+
type:Number,
|
|
31
|
+
required:false
|
|
32
32
|
},
|
|
33
|
-
netLettableArea:
|
|
34
|
-
type:
|
|
35
|
-
required:
|
|
33
|
+
netLettableArea:{
|
|
34
|
+
type:Number,
|
|
35
|
+
required:false
|
|
36
36
|
},
|
|
37
|
-
status:
|
|
38
|
-
type:
|
|
39
|
-
required:
|
|
37
|
+
status:{
|
|
38
|
+
type:String,
|
|
39
|
+
required:true
|
|
40
40
|
},
|
|
41
|
-
facilityId:
|
|
41
|
+
facilityId:{
|
|
42
42
|
type: mongoose.Schema.Types.ObjectId,
|
|
43
43
|
ref: 'Facility',
|
|
44
|
-
},
|
|
45
|
-
homeOwnerId: {
|
|
46
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
47
|
-
ref: 'Customer',
|
|
48
|
-
},
|
|
49
|
-
tenantId: {
|
|
50
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
51
|
-
ref: 'Customer',
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
|
|
46
|
+
|
|
55
47
|
}, {
|
|
56
48
|
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
57
49
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const waterMeterSettingsSchema = mongoose.Schema({
|
|
4
|
+
manufacturers: {
|
|
5
|
+
type: [String],
|
|
6
|
+
required: false
|
|
7
|
+
},
|
|
8
|
+
meterSizes: {
|
|
9
|
+
type: [String],
|
|
10
|
+
required: false
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Middleware to ensure only one record exists
|
|
15
|
+
waterMeterSettingsSchema.pre('save', async function (next) {
|
|
16
|
+
const existingSettings = await WaterMeterSettings.findOne();
|
|
17
|
+
if (existingSettings && !existingSettings._id.equals(this._id)) {
|
|
18
|
+
throw new Error('Only one water meter settings record is allowed.');
|
|
19
|
+
}
|
|
20
|
+
next();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const WaterMeterSettings = mongoose.model("WaterMeterSettings", waterMeterSettingsSchema);
|
|
24
|
+
|
|
25
|
+
module.exports = WaterMeterSettings;
|
package/src/models/access.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const accessSchema = new mongoose.Schema({
|
|
5
|
-
name: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'Name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
location: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Location is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
purpose: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Purpose is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
disabled: {
|
|
21
|
-
type: Boolean,
|
|
22
|
-
default: false,
|
|
23
|
-
},
|
|
24
|
-
facilityId: {
|
|
25
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
26
|
-
ref: 'Facility',
|
|
27
|
-
},
|
|
28
|
-
}, {
|
|
29
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Indexes for improved performance
|
|
33
|
-
accessSchema.index({ name: 1 });
|
|
34
|
-
|
|
35
|
-
// Compile the model from the schema
|
|
36
|
-
const Access = mongoose.model('Access', accessSchema);
|
|
37
|
-
|
|
38
|
-
module.exports = Access;
|
package/src/models/contract.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const contractSchema = new mongoose.Schema({
|
|
5
|
-
contractName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'Contract Name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
contractPhoneNumber: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Phone number is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
contractStart: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Start date is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
contractEnd: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: [true, 'Contract end date is required'],
|
|
23
|
-
trim: true
|
|
24
|
-
},
|
|
25
|
-
facilityId: {
|
|
26
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
27
|
-
ref: 'Facility',
|
|
28
|
-
},
|
|
29
|
-
}, {
|
|
30
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Indexes for improved performance
|
|
34
|
-
contractSchema.index({ name: 1 });
|
|
35
|
-
|
|
36
|
-
// Compile the model from the schema
|
|
37
|
-
const Contract = mongoose.model('Contract', contractSchema);
|
|
38
|
-
|
|
39
|
-
module.exports = Contract;
|
package/src/models/guard.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const guardSchema = new mongoose.Schema({
|
|
5
|
-
firstName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'First name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
lastName: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Last name is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
phoneNumber: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Phone number is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
entryPoint: {
|
|
21
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
-
required: [true, 'Entry point is required'],
|
|
23
|
-
trim: true,
|
|
24
|
-
ref: 'Access'
|
|
25
|
-
},
|
|
26
|
-
startTime: {
|
|
27
|
-
type: String,
|
|
28
|
-
required: [true, 'Start time is required'],
|
|
29
|
-
trim: true
|
|
30
|
-
},
|
|
31
|
-
endTime: {
|
|
32
|
-
type: String,
|
|
33
|
-
required: [true, 'End time is required'],
|
|
34
|
-
trim: true
|
|
35
|
-
},
|
|
36
|
-
disabled: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: false,
|
|
39
|
-
},
|
|
40
|
-
facilityId: {
|
|
41
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
42
|
-
ref: 'Facility',
|
|
43
|
-
},
|
|
44
|
-
}, {
|
|
45
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Indexes for improved performance
|
|
49
|
-
guardSchema.index({ firstName: 1 });
|
|
50
|
-
|
|
51
|
-
// Compile the model from the schema
|
|
52
|
-
const Guard = mongoose.model('Guard', guardSchema);
|
|
53
|
-
|
|
54
|
-
module.exports = Guard;
|
package/src/models/levy.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const levySchema = new mongoose.Schema({
|
|
5
|
-
levyName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'Levy Name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
levyType: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Levy type is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
levyApplicant: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Levy Applicant is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
collectionFrequency: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: [true, 'Collection frequency is required'],
|
|
23
|
-
trim: true
|
|
24
|
-
},
|
|
25
|
-
invoiceDate: {
|
|
26
|
-
type: String,
|
|
27
|
-
required: [true, 'Date is required'],
|
|
28
|
-
trim: true
|
|
29
|
-
},
|
|
30
|
-
amount: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: [true, 'Amount is required'],
|
|
33
|
-
trim: true
|
|
34
|
-
},
|
|
35
|
-
facilityId: {
|
|
36
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
-
ref: 'Facility',
|
|
38
|
-
},
|
|
39
|
-
}, {
|
|
40
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Indexes for improved performance
|
|
44
|
-
levySchema.index({ name: 1 });
|
|
45
|
-
|
|
46
|
-
// Compile the model from the schema
|
|
47
|
-
const Levy = mongoose.model('Levy', levySchema);
|
|
48
|
-
|
|
49
|
-
module.exports = Levy;
|
package/src/models/unitasset.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for companies
|
|
4
|
-
const unitassetSchema = new mongoose.Schema({
|
|
5
|
-
name: {
|
|
6
|
-
type: String,
|
|
7
|
-
required:true
|
|
8
|
-
},
|
|
9
|
-
unitId:{
|
|
10
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
11
|
-
ref: 'Unit',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, {
|
|
16
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// Indexes for improved performance
|
|
20
|
-
unitassetSchema.index({ name: 1 });
|
|
21
|
-
|
|
22
|
-
// Compile the model from the schema
|
|
23
|
-
const UnitAsset = mongoose.model('UnitAsset', unitassetSchema);
|
|
24
|
-
|
|
25
|
-
module.exports = UnitAsset;
|
package/src/models/visitor.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const visitorSchema = new mongoose.Schema({
|
|
5
|
-
firstName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'First name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
lastName: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Last name is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
phoneNumber: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Phone number is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
idNumber: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: [true, 'ID number is required'],
|
|
23
|
-
trim: true
|
|
24
|
-
},
|
|
25
|
-
carRegistration: {
|
|
26
|
-
type: String,
|
|
27
|
-
trim: true
|
|
28
|
-
},
|
|
29
|
-
carMake: {
|
|
30
|
-
type: String,
|
|
31
|
-
trim: true
|
|
32
|
-
},
|
|
33
|
-
carOccupants: {
|
|
34
|
-
type: String,
|
|
35
|
-
trim: true
|
|
36
|
-
},
|
|
37
|
-
carColor: {
|
|
38
|
-
type: String,
|
|
39
|
-
trim: true
|
|
40
|
-
},
|
|
41
|
-
visitorType: {
|
|
42
|
-
type: String,
|
|
43
|
-
trim: true
|
|
44
|
-
},
|
|
45
|
-
entryPoint: {
|
|
46
|
-
type: String,
|
|
47
|
-
trim: true
|
|
48
|
-
},
|
|
49
|
-
houseNumber: {
|
|
50
|
-
type: String,
|
|
51
|
-
trim: true
|
|
52
|
-
},
|
|
53
|
-
resident: {
|
|
54
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
55
|
-
required: [true, 'Resident is required'],
|
|
56
|
-
trim: true,
|
|
57
|
-
ref: 'Customer',
|
|
58
|
-
},
|
|
59
|
-
facilityId: {
|
|
60
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
61
|
-
ref: 'Facility',
|
|
62
|
-
},
|
|
63
|
-
}, {
|
|
64
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Indexes for improved performance
|
|
68
|
-
visitorSchema.index({ fullName: 1 });
|
|
69
|
-
|
|
70
|
-
// Compile the model from the schema
|
|
71
|
-
const Visitor = mongoose.model('Visitor', visitorSchema);
|
|
72
|
-
|
|
73
|
-
module.exports = Visitor;
|