@vibe-flats/booking-engine-common-server 1.0.152 → 1.0.154
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.
|
@@ -88,6 +88,7 @@ const schema = new mongoose_1.default.Schema({
|
|
|
88
88
|
baseMonthlyRate: { type: Number, required: false },
|
|
89
89
|
cleaningFee: { type: Number, required: true },
|
|
90
90
|
utilities: { type: Number, required: true },
|
|
91
|
+
excludeUtilities: { type: Boolean, required: false },
|
|
91
92
|
monthly: [{ month: { type: String, required: true }, price: { type: Number, required: true }, _id: false }]
|
|
92
93
|
}),
|
|
93
94
|
required: true,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
export interface GuestyMoney {
|
|
2
|
+
subTotalPrice: number;
|
|
3
|
+
totalTaxes: number;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
1
6
|
/**
|
|
2
7
|
* Calculates the true Guesty reservation total including taxes.
|
|
3
8
|
* Guesty's `subTotalPrice` excludes taxes, so this adds `totalTaxes` to get the full amount.
|
|
9
|
+
* Accepts the full `money` object from a Guesty reservation so the formula is centralized.
|
|
4
10
|
*/
|
|
5
|
-
export declare const guestyTotal: (money:
|
|
6
|
-
subTotalPrice: number;
|
|
7
|
-
totalTaxes: number;
|
|
8
|
-
}) => number;
|
|
11
|
+
export declare const guestyTotal: (money: GuestyMoney) => number;
|
|
@@ -4,6 +4,7 @@ exports.guestyTotal = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Calculates the true Guesty reservation total including taxes.
|
|
6
6
|
* Guesty's `subTotalPrice` excludes taxes, so this adds `totalTaxes` to get the full amount.
|
|
7
|
+
* Accepts the full `money` object from a Guesty reservation so the formula is centralized.
|
|
7
8
|
*/
|
|
8
9
|
const guestyTotal = (money) => {
|
|
9
10
|
return money.subTotalPrice + money.totalTaxes;
|
|
@@ -19,7 +19,7 @@ const vibePrice = (obj) => {
|
|
|
19
19
|
// Apply multiplier: Guesty's approach to monthly pricing
|
|
20
20
|
const rent = +(stay.reduce((acc, stay) => acc + stay.price, 0) * markupValue).toFixed(0);
|
|
21
21
|
const cleaning = excludeCleaning ? 0 : unit.prices.cleaningFee;
|
|
22
|
-
const utilities = excludeUtilities ? 0 : unit.prices.utilities * nights;
|
|
22
|
+
const utilities = (excludeUtilities || unit.prices.excludeUtilities) ? 0 : unit.prices.utilities * nights;
|
|
23
23
|
const subTotal = rent + utilities + cleaning;
|
|
24
24
|
const discount = (nights >= vibe_common_1.DAYS_IN_MONTH || forceMonthlyDiscount) && unit.prices.monthlyPriceFactor !== 1
|
|
25
25
|
? +(rent * (1 - unit.prices.monthlyPriceFactor)).toFixed(0)
|
|
@@ -28,11 +28,11 @@ const vibePrice = (obj) => {
|
|
|
28
28
|
const taxes = (unit.taxes || [])
|
|
29
29
|
.filter(tax => !tax.maxNightCountToApplyOn || nights <= tax.maxNightCountToApplyOn)
|
|
30
30
|
.map(tax => {
|
|
31
|
-
const baseAmount = tax.units === units_1.TAX_UNITS.PERCENTAGE ?
|
|
31
|
+
const baseAmount = tax.units === units_1.TAX_UNITS.PERCENTAGE ? preTaxTotal * (tax.amount / 100) : tax.amount;
|
|
32
32
|
const taxAmount = tax.quantifier === 'PER_NIGHT' ? baseAmount * nights : baseAmount;
|
|
33
|
-
return { name: tax.name, amount:
|
|
33
|
+
return { name: tax.name, amount: +taxAmount.toFixed(2) };
|
|
34
34
|
});
|
|
35
|
-
const taxTotal = taxes.reduce((sum, tax) => sum + tax.amount, 0);
|
|
35
|
+
const taxTotal = +taxes.reduce((sum, tax) => sum + tax.amount, 0).toFixed(2);
|
|
36
36
|
const total = preTaxTotal + taxTotal;
|
|
37
37
|
const monthly = {
|
|
38
38
|
rent: Math.round(rent / monthsDiff),
|