@vibe-flats/booking-engine-common-server 1.0.108 → 1.0.111

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;
@@ -1,27 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vibePrice = void 0;
4
- const app_1 = require("../config/app");
5
4
  const monthly_diff_1 = require("./monthly-diff");
6
5
  const vibePrice = (obj) => {
7
- const { unit, stay, excludeCleaning, excludeUtilities } = obj;
8
- const nights = stay.length;
9
- const multiplier = nights >= app_1.COMMON_SERVER.priceFactor.monthly ? 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 = excludeCleaning ? 0 : unit.prices.cleaningFee;
13
- const utilities = excludeUtilities ? 0 : unit.prices.utilities * nights;
14
- const subTotal = rent + utilities + cleaning;
15
- const discount = nights >= app_1.COMMON_SERVER.priceFactor.monthly && unit.prices.monthlyPriceFactor !== 1
16
- ? +(subTotal * (1 - unit.prices.monthlyPriceFactor)).toFixed(0)
17
- : 0;
18
- const total = subTotal - discount;
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;
19
9
  // Get min and max dates from stay array
20
10
  const sortedStay = [...stay].sort((a, b) => a.date.getTime() - b.date.getTime());
21
11
  const dateFrom = sortedStay[0].date;
22
12
  const dateTo = sortedStay[sortedStay.length - 1].date;
23
13
  // Calculate exact months difference using dayjs
24
14
  const monthsDiff = (0, monthly_diff_1.calculatePreciseMonthDifference)(dateFrom, dateTo);
15
+ // Nights
16
+ const nights = stay.length;
17
+ // Apply multiplier: Guesty's approach to monthly pricing
18
+ const rent = +(stay.reduce((acc, stay) => acc + stay.price, 0) * markupValue).toFixed(0);
19
+ const cleaning = excludeCleaning ? 0 : unit.prices.cleaningFee;
20
+ const utilities = excludeUtilities ? 0 : unit.prices.utilities * nights;
21
+ const subTotal = rent + utilities + cleaning;
22
+ const discount = monthsDiff >= 1 && unit.prices.monthlyPriceFactor !== 1 ? +(rent * (1 - unit.prices.monthlyPriceFactor)).toFixed(0) : 0;
23
+ const total = subTotal - discount;
25
24
  const monthly = {
26
25
  rent: Math.round(rent / monthsDiff),
27
26
  discount: Math.round(discount / monthsDiff),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-flats/booking-engine-common-server",
3
- "version": "1.0.108",
3
+ "version": "1.0.111",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",