payservedb 9.2.7 → 9.2.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.
Files changed (229) hide show
  1. package/.env +2 -2
  2. package/ZOHO_INTEGRATION_SCHEMA.md +644 -644
  3. package/index.js +415 -414
  4. package/package.json +17 -17
  5. package/src/models/InvoiceWithholdingTax.js +67 -67
  6. package/src/models/account.js +52 -52
  7. package/src/models/agent_departments.js +59 -59
  8. package/src/models/agent_notifications.js +53 -53
  9. package/src/models/agent_performance.js +127 -127
  10. package/src/models/agent_roles.js +77 -77
  11. package/src/models/agents.js +154 -154
  12. package/src/models/apilog.js +18 -18
  13. package/src/models/approvalsWorkflows.js +49 -49
  14. package/src/models/archivedapilog.js +18 -18
  15. package/src/models/asset.js +92 -92
  16. package/src/models/assetsAssignment.js +64 -64
  17. package/src/models/auditTrail.js +346 -346
  18. package/src/models/auto_reply_rule.js +68 -68
  19. package/src/models/bankdetails.js +47 -47
  20. package/src/models/billerAddress.js +124 -124
  21. package/src/models/booking_invoice.js +165 -165
  22. package/src/models/bookinganalytics.js +63 -63
  23. package/src/models/bookingconfig.js +45 -45
  24. package/src/models/bookingproperty.js +179 -179
  25. package/src/models/bookingreservation.js +239 -239
  26. package/src/models/bookingrevenuerecord.js +84 -84
  27. package/src/models/budget.js +95 -95
  28. package/src/models/budgetCategory.js +19 -19
  29. package/src/models/campaigns.js +108 -108
  30. package/src/models/cashpayment.js +290 -290
  31. package/src/models/combinedUnits.js +62 -62
  32. package/src/models/combined_invoice.js +424 -424
  33. package/src/models/common_area_electricity.js +38 -38
  34. package/src/models/common_area_generator.js +41 -41
  35. package/src/models/common_area_utility_alert.js +37 -37
  36. package/src/models/common_area_water.js +39 -39
  37. package/src/models/communication_status.js +33 -33
  38. package/src/models/communication_user_opt.js +32 -32
  39. package/src/models/community_guidelines.js +35 -35
  40. package/src/models/company.js +53 -53
  41. package/src/models/coreBaseSettings.js +16 -16
  42. package/src/models/coreInvoiceSettings.js +100 -100
  43. package/src/models/counter_schema.js +21 -21
  44. package/src/models/country_tax.js +42 -42
  45. package/src/models/currency_settings.js +39 -39
  46. package/src/models/customer.js +234 -234
  47. package/src/models/customer_preference.js +52 -52
  48. package/src/models/customer_satisfaction_survey.js +297 -297
  49. package/src/models/customer_surveys.js +139 -139
  50. package/src/models/customer_tickets.js +237 -237
  51. package/src/models/dailyChecklist.js +312 -312
  52. package/src/models/default_payment_details.js +17 -17
  53. package/src/models/deliveryTimeMarks.js +18 -18
  54. package/src/models/document_type.js +19 -19
  55. package/src/models/dutyRosterChecklist.js +250 -250
  56. package/src/models/dutyroster.js +136 -136
  57. package/src/models/email.js +37 -37
  58. package/src/models/email_cc_config.js +48 -48
  59. package/src/models/email_sms_queue.js +61 -61
  60. package/src/models/email_thread.js +35 -35
  61. package/src/models/entry_exit.js +53 -53
  62. package/src/models/expense.js +99 -99
  63. package/src/models/expense_category.js +45 -45
  64. package/src/models/facility.js +76 -76
  65. package/src/models/facilityBillingPrices.js +29 -29
  66. package/src/models/facilityInvoice.js +240 -240
  67. package/src/models/facilityInvoicePayment.js +52 -52
  68. package/src/models/facilityInvoiceRecipient.js +32 -32
  69. package/src/models/facilityWalletTransactionsMetadata.js +236 -236
  70. package/src/models/facility_departements.js +20 -20
  71. package/src/models/facility_etims_config.js +116 -116
  72. package/src/models/facility_payment_details.js +20 -20
  73. package/src/models/facility_rating.js +78 -78
  74. package/src/models/facilityasset.js +25 -25
  75. package/src/models/faq.js +15 -15
  76. package/src/models/gl_account_double_entries.js +25 -25
  77. package/src/models/gl_accounts.js +56 -56
  78. package/src/models/gl_entries.js +49 -49
  79. package/src/models/goodsReceivedNotes.js +115 -115
  80. package/src/models/guard.js +47 -47
  81. package/src/models/handover.js +258 -258
  82. package/src/models/inspection_category.js +38 -38
  83. package/src/models/invoice.js +528 -528
  84. package/src/models/invoiceCreditAdjustment.js +45 -45
  85. package/src/models/invoice_edit_log.js +81 -81
  86. package/src/models/invoice_generation_approval.js +86 -86
  87. package/src/models/invoicing_schedule.js +40 -40
  88. package/src/models/item_inspection.js +96 -96
  89. package/src/models/knowledge_base.js +109 -109
  90. package/src/models/knowledge_base_rating.js +44 -44
  91. package/src/models/leaseagreement.js +243 -243
  92. package/src/models/leasetemplate.js +17 -17
  93. package/src/models/levy.js +212 -212
  94. package/src/models/levy_deposits.js +126 -126
  95. package/src/models/levy_invoice_settings.js +26 -26
  96. package/src/models/levy_payment_receipt.js +157 -0
  97. package/src/models/levycontract.js +226 -226
  98. package/src/models/levytype.js +23 -23
  99. package/src/models/maintenance_service_vendor.js +38 -38
  100. package/src/models/maintenance_services.js +17 -17
  101. package/src/models/maintenancerequisition.js +31 -31
  102. package/src/models/master_workplan.js +32 -32
  103. package/src/models/master_workplan_child.js +34 -34
  104. package/src/models/message.js +38 -38
  105. package/src/models/module.js +21 -21
  106. package/src/models/movein_amenity.js +13 -13
  107. package/src/models/movein_application.js +28 -28
  108. package/src/models/movein_audit_log.js +21 -21
  109. package/src/models/movein_booking.js +33 -33
  110. package/src/models/movein_commission.js +46 -46
  111. package/src/models/movein_conversation.js +25 -25
  112. package/src/models/movein_deal.js +79 -79
  113. package/src/models/movein_disbursement.js +36 -36
  114. package/src/models/movein_email_thread.js +19 -19
  115. package/src/models/movein_enquiry.js +16 -16
  116. package/src/models/movein_featured_package.js +16 -16
  117. package/src/models/movein_handoff_token.js +16 -16
  118. package/src/models/movein_invoice.js +24 -24
  119. package/src/models/movein_landlord.js +18 -18
  120. package/src/models/movein_landlord_user.js +20 -20
  121. package/src/models/movein_lease.js +37 -37
  122. package/src/models/movein_message.js +27 -27
  123. package/src/models/movein_notification.js +27 -27
  124. package/src/models/movein_otp.js +14 -14
  125. package/src/models/movein_payment.js +46 -46
  126. package/src/models/movein_reminder.js +77 -77
  127. package/src/models/movein_reservation.js +31 -31
  128. package/src/models/movein_settings.js +25 -25
  129. package/src/models/movein_tenancy.js +55 -55
  130. package/src/models/movein_unit.js +59 -59
  131. package/src/models/movein_user.js +15 -15
  132. package/src/models/movein_viewing_slot.js +21 -21
  133. package/src/models/movein_want_unit.js +20 -20
  134. package/src/models/notification.js +44 -44
  135. package/src/models/paymentTermsMarks.js +19 -19
  136. package/src/models/penalty.js +76 -76
  137. package/src/models/pendingCredentials.js +32 -32
  138. package/src/models/powerMeterCommunicationProtocol.js +17 -17
  139. package/src/models/powerMeterCustomerAccount.js +78 -78
  140. package/src/models/powerMeterCustomerBand.js +14 -14
  141. package/src/models/powerMeterDailyReading.js +30 -30
  142. package/src/models/powerMeterGateways.js +40 -40
  143. package/src/models/powerMeterMonthlyReading.js +34 -34
  144. package/src/models/powerMeterPowerCharges.js +85 -85
  145. package/src/models/powerMeterSettings.js +211 -211
  146. package/src/models/powerMeterSingleDayReading.js +32 -32
  147. package/src/models/powerMeters.js +149 -149
  148. package/src/models/powerMetersManufacturer.js +14 -14
  149. package/src/models/power_invoice.js +366 -366
  150. package/src/models/power_meter_account.js +81 -81
  151. package/src/models/power_meter_command_logs.js +30 -30
  152. package/src/models/power_meter_command_queue.js +33 -33
  153. package/src/models/power_meter_negative_balance.js +44 -44
  154. package/src/models/power_prepaid_credits.js +47 -47
  155. package/src/models/power_prepaid_debits.js +53 -53
  156. package/src/models/power_prepaid_orders.js +78 -78
  157. package/src/models/power_sms_notification.js +26 -26
  158. package/src/models/privacy_policy.js +19 -19
  159. package/src/models/propertyManagerContract.js +556 -556
  160. package/src/models/propertyManagerRevenue.js +195 -195
  161. package/src/models/purchaseOrderInvoice.js +74 -74
  162. package/src/models/purchase_order.js +213 -213
  163. package/src/models/purchase_request.js +110 -110
  164. package/src/models/quickbooks_config.js +52 -52
  165. package/src/models/recipient_group.js +61 -61
  166. package/src/models/recipient_group_member.js +62 -62
  167. package/src/models/refresh_token.js +23 -23
  168. package/src/models/reminder.js +197 -197
  169. package/src/models/report.js +13 -13
  170. package/src/models/resident.js +121 -121
  171. package/src/models/rfq_details.js +131 -131
  172. package/src/models/rfq_response.js +153 -153
  173. package/src/models/service_charge_invoice_upload.js +42 -42
  174. package/src/models/service_charge_payments.js +27 -27
  175. package/src/models/servicerequest.js +55 -55
  176. package/src/models/settings.js +62 -62
  177. package/src/models/short_urls.js +21 -21
  178. package/src/models/smart_meter_daily_consumption.js +44 -44
  179. package/src/models/sms_africastalking.js +20 -20
  180. package/src/models/sms_balance_notification.js +26 -26
  181. package/src/models/sms_meliora.js +20 -20
  182. package/src/models/staff.js +36 -36
  183. package/src/models/stocksandspare.js +161 -161
  184. package/src/models/suppliers.js +79 -79
  185. package/src/models/terms_and_conditions.js +19 -19
  186. package/src/models/tickets.js +186 -186
  187. package/src/models/tickets_category.js +72 -72
  188. package/src/models/unitManagementTemplate.js +44 -44
  189. package/src/models/unitasset.js +25 -25
  190. package/src/models/units.js +130 -130
  191. package/src/models/user.js +192 -192
  192. package/src/models/valueaddedservices.js +21 -21
  193. package/src/models/vas_invoices_upload.js +50 -50
  194. package/src/models/vas_payments.js +24 -24
  195. package/src/models/vasinvoice.js +196 -196
  196. package/src/models/vasvendor.js +52 -52
  197. package/src/models/visitLog.js +95 -95
  198. package/src/models/visitor.js +67 -67
  199. package/src/models/waitlist.js +45 -45
  200. package/src/models/wallet.js +44 -44
  201. package/src/models/wallet_transaction.js +67 -67
  202. package/src/models/wallet_transactions.js +50 -50
  203. package/src/models/water_invoice.js +396 -396
  204. package/src/models/water_meter_Command_Queue.js +33 -33
  205. package/src/models/water_meter_account.js +86 -86
  206. package/src/models/water_meter_billing.js +58 -58
  207. package/src/models/water_meter_combined_accounts.js +92 -92
  208. package/src/models/water_meter_communication.js +17 -17
  209. package/src/models/water_meter_communication_logs.js +39 -39
  210. package/src/models/water_meter_concentrator.js +70 -70
  211. package/src/models/water_meter_daily_history.js +32 -32
  212. package/src/models/water_meter_high_risk.js +36 -36
  213. package/src/models/water_meter_iot_cards.js +34 -34
  214. package/src/models/water_meter_loan_deduction.js +134 -134
  215. package/src/models/water_meter_manufacturer.js +35 -35
  216. package/src/models/water_meter_monthly_history.js +36 -36
  217. package/src/models/water_meter_negative_amounts.js +44 -44
  218. package/src/models/water_meter_settings.js +296 -296
  219. package/src/models/water_meter_single_day_history.js +34 -34
  220. package/src/models/water_meter_size.js +15 -15
  221. package/src/models/water_meters.js +176 -176
  222. package/src/models/water_meters_delivery.js +76 -76
  223. package/src/models/water_prepaid_credit.js +47 -47
  224. package/src/models/water_prepaid_debit.js +50 -50
  225. package/src/models/whatsapp_conversation.js +23 -23
  226. package/src/models/workorder.js +49 -49
  227. package/src/models/zohoAccount.js +453 -453
  228. package/src/models/zohoIntegration.js +262 -262
  229. package/src/models/zohoItem.js +504 -504
