payservedb 10.0.8 → 10.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "10.0.8",
3
+ "version": "10.0.9",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -132,17 +132,17 @@ const powerMeterSchema = new mongoose.Schema({
132
132
  });
133
133
 
134
134
  powerMeterSchema.virtual('displayName').get(function () {
135
- return this.meterCategory === 'unit'
136
- ? this.unitName
137
- : this.description;
135
+ return this.unitName || this.description;
138
136
  });
139
137
  powerMeterSchema.pre('save', function (next) {
140
138
  if (this.meterCategory === 'unit') {
141
139
  if (!this.unitId || !this.unitName) {
142
140
  return next(new Error('Unit meters require both unitId and unitName.'));
143
141
  }
142
+ } else if (this.meterCategory === 'commercial' && this.unitId && this.unitName) {
143
+ // commercial unit meter: tied to a unit, no description needed
144
144
  } else {
145
- // common_area or bulk
145
+ // common_area, bulk or non-unit commercial
146
146
  if (!this.description) {
147
147
  return next(new Error(`${this.meterCategory} meters require a description.`));
148
148
  }