payservedb 9.0.4 → 9.0.6

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 CHANGED
@@ -286,6 +286,7 @@ const moveInModelDefs = {
286
286
  MoveInMessage: { file: "./src/models/movein_message", name: "MoveInMessage" },
287
287
  MoveInLandlordUser: { file: "./src/models/movein_landlord_user", name: "MoveInLandlordUser" },
288
288
  MoveInHandoffToken: { file: "./src/models/movein_handoff_token", name: "MoveInHandoffToken" },
289
+ MoveInReminder: { file: "./src/models/movein_reminder", name: "MoveInReminder" },
289
290
  };
290
291
 
291
292
  // Initial moveIn namespace — models on default connection (payserve_property).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "9.0.4",
3
+ "version": "9.0.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -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,77 @@
1
+ const mongoose = require('mongoose');
2
+ const ObjectId = mongoose.Schema.Types.ObjectId;
3
+
4
+ const deliveryResultSchema = new mongoose.Schema(
5
+ {
6
+ channel: { type: String, enum: ['email', 'sms', 'whatsapp'], required: true },
7
+ target: { type: String, enum: ['tenant', 'landlord'], required: true },
8
+ recipient: { type: String, default: null },
9
+ success: { type: Boolean, default: false },
10
+ method: { type: String, default: null },
11
+ error: { type: String, default: null },
12
+ sentAt: { type: Date, default: null },
13
+ },
14
+ { _id: false }
15
+ );
16
+
17
+ const moveInReminderSchema = new mongoose.Schema(
18
+ {
19
+ relatedType: {
20
+ type: String,
21
+ enum: ['application', 'reservation', 'viewing', 'unit', 'deal'],
22
+ required: true,
23
+ index: true,
24
+ },
25
+ relatedId: { type: ObjectId, required: true, index: true },
26
+ unitId: { type: ObjectId, default: null, index: true },
27
+ unitName: { type: String, default: null },
28
+ facilityId: { type: ObjectId, default: null, index: true },
29
+ facilityName: { type: String, default: null },
30
+ landlordId: { type: ObjectId, default: null, index: true },
31
+ landlordName: { type: String, default: null },
32
+ landlordEmail: { type: String, default: null },
33
+ landlordPhone: { type: String, default: null },
34
+ tenantId: { type: ObjectId, default: null, index: true },
35
+ tenantName: { type: String, default: null },
36
+ tenantEmail: { type: String, default: null },
37
+ tenantPhone: { type: String, default: null },
38
+ target: {
39
+ type: String,
40
+ enum: ['tenant', 'landlord', 'both'],
41
+ default: 'both',
42
+ index: true,
43
+ },
44
+ channels: {
45
+ type: [String],
46
+ enum: ['email', 'sms', 'whatsapp'],
47
+ default: ['email'],
48
+ },
49
+ subject: { type: String, default: null },
50
+ message: { type: String, required: true },
51
+ callCenterNumber: { type: String, default: '+254733902550' },
52
+ createdBy: { type: ObjectId, default: null, index: true },
53
+ createdByType: {
54
+ type: String,
55
+ enum: ['admin', 'landlord', 'system'],
56
+ default: 'admin',
57
+ index: true,
58
+ },
59
+ scheduledFor: { type: Date, default: null, index: true },
60
+ sentAt: { type: Date, default: null },
61
+ status: {
62
+ type: String,
63
+ enum: ['pending', 'sent', 'partial', 'failed'],
64
+ default: 'pending',
65
+ index: true,
66
+ },
67
+ results: { type: [deliveryResultSchema], default: [] },
68
+ },
69
+ { timestamps: true }
70
+ );
71
+
72
+ moveInReminderSchema.index({ relatedType: 1, relatedId: 1, createdAt: -1 });
73
+ moveInReminderSchema.index({ landlordId: 1, createdAt: -1 });
74
+ moveInReminderSchema.index({ tenantId: 1, createdAt: -1 });
75
+
76
+ const MoveInReminder = mongoose.model('MoveInReminder', moveInReminderSchema);
77
+ module.exports = MoveInReminder;