@vibe-flats/booking-engine-common-server 1.0.17 → 1.0.18

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
@@ -1 +1,3 @@
1
1
  export * from './src/units-models';
2
+ export * from './src/config/app';
3
+ export * from './src/utils/guesty-price';
package/build/index.js CHANGED
@@ -15,3 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./src/units-models"), exports);
18
+ __exportStar(require("./src/config/app"), exports);
19
+ __exportStar(require("./src/utils/guesty-price"), exports);
@@ -0,0 +1,15 @@
1
+ export declare const COMMON_APP: {
2
+ formats: {
3
+ date: {
4
+ short: {
5
+ db: string;
6
+ display: string;
7
+ };
8
+ };
9
+ };
10
+ guesty: {
11
+ fees: {
12
+ utilities: string;
13
+ };
14
+ };
15
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COMMON_APP = void 0;
4
+ exports.COMMON_APP = {
5
+ formats: {
6
+ date: {
7
+ short: {
8
+ db: 'YYYY-MM-DD',
9
+ display: 'MM/DD/YYYY'
10
+ }
11
+ }
12
+ },
13
+ guesty: {
14
+ fees: {
15
+ utilities: 'Utilities'
16
+ }
17
+ }
18
+ };
@@ -0,0 +1,8 @@
1
+ import { AvailabilityDocument } from '../models/availability';
2
+ import { UnitDocument } from '../models/units';
3
+ export declare const guestyPrice: (unit: UnitDocument, stay: AvailabilityDocument[]) => {
4
+ nights: number;
5
+ rent: number;
6
+ cleaning: number;
7
+ utilities: number;
8
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.guestyPrice = void 0;
4
+ const app_1 = require("../config/app");
5
+ const guestyPrice = (unit, stay) => {
6
+ var _a;
7
+ //
8
+ const nights = stay.length;
9
+ const multiplier = nights >= 30 ? unit.prices.monthlyPriceFactor : 1;
10
+ // Apply multiplier: Guesty's approach to monthly pricing
11
+ const rent = +(stay.reduce((acc, stay) => acc + stay.price, 0) * multiplier).toFixed(0);
12
+ const cleaning = unit.prices.cleaningFee;
13
+ const utilities = (((_a = unit.fees.find(fee => fee.name.trim() === app_1.COMMON_APP.guesty.fees.utilities)) === null || _a === void 0 ? void 0 : _a.value) || 0) * nights;
14
+ return { nights, rent, cleaning, utilities };
15
+ };
16
+ exports.guestyPrice = guestyPrice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-flats/booking-engine-common-server",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",