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