@managesome/eposmatic-toolkit 0.2.761 → 0.2.763

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.
@@ -1423,8 +1423,23 @@ function calculateCartOrderInfoAndSyncData(data, courses, listnerSettings, calcu
1423
1423
  ...item,
1424
1424
  item_discount_details: syncedItemDiscountDetails ?? null,
1425
1425
  });
1426
+ // A completed order marks every not-ready item as ready — keep
1427
+ // ready_minutes in sync with that transition (mirrors the order status
1428
+ // updates): measured from the item's own prep clock, falling back to the
1429
+ // order's stage clock. Already-ready items keep their stored duration.
1430
+ // Keep in sync with items-service updateOrderStatus (aggregation pipeline
1431
+ // stamp) and updateOrder (new-item prep stamp).
1432
+ let readyMinutes;
1433
+ if (item.is_ready !== true && isCompleted) {
1434
+ const readyMinutesAnchor = item.prep_started_at ?? data.order_status_updated_at;
1435
+ const readyMinutesAnchorTime = readyMinutesAnchor != null ? new Date(readyMinutesAnchor).getTime() : undefined;
1436
+ if (readyMinutesAnchorTime != null && !Number.isNaN(readyMinutesAnchorTime)) {
1437
+ readyMinutes = Math.max(0, Math.floor((Date.now() - readyMinutesAnchorTime) / 60000));
1438
+ }
1439
+ }
1426
1440
  const newItem = {
1427
1441
  ...item,
1442
+ ...(readyMinutes != null ? { ready_minutes: readyMinutes } : {}),
1428
1443
  is_ready: item.is_ready || isCompleted,
1429
1444
  item_discount_details,
1430
1445
  subtotal: itemSubtotal,
@@ -47,7 +47,7 @@ type ISimplifiedSetupWithAvailability = {
47
47
  export declare function isSimplifiedSetupApplicable(setup: ISimplifiedSetupWithAvailability, platform: PLATFORMS_ENUM): boolean;
48
48
  export declare function getPlatformModifierOptions(options: IModifierOption[], platform: PLATFORMS_ENUM, excludeIds?: string[]): IModifierOption[];
49
49
  export declare function getPlatformModifiers(modifiers: IModifier[] | null | undefined, platform: PLATFORMS_ENUM | undefined, excludeIds?: string[]): IModifier[] | null;
50
- export declare function convertItemToWorkableItem<T extends IItem | ISimplifiedCatalogItem>(item: T, platform: PLATFORMS_ENUM, tenantId: string | undefined, omitSchedule?: boolean, omitSchedulePricing?: boolean): T | null;
50
+ export declare function convertItemToWorkableItem<T extends IItem | ISimplifiedCatalogItem>(item: T, platform: PLATFORMS_ENUM, tenantId: string | undefined, omitSchedule?: boolean, omitSchedulePricing?: boolean, omitPlatformCheck?: boolean): T | null;
51
51
  export declare function convertOptionToWorkableOption(option: IModifierOption, platform: PLATFORMS_ENUM): IModifierOption | null;
52
52
  export declare function convertCatalogToWorkableCatalog<T extends ICatalog | ISimplifiedCatalog>(catalogs: T[], platform: PLATFORMS_ENUM | undefined, tenantId: string | undefined): T[];
53
53
  /**
@@ -184,10 +184,13 @@ function getPlatformModifiers(modifiers, platform, excludeIds = []) {
184
184
  return platformModifiers;
185
185
  }
186
186
  // ==========================================================><====================================================
187
- function convertItemToWorkableItem(item, platform, tenantId, omitSchedule, omitSchedulePricing) {
187
+ function convertItemToWorkableItem(item, platform, tenantId, omitSchedule, omitSchedulePricing, omitPlatformCheck) {
188
188
  // if item is not active or it is not included in the current platform, we skip it
189
189
  if (!item.active ||
190
- !item.included_platforms.includes(platform) ||
190
+ // Items resolved INSIDE a setup (specials) pass `omitPlatformCheck`: the
191
+ // setup's own platform membership is that gate, and its items are shown
192
+ // even when they don't belong to the current platform.
193
+ (!omitPlatformCheck && !item.included_platforms.includes(platform)) ||
191
194
  // This condition will only work in POS. This condition is for call center
192
195
  (item.tenants != null && !item.tenants.includes(tenantId))) {
193
196
  return null;
@@ -174,12 +174,18 @@ function convertSpecialsToWorkableSpecials(specials, itemsMap, platform, tenant_
174
174
  }
175
175
  continue;
176
176
  }
177
- const workableItem = (0, platform_catalog_1.convertItemToWorkableItem)(catalogItem, platform, tenant_id, omitItemLevelSchedule, true);
177
+ // Constituent items are NOT gated by platform membership (the last
178
+ // `true`): the special's own `included_platforms` is the platform gate,
179
+ // and a deal may legitimately feature items that don't belong to the
180
+ // current platform — they are shown and selectable anyway. Inactive
181
+ // items stay excluded here; when EVERY item of a group is inactive the
182
+ // group resolves empty and blocks the special (see `hasEmptyGroup`).
183
+ const workableItem = (0, platform_catalog_1.convertItemToWorkableItem)(catalogItem, platform, tenant_id, omitItemLevelSchedule, true, true);
178
184
  if (!workableItem) {
179
185
  // The item failed ONLY its own schedule: probe without the schedule
180
186
  // check to tell "scheduled out right now" apart from "structurally
181
- // unavailable" (inactive / platform / tenant filtered).
182
- if ((0, platform_catalog_1.convertItemToWorkableItem)(catalogItem, platform, tenant_id, true, true) != null) {
187
+ // unavailable" (inactive / tenant filtered).
188
+ if ((0, platform_catalog_1.convertItemToWorkableItem)(catalogItem, platform, tenant_id, true, true, true) != null) {
183
189
  hasScheduledOutItem = true;
184
190
  }
185
191
  continue;
@@ -202,6 +208,12 @@ function convertSpecialsToWorkableSpecials(specials, itemsMap, platform, tenant_
202
208
  // its items are merely outside their own schedule right now. Item
203
209
  // schedules filter the selectable options at selection time; menu-level
204
210
  // validity is governed by the special's own schedule.
211
+ //
212
+ // With platform membership no longer gating constituent items, a group
213
+ // only ends up here when NONE of its items are usable: they are all
214
+ // INACTIVE (product rule: all-inactive group blocks the deal), missing
215
+ // from the catalog, or belong to another tenant. Out-of-platform items
216
+ // are resolvable and are shown.
205
217
  if (items.length === 0 && !hasHalfHalfRef && !hasScheduledOutItem) {
206
218
  hasEmptyGroup = true;
207
219
  continue;