@@ -1,18 +1,18 @@
1
- const mongoose = require('mongoose');
2
- const ObjectId = mongoose.Schema.Types.ObjectId;
3
-
4
- // Created in payserve_movein DB when admin assigns the Move-In module to a landlord.
5
- // landlordId references the payserve_property User — no cross-DB constraint enforced by Mongoose.
6
- const moveInLandlordSchema = new mongoose.Schema(
7
- {
8
- landlordId: { type: ObjectId, required: true, unique: true, index: true },
9
- isEnabled: { type: Boolean, default: true, index: true },
10
- assignedBy: { type: ObjectId, default: null }, // core user who assigned
11
- assignedAt: { type: Date, default: Date.now },
12
- revokedAt: { type: Date, default: null },
13
- },
14
- { timestamps: true }
15
- );
16
-
17
- const MoveInLandlord = mongoose.model('MoveInLandlord', moveInLandlordSchema);
18
- module.exports = MoveInLandlord;
1
+ const mongoose = require('mongoose');
2
+ const ObjectId = mongoose.Schema.Types.ObjectId;
3
+
4
+ // Created in payserve_movein DB when admin assigns the Move-In module to a landlord.
5
+ // landlordId references the payserve_property User — no cross-DB constraint enforced by Mongoose.
6
+ const moveInLandlordSchema = new mongoose.Schema(
7
+ {
8
+ landlordId: { type: ObjectId, required: true, unique: true, index: true },
9
+ isEnabled: { type: Boolean, default: true, index: true },
10
+ assignedBy: { type: ObjectId, default: null }, // core user who assigned
11
+ assignedAt: { type: Date, default: Date.now },
12
+ revokedAt: { type: Date, default: null },
13
+ },
14
+ { timestamps: true }
15
+ );
16
+
17
+ const MoveInLandlord = mongoose.model('MoveInLandlord', moveInLandlordSchema);
18
+ module.exports = MoveInLandlord;
@@ -1,20 +1,20 @@
1
- const mongoose = require('mongoose');
2
-
3
- const moveInLandlordUserSchema = new mongoose.Schema(
4
- {
5
- fullName: { type: String, required: true, trim: true },
6
- email: { type: String, required: true, unique: true, lowercase: true, trim: true },
7
- phoneNumber: { type: String, required: true, unique: true },
8
- // Standalone landlords have a bcrypt password.
9
- // PayServe-linked landlords have MANAGED_BY_PAYSERVE — auth defers to payserve_property.
10
- password: { type: String, default: 'MANAGED_BY_PAYSERVE' },
11
- companyName: { type: String, trim: true, default: null },
12
- isEnabled: { type: Boolean, default: true },
13
- // Set when provisioned from an existing PayServe landlord account.
14
- payserveUserId: { type: mongoose.Schema.Types.ObjectId, default: null, index: true },
15
- },
16
- { timestamps: true }
17
- );
18
-
19
- const MoveInLandlordUser = mongoose.model('MoveInLandlordUser', moveInLandlordUserSchema);
20
- module.exports = MoveInLandlordUser;
1
+ const mongoose = require('mongoose');
2
+
3
+ const moveInLandlordUserSchema = new mongoose.Schema(
4
+ {
5
+ fullName: { type: String, required: true, trim: true },
6
+ email: { type: String, required: true, unique: true, lowercase: true, trim: true },
7
+ phoneNumber: { type: String, required: true, unique: true },
8
+ // Standalone landlords have a bcrypt password.
9
+ // PayServe-linked landlords have MANAGED_BY_PAYSERVE — auth defers to payserve_property.
10
+ password: { type: String, default: 'MANAGED_BY_PAYSERVE' },
11
+ companyName: { type: String, trim: true, default: null },
12
+ isEnabled: { type: Boolean, default: true },
13
+ // Set when provisioned from an existing PayServe landlord account.
14
+ payserveUserId: { type: mongoose.Schema.Types.ObjectId, default: null, index: true },
15
+ },
16
+ { timestamps: true }
17
+ );
18
+
19
+ const MoveInLandlordUser = mongoose.model('MoveInLandlordUser', moveInLandlordUserSchema);
20
+ module.exports = MoveInLandlordUser;
@@ -1,38 +1,38 @@
1
- const mongoose = require('mongoose');
2
-
3
- const moveInLeaseSchema = new mongoose.Schema(
4
- {
5
- // 'default' = platform-wide template; 'unit' = unit-specific override
6
- type: { type: String, enum: ['default', 'unit'], required: true, index: true },
7
- unitId: { type: mongoose.Schema.Types.ObjectId, default: null, index: true },
8
- uploadedBy: { type: mongoose.Schema.Types.ObjectId, required: true },
9
-
10
- // File storage
11
- originalName: { type: String, required: true },
12
- filePath: { type: String, required: true },
13
- mimeType: { type: String, default: 'application/pdf' },
14
- fileSizeBytes: { type: Number, default: null },
15
-
16
- status: { type: String, enum: ['active', 'superseded'], default: 'active', index: true },
17
- supersededAt: { type: Date, default: null },
18
-
19
- // Signed copy (per tenancy — embedded subdoc array)
20
- signedCopies: [
21
- {
22
- tenancyId: { type: mongoose.Schema.Types.ObjectId, required: true },
23
- tenantId: { type: mongoose.Schema.Types.ObjectId, required: true },
24
- filePath: { type: String, required: true },
25
- originalName: { type: String, default: null },
26
- uploadedAt: { type: Date, default: Date.now },
27
- status: { type: String, enum: ['pending_review', 'approved', 'rejected'], default: 'pending_review' },
28
- reviewedAt: { type: Date, default: null },
29
- reviewedBy: { type: mongoose.Schema.Types.ObjectId, default: null },
30
- rejectionNote: { type: String, default: null },
31
- }
32
- ],
33
- },
34
- { timestamps: true }
35
- );
36
-
37
- const MoveInLease = mongoose.model('MoveInLease', moveInLeaseSchema);
1
+ const mongoose = require('mongoose');
2
+
3
+ const moveInLeaseSchema = new mongoose.Schema(
4
+ {
5
+ // 'default' = platform-wide template; 'unit' = unit-specific override
6
+ type: { type: String, enum: ['default', 'unit'], required: true, index: true },
7
+ unitId: { type: mongoose.Schema.Types.ObjectId, default: null, index: true },
8
+ uploadedBy: { type: mongoose.Schema.Types.ObjectId, required: true },
9
+
10
+ // File storage
11
+ originalName: { type: String, required: true },
12
+ filePath: { type: String, required: true },
13
+ mimeType: { type: String, default: 'application/pdf' },
14
+ fileSizeBytes: { type: Number, default: null },
15
+
16
+ status: { type: String, enum: ['active', 'superseded'], default: 'active', index: true },
17
+ supersededAt: { type: Date, default: null },
18
+
19
+ // Signed copy (per tenancy — embedded subdoc array)
20
+ signedCopies: [
21
+ {
22
+ tenancyId: { type: mongoose.Schema.Types.ObjectId, required: true },
23
+ tenantId: { type: mongoose.Schema.Types.ObjectId, required: true },
24
+ filePath: { type: String, required: true },
25
+ originalName: { type: String, default: null },
26
+ uploadedAt: { type: Date, default: Date.now },
27
+ status: { type: String, enum: ['pending_review', 'approved', 'rejected'], default: 'pending_review' },
28
+ reviewedAt: { type: Date, default: null },
29
+ reviewedBy: { type: mongoose.Schema.Types.ObjectId, default: null },
30
+ rejectionNote: { type: String, default: null },
31
+ }
32
+ ],
33
+ },
34
+ { timestamps: true }
35
+ );
36
+
37
+ const MoveInLease = mongoose.model('MoveInLease', moveInLeaseSchema);
38
38
  module.exports = MoveInLease;
