@vibe-flats/booking-engine-common-server 1.0.45 → 1.0.47
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
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);
|
|
@@ -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.47",
|
|
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
|
}
|