payservedb 5.6.7 → 5.6.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/.env +2 -2
- package/index.js +194 -193
- package/package.json +17 -17
- package/src/models/account.js +35 -35
- package/src/models/apilog.js +18 -18
- package/src/models/approvalsWorkflows.js +49 -49
- package/src/models/archivedapilog.js +18 -18
- package/src/models/archivedauditlog.js +83 -83
- package/src/models/asset.js +34 -34
- package/src/models/auditlog.js +83 -83
- package/src/models/bankdetails.js +40 -40
- package/src/models/billerAddress.js +120 -0
- package/src/models/booking_invoice.js +151 -151
- package/src/models/bookinganalytics.js +63 -63
- package/src/models/bookingconfig.js +45 -45
- package/src/models/bookingproperty.js +112 -112
- package/src/models/bookingreservation.js +192 -192
- package/src/models/bookingrevenuerecord.js +84 -84
- package/src/models/budget.js +91 -91
- package/src/models/budgetCategory.js +19 -19
- package/src/models/campaigns.js +72 -72
- package/src/models/cashpayment.js +262 -262
- package/src/models/combinedUnits.js +62 -62
- package/src/models/common_area_electricity.js +38 -38
- package/src/models/common_area_generator.js +41 -41
- package/src/models/common_area_utility_alert.js +37 -37
- package/src/models/common_area_water.js +39 -39
- package/src/models/company.js +53 -53
- package/src/models/country_tax.js +42 -42
- package/src/models/currency_settings.js +39 -39
- package/src/models/customer.js +200 -200
- package/src/models/default_payment_details.js +17 -17
- package/src/models/dutyroster.js +107 -107
- package/src/models/email.js +37 -37
- package/src/models/entry_exit.js +53 -53
- package/src/models/expense.js +99 -99
- package/src/models/expense_category.js +45 -19
- package/src/models/facility.js +61 -61
- package/src/models/facility_payment_details.js +20 -20
- package/src/models/facilityasset.js +25 -25
- package/src/models/faq.js +18 -18
- package/src/models/gl_account_double_entries.js +25 -25
- package/src/models/gl_accounts.js +56 -56
- package/src/models/gl_entries.js +49 -49
- package/src/models/guard.js +47 -47
- package/src/models/handover.js +246 -246
- package/src/models/invoice.js +336 -336
- package/src/models/item_inspection.js +67 -67
- package/src/models/leaseagreement.js +221 -221
- package/src/models/leasetemplate.js +17 -17
- package/src/models/levy.js +152 -152
- package/src/models/levy_invoice_settings.js +26 -26
- package/src/models/levycontract.js +117 -117
- package/src/models/levytype.js +23 -23
- package/src/models/maintenance_service_vendor.js +38 -38
- package/src/models/maintenance_services.js +17 -17
- package/src/models/maintenancerequisition.js +31 -31
- package/src/models/message.js +38 -38
- package/src/models/module.js +21 -21
- package/src/models/notification.js +44 -44
- package/src/models/penalty.js +76 -76
- package/src/models/pendingCredentials.js +32 -32
- package/src/models/propertyManagerContract.js +358 -358
- package/src/models/propertyManagerRevenue.js +100 -100
- package/src/models/purchase_order.js +194 -194
- package/src/models/purchase_request.js +110 -110
- package/src/models/refresh_token.js +23 -23
- package/src/models/reminder.js +197 -197
- package/src/models/report.js +13 -13
- package/src/models/resident.js +121 -121
- package/src/models/rfq_details.js +131 -131
- package/src/models/rfq_response.js +105 -105
- package/src/models/service_charge_invoice_upload.js +42 -42
- package/src/models/service_charge_payments.js +27 -27
- package/src/models/servicerequest.js +55 -55
- package/src/models/settings.js +62 -62
- package/src/models/smart_meter_daily_consumption.js +44 -44
- package/src/models/sms_africastalking.js +20 -20
- package/src/models/sms_meliora.js +20 -20
- package/src/models/staff.js +36 -36
- package/src/models/stocksandspare.js +34 -34
- package/src/models/suppliers.js +74 -74
- package/src/models/tickets.js +109 -109
- package/src/models/unitManagementTemplate.js +44 -44
- package/src/models/unitasset.js +25 -25
- package/src/models/units.js +112 -112
- package/src/models/user.js +187 -187
- package/src/models/valueaddedservices.js +79 -79
- package/src/models/vas_invoices_upload.js +50 -50
- package/src/models/vas_payments.js +24 -24
- package/src/models/vasinvoice.js +192 -192
- package/src/models/vasvendor.js +57 -57
- package/src/models/visitLog.js +86 -86
- package/src/models/visitor.js +67 -67
- package/src/models/waitlist.js +45 -45
- package/src/models/water_invoice.js +193 -193
- package/src/models/water_meter_account.js +78 -78
- package/src/models/water_meter_billing.js +58 -58
- package/src/models/water_meter_communication.js +17 -17
- package/src/models/water_meter_communication_logs.js +30 -30
- package/src/models/water_meter_concentrator.js +59 -59
- package/src/models/water_meter_daily_history.js +32 -32
- package/src/models/water_meter_iot_cards.js +34 -34
- package/src/models/water_meter_manufacturer.js +35 -35
- package/src/models/water_meter_monthly_history.js +36 -36
- package/src/models/water_meter_settings.js +114 -88
- package/src/models/water_meter_single_day_history.js +34 -34
- package/src/models/water_meter_size.js +15 -15
- package/src/models/water_meters.js +117 -117
- package/src/models/water_meters_delivery.js +76 -76
- package/src/models/water_prepaid_credit.js +43 -43
- package/src/models/water_prepaid_debit.js +50 -50
- package/src/models/workorder.js +49 -49
package/src/models/levy.js
CHANGED
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
|
|
3
|
-
// Define the schema for Levy
|
|
4
|
-
const levySchema = new mongoose.Schema(
|
|
5
|
-
{
|
|
6
|
-
levyName: {
|
|
7
|
-
type: String,
|
|
8
|
-
required: true,
|
|
9
|
-
trim: true,
|
|
10
|
-
minlength: [1, "Levy name must be at least 1 character long"],
|
|
11
|
-
},
|
|
12
|
-
levyType: {
|
|
13
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
-
ref: "LevyType",
|
|
15
|
-
required: true,
|
|
16
|
-
},
|
|
17
|
-
amount: {
|
|
18
|
-
type: Number,
|
|
19
|
-
required: true,
|
|
20
|
-
min: [0, "Amount must be a positive number"],
|
|
21
|
-
},
|
|
22
|
-
dueDate: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: true,
|
|
25
|
-
},
|
|
26
|
-
levyApplicant: {
|
|
27
|
-
type: String,
|
|
28
|
-
required: true,
|
|
29
|
-
trim: true,
|
|
30
|
-
},
|
|
31
|
-
collectionFrequency: {
|
|
32
|
-
type: String,
|
|
33
|
-
required: true,
|
|
34
|
-
trim: true,
|
|
35
|
-
},
|
|
36
|
-
invoiceDay: {
|
|
37
|
-
type: String,
|
|
38
|
-
required: true,
|
|
39
|
-
},
|
|
40
|
-
// New billing type field
|
|
41
|
-
billingType: {
|
|
42
|
-
type: String,
|
|
43
|
-
enum: ['Prepaid', 'Postpaid'],
|
|
44
|
-
required: true,
|
|
45
|
-
default: 'Postpaid'
|
|
46
|
-
},
|
|
47
|
-
// Fields from levy contract
|
|
48
|
-
currency: {
|
|
49
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
50
|
-
ref: "Currency",
|
|
51
|
-
required: false,
|
|
52
|
-
},
|
|
53
|
-
mobilePayment: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: false,
|
|
56
|
-
required: false,
|
|
57
|
-
},
|
|
58
|
-
paymentMethodId: {
|
|
59
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
60
|
-
required: false,
|
|
61
|
-
},
|
|
62
|
-
// New bank payment field
|
|
63
|
-
bankPayment: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
default: false,
|
|
66
|
-
required: false,
|
|
67
|
-
},
|
|
68
|
-
// Bank details for bank payment
|
|
69
|
-
bankDetails: {
|
|
70
|
-
bankName: {
|
|
71
|
-
type: String,
|
|
72
|
-
required: false,
|
|
73
|
-
trim: true,
|
|
74
|
-
},
|
|
75
|
-
accountName: {
|
|
76
|
-
type: String,
|
|
77
|
-
required: false,
|
|
78
|
-
trim: true,
|
|
79
|
-
},
|
|
80
|
-
accountNumber: {
|
|
81
|
-
type: String,
|
|
82
|
-
required: false,
|
|
83
|
-
trim: true,
|
|
84
|
-
},
|
|
85
|
-
branch: {
|
|
86
|
-
type: String,
|
|
87
|
-
required: false,
|
|
88
|
-
trim: true,
|
|
89
|
-
},
|
|
90
|
-
swiftCode: {
|
|
91
|
-
type: String,
|
|
92
|
-
required: false,
|
|
93
|
-
trim: true,
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
// GL Account Configuration (moved from levy contract)
|
|
97
|
-
glAccounts: {
|
|
98
|
-
invoice: {
|
|
99
|
-
debit: {
|
|
100
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
101
|
-
ref: "GLAccount",
|
|
102
|
-
required: false,
|
|
103
|
-
},
|
|
104
|
-
credit: {
|
|
105
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
106
|
-
ref: "GLAccount",
|
|
107
|
-
required: false,
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
payment: {
|
|
111
|
-
debit: {
|
|
112
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
113
|
-
ref: "GLAccount",
|
|
114
|
-
required: false,
|
|
115
|
-
},
|
|
116
|
-
credit: {
|
|
117
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
118
|
-
ref: "GLAccount",
|
|
119
|
-
required: false,
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
disabled: {
|
|
124
|
-
type: Boolean,
|
|
125
|
-
required: false,
|
|
126
|
-
},
|
|
127
|
-
facilityId: {
|
|
128
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
129
|
-
ref: "Facility",
|
|
130
|
-
required: true,
|
|
131
|
-
},
|
|
132
|
-
// Added reminder reference
|
|
133
|
-
reminderId: {
|
|
134
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
135
|
-
ref: 'Reminder',
|
|
136
|
-
required: false
|
|
137
|
-
},
|
|
138
|
-
// Added penalty reference
|
|
139
|
-
penaltyId: {
|
|
140
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
141
|
-
ref: 'Penalty',
|
|
142
|
-
required: false
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
timestamps: true,
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
// Compile the model from the schema
|
|
151
|
-
const Levy = mongoose.model("Levy", levySchema);
|
|
152
|
-
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
// Define the schema for Levy
|
|
4
|
+
const levySchema = new mongoose.Schema(
|
|
5
|
+
{
|
|
6
|
+
levyName: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
trim: true,
|
|
10
|
+
minlength: [1, "Levy name must be at least 1 character long"],
|
|
11
|
+
},
|
|
12
|
+
levyType: {
|
|
13
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
+
ref: "LevyType",
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
amount: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: true,
|
|
20
|
+
min: [0, "Amount must be a positive number"],
|
|
21
|
+
},
|
|
22
|
+
dueDate: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
levyApplicant: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
trim: true,
|
|
30
|
+
},
|
|
31
|
+
collectionFrequency: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
trim: true,
|
|
35
|
+
},
|
|
36
|
+
invoiceDay: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
// New billing type field
|
|
41
|
+
billingType: {
|
|
42
|
+
type: String,
|
|
43
|
+
enum: ['Prepaid', 'Postpaid'],
|
|
44
|
+
required: true,
|
|
45
|
+
default: 'Postpaid'
|
|
46
|
+
},
|
|
47
|
+
// Fields from levy contract
|
|
48
|
+
currency: {
|
|
49
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
50
|
+
ref: "Currency",
|
|
51
|
+
required: false,
|
|
52
|
+
},
|
|
53
|
+
mobilePayment: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false,
|
|
56
|
+
required: false,
|
|
57
|
+
},
|
|
58
|
+
paymentMethodId: {
|
|
59
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
60
|
+
required: false,
|
|
61
|
+
},
|
|
62
|
+
// New bank payment field
|
|
63
|
+
bankPayment: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: false,
|
|
66
|
+
required: false,
|
|
67
|
+
},
|
|
68
|
+
// Bank details for bank payment
|
|
69
|
+
bankDetails: {
|
|
70
|
+
bankName: {
|
|
71
|
+
type: String,
|
|
72
|
+
required: false,
|
|
73
|
+
trim: true,
|
|
74
|
+
},
|
|
75
|
+
accountName: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: false,
|
|
78
|
+
trim: true,
|
|
79
|
+
},
|
|
80
|
+
accountNumber: {
|
|
81
|
+
type: String,
|
|
82
|
+
required: false,
|
|
83
|
+
trim: true,
|
|
84
|
+
},
|
|
85
|
+
branch: {
|
|
86
|
+
type: String,
|
|
87
|
+
required: false,
|
|
88
|
+
trim: true,
|
|
89
|
+
},
|
|
90
|
+
swiftCode: {
|
|
91
|
+
type: String,
|
|
92
|
+
required: false,
|
|
93
|
+
trim: true,
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
// GL Account Configuration (moved from levy contract)
|
|
97
|
+
glAccounts: {
|
|
98
|
+
invoice: {
|
|
99
|
+
debit: {
|
|
100
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
101
|
+
ref: "GLAccount",
|
|
102
|
+
required: false,
|
|
103
|
+
},
|
|
104
|
+
credit: {
|
|
105
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
106
|
+
ref: "GLAccount",
|
|
107
|
+
required: false,
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
payment: {
|
|
111
|
+
debit: {
|
|
112
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
113
|
+
ref: "GLAccount",
|
|
114
|
+
required: false,
|
|
115
|
+
},
|
|
116
|
+
credit: {
|
|
117
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
118
|
+
ref: "GLAccount",
|
|
119
|
+
required: false,
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
disabled: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
required: false,
|
|
126
|
+
},
|
|
127
|
+
facilityId: {
|
|
128
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
129
|
+
ref: "Facility",
|
|
130
|
+
required: true,
|
|
131
|
+
},
|
|
132
|
+
// Added reminder reference
|
|
133
|
+
reminderId: {
|
|
134
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
135
|
+
ref: 'Reminder',
|
|
136
|
+
required: false
|
|
137
|
+
},
|
|
138
|
+
// Added penalty reference
|
|
139
|
+
penaltyId: {
|
|
140
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
141
|
+
ref: 'Penalty',
|
|
142
|
+
required: false
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
timestamps: true,
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
// Compile the model from the schema
|
|
151
|
+
const Levy = mongoose.model("Levy", levySchema);
|
|
152
|
+
|
|
153
153
|
module.exports = Levy;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
const InvoiceSettingsSchema = new mongoose.Schema({
|
|
4
|
-
facilityId: {
|
|
5
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
-
ref: 'Facility',
|
|
7
|
-
required: [true, 'Facility ID is required']
|
|
8
|
-
},
|
|
9
|
-
termsAndConditions: {
|
|
10
|
-
type: String,
|
|
11
|
-
default: 'Payment is due within 15 days'
|
|
12
|
-
},
|
|
13
|
-
bankName: {
|
|
14
|
-
type: String,
|
|
15
|
-
required: [true, 'Bank name is required']
|
|
16
|
-
},
|
|
17
|
-
accountNumber: {
|
|
18
|
-
type: String,
|
|
19
|
-
required: [true, 'Account number is required']
|
|
20
|
-
}
|
|
21
|
-
}, {
|
|
22
|
-
timestamps: true
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const InvoiceSettings = mongoose.model('InvoiceSettings', InvoiceSettingsSchema);
|
|
26
|
-
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const InvoiceSettingsSchema = new mongoose.Schema({
|
|
4
|
+
facilityId: {
|
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref: 'Facility',
|
|
7
|
+
required: [true, 'Facility ID is required']
|
|
8
|
+
},
|
|
9
|
+
termsAndConditions: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: 'Payment is due within 15 days'
|
|
12
|
+
},
|
|
13
|
+
bankName: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: [true, 'Bank name is required']
|
|
16
|
+
},
|
|
17
|
+
accountNumber: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: [true, 'Account number is required']
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
timestamps: true
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const InvoiceSettings = mongoose.model('InvoiceSettings', InvoiceSettingsSchema);
|
|
26
|
+
|
|
27
27
|
module.exports = InvoiceSettings;
|
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
const Schema = mongoose.Schema;
|
|
3
|
-
|
|
4
|
-
const LevyContractSchema = new Schema(
|
|
5
|
-
{
|
|
6
|
-
contractName: {
|
|
7
|
-
type: String,
|
|
8
|
-
required: [true, 'Contract name is required']
|
|
9
|
-
},
|
|
10
|
-
levyId: {
|
|
11
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
-
ref: 'Levy',
|
|
13
|
-
required: [true, 'Levy ID is required']
|
|
14
|
-
},
|
|
15
|
-
customerId: {
|
|
16
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
17
|
-
ref: 'Customer',
|
|
18
|
-
required: [true, 'Customer ID is required']
|
|
19
|
-
},
|
|
20
|
-
unitId: {
|
|
21
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
-
ref: 'Unit',
|
|
23
|
-
required: [true, 'Unit ID is required']
|
|
24
|
-
},
|
|
25
|
-
amount: {
|
|
26
|
-
type: Number,
|
|
27
|
-
required: [true, 'Amount is required'],
|
|
28
|
-
min: [0, 'Amount cannot be negative']
|
|
29
|
-
},
|
|
30
|
-
startDate: {
|
|
31
|
-
type: Date,
|
|
32
|
-
required: [true, 'Start date is required']
|
|
33
|
-
},
|
|
34
|
-
endDate: {
|
|
35
|
-
type: Date,
|
|
36
|
-
required: [true, 'End date is required']
|
|
37
|
-
},
|
|
38
|
-
status: {
|
|
39
|
-
type: String,
|
|
40
|
-
enum: ['Active', 'Inactive', 'Completed', 'Suspended', 'Terminated'],
|
|
41
|
-
default: 'Active',
|
|
42
|
-
required: [true, 'Status is required']
|
|
43
|
-
},
|
|
44
|
-
balanceBroughtForward: {
|
|
45
|
-
type: Number,
|
|
46
|
-
default: 0
|
|
47
|
-
},
|
|
48
|
-
paymentFrequency: {
|
|
49
|
-
type: String,
|
|
50
|
-
enum: ['Daily', 'Weekly', 'Bi-Weekly', 'Monthly', 'Quarterly', 'Semi-Annually', 'Annually'],
|
|
51
|
-
default: 'Monthly'
|
|
52
|
-
},
|
|
53
|
-
facilityId: {
|
|
54
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
55
|
-
ref: 'Facility',
|
|
56
|
-
required: [true, 'Facility ID is required']
|
|
57
|
-
},
|
|
58
|
-
lastInvoiceDate: {
|
|
59
|
-
type: Date
|
|
60
|
-
},
|
|
61
|
-
createdBy: {
|
|
62
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
63
|
-
ref: 'User'
|
|
64
|
-
},
|
|
65
|
-
updatedBy: {
|
|
66
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
67
|
-
ref: 'User'
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
timestamps: true,
|
|
72
|
-
toJSON: { virtuals: true },
|
|
73
|
-
toObject: { virtuals: true }
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// Virtual populate for Levy details
|
|
78
|
-
LevyContractSchema.virtual('levy', {
|
|
79
|
-
ref: 'Levy',
|
|
80
|
-
localField: 'levyId',
|
|
81
|
-
foreignField: '_id',
|
|
82
|
-
justOne: true
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Virtual populate for Customer details
|
|
86
|
-
LevyContractSchema.virtual('customer', {
|
|
87
|
-
ref: 'Customer',
|
|
88
|
-
localField: 'customerId',
|
|
89
|
-
foreignField: '_id',
|
|
90
|
-
justOne: true
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Virtual populate for Unit details
|
|
94
|
-
LevyContractSchema.virtual('unit', {
|
|
95
|
-
ref: 'Unit',
|
|
96
|
-
localField: 'unitId',
|
|
97
|
-
foreignField: '_id',
|
|
98
|
-
justOne: true
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Pre-save middleware to ensure endDate is after startDate
|
|
102
|
-
LevyContractSchema.pre('save', function (next) {
|
|
103
|
-
if (this.startDate && this.endDate && this.startDate >= this.endDate) {
|
|
104
|
-
next(new Error('End date must be after start date'));
|
|
105
|
-
} else {
|
|
106
|
-
next();
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Index for efficient queries
|
|
111
|
-
LevyContractSchema.index({ levyId: 1, unitId: 1, status: 1 });
|
|
112
|
-
LevyContractSchema.index({ facilityId: 1 });
|
|
113
|
-
LevyContractSchema.index({ customerId: 1 });
|
|
114
|
-
|
|
115
|
-
module.exports = {
|
|
116
|
-
schema: LevyContractSchema,
|
|
117
|
-
name: 'LevyContract'
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const Schema = mongoose.Schema;
|
|
3
|
+
|
|
4
|
+
const LevyContractSchema = new Schema(
|
|
5
|
+
{
|
|
6
|
+
contractName: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: [true, 'Contract name is required']
|
|
9
|
+
},
|
|
10
|
+
levyId: {
|
|
11
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'Levy',
|
|
13
|
+
required: [true, 'Levy ID is required']
|
|
14
|
+
},
|
|
15
|
+
customerId: {
|
|
16
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
17
|
+
ref: 'Customer',
|
|
18
|
+
required: [true, 'Customer ID is required']
|
|
19
|
+
},
|
|
20
|
+
unitId: {
|
|
21
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
+
ref: 'Unit',
|
|
23
|
+
required: [true, 'Unit ID is required']
|
|
24
|
+
},
|
|
25
|
+
amount: {
|
|
26
|
+
type: Number,
|
|
27
|
+
required: [true, 'Amount is required'],
|
|
28
|
+
min: [0, 'Amount cannot be negative']
|
|
29
|
+
},
|
|
30
|
+
startDate: {
|
|
31
|
+
type: Date,
|
|
32
|
+
required: [true, 'Start date is required']
|
|
33
|
+
},
|
|
34
|
+
endDate: {
|
|
35
|
+
type: Date,
|
|
36
|
+
required: [true, 'End date is required']
|
|
37
|
+
},
|
|
38
|
+
status: {
|
|
39
|
+
type: String,
|
|
40
|
+
enum: ['Active', 'Inactive', 'Completed', 'Suspended', 'Terminated'],
|
|
41
|
+
default: 'Active',
|
|
42
|
+
required: [true, 'Status is required']
|
|
43
|
+
},
|
|
44
|
+
balanceBroughtForward: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: 0
|
|
47
|
+
},
|
|
48
|
+
paymentFrequency: {
|
|
49
|
+
type: String,
|
|
50
|
+
enum: ['Daily', 'Weekly', 'Bi-Weekly', 'Monthly', 'Quarterly', 'Semi-Annually', 'Annually'],
|
|
51
|
+
default: 'Monthly'
|
|
52
|
+
},
|
|
53
|
+
facilityId: {
|
|
54
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
55
|
+
ref: 'Facility',
|
|
56
|
+
required: [true, 'Facility ID is required']
|
|
57
|
+
},
|
|
58
|
+
lastInvoiceDate: {
|
|
59
|
+
type: Date
|
|
60
|
+
},
|
|
61
|
+
createdBy: {
|
|
62
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
63
|
+
ref: 'User'
|
|
64
|
+
},
|
|
65
|
+
updatedBy: {
|
|
66
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
67
|
+
ref: 'User'
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
timestamps: true,
|
|
72
|
+
toJSON: { virtuals: true },
|
|
73
|
+
toObject: { virtuals: true }
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Virtual populate for Levy details
|
|
78
|
+
LevyContractSchema.virtual('levy', {
|
|
79
|
+
ref: 'Levy',
|
|
80
|
+
localField: 'levyId',
|
|
81
|
+
foreignField: '_id',
|
|
82
|
+
justOne: true
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Virtual populate for Customer details
|
|
86
|
+
LevyContractSchema.virtual('customer', {
|
|
87
|
+
ref: 'Customer',
|
|
88
|
+
localField: 'customerId',
|
|
89
|
+
foreignField: '_id',
|
|
90
|
+
justOne: true
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Virtual populate for Unit details
|
|
94
|
+
LevyContractSchema.virtual('unit', {
|
|
95
|
+
ref: 'Unit',
|
|
96
|
+
localField: 'unitId',
|
|
97
|
+
foreignField: '_id',
|
|
98
|
+
justOne: true
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Pre-save middleware to ensure endDate is after startDate
|
|
102
|
+
LevyContractSchema.pre('save', function (next) {
|
|
103
|
+
if (this.startDate && this.endDate && this.startDate >= this.endDate) {
|
|
104
|
+
next(new Error('End date must be after start date'));
|
|
105
|
+
} else {
|
|
106
|
+
next();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Index for efficient queries
|
|
111
|
+
LevyContractSchema.index({ levyId: 1, unitId: 1, status: 1 });
|
|
112
|
+
LevyContractSchema.index({ facilityId: 1 });
|
|
113
|
+
LevyContractSchema.index({ customerId: 1 });
|
|
114
|
+
|
|
115
|
+
module.exports = {
|
|
116
|
+
schema: LevyContractSchema,
|
|
117
|
+
name: 'LevyContract'
|
|
118
118
|
};
|
package/src/models/levytype.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for LevyType
|
|
4
|
-
const levyTypeSchema = new mongoose.Schema({
|
|
5
|
-
name: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: true,
|
|
8
|
-
trim: true,
|
|
9
|
-
minlength: [1, 'Levy type name must be at least 1 character long']
|
|
10
|
-
},
|
|
11
|
-
facilityId: {
|
|
12
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
-
ref: 'Facility',
|
|
14
|
-
required: [true, 'Facility ID is required']
|
|
15
|
-
}
|
|
16
|
-
}, {
|
|
17
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Compile the model from the schema
|
|
21
|
-
const LevyType = mongoose.model('LevyType', levyTypeSchema);
|
|
22
|
-
|
|
23
|
-
module.exports = LevyType;
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for LevyType
|
|
4
|
+
const levyTypeSchema = new mongoose.Schema({
|
|
5
|
+
name: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
trim: true,
|
|
9
|
+
minlength: [1, 'Levy type name must be at least 1 character long']
|
|
10
|
+
},
|
|
11
|
+
facilityId: {
|
|
12
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'Facility',
|
|
14
|
+
required: [true, 'Facility ID is required']
|
|
15
|
+
}
|
|
16
|
+
}, {
|
|
17
|
+
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Compile the model from the schema
|
|
21
|
+
const LevyType = mongoose.model('LevyType', levyTypeSchema);
|
|
22
|
+
|
|
23
|
+
module.exports = LevyType;
|