@vibe-flats/booking-engine-common-server 1.0.107 → 1.0.110

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,5 +1,5 @@
1
1
  export * from './src/units-models';
2
2
  export * from './src/config/app';
3
- export * from './src/utils/guesty-price';
3
+ export * from './src/utils/vibe-price';
4
4
  export * from './src/utils/monthly-diff';
5
5
  export * from './src/utils/purge-unit-cache';
package/build/index.js CHANGED
@@ -16,6 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./src/units-models"), exports);
18
18
  __exportStar(require("./src/config/app"), exports);
19
- __exportStar(require("./src/utils/guesty-price"), exports);
19
+ __exportStar(require("./src/utils/vibe-price"), exports);
20
20
  __exportStar(require("./src/utils/monthly-diff"), exports);
21
21
  __exportStar(require("./src/utils/purge-unit-cache"), exports);
@@ -1,5 +1,5 @@
1
- import { UnitDocument } from '../models/units';
2
1
  import { AvailabilityDocument } from '../models/availability';
2
+ import { UnitDocument } from '../models/units';
3
3
  export interface VibePrice {
4
4
  nights: number;
5
5
  rent: number;
@@ -20,4 +20,5 @@ export declare const vibePrice: (obj: {
20
20
  stay: AvailabilityDocument[];
21
21
  excludeCleaning?: boolean;
22
22
  excludeUtilities?: boolean;
23
+ markup?: number;
23
24
  }) => VibePrice;
@@ -4,16 +4,18 @@ exports.vibePrice = void 0;
4
4
  const app_1 = require("../config/app");
5
5
  const monthly_diff_1 = require("./monthly-diff");
6
6
  const vibePrice = (obj) => {
7
- const { unit, stay, excludeCleaning, excludeUtilities } = obj;
7
+ const { unit, stay, excludeCleaning, excludeUtilities, markup } = obj;
8
+ // Additional channel markup, added static because its available only on quotes
9
+ const markupValue = markup || 1;
8
10
  const nights = stay.length;
9
11
  const multiplier = nights >= app_1.COMMON_SERVER.priceFactor.monthly ? unit.prices.monthlyPriceFactor : 1;
10
12
  // Apply multiplier: Guesty's approach to monthly pricing
11
- const rent = +(stay.reduce((acc, stay) => acc + stay.price, 0) * multiplier).toFixed(0);
13
+ const rent = +(stay.reduce((acc, stay) => acc + stay.price, 0) * multiplier * markupValue).toFixed(0);
12
14
  const cleaning = excludeCleaning ? 0 : unit.prices.cleaningFee;
13
15
  const utilities = excludeUtilities ? 0 : unit.prices.utilities * nights;
14
16
  const subTotal = rent + utilities + cleaning;
15
17
  const discount = nights >= app_1.COMMON_SERVER.priceFactor.monthly && unit.prices.monthlyPriceFactor !== 1
16
- ? subTotal * (1 - unit.prices.monthlyPriceFactor)
18
+ ? +(subTotal * (1 - unit.prices.monthlyPriceFactor)).toFixed(0)
17
19
  : 0;
18
20
  const total = subTotal - discount;
19
21
  // Get min and max dates from stay array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-flats/booking-engine-common-server",
3
- "version": "1.0.107",
3
+ "version": "1.0.110",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",