@happychef/algorithm 1.2.2 → 1.2.4

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.
@@ -92,17 +92,18 @@ function getMealType(time) {
92
92
 
93
93
  // Get max arrivals value for this specific time
94
94
  const maxArrivals = extractNumber(maxArrivalsConfig[time]);
95
- if (maxArrivals === null) {
96
- // Keep the timeblock if no specific max arrivals for this time
95
+ if (maxArrivals === null || maxArrivals <= 0) {
96
+ // Keep the timeblock if no specific max arrivals for this time, or if set to 0 (unlimited)
97
97
  filteredBlocks[time] = timeData;
98
98
  continue;
99
99
  }
100
-
100
+
101
101
  // Count current arrivals at this exact time
102
102
  const currentArrivals = countArrivalsAtTime(reservations, date, time);
103
-
103
+
104
104
  // Only include timeblock if adding these guests doesn't exceed max arrivals
105
- if (currentArrivals + guests <= maxArrivals) {
105
+ // Note: maxArrivals is the number of GROUPS (arrivals), not guests
106
+ if (currentArrivals + 1 <= maxArrivals) {
106
107
  filteredBlocks[time] = timeData;
107
108
  }
108
109
  }
@@ -166,10 +166,11 @@ function getMealType(time) {
166
166
  // Extract the maximum number of groups allowed for this threshold
167
167
  const maxAllowedCount = extractNumber(maxGroupSettings[limitSizeStr]);
168
168
  logDebug(` Max groups allowed for >=${limitSize} is: ${maxAllowedCount} (raw setting: ${JSON.stringify(maxGroupSettings[limitSizeStr])})`);
169
-
170
- // If the setting for this limit size is invalid (null or negative), treat it as 'no limit'
171
- if (maxAllowedCount === null || maxAllowedCount < 0) {
172
- logDebug(` Skipping check: Invalid or non-positive max count defined for size ${limitSize}.`);
169
+
170
+ // If the setting for this limit size is invalid (null, zero, or negative), treat it as 'no limit'
171
+ // IMPORTANT: A value of 0 means "unlimited" - don't apply this filter
172
+ if (maxAllowedCount === null || maxAllowedCount <= 0) {
173
+ logDebug(` Skipping check: Invalid or non-positive max count (${maxAllowedCount}) - treating as unlimited for size ${limitSize}.`);
173
174
  continue; // Skip to the next limitSize
174
175
  }
175
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happychef/algorithm",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Restaurant and reservation algorithm utilities",
5
5
  "main": "index.js",
6
6
  "author": "happy chef",