payservedb 3.2.0 → 3.2.2

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 CHANGED
@@ -111,6 +111,7 @@ const models = {
111
111
  MeterProtocol:require('./src/models/water_meter_communication'),
112
112
  MeterManufacturer:require('./src/models/water_meter_manufacturer'),
113
113
  MeterIotCard:require('./src/models/water_meter_iot_cards'),
114
+ MetersDelivery:require('./src/models/water_meters_delivery'),
114
115
  Concentrator:require('./src/models/water_meter_concentrator'),
115
116
  Handover:require('./src/models/handover')
116
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -12,25 +12,22 @@ const meterSchema = new mongoose.Schema({
12
12
  unique: true,
13
13
  },
14
14
  manufacturer: {
15
- type: String,
16
- required: true,
17
- trim: true,
15
+ type: mongoose.Schema.Types.ObjectId,
16
+ ref: 'MeterManufacturer',
18
17
  },
19
18
  protocol: {
20
- type: String,
21
- required: true,
22
- trim: true,
19
+ type: mongoose.Schema.Types.ObjectId,
20
+ ref: 'MeterProtocol',
23
21
  },
24
22
  size: {
25
- type: String,
26
- required: true,
27
- trim: true,
23
+ type: mongoose.Schema.Types.ObjectId,
24
+ ref: 'MeterSize',
28
25
  },
29
26
  status: {
30
27
  type: String,
31
28
  required: true,
32
29
  enum: ['active', 'inactive', 'maintenance', 'faulty'],
33
- default: 'active',
30
+ default: 'inactive',
34
31
  },
35
32
  value: {
36
33
  type: Number,
@@ -13,9 +13,8 @@ const iotCardSchema = new mongoose.Schema({
13
13
  trim: true
14
14
  },
15
15
  concentrator: {
16
- type: String,
17
- required: true,
18
- trim: true
16
+ type: mongoose.Schema.Types.ObjectId,
17
+ ref: 'Concentrator'
19
18
  },
20
19
  location: {
21
20
  type: String,
@@ -0,0 +1,61 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const deliverySchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true
8
+ },
9
+ facilityName: {
10
+ type: String,
11
+ required: true,
12
+ trim: true
13
+ },
14
+ deliveredBy: {
15
+ type: String,
16
+ required: true,
17
+ trim: true
18
+ },
19
+ deliveryDate: {
20
+ type: Date,
21
+ required: true,
22
+ default: Date.now
23
+ },
24
+ notes: {
25
+ type: String,
26
+ trim: true
27
+ },
28
+ concentrators: [{
29
+ concentratorId: {
30
+ type: mongoose.Schema.Types.ObjectId,
31
+ ref: 'Concentrator',
32
+ required: true
33
+ },
34
+ serialNumber: {
35
+ type: String,
36
+ required: true
37
+ }
38
+ }],
39
+ meters: [{
40
+ meterId: {
41
+ type: mongoose.Schema.Types.ObjectId,
42
+ ref: 'Meter',
43
+ required: true
44
+ },
45
+ serialNumber: {
46
+ type: String,
47
+ required: true
48
+ }
49
+ }],
50
+ status: {
51
+ type: String,
52
+ enum: ['pending', 'completed', 'cancelled'],
53
+ default: 'pending'
54
+ }
55
+ }, {
56
+ timestamps: true
57
+ });
58
+
59
+ const MetersDelivery = mongoose.model('MetersDelivery', deliverySchema);
60
+
61
+ module.exports = MetersDelivery;