payservedb 9.9.2 → 9.9.3
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/ZOHO_INTEGRATION_SCHEMA.md +644 -644
- package/index.js +421 -420
- package/package.json +17 -17
- package/src/models/InvoiceWithholdingTax.js +67 -67
- package/src/models/account.js +59 -59
- package/src/models/agent_departments.js +59 -59
- package/src/models/agent_notifications.js +53 -53
- package/src/models/agent_performance.js +127 -127
- package/src/models/agent_roles.js +77 -77
- package/src/models/agents.js +154 -154
- package/src/models/apilog.js +18 -18
- package/src/models/approvalsWorkflows.js +49 -49
- package/src/models/archivedapilog.js +18 -18
- package/src/models/asset.js +92 -92
- package/src/models/assetsAssignment.js +64 -64
- package/src/models/auditTrail.js +346 -346
- package/src/models/auto_reply_rule.js +68 -68
- package/src/models/bankdetails.js +47 -47
- package/src/models/billerAddress.js +124 -124
- package/src/models/booking_invoice.js +191 -191
- package/src/models/booking_voucher.js +131 -131
- package/src/models/booking_voucher_config.js +56 -56
- package/src/models/bookinganalytics.js +63 -63
- package/src/models/bookingconfig.js +74 -74
- package/src/models/bookingproperty.js +211 -211
- package/src/models/bookingreservation.js +330 -330
- package/src/models/bookingrevenuerecord.js +99 -99
- package/src/models/budget.js +95 -95
- package/src/models/budgetCategory.js +19 -19
- package/src/models/campaigns.js +108 -108
- package/src/models/cancellation_policy.js +56 -56
- package/src/models/cashpayment.js +289 -289
- package/src/models/combinedUnits.js +62 -62
- package/src/models/combined_invoice.js +424 -424
- 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/communication_status.js +33 -33
- package/src/models/communication_user_opt.js +32 -32
- package/src/models/community_guidelines.js +35 -35
- package/src/models/company.js +53 -53
- package/src/models/coreBaseSettings.js +16 -16
- package/src/models/coreInvoiceSettings.js +100 -100
- package/src/models/counter_schema.js +21 -21
- package/src/models/country_tax.js +42 -42
- package/src/models/currency_settings.js +39 -39
- package/src/models/customer.js +267 -267
- package/src/models/customer_preference.js +52 -52
- package/src/models/customer_satisfaction_survey.js +297 -297
- package/src/models/customer_surveys.js +139 -139
- package/src/models/customer_tickets.js +237 -237
- package/src/models/dailyChecklist.js +312 -312
- package/src/models/default_payment_details.js +17 -17
- package/src/models/deliveryTimeMarks.js +18 -18
- package/src/models/document_type.js +19 -19
- package/src/models/dutyRosterChecklist.js +250 -250
- package/src/models/dutyroster.js +136 -136
- package/src/models/email.js +37 -37
- package/src/models/email_cc_config.js +48 -48
- package/src/models/email_sms_queue.js +61 -61
- package/src/models/email_thread.js +35 -35
- package/src/models/entry_exit.js +53 -53
- package/src/models/expense.js +99 -99
- package/src/models/expense_category.js +45 -45
- package/src/models/facility.js +131 -131
- package/src/models/facilityBillingPrices.js +29 -29
- package/src/models/facilityInvoice.js +240 -240
- package/src/models/facilityInvoicePayment.js +52 -52
- package/src/models/facilityInvoiceRecipient.js +32 -32
- package/src/models/facilityWalletTransactionsMetadata.js +236 -236
- package/src/models/facility_departements.js +20 -20
- package/src/models/facility_etims_config.js +116 -116
- package/src/models/facility_payment_details.js +20 -20
- package/src/models/facility_rating.js +78 -78
- package/src/models/facilityasset.js +25 -25
- package/src/models/faq.js +15 -15
- 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/goodsReceivedNotes.js +115 -115
- package/src/models/guard.js +47 -47
- package/src/models/handover.js +258 -258
- package/src/models/inspection_category.js +38 -38
- package/src/models/invoice.js +715 -715
- package/src/models/invoiceCreditAdjustment.js +45 -45
- package/src/models/invoice_edit_log.js +81 -81
- package/src/models/invoice_generation_approval.js +86 -86
- package/src/models/invoicing_schedule.js +40 -40
- package/src/models/item_inspection.js +96 -96
- package/src/models/knowledge_base.js +109 -109
- package/src/models/knowledge_base_rating.js +44 -44
- package/src/models/leaseagreement.js +270 -270
- package/src/models/leasetemplate.js +17 -17
- package/src/models/levy.js +235 -235
- package/src/models/levy_deposits.js +145 -145
- package/src/models/levy_invoice_settings.js +26 -26
- package/src/models/levy_payment_receipt.js +158 -158
- package/src/models/levycontract.js +250 -250
- 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/master_workplan.js +32 -32
- package/src/models/master_workplan_child.js +34 -34
- package/src/models/message.js +38 -38
- package/src/models/module.js +21 -21
- package/src/models/movein_amenity.js +13 -13
- package/src/models/movein_application.js +28 -28
- package/src/models/movein_audit_log.js +21 -21
- package/src/models/movein_booking.js +33 -33
- package/src/models/movein_commission.js +46 -46
- package/src/models/movein_conversation.js +25 -25
- package/src/models/movein_deal.js +79 -79
- package/src/models/movein_disbursement.js +36 -36
- package/src/models/movein_email_thread.js +19 -19
- package/src/models/movein_enquiry.js +16 -16
- package/src/models/movein_featured_package.js +16 -16
- package/src/models/movein_handoff_token.js +16 -16
- package/src/models/movein_invoice.js +24 -24
- package/src/models/movein_landlord.js +18 -18
- package/src/models/movein_landlord_user.js +20 -20
- package/src/models/movein_lease.js +37 -37
- package/src/models/movein_message.js +27 -27
- package/src/models/movein_notification.js +27 -27
- package/src/models/movein_otp.js +14 -14
- package/src/models/movein_payment.js +46 -46
- package/src/models/movein_reminder.js +77 -77
- package/src/models/movein_reservation.js +31 -31
- package/src/models/movein_settings.js +25 -25
- package/src/models/movein_tenancy.js +55 -55
- package/src/models/movein_unit.js +59 -59
- package/src/models/movein_user.js +15 -15
- package/src/models/movein_viewing_slot.js +21 -21
- package/src/models/movein_want_unit.js +20 -20
- package/src/models/notification.js +44 -44
- package/src/models/paymentTermsMarks.js +19 -19
- package/src/models/penalty.js +76 -76
- package/src/models/pendingCredentials.js +32 -32
- package/src/models/powerMeterCommunicationProtocol.js +17 -17
- package/src/models/powerMeterCustomerAccount.js +78 -78
- package/src/models/powerMeterCustomerBand.js +14 -14
- package/src/models/powerMeterDailyReading.js +30 -30
- package/src/models/powerMeterGateways.js +40 -40
- package/src/models/powerMeterMonthlyReading.js +34 -34
- package/src/models/powerMeterPowerCharges.js +85 -85
- package/src/models/powerMeterSettings.js +211 -211
- package/src/models/powerMeterSingleDayReading.js +32 -32
- package/src/models/powerMeters.js +154 -154
- package/src/models/powerMetersManufacturer.js +14 -14
- package/src/models/power_invoice.js +383 -383
- package/src/models/power_meter_account.js +81 -81
- package/src/models/power_meter_command_logs.js +30 -30
- package/src/models/power_meter_command_queue.js +33 -33
- package/src/models/power_meter_negative_balance.js +44 -44
- package/src/models/power_prepaid_credits.js +47 -47
- package/src/models/power_prepaid_debits.js +53 -53
- package/src/models/power_prepaid_orders.js +78 -78
- package/src/models/power_sms_notification.js +26 -26
- package/src/models/privacy_policy.js +19 -19
- package/src/models/propertyManagementSettings.js +55 -55
- package/src/models/propertyManagerContract.js +663 -663
- package/src/models/propertyManagerRevenue.js +195 -195
- package/src/models/propertyManagerRevenueEntry.js +118 -118
- package/src/models/purchaseOrderInvoice.js +74 -74
- package/src/models/purchase_order.js +213 -213
- package/src/models/purchase_request.js +110 -110
- package/src/models/quickbooks_config.js +52 -52
- package/src/models/reception.js +33 -0
- package/src/models/recipient_group.js +61 -61
- package/src/models/recipient_group_member.js +62 -62
- 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 +153 -153
- 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/short_urls.js +21 -21
- package/src/models/smart_meter_daily_consumption.js +44 -44
- package/src/models/sms_africastalking.js +20 -20
- package/src/models/sms_balance_notification.js +26 -26
- package/src/models/sms_meliora.js +20 -20
- package/src/models/staff.js +36 -36
- package/src/models/stocksandspare.js +161 -161
- package/src/models/suppliers.js +79 -79
- package/src/models/terms_and_conditions.js +19 -19
- package/src/models/tickets.js +186 -186
- package/src/models/tickets_category.js +72 -72
- package/src/models/unitManagementTemplate.js +44 -44
- package/src/models/unitasset.js +25 -25
- package/src/models/units.js +148 -148
- package/src/models/user.js +191 -186
- package/src/models/valueaddedservices.js +50 -50
- package/src/models/vas_invoices_upload.js +50 -50
- package/src/models/vas_payments.js +24 -24
- package/src/models/vasinvoice.js +196 -196
- package/src/models/vasvendor.js +52 -52
- package/src/models/visitLog.js +120 -120
- package/src/models/visitor.js +75 -75
- package/src/models/waitlist.js +45 -45
- package/src/models/wallet.js +44 -44
- package/src/models/wallet_transaction.js +67 -67
- package/src/models/wallet_transactions.js +72 -72
- package/src/models/water_invoice.js +362 -362
- package/src/models/water_meter_Command_Queue.js +33 -33
- package/src/models/water_meter_account.js +94 -94
- package/src/models/water_meter_billing.js +58 -58
- package/src/models/water_meter_combined_accounts.js +92 -92
- package/src/models/water_meter_communication.js +17 -17
- package/src/models/water_meter_communication_logs.js +39 -39
- package/src/models/water_meter_concentrator.js +77 -77
- package/src/models/water_meter_daily_history.js +32 -32
- package/src/models/water_meter_high_risk.js +36 -36
- package/src/models/water_meter_iot_cards.js +34 -34
- package/src/models/water_meter_loan_deduction.js +134 -134
- package/src/models/water_meter_manufacturer.js +35 -35
- package/src/models/water_meter_monthly_history.js +36 -36
- package/src/models/water_meter_negative_amounts.js +44 -44
- package/src/models/water_meter_settings.js +348 -348
- 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 +176 -176
- package/src/models/water_meters_delivery.js +76 -76
- package/src/models/water_prepaid_credit.js +47 -47
- package/src/models/water_prepaid_debit.js +50 -50
- package/src/models/whatsapp_conversation.js +23 -23
- package/src/models/workorder.js +49 -49
- package/src/models/zohoAccount.js +453 -453
- package/src/models/zohoIntegration.js +262 -262
- package/src/models/zohoItem.js +504 -504
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for Booking Invoices
|
|
4
|
-
const bookingInvoiceSchema = new mongoose.Schema({
|
|
5
|
-
invoiceNumber: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: true,
|
|
8
|
-
unique: true,
|
|
9
|
-
},
|
|
10
|
-
facilityId: {
|
|
11
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
-
ref: 'Facility',
|
|
13
|
-
required: true
|
|
14
|
-
},
|
|
15
|
-
invoiceId: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: true,
|
|
18
|
-
unique: true
|
|
19
|
-
},
|
|
20
|
-
accountNumber: {
|
|
21
|
-
type: String,
|
|
22
|
-
unique: true,
|
|
23
|
-
sparse: true // Allow null/undefined values while maintaining uniqueness for non-null values
|
|
24
|
-
},
|
|
25
|
-
// Reservation-billed invoices (the default/original use of this model)
|
|
26
|
-
// always set bookingReservationId. Recurring landlord listing-fee
|
|
27
|
-
// invoices (invoiceType: 'ListingFee') are not tied to a reservation,
|
|
28
|
-
// so this is intentionally not required at the schema level.
|
|
29
|
-
bookingReservationId: {
|
|
30
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
31
|
-
ref: 'BookingReservation'
|
|
32
|
-
},
|
|
33
|
-
// Distinguishes a guest-facing reservation invoice from a recurring
|
|
34
|
-
// landlord listing-fee invoice billed for hosting a unit on the
|
|
35
|
-
// booking platform (Managed by Landlord units).
|
|
36
|
-
invoiceType: {
|
|
37
|
-
type: String,
|
|
38
|
-
enum: ['Reservation', 'ListingFee'],
|
|
39
|
-
default: 'Reservation'
|
|
40
|
-
},
|
|
41
|
-
// Landlord being billed - only set for invoiceType: 'ListingFee'
|
|
42
|
-
landlordId: {
|
|
43
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
44
|
-
ref: 'Customer'
|
|
45
|
-
},
|
|
46
|
-
// "YYYY-MM" of the billing period - only set for invoiceType: 'ListingFee',
|
|
47
|
-
// used to prevent generating more than one listing-fee invoice per unit
|
|
48
|
-
// per month
|
|
49
|
-
billingYearMonth: {
|
|
50
|
-
type: String
|
|
51
|
-
},
|
|
52
|
-
unitId: {
|
|
53
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
54
|
-
ref: 'Unit',
|
|
55
|
-
required: true
|
|
56
|
-
},
|
|
57
|
-
guestInfo: {
|
|
58
|
-
name: {
|
|
59
|
-
type: String,
|
|
60
|
-
required: true
|
|
61
|
-
},
|
|
62
|
-
email: {
|
|
63
|
-
type: String,
|
|
64
|
-
required: true
|
|
65
|
-
},
|
|
66
|
-
phone: {
|
|
67
|
-
type: String,
|
|
68
|
-
required: true
|
|
69
|
-
},
|
|
70
|
-
idNumber: {
|
|
71
|
-
type: String
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
issueDate: {
|
|
75
|
-
type: Date,
|
|
76
|
-
default: Date.now,
|
|
77
|
-
required: true
|
|
78
|
-
},
|
|
79
|
-
dueDate: {
|
|
80
|
-
type: Date,
|
|
81
|
-
required: true
|
|
82
|
-
},
|
|
83
|
-
checkIn: {
|
|
84
|
-
type: Date,
|
|
85
|
-
required: true
|
|
86
|
-
},
|
|
87
|
-
checkOut: {
|
|
88
|
-
type: Date,
|
|
89
|
-
required: true
|
|
90
|
-
},
|
|
91
|
-
basePrice: {
|
|
92
|
-
type: Number,
|
|
93
|
-
required: true
|
|
94
|
-
},
|
|
95
|
-
totalAmount: {
|
|
96
|
-
type: Number,
|
|
97
|
-
required: true
|
|
98
|
-
},
|
|
99
|
-
additionalServices: [{
|
|
100
|
-
serviceId: {
|
|
101
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
102
|
-
ref: 'ValueAddedService'
|
|
103
|
-
},
|
|
104
|
-
serviceName: {
|
|
105
|
-
type: String,
|
|
106
|
-
required: true
|
|
107
|
-
},
|
|
108
|
-
quantity: {
|
|
109
|
-
type: Number,
|
|
110
|
-
default: 1
|
|
111
|
-
},
|
|
112
|
-
price: {
|
|
113
|
-
type: Number,
|
|
114
|
-
required: true
|
|
115
|
-
}
|
|
116
|
-
}],
|
|
117
|
-
discountAmount: {
|
|
118
|
-
type: Number,
|
|
119
|
-
default: 0
|
|
120
|
-
},
|
|
121
|
-
taxAmount: {
|
|
122
|
-
type: Number,
|
|
123
|
-
default: 0
|
|
124
|
-
},
|
|
125
|
-
paymentMethod: {
|
|
126
|
-
type: String,
|
|
127
|
-
// Card is not offered - card payment processing is not yet
|
|
128
|
-
// integrated for bookings.
|
|
129
|
-
enum: ['Cash', 'Bank Transfer', 'Mobile Money', 'Other'],
|
|
130
|
-
required: true
|
|
131
|
-
},
|
|
132
|
-
paymentStatus: {
|
|
133
|
-
type: String,
|
|
134
|
-
enum: ['Pending', 'Paid', 'Partially Paid', 'Refunded', 'Cancelled'],
|
|
135
|
-
default: 'Pending'
|
|
136
|
-
},
|
|
137
|
-
paymentHistory: [{
|
|
138
|
-
amount: {
|
|
139
|
-
type: Number,
|
|
140
|
-
required: true
|
|
141
|
-
},
|
|
142
|
-
paymentMethod: {
|
|
143
|
-
type: String,
|
|
144
|
-
// Card is not offered - card payment processing is not yet
|
|
145
|
-
// integrated for bookings.
|
|
146
|
-
enum: ['Cash', 'Bank Transfer', 'Mobile Money', 'Other'],
|
|
147
|
-
required: true
|
|
148
|
-
},
|
|
149
|
-
transactionId: String,
|
|
150
|
-
date: {
|
|
151
|
-
type: Date,
|
|
152
|
-
default: Date.now
|
|
153
|
-
},
|
|
154
|
-
notes: String
|
|
155
|
-
}],
|
|
156
|
-
currencyId: {
|
|
157
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
158
|
-
ref: 'Currency',
|
|
159
|
-
required: true
|
|
160
|
-
},
|
|
161
|
-
// Payment details for M-Pesa STK push
|
|
162
|
-
paymentDetails: {
|
|
163
|
-
paybillNumber: String,
|
|
164
|
-
paybillAccountName: String,
|
|
165
|
-
facilityPaymentDetailsId: {
|
|
166
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
167
|
-
ref: 'FacilityPaymentDetails'
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
status: {
|
|
171
|
-
type: String,
|
|
172
|
-
enum: ['active', 'cancelled', 'void'],
|
|
173
|
-
default: 'active'
|
|
174
|
-
},
|
|
175
|
-
notes: {
|
|
176
|
-
type: String
|
|
177
|
-
},
|
|
178
|
-
createdBy: {
|
|
179
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
180
|
-
ref: 'User'
|
|
181
|
-
},
|
|
182
|
-
updatedBy: {
|
|
183
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
184
|
-
ref: 'User'
|
|
185
|
-
}
|
|
186
|
-
}, {
|
|
187
|
-
timestamps: true
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const BookingInvoice = mongoose.model('BookingInvoice', bookingInvoiceSchema);
|
|
191
|
-
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// Define the schema for Booking Invoices
|
|
4
|
+
const bookingInvoiceSchema = new mongoose.Schema({
|
|
5
|
+
invoiceNumber: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
unique: true,
|
|
9
|
+
},
|
|
10
|
+
facilityId: {
|
|
11
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'Facility',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
invoiceId: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
unique: true
|
|
19
|
+
},
|
|
20
|
+
accountNumber: {
|
|
21
|
+
type: String,
|
|
22
|
+
unique: true,
|
|
23
|
+
sparse: true // Allow null/undefined values while maintaining uniqueness for non-null values
|
|
24
|
+
},
|
|
25
|
+
// Reservation-billed invoices (the default/original use of this model)
|
|
26
|
+
// always set bookingReservationId. Recurring landlord listing-fee
|
|
27
|
+
// invoices (invoiceType: 'ListingFee') are not tied to a reservation,
|
|
28
|
+
// so this is intentionally not required at the schema level.
|
|
29
|
+
bookingReservationId: {
|
|
30
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
31
|
+
ref: 'BookingReservation'
|
|
32
|
+
},
|
|
33
|
+
// Distinguishes a guest-facing reservation invoice from a recurring
|
|
34
|
+
// landlord listing-fee invoice billed for hosting a unit on the
|
|
35
|
+
// booking platform (Managed by Landlord units).
|
|
36
|
+
invoiceType: {
|
|
37
|
+
type: String,
|
|
38
|
+
enum: ['Reservation', 'ListingFee'],
|
|
39
|
+
default: 'Reservation'
|
|
40
|
+
},
|
|
41
|
+
// Landlord being billed - only set for invoiceType: 'ListingFee'
|
|
42
|
+
landlordId: {
|
|
43
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
44
|
+
ref: 'Customer'
|
|
45
|
+
},
|
|
46
|
+
// "YYYY-MM" of the billing period - only set for invoiceType: 'ListingFee',
|
|
47
|
+
// used to prevent generating more than one listing-fee invoice per unit
|
|
48
|
+
// per month
|
|
49
|
+
billingYearMonth: {
|
|
50
|
+
type: String
|
|
51
|
+
},
|
|
52
|
+
unitId: {
|
|
53
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
54
|
+
ref: 'Unit',
|
|
55
|
+
required: true
|
|
56
|
+
},
|
|
57
|
+
guestInfo: {
|
|
58
|
+
name: {
|
|
59
|
+
type: String,
|
|
60
|
+
required: true
|
|
61
|
+
},
|
|
62
|
+
email: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: true
|
|
65
|
+
},
|
|
66
|
+
phone: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
idNumber: {
|
|
71
|
+
type: String
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
issueDate: {
|
|
75
|
+
type: Date,
|
|
76
|
+
default: Date.now,
|
|
77
|
+
required: true
|
|
78
|
+
},
|
|
79
|
+
dueDate: {
|
|
80
|
+
type: Date,
|
|
81
|
+
required: true
|
|
82
|
+
},
|
|
83
|
+
checkIn: {
|
|
84
|
+
type: Date,
|
|
85
|
+
required: true
|
|
86
|
+
},
|
|
87
|
+
checkOut: {
|
|
88
|
+
type: Date,
|
|
89
|
+
required: true
|
|
90
|
+
},
|
|
91
|
+
basePrice: {
|
|
92
|
+
type: Number,
|
|
93
|
+
required: true
|
|
94
|
+
},
|
|
95
|
+
totalAmount: {
|
|
96
|
+
type: Number,
|
|
97
|
+
required: true
|
|
98
|
+
},
|
|
99
|
+
additionalServices: [{
|
|
100
|
+
serviceId: {
|
|
101
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
102
|
+
ref: 'ValueAddedService'
|
|
103
|
+
},
|
|
104
|
+
serviceName: {
|
|
105
|
+
type: String,
|
|
106
|
+
required: true
|
|
107
|
+
},
|
|
108
|
+
quantity: {
|
|
109
|
+
type: Number,
|
|
110
|
+
default: 1
|
|
111
|
+
},
|
|
112
|
+
price: {
|
|
113
|
+
type: Number,
|
|
114
|
+
required: true
|
|
115
|
+
}
|
|
116
|
+
}],
|
|
117
|
+
discountAmount: {
|
|
118
|
+
type: Number,
|
|
119
|
+
default: 0
|
|
120
|
+
},
|
|
121
|
+
taxAmount: {
|
|
122
|
+
type: Number,
|
|
123
|
+
default: 0
|
|
124
|
+
},
|
|
125
|
+
paymentMethod: {
|
|
126
|
+
type: String,
|
|
127
|
+
// Card is not offered - card payment processing is not yet
|
|
128
|
+
// integrated for bookings.
|
|
129
|
+
enum: ['Cash', 'Bank Transfer', 'Mobile Money', 'Other'],
|
|
130
|
+
required: true
|
|
131
|
+
},
|
|
132
|
+
paymentStatus: {
|
|
133
|
+
type: String,
|
|
134
|
+
enum: ['Pending', 'Paid', 'Partially Paid', 'Refunded', 'Cancelled'],
|
|
135
|
+
default: 'Pending'
|
|
136
|
+
},
|
|
137
|
+
paymentHistory: [{
|
|
138
|
+
amount: {
|
|
139
|
+
type: Number,
|
|
140
|
+
required: true
|
|
141
|
+
},
|
|
142
|
+
paymentMethod: {
|
|
143
|
+
type: String,
|
|
144
|
+
// Card is not offered - card payment processing is not yet
|
|
145
|
+
// integrated for bookings.
|
|
146
|
+
enum: ['Cash', 'Bank Transfer', 'Mobile Money', 'Other'],
|
|
147
|
+
required: true
|
|
148
|
+
},
|
|
149
|
+
transactionId: String,
|
|
150
|
+
date: {
|
|
151
|
+
type: Date,
|
|
152
|
+
default: Date.now
|
|
153
|
+
},
|
|
154
|
+
notes: String
|
|
155
|
+
}],
|
|
156
|
+
currencyId: {
|
|
157
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
158
|
+
ref: 'Currency',
|
|
159
|
+
required: true
|
|
160
|
+
},
|
|
161
|
+
// Payment details for M-Pesa STK push
|
|
162
|
+
paymentDetails: {
|
|
163
|
+
paybillNumber: String,
|
|
164
|
+
paybillAccountName: String,
|
|
165
|
+
facilityPaymentDetailsId: {
|
|
166
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
167
|
+
ref: 'FacilityPaymentDetails'
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
status: {
|
|
171
|
+
type: String,
|
|
172
|
+
enum: ['active', 'cancelled', 'void'],
|
|
173
|
+
default: 'active'
|
|
174
|
+
},
|
|
175
|
+
notes: {
|
|
176
|
+
type: String
|
|
177
|
+
},
|
|
178
|
+
createdBy: {
|
|
179
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
180
|
+
ref: 'User'
|
|
181
|
+
},
|
|
182
|
+
updatedBy: {
|
|
183
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
184
|
+
ref: 'User'
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
timestamps: true
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const BookingInvoice = mongoose.model('BookingInvoice', bookingInvoiceSchema);
|
|
191
|
+
|
|
192
192
|
module.exports = BookingInvoice;
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
const EXPIRY_DURATION_MS = {
|
|
4
|
-
'2_weeks': 14 * 24 * 60 * 60 * 1000,
|
|
5
|
-
'1_month': 30 * 24 * 60 * 60 * 1000,
|
|
6
|
-
'3_months': 90 * 24 * 60 * 60 * 1000,
|
|
7
|
-
'6_months': 182 * 24 * 60 * 60 * 1000
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const bookingVoucherSchema = new mongoose.Schema({
|
|
11
|
-
facilityId: {
|
|
12
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
-
ref: 'Facility',
|
|
14
|
-
required: true
|
|
15
|
-
},
|
|
16
|
-
voucherCode: {
|
|
17
|
-
type: String,
|
|
18
|
-
required: true,
|
|
19
|
-
unique: true
|
|
20
|
-
},
|
|
21
|
-
sourceReservationId: {
|
|
22
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
23
|
-
ref: 'BookingReservation',
|
|
24
|
-
required: true
|
|
25
|
-
},
|
|
26
|
-
sourceInvoiceId: {
|
|
27
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
28
|
-
ref: 'BookingInvoice'
|
|
29
|
-
},
|
|
30
|
-
guestInfo: {
|
|
31
|
-
name: { type: String, required: true },
|
|
32
|
-
email: { type: String, required: true },
|
|
33
|
-
phone: { type: String, required: true }
|
|
34
|
-
},
|
|
35
|
-
// Audit trail for how `amount` was derived.
|
|
36
|
-
calculation: {
|
|
37
|
-
nightlyRate: { type: Number, required: true, min: 0 },
|
|
38
|
-
nightsUnused: { type: Number, required: true, min: 0 },
|
|
39
|
-
// 100% value of the unused nights, before percentageApplied
|
|
40
|
-
remainingAmount: { type: Number, required: true, min: 0 },
|
|
41
|
-
percentageApplied: { type: Number, required: true, min: 1, max: 100 }
|
|
42
|
-
},
|
|
43
|
-
// Redeemable value = remainingAmount * percentageApplied / 100
|
|
44
|
-
amount: {
|
|
45
|
-
type: Number,
|
|
46
|
-
required: true,
|
|
47
|
-
min: 0
|
|
48
|
-
},
|
|
49
|
-
currencyId: {
|
|
50
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
51
|
-
ref: 'Currency',
|
|
52
|
-
required: true
|
|
53
|
-
},
|
|
54
|
-
// 'revoked' (not 'cancelled') - a voucher is void by staff action
|
|
55
|
-
// (issued in error, flagged fraudulent, etc), which is deliberately a
|
|
56
|
-
// different word and a different code path from 'expired' (passive,
|
|
57
|
-
// time-based). Both are terminal and non-redeemable, but staff need
|
|
58
|
-
// to distinguish "we killed this on purpose, here's why" from "nobody
|
|
59
|
-
// used it in time" when reviewing a facility's voucher history.
|
|
60
|
-
status: {
|
|
61
|
-
type: String,
|
|
62
|
-
enum: ['active', 'used', 'expired', 'revoked'],
|
|
63
|
-
default: 'active'
|
|
64
|
-
},
|
|
65
|
-
statusHistory: [{
|
|
66
|
-
status: {
|
|
67
|
-
type: String,
|
|
68
|
-
enum: ['active', 'used', 'expired', 'revoked'],
|
|
69
|
-
required: true
|
|
70
|
-
},
|
|
71
|
-
timestamp: {
|
|
72
|
-
type: Date,
|
|
73
|
-
default: Date.now
|
|
74
|
-
},
|
|
75
|
-
updatedBy: mongoose.Schema.Types.ObjectId,
|
|
76
|
-
notes: String
|
|
77
|
-
}],
|
|
78
|
-
// Optional fixed-duration safety net (see BookingVoucherConfig). null
|
|
79
|
-
// means no calendar expiry - the voucher only dies when redeemed or
|
|
80
|
-
// explicitly revoked.
|
|
81
|
-
expiryDuration: {
|
|
82
|
-
type: String,
|
|
83
|
-
enum: ['2_weeks', '1_month', '3_months', '6_months', null],
|
|
84
|
-
default: null
|
|
85
|
-
},
|
|
86
|
-
expiresAt: {
|
|
87
|
-
type: Date,
|
|
88
|
-
default: null
|
|
89
|
-
},
|
|
90
|
-
usedAt: {
|
|
91
|
-
type: Date
|
|
92
|
-
},
|
|
93
|
-
usedOnReservationId: {
|
|
94
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
95
|
-
ref: 'BookingReservation'
|
|
96
|
-
},
|
|
97
|
-
amountApplied: {
|
|
98
|
-
type: Number
|
|
99
|
-
},
|
|
100
|
-
revokedReason: {
|
|
101
|
-
type: String
|
|
102
|
-
},
|
|
103
|
-
revokedAt: {
|
|
104
|
-
type: Date
|
|
105
|
-
},
|
|
106
|
-
issuedBy: {
|
|
107
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
108
|
-
ref: 'User'
|
|
109
|
-
},
|
|
110
|
-
updatedBy: {
|
|
111
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
112
|
-
ref: 'User'
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
timestamps: true
|
|
116
|
-
});
|
|
117
|
-
bookingVoucherSchema.pre('validate', function computeExpiresAt(next) {
|
|
118
|
-
if (this.expiryDuration && !this.expiresAt) {
|
|
119
|
-
const base = this.isNew ? Date.now() : (this.get('createdAt') ? this.get('createdAt').getTime() : Date.now());
|
|
120
|
-
this.expiresAt = new Date(base + EXPIRY_DURATION_MS[this.expiryDuration]);
|
|
121
|
-
}
|
|
122
|
-
next();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
bookingVoucherSchema.index({ facilityId: 1, status: 1 });
|
|
126
|
-
bookingVoucherSchema.index({ 'guestInfo.email': 1 });
|
|
127
|
-
bookingVoucherSchema.index({ 'guestInfo.phone': 1 });
|
|
128
|
-
bookingVoucherSchema.index({ status: 1, expiresAt: 1 });
|
|
129
|
-
|
|
130
|
-
const BookingVoucher = mongoose.model('BookingVoucher', bookingVoucherSchema);
|
|
131
|
-
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const EXPIRY_DURATION_MS = {
|
|
4
|
+
'2_weeks': 14 * 24 * 60 * 60 * 1000,
|
|
5
|
+
'1_month': 30 * 24 * 60 * 60 * 1000,
|
|
6
|
+
'3_months': 90 * 24 * 60 * 60 * 1000,
|
|
7
|
+
'6_months': 182 * 24 * 60 * 60 * 1000
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const bookingVoucherSchema = new mongoose.Schema({
|
|
11
|
+
facilityId: {
|
|
12
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'Facility',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
voucherCode: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
unique: true
|
|
20
|
+
},
|
|
21
|
+
sourceReservationId: {
|
|
22
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
23
|
+
ref: 'BookingReservation',
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
sourceInvoiceId: {
|
|
27
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
28
|
+
ref: 'BookingInvoice'
|
|
29
|
+
},
|
|
30
|
+
guestInfo: {
|
|
31
|
+
name: { type: String, required: true },
|
|
32
|
+
email: { type: String, required: true },
|
|
33
|
+
phone: { type: String, required: true }
|
|
34
|
+
},
|
|
35
|
+
// Audit trail for how `amount` was derived.
|
|
36
|
+
calculation: {
|
|
37
|
+
nightlyRate: { type: Number, required: true, min: 0 },
|
|
38
|
+
nightsUnused: { type: Number, required: true, min: 0 },
|
|
39
|
+
// 100% value of the unused nights, before percentageApplied
|
|
40
|
+
remainingAmount: { type: Number, required: true, min: 0 },
|
|
41
|
+
percentageApplied: { type: Number, required: true, min: 1, max: 100 }
|
|
42
|
+
},
|
|
43
|
+
// Redeemable value = remainingAmount * percentageApplied / 100
|
|
44
|
+
amount: {
|
|
45
|
+
type: Number,
|
|
46
|
+
required: true,
|
|
47
|
+
min: 0
|
|
48
|
+
},
|
|
49
|
+
currencyId: {
|
|
50
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
51
|
+
ref: 'Currency',
|
|
52
|
+
required: true
|
|
53
|
+
},
|
|
54
|
+
// 'revoked' (not 'cancelled') - a voucher is void by staff action
|
|
55
|
+
// (issued in error, flagged fraudulent, etc), which is deliberately a
|
|
56
|
+
// different word and a different code path from 'expired' (passive,
|
|
57
|
+
// time-based). Both are terminal and non-redeemable, but staff need
|
|
58
|
+
// to distinguish "we killed this on purpose, here's why" from "nobody
|
|
59
|
+
// used it in time" when reviewing a facility's voucher history.
|
|
60
|
+
status: {
|
|
61
|
+
type: String,
|
|
62
|
+
enum: ['active', 'used', 'expired', 'revoked'],
|
|
63
|
+
default: 'active'
|
|
64
|
+
},
|
|
65
|
+
statusHistory: [{
|
|
66
|
+
status: {
|
|
67
|
+
type: String,
|
|
68
|
+
enum: ['active', 'used', 'expired', 'revoked'],
|
|
69
|
+
required: true
|
|
70
|
+
},
|
|
71
|
+
timestamp: {
|
|
72
|
+
type: Date,
|
|
73
|
+
default: Date.now
|
|
74
|
+
},
|
|
75
|
+
updatedBy: mongoose.Schema.Types.ObjectId,
|
|
76
|
+
notes: String
|
|
77
|
+
}],
|
|
78
|
+
// Optional fixed-duration safety net (see BookingVoucherConfig). null
|
|
79
|
+
// means no calendar expiry - the voucher only dies when redeemed or
|
|
80
|
+
// explicitly revoked.
|
|
81
|
+
expiryDuration: {
|
|
82
|
+
type: String,
|
|
83
|
+
enum: ['2_weeks', '1_month', '3_months', '6_months', null],
|
|
84
|
+
default: null
|
|
85
|
+
},
|
|
86
|
+
expiresAt: {
|
|
87
|
+
type: Date,
|
|
88
|
+
default: null
|
|
89
|
+
},
|
|
90
|
+
usedAt: {
|
|
91
|
+
type: Date
|
|
92
|
+
},
|
|
93
|
+
usedOnReservationId: {
|
|
94
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
95
|
+
ref: 'BookingReservation'
|
|
96
|
+
},
|
|
97
|
+
amountApplied: {
|
|
98
|
+
type: Number
|
|
99
|
+
},
|
|
100
|
+
revokedReason: {
|
|
101
|
+
type: String
|
|
102
|
+
},
|
|
103
|
+
revokedAt: {
|
|
104
|
+
type: Date
|
|
105
|
+
},
|
|
106
|
+
issuedBy: {
|
|
107
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
108
|
+
ref: 'User'
|
|
109
|
+
},
|
|
110
|
+
updatedBy: {
|
|
111
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
112
|
+
ref: 'User'
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
timestamps: true
|
|
116
|
+
});
|
|
117
|
+
bookingVoucherSchema.pre('validate', function computeExpiresAt(next) {
|
|
118
|
+
if (this.expiryDuration && !this.expiresAt) {
|
|
119
|
+
const base = this.isNew ? Date.now() : (this.get('createdAt') ? this.get('createdAt').getTime() : Date.now());
|
|
120
|
+
this.expiresAt = new Date(base + EXPIRY_DURATION_MS[this.expiryDuration]);
|
|
121
|
+
}
|
|
122
|
+
next();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
bookingVoucherSchema.index({ facilityId: 1, status: 1 });
|
|
126
|
+
bookingVoucherSchema.index({ 'guestInfo.email': 1 });
|
|
127
|
+
bookingVoucherSchema.index({ 'guestInfo.phone': 1 });
|
|
128
|
+
bookingVoucherSchema.index({ status: 1, expiresAt: 1 });
|
|
129
|
+
|
|
130
|
+
const BookingVoucher = mongoose.model('BookingVoucher', bookingVoucherSchema);
|
|
131
|
+
|
|
132
132
|
module.exports = BookingVoucher;
|