@managesome/eposmatic-toolkit 0.2.761 → 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,