payservedb 9.4.8 → 9.4.9
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
CHANGED
|
@@ -5,6 +5,10 @@ const bookingReservationSchema = new mongoose.Schema({
|
|
|
5
5
|
checkOutActual: {
|
|
6
6
|
type: Date
|
|
7
7
|
},
|
|
8
|
+
// When the guest was actually checked in (set by the Check In action)
|
|
9
|
+
checkedInAt: {
|
|
10
|
+
type: Date
|
|
11
|
+
},
|
|
8
12
|
// Field for checkout notes
|
|
9
13
|
checkoutNotes: {
|
|
10
14
|
type: String,
|
|
@@ -167,15 +171,24 @@ const bookingReservationSchema = new mongoose.Schema({
|
|
|
167
171
|
specialRequests: {
|
|
168
172
|
type: String
|
|
169
173
|
},
|
|
174
|
+
// This enum is a superset shared across companies on this multitenant
|
|
175
|
+
// platform (payservedb has no per-company branch) - each company's own
|
|
176
|
+
// controller code decides how 'booked'/'reserved' are actually used, so
|
|
177
|
+
// do not change the default here without checking every consumer.
|
|
178
|
+
// Swan: booked = created, zero payment. reserved = has payment (partial
|
|
179
|
+
// or full), not yet checked in. checked-in = guest on premises.
|
|
180
|
+
// checked-out = guest left but balance outstanding (e.g. damage
|
|
181
|
+
// charges). completed = balance cleared. cancelled = terminal, reachable
|
|
182
|
+
// from booked/reserved.
|
|
170
183
|
status: {
|
|
171
184
|
type: String,
|
|
172
|
-
enum: ['reserved', 'booked', 'canceled', 'completed'],
|
|
185
|
+
enum: ['reserved', 'booked', 'canceled', 'cancelled', 'checked-in', 'checked-out', 'completed'],
|
|
173
186
|
default: 'reserved'
|
|
174
187
|
},
|
|
175
188
|
statusHistory: [{
|
|
176
189
|
status: {
|
|
177
190
|
type: String,
|
|
178
|
-
enum: ['reserved', 'booked', 'canceled', 'completed'],
|
|
191
|
+
enum: ['reserved', 'booked', 'canceled', 'cancelled', 'checked-in', 'checked-out', 'completed'],
|
|
179
192
|
required: true
|
|
180
193
|
},
|
|
181
194
|
timestamp: {
|
|
@@ -218,7 +231,17 @@ const bookingReservationSchema = new mongoose.Schema({
|
|
|
218
231
|
refundRequestedAt: Date,
|
|
219
232
|
refundApprovedAt: Date,
|
|
220
233
|
refundRejectedAt: Date,
|
|
221
|
-
refundRejectionReason: String
|
|
234
|
+
refundRejectionReason: String,
|
|
235
|
+
// Records which named CancellationPolicy (if any) determined
|
|
236
|
+
// refundAmount, for display/audit purposes
|
|
237
|
+
appliedPolicy: {
|
|
238
|
+
policyId: {
|
|
239
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
240
|
+
ref: 'CancellationPolicy'
|
|
241
|
+
},
|
|
242
|
+
policyName: String,
|
|
243
|
+
refundPercentage: Number
|
|
244
|
+
}
|
|
222
245
|
},
|
|
223
246
|
createdBy: {
|
|
224
247
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -236,4 +259,3 @@ const bookingReservationSchema = new mongoose.Schema({
|
|
|
236
259
|
const BookingReservation = mongoose.model('BookingReservation', bookingReservationSchema);
|
|
237
260
|
|
|
238
261
|
module.exports = BookingReservation;
|
|
239
|
-
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
// A reusable, named cancellation policy. One policy can be assigned to many
|
|
4
|
+
// BookingProperty units (BookingProperty.cancellationPolicyId).
|
|
5
|
+
const cancellationPolicySchema = new mongoose.Schema({
|
|
6
|
+
facilityId: {
|
|
7
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
8
|
+
ref: 'Facility',
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
name: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
trim: true
|
|
15
|
+
},
|
|
16
|
+
description: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: ''
|
|
19
|
+
},
|
|
20
|
+
// If true, no refund is ever given under this policy regardless of
|
|
21
|
+
// refundRules
|
|
22
|
+
isNonRefundable: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false
|
|
25
|
+
},
|
|
26
|
+
// Tiered refund rules: a guest cancelling at least `daysBeforeCheckIn`
|
|
27
|
+
// days before check-in receives `refundPercentage` of what they paid.
|
|
28
|
+
// The rule with the highest daysBeforeCheckIn that the guest still
|
|
29
|
+
// qualifies for applies.
|
|
30
|
+
refundRules: [{
|
|
31
|
+
daysBeforeCheckIn: {
|
|
32
|
+
type: Number,
|
|
33
|
+
required: true,
|
|
34
|
+
min: 0
|
|
35
|
+
},
|
|
36
|
+
refundPercentage: {
|
|
37
|
+
type: Number,
|
|
38
|
+
required: true,
|
|
39
|
+
min: 0,
|
|
40
|
+
max: 100
|
|
41
|
+
},
|
|
42
|
+
description: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: ''
|
|
45
|
+
}
|
|
46
|
+
}],
|
|
47
|
+
createdBy: {
|
|
48
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
49
|
+
ref: 'User'
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
timestamps: true
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const CancellationPolicy = mongoose.model('CancellationPolicy', cancellationPolicySchema);
|
|
56
|
+
|
|
57
|
+
module.exports = CancellationPolicy;
|
package/src/models/invoice.js
CHANGED
|
@@ -45,6 +45,15 @@ const invoiceSchema = new mongoose.Schema(
|
|
|
45
45
|
id: { type: mongoose.Schema.Types.ObjectId, ref: "Unit", required: true },
|
|
46
46
|
name: { type: String, required: true },
|
|
47
47
|
},
|
|
48
|
+
// Per-unit fee breakdown for a single invoice covering multiple units
|
|
49
|
+
// (e.g. a Property-Management contract billing several units at
|
|
50
|
+
// different rates). Only set when the invoice spans more than one
|
|
51
|
+
// unit - `unit` above still identifies the contract's primary unit for
|
|
52
|
+
// backward compatibility with code that expects a single unit.
|
|
53
|
+
unitBreakdown: [{
|
|
54
|
+
unitId: { type: mongoose.Schema.Types.ObjectId, ref: "Unit" },
|
|
55
|
+
amount: Number
|
|
56
|
+
}],
|
|
48
57
|
currency: {
|
|
49
58
|
id: {
|
|
50
59
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -558,4 +567,4 @@ invoiceSchema.pre("save", function (next) {
|
|
|
558
567
|
|
|
559
568
|
const Invoice = mongoose.model("Invoice", invoiceSchema);
|
|
560
569
|
|
|
561
|
-
module.exports = Invoice;
|
|
570
|
+
module.exports = Invoice;
|
|
@@ -118,6 +118,48 @@ const PropertyManagerContractSchema = new Schema(
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
|
+
// Currency for fixed-amount managementFee/leaseFee values above.
|
|
122
|
+
// Only meaningful when the fee type is 'amount' (percentage fees are
|
|
123
|
+
// currency-agnostic).
|
|
124
|
+
currencyId: {
|
|
125
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
126
|
+
ref: 'Currency'
|
|
127
|
+
},
|
|
128
|
+
// Per-unit fee overrides. Each unit in `units` may have a different
|
|
129
|
+
// management/lease fee here; a unit with no entry here falls back to
|
|
130
|
+
// the contract-level managementFee/leaseFee/currencyId above. This is
|
|
131
|
+
// what lets one contract cover multiple units at different rates.
|
|
132
|
+
unitFees: [{
|
|
133
|
+
unitId: {
|
|
134
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
135
|
+
ref: 'Unit',
|
|
136
|
+
required: true
|
|
137
|
+
},
|
|
138
|
+
managementFee: {
|
|
139
|
+
type: {
|
|
140
|
+
type: String,
|
|
141
|
+
enum: ['percentage', 'amount']
|
|
142
|
+
},
|
|
143
|
+
value: {
|
|
144
|
+
type: Number,
|
|
145
|
+
min: [0, 'Management fee value cannot be negative']
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
leaseFee: {
|
|
149
|
+
type: {
|
|
150
|
+
type: String,
|
|
151
|
+
enum: ['percentage', 'amount']
|
|
152
|
+
},
|
|
153
|
+
value: {
|
|
154
|
+
type: Number,
|
|
155
|
+
min: [0, 'Lease commission value cannot be negative']
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
currencyId: {
|
|
159
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
160
|
+
ref: 'Currency'
|
|
161
|
+
}
|
|
162
|
+
}],
|
|
121
163
|
// GL Account configurations - updated to match sample data structure
|
|
122
164
|
invoiceDoubleEntryAccount: {
|
|
123
165
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -152,7 +194,10 @@ const PropertyManagerContractSchema = new Schema(
|
|
|
152
194
|
status: {
|
|
153
195
|
type: String,
|
|
154
196
|
enum: ['Active', 'Inactive', 'Completed', 'Suspended', 'Terminated'],
|
|
155
|
-
default
|
|
197
|
+
// Contracts default Active on creation - billing eligibility is
|
|
198
|
+
// driven by lease existence, not contract status. Status is now
|
|
199
|
+
// a purely manual lifecycle field the property manager controls.
|
|
200
|
+
default: 'Active',
|
|
156
201
|
required: [true, 'Status is required']
|
|
157
202
|
},
|
|
158
203
|
createdBy: {
|
|
@@ -219,26 +264,13 @@ PropertyManagerContractSchema.pre('save', function (next) {
|
|
|
219
264
|
return;
|
|
220
265
|
}
|
|
221
266
|
|
|
222
|
-
//
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
next(new Error('End date is required for Active contracts'));
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (!this.paymentDueDate) {
|
|
233
|
-
next(new Error('Payment due date is required for Active contracts'));
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
if (!this.frequency) {
|
|
237
|
-
next(new Error('Payment frequency is required for Active contracts'));
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
267
|
+
// Note: startDate/endDate/paymentDueDate/frequency are no longer
|
|
268
|
+
// required for Active status - contracts are always Active regardless
|
|
269
|
+
// of whether a lease has populated those fields yet. They remain
|
|
270
|
+
// required only for billing (see invoice_service's eligibility checks,
|
|
271
|
+
// which additionally require an active lease before generating an
|
|
272
|
+
// invoice).
|
|
273
|
+
|
|
242
274
|
next();
|
|
243
275
|
});
|
|
244
276
|
|
|
@@ -32,6 +32,14 @@ const propertyManagerRevenueEntrySchema = new mongoose.Schema({
|
|
|
32
32
|
required: true
|
|
33
33
|
},
|
|
34
34
|
unitName: String,
|
|
35
|
+
// Informational per-unit split when this entry's source invoice covered
|
|
36
|
+
// multiple units (e.g. a multi-unit management-fee invoice) - `unit`/
|
|
37
|
+
// `unitName` above remain the primary unit for backward compatibility.
|
|
38
|
+
unitBreakdown: [{
|
|
39
|
+
unitId: { type: mongoose.Schema.Types.ObjectId, ref: 'Unit' },
|
|
40
|
+
unitName: String,
|
|
41
|
+
amount: Number
|
|
42
|
+
}],
|
|
35
43
|
source: {
|
|
36
44
|
type: String,
|
|
37
45
|
enum: ['booking_commission', 'lease_fee', 'management_fee'],
|