payservedb 9.0.5 → 9.0.7
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 +1 -0
- package/package.json +1 -1
- package/src/models/customer.js +20 -0
- package/src/models/invoiceCreditAdjustment.js +46 -0
- package/src/models/powerMeters.js +35 -1
- package/src/models/suppliers.js +5 -0
package/index.js
CHANGED
|
@@ -259,6 +259,7 @@ const models = {
|
|
|
259
259
|
MoveinLandlord: require("./src/models/movein_landlord"),
|
|
260
260
|
MoveinUser: require("./src/models/movein_user"),
|
|
261
261
|
InvoiceWithholdingTax: require("./src/models/InvoiceWithholdingTax"),
|
|
262
|
+
InvoiceCreditAdjustment: require("./src/models/invoiceCreditAdjustment"),
|
|
262
263
|
// Customer Obsession admin-managed config
|
|
263
264
|
EmailCcConfig: require("./src/models/email_cc_config"),
|
|
264
265
|
AutoReplyRule: require("./src/models/auto_reply_rule"),
|
package/package.json
CHANGED
package/src/models/customer.js
CHANGED
|
@@ -207,6 +207,26 @@ const CustomerSchema = new mongoose.Schema({
|
|
|
207
207
|
},
|
|
208
208
|
},
|
|
209
209
|
],
|
|
210
|
+
secondaryContacts: [
|
|
211
|
+
{
|
|
212
|
+
name: {
|
|
213
|
+
type: String,
|
|
214
|
+
required: true,
|
|
215
|
+
},
|
|
216
|
+
phone: {
|
|
217
|
+
type: String,
|
|
218
|
+
required: false,
|
|
219
|
+
},
|
|
220
|
+
email: {
|
|
221
|
+
type: String,
|
|
222
|
+
required: false,
|
|
223
|
+
},
|
|
224
|
+
receiveNotifications: {
|
|
225
|
+
type: Boolean,
|
|
226
|
+
default: true,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
],
|
|
210
230
|
});
|
|
211
231
|
|
|
212
232
|
const Customer = mongoose.model("Customer", CustomerSchema);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const invoiceCreditAdjustmentSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
invoice: {
|
|
6
|
+
id: { type: mongoose.Schema.Types.ObjectId, ref: "Invoice", required: true },
|
|
7
|
+
invoiceNumber: { type: String, required: true },
|
|
8
|
+
},
|
|
9
|
+
facility: {
|
|
10
|
+
id: { type: mongoose.Schema.Types.ObjectId, ref: "Facility", required: true },
|
|
11
|
+
name: { type: String, required: true },
|
|
12
|
+
},
|
|
13
|
+
client: {
|
|
14
|
+
clientId: { type: mongoose.Schema.Types.ObjectId, ref: "Customer", required: true },
|
|
15
|
+
firstName: { type: String, required: true },
|
|
16
|
+
lastName: { type: String, required: true },
|
|
17
|
+
},
|
|
18
|
+
adjustmentType: {
|
|
19
|
+
type: String,
|
|
20
|
+
enum: ["credit", "debit", "opening-balance"],
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
previousBalance: { type: Number, required: true }, // balanceBroughtForward before change
|
|
24
|
+
adjustmentAmount: { type: Number, required: true }, // the actual change (can be negative)
|
|
25
|
+
newBalance: { type: Number, required: true }, // balanceBroughtForward after change
|
|
26
|
+
reason: { type: String, required: true },
|
|
27
|
+
madeBy: {
|
|
28
|
+
userId: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true },
|
|
29
|
+
name: { type: String, required: true },
|
|
30
|
+
role: { type: String, required: true },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{ timestamps: true }
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
invoiceCreditAdjustmentSchema.index({ "invoice.id": 1 });
|
|
37
|
+
invoiceCreditAdjustmentSchema.index({ "client.clientId": 1 });
|
|
38
|
+
invoiceCreditAdjustmentSchema.index({ "facility.id": 1 });
|
|
39
|
+
invoiceCreditAdjustmentSchema.index({ adjustmentType: 1 });
|
|
40
|
+
|
|
41
|
+
const InvoiceCreditAdjustment = mongoose.model(
|
|
42
|
+
"InvoiceCreditAdjustment",
|
|
43
|
+
invoiceCreditAdjustmentSchema
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
module.exports = InvoiceCreditAdjustment;
|
|
@@ -59,6 +59,14 @@ const powerMeterSchema = new mongoose.Schema({
|
|
|
59
59
|
type: String,
|
|
60
60
|
required: true
|
|
61
61
|
},
|
|
62
|
+
|
|
63
|
+
meterCategory: {
|
|
64
|
+
type: String,
|
|
65
|
+
required: true,
|
|
66
|
+
enum: ['unit', 'common_area', 'bulk'],
|
|
67
|
+
default: 'unit'
|
|
68
|
+
},
|
|
69
|
+
|
|
62
70
|
unitId: {
|
|
63
71
|
type: mongoose.Schema.Types.ObjectId,
|
|
64
72
|
ref: 'Unit',
|
|
@@ -68,6 +76,13 @@ const powerMeterSchema = new mongoose.Schema({
|
|
|
68
76
|
type: String,
|
|
69
77
|
trim: true
|
|
70
78
|
},
|
|
79
|
+
|
|
80
|
+
// ─── Common Area / Bulk Meter Fields ──────────────────────────────────────
|
|
81
|
+
description: {
|
|
82
|
+
type: String,
|
|
83
|
+
trim: true
|
|
84
|
+
},
|
|
85
|
+
|
|
71
86
|
type: {
|
|
72
87
|
type: String,
|
|
73
88
|
required: true,
|
|
@@ -111,6 +126,25 @@ const powerMeterSchema = new mongoose.Schema({
|
|
|
111
126
|
timestamps: true
|
|
112
127
|
});
|
|
113
128
|
|
|
129
|
+
powerMeterSchema.virtual('displayName').get(function () {
|
|
130
|
+
return this.meterCategory === 'unit'
|
|
131
|
+
? this.unitName
|
|
132
|
+
: this.description;
|
|
133
|
+
});
|
|
134
|
+
powerMeterSchema.pre('save', function (next) {
|
|
135
|
+
if (this.meterCategory === 'unit') {
|
|
136
|
+
if (!this.unitId || !this.unitName) {
|
|
137
|
+
return next(new Error('Unit meters require both unitId and unitName.'));
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
// common_area or bulk
|
|
141
|
+
if (!this.description) {
|
|
142
|
+
return next(new Error(`${this.meterCategory} meters require a description.`));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
next();
|
|
146
|
+
});
|
|
147
|
+
|
|
114
148
|
const PowerMeters = mongoose.model('PowerMeters', powerMeterSchema);
|
|
115
149
|
|
|
116
|
-
module.exports = PowerMeters;
|
|
150
|
+
module.exports = PowerMeters;
|