@vibe-flats/booking-engine-common-server 1.0.162 → 1.0.164

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
@@ -5,4 +5,5 @@ export * from './src/utils/monthly-diff';
5
5
  export * from './src/utils/purge-unit-cache';
6
6
  export * from './src/utils/cache';
7
7
  export * from './src/utils/guesty-total';
8
+ export * from './src/utils/extension-grace';
8
9
  export * from './src/types/guesty-reservation';
package/build/index.js CHANGED
@@ -21,4 +21,5 @@ __exportStar(require("./src/utils/monthly-diff"), exports);
21
21
  __exportStar(require("./src/utils/purge-unit-cache"), exports);
22
22
  __exportStar(require("./src/utils/cache"), exports);
23
23
  __exportStar(require("./src/utils/guesty-total"), exports);
24
+ __exportStar(require("./src/utils/extension-grace"), exports);
24
25
  __exportStar(require("./src/types/guesty-reservation"), exports);
@@ -6,6 +6,9 @@ export declare const COMMON_SERVER: {
6
6
  website: {
7
7
  purgeUnitCacheInterval: number;
8
8
  };
9
+ extensions: {
10
+ postStayGraceHours: number;
11
+ };
9
12
  guesty: {
10
13
  stripe: {
11
14
  paymentProviderId: string;
@@ -9,6 +9,12 @@ exports.COMMON_SERVER = {
9
9
  website: {
10
10
  purgeUnitCacheInterval: 60
11
11
  },
12
+ extensions: {
13
+ // Single source of truth: how many hours after the approved checkout time an
14
+ // extension may still be created/paid for once a reservation is in post stay.
15
+ // When changed, until the hubspot-ui cards is migrated to this project, need to update the value there as well
16
+ postStayGraceHours: 2
17
+ },
12
18
  guesty: {
13
19
  stripe: {
14
20
  paymentProviderId: '664d9dc85fadb20011ee5b04'
@@ -0,0 +1,11 @@
1
+ import dayjs from 'dayjs';
2
+ /**
3
+ * The latest moment an extension may still be created or paid for, based on the
4
+ * reservation's approved checkout time and the shared post-stay grace window.
5
+ */
6
+ export declare const postStayExtensionDeadline: (approvedCheckOutTime: string | Date) => dayjs.Dayjs;
7
+ /**
8
+ * Whether "now" is still within the post-stay extension grace window.
9
+ * Returns false when no approved checkout time is available or it can't be parsed.
10
+ */
11
+ export declare const isWithinPostStayExtensionWindow: (approvedCheckOutTime?: string | Date | null) => boolean;
@@ -0,0 +1,26 @@
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.isWithinPostStayExtensionWindow = exports.postStayExtensionDeadline = void 0;
7
+ const dayjs_1 = __importDefault(require("dayjs"));
8
+ const app_1 = require("../config/app");
9
+ /**
10
+ * The latest moment an extension may still be created or paid for, based on the
11
+ * reservation's approved checkout time and the shared post-stay grace window.
12
+ */
13
+ const postStayExtensionDeadline = (approvedCheckOutTime) => (0, dayjs_1.default)(approvedCheckOutTime).add(app_1.COMMON_SERVER.extensions.postStayGraceHours, 'hour');
14
+ exports.postStayExtensionDeadline = postStayExtensionDeadline;
15
+ /**
16
+ * Whether "now" is still within the post-stay extension grace window.
17
+ * Returns false when no approved checkout time is available or it can't be parsed.
18
+ */
19
+ const isWithinPostStayExtensionWindow = (approvedCheckOutTime) => {
20
+ if (!approvedCheckOutTime) {
21
+ return false;
22
+ }
23
+ const deadline = (0, exports.postStayExtensionDeadline)(approvedCheckOutTime);
24
+ return deadline.isValid() && !(0, dayjs_1.default)().isAfter(deadline);
25
+ };
26
+ exports.isWithinPostStayExtensionWindow = isWithinPostStayExtensionWindow;
@@ -17,7 +17,7 @@ const vibePrice = (obj) => {
17
17
  // Additional channel markup, added as prop because its available only on quotes
18
18
  const markupValue = markup ? markup / 100 + 1 : 1;
19
19
  // Apply multiplier: Guesty's approach to monthly pricing
20
- const rent = +(stay.reduce((acc, stay) => acc + stay.price, 0) * markupValue).toFixed(0);
20
+ const rent = Math.ceil(stay.reduce((acc, stay) => acc + stay.price, 0) * markupValue);
21
21
  const cleaning = excludeCleaning ? 0 : unit.prices.cleaningFee;
22
22
  const utilities = (excludeUtilities || unit.prices.excludeUtilities) ? 0 : unit.prices.utilities * nights;
23
23
  const subTotal = rent + utilities + cleaning;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-flats/booking-engine-common-server",
3
- "version": "1.0.162",
3
+ "version": "1.0.164",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",