@managesome/eposmatic-toolkit 0.2.760 → 0.2.762

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,21 @@ 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
+ let readyMinutes;
1431
+ if (item.is_ready !== true && isCompleted) {
1432
+ const readyMinutesAnchor = item.prep_started_at ?? data.order_status_updated_at;
1433
+ const readyMinutesAnchorTime = readyMinutesAnchor != null ? new Date(readyMinutesAnchor).getTime() : undefined;
1434
+ if (readyMinutesAnchorTime != null && !Number.isNaN(readyMinutesAnchorTime)) {
1435
+ readyMinutes = Math.max(0, Math.floor((Date.now() - readyMinutesAnchorTime) / 60000));
1436
+ }
1437
+ }
1426
1438
  const newItem = {
1427
1439
  ...item,
1440
+ ...(readyMinutes != null ? { ready_minutes: readyMinutes } : {}),
1428
1441
  is_ready: item.is_ready || isCompleted,
1429
1442
  item_discount_details,
1430
1443
  subtotal: itemSubtotal,
@@ -64,6 +64,7 @@ export interface IOrderEngineItem {
64
64
  moved_to_order_id?: string | null;
65
65
  moved_from_order_id?: string | null;
66
66
  ready_minutes?: number | null;
67
+ prep_started_at?: Date | null;
67
68
  name: string;
68
69
  description: string;
69
70
  loyalty_applied: boolean;
@@ -683,6 +683,7 @@ function convertHalfHalfToOrderEngineItem({ halfHalfItem, selectedHalfHalfItems,
683
683
  moved_to_order_id: existingOrderItem?.moved_to_order_id,
684
684
  moved_from_order_id: existingOrderItem?.moved_from_order_id,
685
685
  ready_minutes: existingOrderItem?.ready_minutes,
686
+ prep_started_at: existingOrderItem?.prep_started_at,
686
687
  name: halfHalfItem.name,
687
688
  description: halfHalfItem.description,
688
689
  loyalty_applied: false,
@@ -926,6 +926,7 @@ function convertOrderEngineItemToOrderItem(orderItem, tenantId, offers, giftCard
926
926
  moved_to_order_id: orderItem.moved_to_order_id,
927
927
  moved_from_order_id: orderItem.moved_from_order_id,
928
928
  ready_minutes: orderItem.ready_minutes,
929
+ prep_started_at: orderItem.prep_started_at,
929
930
  name: orderItem.name,
930
931
  price: orderItem.price,
931
932
  subtotal: orderItem.price,
@@ -1014,7 +1015,7 @@ function convertCatalogItemToOrderEngineItem({ item, orderItem, platform, tenant
1014
1015
  }
1015
1016
  const { _id = (0, bson_objectid_1.default)().toHexString(), menu_id = defaultMenuId,
1016
1017
  // For New Item, If zeroPriceRefs is present then we set the price to 0
1017
- price = defaultItemPrice, tax_rate = (0, platform_catalog_1.getPriceEnum)(item.tax_rate, platform), quantity = 1, subtotal = 0, special_instructions = '', item_discount_details = convertItemDiscountToOrderItemDiscount(discount_amount, is_special_discount_percentage, platform, item._id), item_type = orderItemType, is_ready, is_split, moved_to_order_id, moved_from_order_id, ready_minutes, } = orderItem ?? {};
1018
+ price = defaultItemPrice, tax_rate = (0, platform_catalog_1.getPriceEnum)(item.tax_rate, platform), quantity = 1, subtotal = 0, special_instructions = '', item_discount_details = convertItemDiscountToOrderItemDiscount(discount_amount, is_special_discount_percentage, platform, item._id), item_type = orderItemType, is_ready, is_split, moved_to_order_id, moved_from_order_id, ready_minutes, prep_started_at, } = orderItem ?? {};
1018
1019
  const loyaltyApplied = applyLoyalty != null && applyLoyalty.refs.includes(item._id);
1019
1020
  const voucherApplied = applyVoucher != null && applyVoucher.refs.includes(item._id);
1020
1021
  let mergedItemDiscountDetails = item_discount_details;
@@ -1063,6 +1064,7 @@ function convertCatalogItemToOrderEngineItem({ item, orderItem, platform, tenant
1063
1064
  moved_to_order_id,
1064
1065
  moved_from_order_id,
1065
1066
  ready_minutes,
1067
+ prep_started_at,
1066
1068
  price,
1067
1069
  tax_rate,
1068
1070
  quantity,