payservedb 3.5.6 → 3.5.8
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 +1 -1
- package/src/models/reminder.js +11 -6
package/package.json
CHANGED
package/src/models/reminder.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
2
|
const moment = require("moment-timezone");
|
|
3
3
|
|
|
4
|
-
// Define the schema for Reminder
|
|
5
4
|
const reminderSchema = new mongoose.Schema(
|
|
6
5
|
{
|
|
7
6
|
name: {
|
|
@@ -39,10 +38,7 @@ const reminderSchema = new mongoose.Schema(
|
|
|
39
38
|
type: [Number],
|
|
40
39
|
validate: {
|
|
41
40
|
validator: function (value) {
|
|
42
|
-
// If afterOverdue is not enabled, any value is valid
|
|
43
41
|
if (!this.remindOn.afterOverdue.enabled) return true;
|
|
44
|
-
|
|
45
|
-
// When enabled, days must be 1, 3, or 7
|
|
46
42
|
return Array.isArray(value) &&
|
|
47
43
|
value.length > 0 &&
|
|
48
44
|
value.every(day => [1, 3, 7].includes(day));
|
|
@@ -94,7 +90,16 @@ const reminderSchema = new mongoose.Schema(
|
|
|
94
90
|
levyId: {
|
|
95
91
|
type: mongoose.Schema.Types.ObjectId,
|
|
96
92
|
ref: "Levy",
|
|
97
|
-
required:
|
|
93
|
+
required: function() {
|
|
94
|
+
return this.module === 'levy';
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
leaseId: {
|
|
98
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
99
|
+
ref: "LeaseAgreement",
|
|
100
|
+
required: function() {
|
|
101
|
+
return this.module === 'lease';
|
|
102
|
+
}
|
|
98
103
|
},
|
|
99
104
|
facilityId: {
|
|
100
105
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -116,13 +121,13 @@ const reminderSchema = new mongoose.Schema(
|
|
|
116
121
|
},
|
|
117
122
|
{
|
|
118
123
|
timestamps: true,
|
|
119
|
-
// Add indexes for frequently queried fields
|
|
120
124
|
indexes: [
|
|
121
125
|
{ facilityId: 1, isActive: 1 },
|
|
122
126
|
{ facilityId: 1, isActive: 1, 'remindOn.invoiceDate': 1 },
|
|
123
127
|
{ facilityId: 1, isActive: 1, 'remindOn.dueDate': 1 },
|
|
124
128
|
{ facilityId: 1, isActive: 1, 'remindOn.afterOverdue.enabled': 1 },
|
|
125
129
|
{ levyId: 1, isActive: 1 },
|
|
130
|
+
{ leaseId: 1, isActive: 1 },
|
|
126
131
|
{ facilityId: 1, lastProcessed: 1 }
|
|
127
132
|
]
|
|
128
133
|
}
|