@vibe-flats/booking-engine-common-server 1.0.111 → 1.0.113
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.
|
@@ -4,8 +4,6 @@ exports.vibePrice = void 0;
|
|
|
4
4
|
const monthly_diff_1 = require("./monthly-diff");
|
|
5
5
|
const vibePrice = (obj) => {
|
|
6
6
|
const { unit, stay, excludeCleaning, excludeUtilities, markup } = obj;
|
|
7
|
-
// Additional channel markup, added static because its available only on quotes
|
|
8
|
-
const markupValue = markup || 1;
|
|
9
7
|
// Get min and max dates from stay array
|
|
10
8
|
const sortedStay = [...stay].sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
11
9
|
const dateFrom = sortedStay[0].date;
|
|
@@ -14,12 +12,14 @@ const vibePrice = (obj) => {
|
|
|
14
12
|
const monthsDiff = (0, monthly_diff_1.calculatePreciseMonthDifference)(dateFrom, dateTo);
|
|
15
13
|
// Nights
|
|
16
14
|
const nights = stay.length;
|
|
15
|
+
// Additional channel markup, added as prop because its available only on quotes
|
|
16
|
+
const markupValue = markup ? markup / 100 + 1 : 1;
|
|
17
17
|
// Apply multiplier: Guesty's approach to monthly pricing
|
|
18
18
|
const rent = +(stay.reduce((acc, stay) => acc + stay.price, 0) * markupValue).toFixed(0);
|
|
19
19
|
const cleaning = excludeCleaning ? 0 : unit.prices.cleaningFee;
|
|
20
20
|
const utilities = excludeUtilities ? 0 : unit.prices.utilities * nights;
|
|
21
21
|
const subTotal = rent + utilities + cleaning;
|
|
22
|
-
const discount =
|
|
22
|
+
const discount = nights >= 30 && unit.prices.monthlyPriceFactor !== 1 ? +(rent * (1 - unit.prices.monthlyPriceFactor)).toFixed(0) : 0;
|
|
23
23
|
const total = subTotal - discount;
|
|
24
24
|
const monthly = {
|
|
25
25
|
rent: Math.round(rent / monthsDiff),
|