payservedb 3.9.2 → 3.9.4

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": "3.9.2",
3
+ "version": "3.9.4",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,48 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const analogBillingSchema = new mongoose.Schema({
4
+ facilityId: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Facility',
7
+ required: true,
8
+ },
9
+ meterNumber: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ currentReading: {
14
+ type: Number,
15
+ required: true,
16
+ },
17
+ previousReading: {
18
+ type: Number,
19
+ required: true,
20
+ },
21
+ yearMonth: {
22
+ type: String, // Expected format: 'YYYY-MM'
23
+ required: true,
24
+ },
25
+ totalUsage: {
26
+ type: Number,
27
+ required: true,
28
+ },
29
+ unitId: {
30
+ type: mongoose.Schema.Types.ObjectId,
31
+ ref: 'Unit',
32
+ },
33
+ customerId: {
34
+ type: mongoose.Schema.Types.ObjectId,
35
+ ref: 'Customer',
36
+ },
37
+ status: {
38
+ type: String,
39
+ enum: ['pending', 'reviewed', 'billed'],
40
+ default: 'pending',
41
+ }
42
+ }, {
43
+ timestamps: true,
44
+ });
45
+
46
+ analogBillingSchema.index({ meterNumber: 1, yearMonth: 1 }, { unique: true });
47
+
48
+ module.exports = mongoose.model('AnalogBilling', analogBillingSchema);
@@ -54,12 +54,12 @@ const handoverSchema = new mongoose.Schema({
54
54
  ref: 'Unit',
55
55
  required: true
56
56
  },
57
+ // IMPORTANT: For Customer, we don't specify 'ref' since it's in a different database
58
+ // This avoids the cross-database population errors
57
59
  customerId: {
58
60
  type: mongoose.Schema.Types.ObjectId,
59
- ref: 'Customer',
60
61
  required: true
61
62
  },
62
- // propertyManagerId removed as requested
63
63
 
64
64
  // Handover details
65
65
  handoverType: {
@@ -236,6 +236,7 @@ handoverSchema.methods.compareWithMoveIn = async function() {
236
236
  return differences;
237
237
  };
238
238
 
239
+ // Create and export the model with the standard pattern
239
240
  const Handover = mongoose.model('Handover', handoverSchema);
240
241
 
241
242
  module.exports = Handover;