@vibe-flats/booking-engine-common-server 1.0.60 → 1.0.61
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/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/src/config/app.d.ts +3 -3
- package/build/src/config/app.js +3 -3
- package/build/src/models/areas.d.ts +4 -1
- package/build/src/models/areas.js +7 -3
- package/build/src/models/availability.d.ts +5 -0
- package/build/src/models/availability.js +12 -0
- package/build/src/models/cities.d.ts +17 -2
- package/build/src/models/cities.js +33 -5
- package/build/src/models/units.d.ts +14 -1
- package/build/src/models/units.js +20 -1
- package/build/src/utils/guesty-price.js +1 -1
- package/build/src/utils/monthly-diff.d.ts +1 -0
- package/build/src/utils/monthly-diff.js +17 -0
- package/package.json +2 -1
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./src/units-models"), exports);
|
|
18
18
|
__exportStar(require("./src/config/app"), exports);
|
|
19
19
|
__exportStar(require("./src/utils/guesty-price"), exports);
|
|
20
|
+
__exportStar(require("./src/utils/monthly-diff"), exports);
|
|
@@ -3,6 +3,9 @@ export declare const COMMON_SERVER: {
|
|
|
3
3
|
symbol: string;
|
|
4
4
|
code: string;
|
|
5
5
|
};
|
|
6
|
+
priceFactor: {
|
|
7
|
+
monthly: number;
|
|
8
|
+
};
|
|
6
9
|
guesty: {
|
|
7
10
|
fees: {
|
|
8
11
|
utilities: string;
|
|
@@ -15,9 +18,6 @@ export declare const COMMON_SERVER: {
|
|
|
15
18
|
reservation: string;
|
|
16
19
|
};
|
|
17
20
|
reservations: {
|
|
18
|
-
associations: {
|
|
19
|
-
guest: number;
|
|
20
|
-
};
|
|
21
21
|
channels: {
|
|
22
22
|
direct: string;
|
|
23
23
|
};
|
package/build/src/config/app.js
CHANGED
|
@@ -6,6 +6,9 @@ exports.COMMON_SERVER = {
|
|
|
6
6
|
symbol: '$',
|
|
7
7
|
code: 'USD'
|
|
8
8
|
},
|
|
9
|
+
priceFactor: {
|
|
10
|
+
monthly: 30
|
|
11
|
+
},
|
|
9
12
|
guesty: {
|
|
10
13
|
fees: {
|
|
11
14
|
utilities: 'Utilities'
|
|
@@ -18,9 +21,6 @@ exports.COMMON_SERVER = {
|
|
|
18
21
|
reservation: '2-30640026'
|
|
19
22
|
},
|
|
20
23
|
reservations: {
|
|
21
|
-
associations: {
|
|
22
|
-
guest: 41
|
|
23
|
-
},
|
|
24
24
|
channels: {
|
|
25
25
|
direct: 'Direct'
|
|
26
26
|
},
|
|
@@ -5,7 +5,10 @@ export interface AreaDocument extends mongoose.Document {
|
|
|
5
5
|
externalName: string;
|
|
6
6
|
publicId: string;
|
|
7
7
|
city: CityDocument;
|
|
8
|
-
|
|
8
|
+
website: {
|
|
9
|
+
summary: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
9
12
|
}
|
|
10
13
|
export declare const AreaModel: (connection: mongoose.Connection) => mongoose.Model<AreaDocument, {}, {}, {}, mongoose.Document<unknown, {}, AreaDocument> & AreaDocument & Required<{
|
|
11
14
|
_id: unknown;
|
|
@@ -42,9 +42,13 @@ const schema = new mongoose_1.default.Schema({
|
|
|
42
42
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
43
43
|
ref: 'City'
|
|
44
44
|
},
|
|
45
|
-
|
|
46
|
-
type:
|
|
47
|
-
|
|
45
|
+
website: {
|
|
46
|
+
type: new mongoose_1.default.Schema({
|
|
47
|
+
summary: { type: String, required: false },
|
|
48
|
+
description: { type: String, required: false }
|
|
49
|
+
}),
|
|
50
|
+
required: false,
|
|
51
|
+
_id: false
|
|
48
52
|
}
|
|
49
53
|
});
|
|
50
54
|
schema.index({ publicId: 1 });
|
|
@@ -6,6 +6,11 @@ export interface AvailabilityDocument extends mongoose.Document {
|
|
|
6
6
|
isAvailable: boolean;
|
|
7
7
|
price: number;
|
|
8
8
|
minNights: number;
|
|
9
|
+
checkin: boolean;
|
|
10
|
+
checkout?: {
|
|
11
|
+
min: Date;
|
|
12
|
+
max: Date;
|
|
13
|
+
};
|
|
9
14
|
}
|
|
10
15
|
export declare const AvailabilityModel: (connection: mongoose.Connection) => mongoose.Model<AvailabilityDocument, {}, {}, {}, mongoose.Document<unknown, {}, AvailabilityDocument> & AvailabilityDocument & Required<{
|
|
11
16
|
_id: unknown;
|
|
@@ -46,6 +46,18 @@ const schema = new mongoose_1.default.Schema({
|
|
|
46
46
|
minNights: {
|
|
47
47
|
type: Number,
|
|
48
48
|
required: true
|
|
49
|
+
},
|
|
50
|
+
checkin: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
required: true
|
|
53
|
+
},
|
|
54
|
+
checkout: {
|
|
55
|
+
type: new mongoose_1.default.Schema({
|
|
56
|
+
min: { type: Date, required: true },
|
|
57
|
+
max: { type: Date, required: true }
|
|
58
|
+
}),
|
|
59
|
+
required: false,
|
|
60
|
+
_id: false
|
|
49
61
|
}
|
|
50
62
|
}, {
|
|
51
63
|
timestamps: true,
|
|
@@ -3,8 +3,23 @@ export interface CityDocument extends mongoose.Document {
|
|
|
3
3
|
name: string;
|
|
4
4
|
externalName: string;
|
|
5
5
|
publicId: string;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
isActive: boolean;
|
|
7
|
+
minNights: number;
|
|
8
|
+
website: {
|
|
9
|
+
summary: string;
|
|
10
|
+
description: string;
|
|
11
|
+
slug: string;
|
|
12
|
+
meta: {
|
|
13
|
+
title: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
faq: {
|
|
17
|
+
question: string;
|
|
18
|
+
answer: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
8
23
|
}
|
|
9
24
|
export declare const CityModel: (connection: mongoose.Connection) => mongoose.Model<CityDocument, {}, {}, {}, mongoose.Document<unknown, {}, CityDocument> & CityDocument & Required<{
|
|
10
25
|
_id: unknown;
|
|
@@ -18,14 +18,42 @@ const schema = new mongoose_1.default.Schema({
|
|
|
18
18
|
type: String,
|
|
19
19
|
required: true
|
|
20
20
|
},
|
|
21
|
-
|
|
22
|
-
type:
|
|
23
|
-
required:
|
|
21
|
+
isActive: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
required: true,
|
|
24
|
+
default: true
|
|
24
25
|
},
|
|
25
|
-
|
|
26
|
+
minNights: {
|
|
26
27
|
type: String,
|
|
27
|
-
required:
|
|
28
|
+
required: true,
|
|
29
|
+
default: 2
|
|
30
|
+
},
|
|
31
|
+
website: {
|
|
32
|
+
type: new mongoose_1.default.Schema({
|
|
33
|
+
summary: { type: String },
|
|
34
|
+
description: { type: String },
|
|
35
|
+
slug: { type: String },
|
|
36
|
+
meta: {
|
|
37
|
+
type: new mongoose_1.default.Schema({
|
|
38
|
+
title: { type: String },
|
|
39
|
+
description: { type: String }
|
|
40
|
+
}),
|
|
41
|
+
_id: false
|
|
42
|
+
},
|
|
43
|
+
faq: [
|
|
44
|
+
{
|
|
45
|
+
type: new mongoose_1.default.Schema({
|
|
46
|
+
question: { type: String },
|
|
47
|
+
answer: { type: String }
|
|
48
|
+
}),
|
|
49
|
+
_id: false
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}),
|
|
53
|
+
_id: false
|
|
28
54
|
}
|
|
55
|
+
}, {
|
|
56
|
+
timestamps: true
|
|
29
57
|
});
|
|
30
58
|
schema.index({ publicId: 1 });
|
|
31
59
|
schema.index({ slug: 1 }, { unique: true });
|
|
@@ -58,7 +58,20 @@ export interface UnitDocument extends mongoose.Document {
|
|
|
58
58
|
vrbo: string;
|
|
59
59
|
booking: string;
|
|
60
60
|
};
|
|
61
|
-
|
|
61
|
+
website: {
|
|
62
|
+
description: string;
|
|
63
|
+
slug: string;
|
|
64
|
+
};
|
|
65
|
+
deal: {
|
|
66
|
+
total: number;
|
|
67
|
+
monthly: number;
|
|
68
|
+
nights: number;
|
|
69
|
+
from: Date;
|
|
70
|
+
to: Date;
|
|
71
|
+
};
|
|
72
|
+
availableFrom?: Date;
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
updatedAt: Date;
|
|
62
75
|
}
|
|
63
76
|
export declare const UnitModel: (connection: mongoose.Connection) => mongoose.Model<UnitDocument, {}, {}, {}, mongoose.Document<unknown, {}, UnitDocument> & UnitDocument & Required<{
|
|
64
77
|
_id: unknown;
|
|
@@ -93,7 +93,26 @@ const schema = new mongoose_1.default.Schema({
|
|
|
93
93
|
required: false,
|
|
94
94
|
_id: false
|
|
95
95
|
},
|
|
96
|
-
|
|
96
|
+
website: {
|
|
97
|
+
type: new mongoose_1.default.Schema({
|
|
98
|
+
description: { type: String, required: false },
|
|
99
|
+
slug: { type: String, required: false }
|
|
100
|
+
}),
|
|
101
|
+
required: false,
|
|
102
|
+
_id: false
|
|
103
|
+
},
|
|
104
|
+
deal: {
|
|
105
|
+
type: new mongoose_1.default.Schema({
|
|
106
|
+
total: { type: Number, required: true },
|
|
107
|
+
monthly: { type: Number, required: true },
|
|
108
|
+
nights: { type: Number, required: true },
|
|
109
|
+
from: { type: Date, required: false },
|
|
110
|
+
to: { type: Date, required: false }
|
|
111
|
+
}),
|
|
112
|
+
required: false,
|
|
113
|
+
_id: false
|
|
114
|
+
},
|
|
115
|
+
availableFrom: { type: Date, required: false }
|
|
97
116
|
}, {
|
|
98
117
|
timestamps: true,
|
|
99
118
|
versionKey: false,
|
|
@@ -6,7 +6,7 @@ const guestyPrice = (unit, stay) => {
|
|
|
6
6
|
var _a;
|
|
7
7
|
//
|
|
8
8
|
const nights = stay.length;
|
|
9
|
-
const multiplier = nights >=
|
|
9
|
+
const multiplier = nights >= app_1.COMMON_SERVER.priceFactor.monthly ? unit.prices.monthlyPriceFactor : 1;
|
|
10
10
|
// Apply multiplier: Guesty's approach to monthly pricing
|
|
11
11
|
const rent = +(stay.reduce((acc, stay) => acc + stay.price, 0) * multiplier).toFixed(0);
|
|
12
12
|
const cleaning = unit.prices.cleaningFee;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const calculatePreciseMonthDifference: (from: Date, to: Date) => number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calculatePreciseMonthDifference = void 0;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
const calculatePreciseMonthDifference = (from, to) => {
|
|
9
|
+
//
|
|
10
|
+
const monthsDiff = (0, dayjs_1.default)(to).diff(from, 'month', true);
|
|
11
|
+
if (monthsDiff >= 1) {
|
|
12
|
+
return monthsDiff;
|
|
13
|
+
}
|
|
14
|
+
const daysDiff = (0, dayjs_1.default)(to).diff(from, 'day');
|
|
15
|
+
return Number((daysDiff / 30).toFixed(2));
|
|
16
|
+
};
|
|
17
|
+
exports.calculatePreciseMonthDifference = calculatePreciseMonthDifference;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibe-flats/booking-engine-common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.61",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"typescript": "^5.1.6"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"dayjs": "^1.11.13",
|
|
24
25
|
"mongoose": "^8.5.2"
|
|
25
26
|
}
|
|
26
27
|
}
|