payservedb 3.8.5 → 3.8.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/package.json +1 -1
- package/src/models/leaseagreement.js +113 -32
package/package.json
CHANGED
|
@@ -36,43 +36,124 @@ const leaseAgreementSchema = new mongoose.Schema({
|
|
|
36
36
|
monthlyRent: { type: Number, required: true },
|
|
37
37
|
paymentDueDate: { type: Number, required: true },
|
|
38
38
|
paymentMethods: [{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
details: {
|
|
45
|
-
// Bank Transfer details
|
|
46
|
-
bankName: String,
|
|
47
|
-
accountName: String,
|
|
48
|
-
accountNumber: String,
|
|
49
|
-
branch: String,
|
|
50
|
-
swiftCode: String,
|
|
51
|
-
// Cheque details
|
|
52
|
-
bankToDraft: String,
|
|
53
|
-
chequeAccountNumber: String,
|
|
54
|
-
// Cash details
|
|
55
|
-
preferredCashLocation: String,
|
|
56
|
-
// MPESA details
|
|
57
|
-
settingsId: {
|
|
58
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
59
|
-
ref: 'Settings'
|
|
39
|
+
type: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: true,
|
|
42
|
+
enum: ['Bank Transfer', 'Cash', 'Cheque']
|
|
60
43
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
details: {
|
|
45
|
+
// Bank Transfer details
|
|
46
|
+
bankName: String,
|
|
47
|
+
accountName: String,
|
|
48
|
+
accountNumber: String,
|
|
49
|
+
branch: String,
|
|
50
|
+
swiftCode: String,
|
|
51
|
+
// Cheque details
|
|
52
|
+
bankToDraft: String,
|
|
53
|
+
chequeAccountNumber: String,
|
|
54
|
+
// Cash details
|
|
55
|
+
preferredCashLocation: String
|
|
56
|
+
},
|
|
57
|
+
isPrimary: { type: Boolean, default: false }
|
|
65
58
|
}],
|
|
66
59
|
securityDeposit: { type: Number, required: true },
|
|
67
60
|
penaltyId: {
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
62
|
+
ref: 'Penalty'
|
|
63
|
+
},
|
|
64
|
+
mpesaEnabled: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false
|
|
67
|
+
},
|
|
68
|
+
mpesaDetails: {
|
|
69
|
+
businessNumber: String, // Paybill or Till number
|
|
70
|
+
accountNumber: String, // Account number if using Paybill
|
|
71
|
+
phoneNumber: String // Phone number for receiving payments
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
billingCycle: {
|
|
75
|
+
frequency: {
|
|
76
|
+
type: String,
|
|
77
|
+
enum: ['Monthly', 'Quarterly', 'Annually'],
|
|
78
|
+
required: true
|
|
79
|
+
},
|
|
80
|
+
nextInvoiceDate: { type: Date },
|
|
81
|
+
autoSend: { type: Boolean, default: false }
|
|
82
|
+
},
|
|
83
|
+
invoices: [
|
|
84
|
+
{ type: mongoose.Schema.Types.ObjectId, ref: 'Invoice' }
|
|
85
|
+
],
|
|
86
|
+
leaseTemplate: {
|
|
87
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
88
|
+
ref: 'LeaseTemplate',
|
|
89
|
+
required: true
|
|
90
|
+
},
|
|
91
|
+
leaseDocuments: [
|
|
92
|
+
{
|
|
93
|
+
fileName: { type: String },
|
|
94
|
+
fileUrl: { type: String },
|
|
95
|
+
uploadedAt: { type: Date, default: Date.now }
|
|
70
96
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
97
|
+
],
|
|
98
|
+
reminders: [
|
|
99
|
+
{
|
|
100
|
+
reminderId: {
|
|
101
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
102
|
+
ref: 'Reminder'
|
|
103
|
+
},
|
|
104
|
+
status: {
|
|
105
|
+
type: String,
|
|
106
|
+
enum: ['Pending', 'Sent'],
|
|
107
|
+
default: 'Pending'
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
status: {
|
|
112
|
+
type: String,
|
|
113
|
+
enum: ['Active', 'Pending', 'Expired', 'Terminated'],
|
|
114
|
+
default: 'Active'
|
|
115
|
+
},
|
|
116
|
+
payments: [
|
|
117
|
+
{
|
|
118
|
+
invoiceId: {
|
|
119
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
120
|
+
ref: 'Invoice',
|
|
121
|
+
required: true
|
|
122
|
+
},
|
|
123
|
+
method: {
|
|
124
|
+
type: {
|
|
125
|
+
type: String,
|
|
126
|
+
enum: ['Bank Transfer', 'Cash', 'Cheque', 'MPESA'],
|
|
127
|
+
required: true
|
|
128
|
+
},
|
|
129
|
+
details: {
|
|
130
|
+
// Bank Transfer payment details
|
|
131
|
+
bankName: String,
|
|
132
|
+
accountNumber: String,
|
|
133
|
+
transactionId: String,
|
|
134
|
+
// Cheque payment details
|
|
135
|
+
chequeNumber: String,
|
|
136
|
+
// MPESA payment details
|
|
137
|
+
mpesaTransactionId: String,
|
|
138
|
+
mpesaPhoneNumber: String
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
amount: { type: Number, required: true },
|
|
142
|
+
receivedBy: {
|
|
143
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
144
|
+
ref: 'User',
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
receivedAt: { type: Date, default: Date.now }
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
createdBy: {
|
|
151
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
152
|
+
ref: 'User'
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
timestamps: true
|
|
156
|
+
});
|
|
76
157
|
|
|
77
158
|
// Add index for multi-tenancy queries
|
|
78
159
|
leaseAgreementSchema.index({ facilityId: 1 });
|