@@ -1,27 +1,27 @@
1
- const mongoose = require('mongoose');
2
- const ObjectId = mongoose.Schema.Types.ObjectId;
3
-
4
- const moveInMessageSchema = new mongoose.Schema(
5
- {
6
- conversationId: { type: ObjectId, ref: 'MoveInConversation', required: true, index: true },
7
- senderId: { type: ObjectId, required: true, index: true },
8
- senderType: {
9
- type: String,
10
- enum: ['tenant', 'landlord'],
11
- required: true,
12
- },
13
- body: { type: String, required: true },
14
- type: {
15
- type: String,
16
- enum: ['text', 'image'],
17
- default: 'text',
18
- },
19
- attachmentUrl: { type: String, default: null },
20
- isRead: { type: Boolean, default: false, index: true },
21
- readAt: { type: Date, default: null },
22
- },
23
- { timestamps: true }
24
- );
25
-
26
- const MoveInMessage = mongoose.model('MoveInMessage', moveInMessageSchema);
27
- module.exports = MoveInMessage;
1
+ const mongoose = require('mongoose');
2
+ const ObjectId = mongoose.Schema.Types.ObjectId;
3
+
4
+ const moveInMessageSchema = new mongoose.Schema(
5
+ {
6
+ conversationId: { type: ObjectId, ref: 'MoveInConversation', required: true, index: true },
7
+ senderId: { type: ObjectId, required: true, index: true },
8
+ senderType: {
9
+ type: String,
10
+ enum: ['tenant', 'landlord'],
11
+ required: true,
12
+ },
13
+ body: { type: String, required: true },
14
+ type: {
15
+ type: String,
16
+ enum: ['text', 'image'],
17
+ default: 'text',
18
+ },
19
+ attachmentUrl: { type: String, default: null },
20
+ isRead: { type: Boolean, default: false, index: true },
21
+ readAt: { type: Date, default: null },
22
+ },
23
+ { timestamps: true }
24
+ );
25
+
26
+ const MoveInMessage = mongoose.model('MoveInMessage', moveInMessageSchema);
27
+ module.exports = MoveInMessage;
@@ -1,27 +1,27 @@
1
- const mongoose = require('mongoose');
2
- const ObjectId = mongoose.Schema.Types.ObjectId;
3
-
4
- const moveInNotificationSchema = new mongoose.Schema(
5
- {
6
- recipientId: { type: ObjectId, required: true, index: true },
7
- recipientType: {
8
- type: String,
9
- enum: ['tenant', 'landlord'],
10
- required: true,
11
- },
12
- title: { type: String, required: true },
13
- body: { type: String, required: true },
14
- type: {
15
- type: String,
16
- enum: ['application', 'viewing', 'reservation', 'payment', 'message', 'general'],
17
- default: 'general',
18
- },
19
- relatedId: { type: ObjectId, default: null },
20
- isRead: { type: Boolean, default: false, index: true },
21
- readAt: { type: Date, default: null },
22
- },
23
- { timestamps: true }
24
- );
25
-
26
- const MoveInNotification = mongoose.model('MoveInNotification', moveInNotificationSchema);
27
- module.exports = MoveInNotification;
1
+ const mongoose = require('mongoose');
2
+ const ObjectId = mongoose.Schema.Types.ObjectId;
3
+
4
+ const moveInNotificationSchema = new mongoose.Schema(
5
+ {
6
+ recipientId: { type: ObjectId, required: true, index: true },
7
+ recipientType: {
8
+ type: String,
9
+ enum: ['tenant', 'landlord'],
10
+ required: true,
11
+ },
12
+ title: { type: String, required: true },
13
+ body: { type: String, required: true },
14
+ type: {
15
+ type: String,
16
+ enum: ['application', 'viewing', 'reservation', 'payment', 'message', 'general'],
17
+ default: 'general',
18
+ },
19
+ relatedId: { type: ObjectId, default: null },
20
+ isRead: { type: Boolean, default: false, index: true },
21
+ readAt: { type: Date, default: null },
22
+ },
23
+ { timestamps: true }
24
+ );
25
+
26
+ const MoveInNotification = mongoose.model('MoveInNotification', moveInNotificationSchema);
27
+ module.exports = MoveInNotification;
@@ -1,14 +1,14 @@
1
- const mongoose = require('mongoose');
2
-
3
- const moveInOtpSchema = new mongoose.Schema(
4
- {
5
- email: { type: String, required: true, lowercase: true, trim: true, index: true },
6
- otp: { type: String, required: true },
7
- expiresAt: { type: Date, required: true },
8
- used: { type: Boolean, default: false },
9
- },
10
- { timestamps: true }
11
- );
12
-
13
- const MoveInOtp = mongoose.model('MoveInOtp', moveInOtpSchema);
14
- module.exports = MoveInOtp;
1
+ const mongoose = require('mongoose');
2
+
3
+ const moveInOtpSchema = new mongoose.Schema(
4
+ {
5
+ email: { type: String, required: true, lowercase: true, trim: true, index: true },
6
+ otp: { type: String, required: true },
7
+ expiresAt: { type: Date, required: true },
8
+ used: { type: Boolean, default: false },
9
+ },
10
+ { timestamps: true }
11
+ );
12
+
13
+ const MoveInOtp = mongoose.model('MoveInOtp', moveInOtpSchema);
14
+ module.exports = MoveInOtp;
@@ -1,46 +1,46 @@
1
- const mongoose = require('mongoose');
2
- const ObjectId = mongoose.Schema.Types.ObjectId;
3
-
4
- const moveInPaymentSchema = new mongoose.Schema(
5
- {
6
- tenantId: { type: ObjectId, ref: 'MoveInUser', default: null, index: true },
7
- tenantName: { type: String, default: null },
8
- unitId: { type: ObjectId, default: null, index: true },
9
- unitName: { type: String, default: null },
10
- reservationId: { type: ObjectId, ref: 'MoveInReservation', default: null, index: true },
11
- dealId: { type: ObjectId, ref: 'MoveInDeal', default: null, index: true },
12
- commissionId: { type: ObjectId, ref: 'MoveInCommission', default: null, index: true },
13
- type: {
14
- type: String,
15
- enum: ['reservation_fee', 'deposit', 'first_month_rent', 'commission', 'other'],
16
- required: true,
17
- },
18
- amount: { type: Number, required: true },
19
- currency: { type: String, default: 'KES' },
20
- status: {
21
- type: String,
22
- enum: ['pending', 'paid', 'failed', 'refunded', 'waived', 'cancelled', 'disputed'],
23
- default: 'pending',
24
- index: true,
25
- },
26
- reference: { type: String, default: null },
27
- externalReference: { type: String, default: null, index: true },
28
- paymentMethod: {
29
- type: String,
30
- enum: ['mpesa', 'card', 'cash', 'other'],
31
- default: null,
32
- },
33
- payerType: {
34
- type: String,
35
- enum: ['tenant', 'landlord', 'owner', 'admin'],
36
- default: 'tenant',
37
- index: true,
38
- },
39
- paidAt: { type: Date, default: null },
40
- notes: { type: String, default: null },
41
- },
42
- { timestamps: true }
43
- );
44
-
45
- const MoveInPayment = mongoose.model('MoveInPayment', moveInPaymentSchema);
46
- module.exports = MoveInPayment;
1
+ const mongoose = require('mongoose');
2
+ const ObjectId = mongoose.Schema.Types.ObjectId;
3
+
4
+ const moveInPaymentSchema = new mongoose.Schema(
5
+ {
6
+ tenantId: { type: ObjectId, ref: 'MoveInUser', default: null, index: true },
7
+ tenantName: { type: String, default: null },
8
+ unitId: { type: ObjectId, default: null, index: true },
9
+ unitName: { type: String, default: null },
10
+ reservationId: { type: ObjectId, ref: 'MoveInReservation', default: null, index: true },
11
+ dealId: { type: ObjectId, ref: 'MoveInDeal', default: null, index: true },
12
+ commissionId: { type: ObjectId, ref: 'MoveInCommission', default: null, index: true },
13
+ type: {
14
+ type: String,
15
+ enum: ['reservation_fee', 'deposit', 'first_month_rent', 'commission', 'other'],
16
+ required: true,
17
+ },
18
+ amount: { type: Number, required: true },
19
+ currency: { type: String, default: 'KES' },
20
+ status: {
21
+ type: String,
22
+ enum: ['pending', 'paid', 'failed', 'refunded', 'waived', 'cancelled', 'disputed'],
23
+ default: 'pending',
24
+ index: true,
25
+ },
26
+ reference: { type: String, default: null },
27
+ externalReference: { type: String, default: null, index: true },
28
+ paymentMethod: {
29
+ type: String,
30
+ enum: ['mpesa', 'card', 'cash', 'other'],
31
+ default: null,
32
+ },
33
+ payerType: {
34
+ type: String,
35
+ enum: ['tenant', 'landlord', 'owner', 'admin'],
36
+ default: 'tenant',
37
+ index: true,
38
+ },
39
+ paidAt: { type: Date, default: null },
40
+ notes: { type: String, default: null },
41
+ },
42
+ { timestamps: true }
43
+ );
44
+
45
+ const MoveInPayment = mongoose.model('MoveInPayment', moveInPaymentSchema);
46
+ module.exports = MoveInPayment;
@@ -1,77 +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;
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;
@@ -1,31 +1,31 @@
1
- const mongoose = require('mongoose');
2
- const ObjectId = mongoose.Schema.Types.ObjectId;
3
-
4
- const moveInReservationSchema = new mongoose.Schema(
5
- {
6
- tenantId: { type: ObjectId, ref: 'MoveInUser', default: null, index: true },
7
- tenantName: { type: String, default: null },
8
- tenantEmail: { type: String, default: null },
9
- tenantPhone: { type: String, default: null },
10
- isGuest: { type: Boolean, default: false, index: true },
11
- unitId: { type: ObjectId, required: true, index: true },
12
- unitName: { type: String, default: null },
13
- facilityId: { type: ObjectId, ref: 'Facility', default: null, index: true },
14
- landlordId: { type: ObjectId, ref: 'User', default: null, index: true },
15
- desiredMoveInDate:{ type: Date, default: null },
16
- monthsToStay: { type: Number, default: null },
17
- status: {
18
- type: String,
19
- enum: ['pending', 'confirmed', 'expired', 'cancelled'],
20
- default: 'pending',
21
- index: true,
22
- },
23
- expiresAt: { type: Date, default: null },
24
- adminNote: { type: String, default: null },
25
- landlordNote: { type: String, default: null },
26
- },
27
- { timestamps: true }
28
- );
29
-
30
- const MoveInReservation = mongoose.model('MoveInReservation', moveInReservationSchema);
31
- module.exports = MoveInReservation;
1
+ const mongoose = require('mongoose');
2
+ const ObjectId = mongoose.Schema.Types.ObjectId;
3
+
4
+ const moveInReservationSchema = new mongoose.Schema(
5
+ {
6
+ tenantId: { type: ObjectId, ref: 'MoveInUser', default: null, index: true },
7
+ tenantName: { type: String, default: null },
8
+ tenantEmail: { type: String, default: null },
9
+ tenantPhone: { type: String, default: null },
10
+ isGuest: { type: Boolean, default: false, index: true },
11
+ unitId: { type: ObjectId, required: true, index: true },
12
+ unitName: { type: String, default: null },
13
+ facilityId: { type: ObjectId, ref: 'Facility', default: null, index: true },
14
+ landlordId: { type: ObjectId, ref: 'User', default: null, index: true },
15
+ desiredMoveInDate:{ type: Date, default: null },
16
+ monthsToStay: { type: Number, default: null },
17
+ status: {
18
+ type: String,
19
+ enum: ['pending', 'confirmed', 'expired', 'cancelled'],
20
+ default: 'pending',
21
+ index: true,
22
+ },
23
+ expiresAt: { type: Date, default: null },
24
+ adminNote: { type: String, default: null },
25
+ landlordNote: { type: String, default: null },
26
+ },
27
+ { timestamps: true }
28
+ );
29
+
30
+ const MoveInReservation = mongoose.model('MoveInReservation', moveInReservationSchema);
31
+ module.exports = MoveInReservation;