@happychef/algorithm 1.2.11 → 1.2.12
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/.github/workflows/ci-cd.yml +234 -234
- package/BRANCH_PROTECTION_SETUP.md +167 -167
- package/CHANGELOG.md +8 -8
- package/README.md +144 -144
- package/RESERVERINGEN_GIDS.md +986 -986
- package/__tests__/filters.test.js +276 -276
- package/__tests__/isDateAvailable.test.js +175 -175
- package/__tests__/isTimeAvailable.test.js +168 -168
- package/__tests__/restaurantData.test.js +422 -422
- package/__tests__/tableHelpers.test.js +247 -247
- package/assignTables.js +424 -424
- package/changes/2025/December/PR2___change.md +14 -14
- package/changes/2025/December/PR3_add__change.md +20 -20
- package/changes/2025/December/PR4___.md +15 -15
- package/changes/2025/December/PR5___.md +15 -15
- package/changes/2025/December/PR6__del_.md +17 -17
- package/changes/2025/December/PR7_add__change.md +21 -21
- package/changes/2026/January/PR8_add__change.md +39 -0
- package/changes/2026/January/PR9_add__change.md +20 -0
- package/filters/maxArrivalsFilter.js +114 -114
- package/filters/maxGroupsFilter.js +221 -221
- package/filters/timeFilter.js +89 -89
- package/getAvailableTimeblocks.js +158 -158
- package/grouping.js +162 -162
- package/index.js +42 -42
- package/isDateAvailable.js +80 -80
- package/isDateAvailableWithTableCheck.js +171 -171
- package/isTimeAvailable.js +25 -25
- package/jest.config.js +23 -23
- package/package.json +27 -27
- package/processing/dailyGuestCounts.js +73 -73
- package/processing/mealTypeCount.js +133 -133
- package/processing/timeblocksAvailable.js +167 -167
- package/reservation_data/counter.js +64 -64
- package/restaurant_data/exceptions.js +149 -149
- package/restaurant_data/openinghours.js +123 -123
- package/simulateTableAssignment.js +709 -699
- package/tableHelpers.js +178 -178
- package/tables/time/parseTime.js +19 -19
- package/tables/time/shifts.js +7 -7
- package/tables/utils/calculateDistance.js +13 -13
- package/tables/utils/isTableFreeForAllSlots.js +14 -14
- package/tables/utils/isTemporaryTableValid.js +39 -39
- package/test/test_counter.js +194 -194
- package/test/test_dailyCount.js +81 -81
- package/test/test_datesAvailable.js +106 -106
- package/test/test_exceptions.js +172 -172
- package/test/test_isDateAvailable.js +330 -330
- package/test/test_mealTypeCount.js +54 -54
- package/test/test_timesAvailable.js +88 -88
- package/test-detailed-filter.js +100 -100
- package/test-lunch-debug.js +110 -110
- package/test-max-arrivals-filter.js +79 -79
- package/test-meal-stop-fix.js +147 -147
- package/test-meal-stop-simple.js +93 -93
- package/test-timezone-debug.js +47 -47
- package/test.js +336 -336
package/test-lunch-debug.js
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
// Test script to debug why Monday lunch isn't showing
|
|
2
|
-
const { getAvailableTimeblocks } = require('./getAvailableTimeblocks');
|
|
3
|
-
const { timeblocksAvailable } = require('./processing/timeblocksAvailable');
|
|
4
|
-
const { getDailyGuestCounts } = require('./processing/dailyGuestCounts');
|
|
5
|
-
|
|
6
|
-
// Your restaurant data
|
|
7
|
-
const restaurantData = {
|
|
8
|
-
"_id": "demo",
|
|
9
|
-
"openinghours-lunch": {
|
|
10
|
-
"schemeSettings": {
|
|
11
|
-
"Monday": {
|
|
12
|
-
"enabled": true,
|
|
13
|
-
"startTime": "14:15",
|
|
14
|
-
"endTime": "15:00",
|
|
15
|
-
"maxCapacityEnabled": true,
|
|
16
|
-
"maxCapacity": "10",
|
|
17
|
-
"shiftsEnabled": false,
|
|
18
|
-
"shifts": [],
|
|
19
|
-
"giftcardsEnabled": false,
|
|
20
|
-
"giftcards": [],
|
|
21
|
-
"giftcardTakeawayEnabled": false,
|
|
22
|
-
"giftcardTakeawayStart": "",
|
|
23
|
-
"giftcardTakeawayEnd": ""
|
|
24
|
-
},
|
|
25
|
-
"Wednesday": {
|
|
26
|
-
"enabled": true,
|
|
27
|
-
"startTime": "13:45",
|
|
28
|
-
"endTime": "14:45",
|
|
29
|
-
"maxCapacityEnabled": false,
|
|
30
|
-
"maxCapacity": "",
|
|
31
|
-
"shiftsEnabled": false,
|
|
32
|
-
"shifts": [],
|
|
33
|
-
"giftcardsEnabled": false,
|
|
34
|
-
"giftcards": [],
|
|
35
|
-
"giftcardTakeawayEnabled": true,
|
|
36
|
-
"giftcardTakeawayStart": "11:00",
|
|
37
|
-
"giftcardTakeawayEnd": "16:00"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"general-settings": {
|
|
42
|
-
"zitplaatsen": 13,
|
|
43
|
-
"uurOpVoorhand": 0,
|
|
44
|
-
"dagenInToekomst": 365,
|
|
45
|
-
"minGasten": 1,
|
|
46
|
-
"maxGasten": 10,
|
|
47
|
-
"intervalReservatie": 30,
|
|
48
|
-
"duurReservatie": 60,
|
|
49
|
-
"ontbijtStop": "",
|
|
50
|
-
"lunchStop": "",
|
|
51
|
-
"dinerStop": ""
|
|
52
|
-
},
|
|
53
|
-
"max-arrivals-lunch": {
|
|
54
|
-
"12:00": 6,
|
|
55
|
-
"12:15": 1,
|
|
56
|
-
"12:30": 6,
|
|
57
|
-
"12:45": 4,
|
|
58
|
-
"13:00": 10,
|
|
59
|
-
"14:15": 10,
|
|
60
|
-
"14:30": 10,
|
|
61
|
-
"14:45": 10,
|
|
62
|
-
"storedNumber": 30
|
|
63
|
-
},
|
|
64
|
-
"exceptions": [],
|
|
65
|
-
"blocked-slots": []
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// Test for Monday December 8, 2025
|
|
69
|
-
const testDate = "2025-12-08"; // Monday
|
|
70
|
-
const guests = 2;
|
|
71
|
-
const reservations = [];
|
|
72
|
-
|
|
73
|
-
console.log('=== LUNCH AVAILABILITY DEBUG ===\n');
|
|
74
|
-
console.log('Date:', testDate, '(Monday)');
|
|
75
|
-
console.log('Guests:', guests);
|
|
76
|
-
console.log('Current time:', new Date().toISOString());
|
|
77
|
-
console.log('\n--- Restaurant Settings ---');
|
|
78
|
-
console.log('Lunch Opening Hours (Monday):', restaurantData['openinghours-lunch'].schemeSettings.Monday);
|
|
79
|
-
console.log('General Settings:', restaurantData['general-settings']);
|
|
80
|
-
console.log('Max Arrivals Lunch:', restaurantData['max-arrivals-lunch']);
|
|
81
|
-
|
|
82
|
-
console.log('\n--- Step 1: getDailyGuestCounts ---');
|
|
83
|
-
const { guestCounts, shiftsInfo } = getDailyGuestCounts(restaurantData, testDate, reservations);
|
|
84
|
-
console.log('Guest Counts:', guestCounts);
|
|
85
|
-
console.log('Shifts Info:', shiftsInfo);
|
|
86
|
-
|
|
87
|
-
console.log('\n--- Step 2: timeblocksAvailable ---');
|
|
88
|
-
const timeblocks = timeblocksAvailable(restaurantData, testDate, reservations, guests, [], null, false);
|
|
89
|
-
console.log('Available Timeblocks:', timeblocks);
|
|
90
|
-
|
|
91
|
-
console.log('\n--- Step 3: getAvailableTimeblocks (with filters) ---');
|
|
92
|
-
const finalTimeblocks = getAvailableTimeblocks(restaurantData, testDate, reservations, guests, [], null, false);
|
|
93
|
-
console.log('Final Available Timeblocks:', finalTimeblocks);
|
|
94
|
-
|
|
95
|
-
console.log('\n--- Step 4: Test with Admin Flag ---');
|
|
96
|
-
const adminTimeblocks = getAvailableTimeblocks(restaurantData, testDate, reservations, guests, [], null, true);
|
|
97
|
-
console.log('Admin Timeblocks (no time restrictions):', adminTimeblocks);
|
|
98
|
-
|
|
99
|
-
// Check if lunch times exist
|
|
100
|
-
const lunchTimes = ['14:15', '14:30', '14:45'];
|
|
101
|
-
console.log('\n--- Lunch Time Analysis ---');
|
|
102
|
-
lunchTimes.forEach(time => {
|
|
103
|
-
console.log(`${time}:`);
|
|
104
|
-
console.log(` - In guestCounts: ${guestCounts.hasOwnProperty(time) ? 'YES (capacity: ' + guestCounts[time] + ')' : 'NO'}`);
|
|
105
|
-
console.log(` - In timeblocks: ${timeblocks.hasOwnProperty(time) ? 'YES' : 'NO'}`);
|
|
106
|
-
console.log(` - In final: ${finalTimeblocks.hasOwnProperty(time) ? 'YES' : 'NO'}`);
|
|
107
|
-
console.log(` - In admin: ${adminTimeblocks.hasOwnProperty(time) ? 'YES' : 'NO'}`);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
console.log('\n=== END DEBUG ===');
|
|
1
|
+
// Test script to debug why Monday lunch isn't showing
|
|
2
|
+
const { getAvailableTimeblocks } = require('./getAvailableTimeblocks');
|
|
3
|
+
const { timeblocksAvailable } = require('./processing/timeblocksAvailable');
|
|
4
|
+
const { getDailyGuestCounts } = require('./processing/dailyGuestCounts');
|
|
5
|
+
|
|
6
|
+
// Your restaurant data
|
|
7
|
+
const restaurantData = {
|
|
8
|
+
"_id": "demo",
|
|
9
|
+
"openinghours-lunch": {
|
|
10
|
+
"schemeSettings": {
|
|
11
|
+
"Monday": {
|
|
12
|
+
"enabled": true,
|
|
13
|
+
"startTime": "14:15",
|
|
14
|
+
"endTime": "15:00",
|
|
15
|
+
"maxCapacityEnabled": true,
|
|
16
|
+
"maxCapacity": "10",
|
|
17
|
+
"shiftsEnabled": false,
|
|
18
|
+
"shifts": [],
|
|
19
|
+
"giftcardsEnabled": false,
|
|
20
|
+
"giftcards": [],
|
|
21
|
+
"giftcardTakeawayEnabled": false,
|
|
22
|
+
"giftcardTakeawayStart": "",
|
|
23
|
+
"giftcardTakeawayEnd": ""
|
|
24
|
+
},
|
|
25
|
+
"Wednesday": {
|
|
26
|
+
"enabled": true,
|
|
27
|
+
"startTime": "13:45",
|
|
28
|
+
"endTime": "14:45",
|
|
29
|
+
"maxCapacityEnabled": false,
|
|
30
|
+
"maxCapacity": "",
|
|
31
|
+
"shiftsEnabled": false,
|
|
32
|
+
"shifts": [],
|
|
33
|
+
"giftcardsEnabled": false,
|
|
34
|
+
"giftcards": [],
|
|
35
|
+
"giftcardTakeawayEnabled": true,
|
|
36
|
+
"giftcardTakeawayStart": "11:00",
|
|
37
|
+
"giftcardTakeawayEnd": "16:00"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"general-settings": {
|
|
42
|
+
"zitplaatsen": 13,
|
|
43
|
+
"uurOpVoorhand": 0,
|
|
44
|
+
"dagenInToekomst": 365,
|
|
45
|
+
"minGasten": 1,
|
|
46
|
+
"maxGasten": 10,
|
|
47
|
+
"intervalReservatie": 30,
|
|
48
|
+
"duurReservatie": 60,
|
|
49
|
+
"ontbijtStop": "",
|
|
50
|
+
"lunchStop": "",
|
|
51
|
+
"dinerStop": ""
|
|
52
|
+
},
|
|
53
|
+
"max-arrivals-lunch": {
|
|
54
|
+
"12:00": 6,
|
|
55
|
+
"12:15": 1,
|
|
56
|
+
"12:30": 6,
|
|
57
|
+
"12:45": 4,
|
|
58
|
+
"13:00": 10,
|
|
59
|
+
"14:15": 10,
|
|
60
|
+
"14:30": 10,
|
|
61
|
+
"14:45": 10,
|
|
62
|
+
"storedNumber": 30
|
|
63
|
+
},
|
|
64
|
+
"exceptions": [],
|
|
65
|
+
"blocked-slots": []
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Test for Monday December 8, 2025
|
|
69
|
+
const testDate = "2025-12-08"; // Monday
|
|
70
|
+
const guests = 2;
|
|
71
|
+
const reservations = [];
|
|
72
|
+
|
|
73
|
+
console.log('=== LUNCH AVAILABILITY DEBUG ===\n');
|
|
74
|
+
console.log('Date:', testDate, '(Monday)');
|
|
75
|
+
console.log('Guests:', guests);
|
|
76
|
+
console.log('Current time:', new Date().toISOString());
|
|
77
|
+
console.log('\n--- Restaurant Settings ---');
|
|
78
|
+
console.log('Lunch Opening Hours (Monday):', restaurantData['openinghours-lunch'].schemeSettings.Monday);
|
|
79
|
+
console.log('General Settings:', restaurantData['general-settings']);
|
|
80
|
+
console.log('Max Arrivals Lunch:', restaurantData['max-arrivals-lunch']);
|
|
81
|
+
|
|
82
|
+
console.log('\n--- Step 1: getDailyGuestCounts ---');
|
|
83
|
+
const { guestCounts, shiftsInfo } = getDailyGuestCounts(restaurantData, testDate, reservations);
|
|
84
|
+
console.log('Guest Counts:', guestCounts);
|
|
85
|
+
console.log('Shifts Info:', shiftsInfo);
|
|
86
|
+
|
|
87
|
+
console.log('\n--- Step 2: timeblocksAvailable ---');
|
|
88
|
+
const timeblocks = timeblocksAvailable(restaurantData, testDate, reservations, guests, [], null, false);
|
|
89
|
+
console.log('Available Timeblocks:', timeblocks);
|
|
90
|
+
|
|
91
|
+
console.log('\n--- Step 3: getAvailableTimeblocks (with filters) ---');
|
|
92
|
+
const finalTimeblocks = getAvailableTimeblocks(restaurantData, testDate, reservations, guests, [], null, false);
|
|
93
|
+
console.log('Final Available Timeblocks:', finalTimeblocks);
|
|
94
|
+
|
|
95
|
+
console.log('\n--- Step 4: Test with Admin Flag ---');
|
|
96
|
+
const adminTimeblocks = getAvailableTimeblocks(restaurantData, testDate, reservations, guests, [], null, true);
|
|
97
|
+
console.log('Admin Timeblocks (no time restrictions):', adminTimeblocks);
|
|
98
|
+
|
|
99
|
+
// Check if lunch times exist
|
|
100
|
+
const lunchTimes = ['14:15', '14:30', '14:45'];
|
|
101
|
+
console.log('\n--- Lunch Time Analysis ---');
|
|
102
|
+
lunchTimes.forEach(time => {
|
|
103
|
+
console.log(`${time}:`);
|
|
104
|
+
console.log(` - In guestCounts: ${guestCounts.hasOwnProperty(time) ? 'YES (capacity: ' + guestCounts[time] + ')' : 'NO'}`);
|
|
105
|
+
console.log(` - In timeblocks: ${timeblocks.hasOwnProperty(time) ? 'YES' : 'NO'}`);
|
|
106
|
+
console.log(` - In final: ${finalTimeblocks.hasOwnProperty(time) ? 'YES' : 'NO'}`);
|
|
107
|
+
console.log(` - In admin: ${adminTimeblocks.hasOwnProperty(time) ? 'YES' : 'NO'}`);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
console.log('\n=== END DEBUG ===');
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
// Test the max arrivals filter specifically
|
|
2
|
-
const { filterTimeblocksByMaxArrivals } = require('./filters/maxArrivalsFilter');
|
|
3
|
-
const { getAvailableTimeblocks } = require('./getAvailableTimeblocks');
|
|
4
|
-
|
|
5
|
-
const restaurantData = {
|
|
6
|
-
"_id": "demo",
|
|
7
|
-
"openinghours-lunch": {
|
|
8
|
-
"schemeSettings": {
|
|
9
|
-
"Monday": {
|
|
10
|
-
"enabled": true,
|
|
11
|
-
"startTime": "14:15",
|
|
12
|
-
"endTime": "15:00",
|
|
13
|
-
"maxCapacityEnabled": true,
|
|
14
|
-
"maxCapacity": "10"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"general-settings": {
|
|
19
|
-
"zitplaatsen": 13,
|
|
20
|
-
"uurOpVoorhand": 0,
|
|
21
|
-
"dagenInToekomst": 365,
|
|
22
|
-
"intervalReservatie": 30,
|
|
23
|
-
"duurReservatie": 60,
|
|
24
|
-
"ontbijtStop": "",
|
|
25
|
-
"lunchStop": "",
|
|
26
|
-
"dinerStop": ""
|
|
27
|
-
},
|
|
28
|
-
"max-arrivals-lunch": {
|
|
29
|
-
"12:00": 6,
|
|
30
|
-
"12:15": 1,
|
|
31
|
-
"12:30": 6,
|
|
32
|
-
"12:45": 4,
|
|
33
|
-
"13:00": 10,
|
|
34
|
-
"14:15": 10,
|
|
35
|
-
"14:30": 10,
|
|
36
|
-
"14:45": 10,
|
|
37
|
-
"storedNumber": 30
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const testDate = "2025-12-08";
|
|
42
|
-
const guests = 2;
|
|
43
|
-
const reservations = [];
|
|
44
|
-
|
|
45
|
-
console.log('=== MAX ARRIVALS FILTER TEST ===\n');
|
|
46
|
-
|
|
47
|
-
// Get initial timeblocks from algorithm
|
|
48
|
-
const timeblocks = getAvailableTimeblocks(restaurantData, testDate, reservations, guests, [], null, true);
|
|
49
|
-
console.log('Timeblocks from algorithm (admin mode):', Object.keys(timeblocks));
|
|
50
|
-
|
|
51
|
-
// Apply max arrivals filter
|
|
52
|
-
const filtered = filterTimeblocksByMaxArrivals(restaurantData, testDate, timeblocks, reservations, guests);
|
|
53
|
-
console.log('\nAfter max arrivals filter:', Object.keys(filtered));
|
|
54
|
-
|
|
55
|
-
// Debug each time slot
|
|
56
|
-
console.log('\n--- Detailed Analysis ---');
|
|
57
|
-
for (const time of Object.keys(timeblocks)) {
|
|
58
|
-
const maxArrivalsConfig = restaurantData['max-arrivals-lunch'];
|
|
59
|
-
const maxArrivals = maxArrivalsConfig ? maxArrivalsConfig[time] : null;
|
|
60
|
-
|
|
61
|
-
const currentArrivals = reservations
|
|
62
|
-
.filter(r => r.date === testDate && r.time === time)
|
|
63
|
-
.reduce((sum, r) => sum + (parseInt(r.guests, 10) || 0), 0);
|
|
64
|
-
|
|
65
|
-
const isInFiltered = filtered.hasOwnProperty(time);
|
|
66
|
-
|
|
67
|
-
console.log(`\n${time}:`);
|
|
68
|
-
console.log(` Max arrivals setting: ${maxArrivals || 'NOT SET'}`);
|
|
69
|
-
console.log(` Current arrivals: ${currentArrivals}`);
|
|
70
|
-
console.log(` New reservation: ${guests} guests`);
|
|
71
|
-
console.log(` Total after adding: ${currentArrivals + guests}`);
|
|
72
|
-
console.log(` Passes filter: ${isInFiltered ? 'YES' : 'NO'}`);
|
|
73
|
-
|
|
74
|
-
if (maxArrivals !== null && maxArrivals !== undefined) {
|
|
75
|
-
console.log(` Logic: ${currentArrivals} + ${guests} = ${currentArrivals + guests} ${currentArrivals + guests <= maxArrivals ? '<=' : '>'} ${maxArrivals}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
console.log('\n=== END TEST ===');
|
|
1
|
+
// Test the max arrivals filter specifically
|
|
2
|
+
const { filterTimeblocksByMaxArrivals } = require('./filters/maxArrivalsFilter');
|
|
3
|
+
const { getAvailableTimeblocks } = require('./getAvailableTimeblocks');
|
|
4
|
+
|
|
5
|
+
const restaurantData = {
|
|
6
|
+
"_id": "demo",
|
|
7
|
+
"openinghours-lunch": {
|
|
8
|
+
"schemeSettings": {
|
|
9
|
+
"Monday": {
|
|
10
|
+
"enabled": true,
|
|
11
|
+
"startTime": "14:15",
|
|
12
|
+
"endTime": "15:00",
|
|
13
|
+
"maxCapacityEnabled": true,
|
|
14
|
+
"maxCapacity": "10"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"general-settings": {
|
|
19
|
+
"zitplaatsen": 13,
|
|
20
|
+
"uurOpVoorhand": 0,
|
|
21
|
+
"dagenInToekomst": 365,
|
|
22
|
+
"intervalReservatie": 30,
|
|
23
|
+
"duurReservatie": 60,
|
|
24
|
+
"ontbijtStop": "",
|
|
25
|
+
"lunchStop": "",
|
|
26
|
+
"dinerStop": ""
|
|
27
|
+
},
|
|
28
|
+
"max-arrivals-lunch": {
|
|
29
|
+
"12:00": 6,
|
|
30
|
+
"12:15": 1,
|
|
31
|
+
"12:30": 6,
|
|
32
|
+
"12:45": 4,
|
|
33
|
+
"13:00": 10,
|
|
34
|
+
"14:15": 10,
|
|
35
|
+
"14:30": 10,
|
|
36
|
+
"14:45": 10,
|
|
37
|
+
"storedNumber": 30
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const testDate = "2025-12-08";
|
|
42
|
+
const guests = 2;
|
|
43
|
+
const reservations = [];
|
|
44
|
+
|
|
45
|
+
console.log('=== MAX ARRIVALS FILTER TEST ===\n');
|
|
46
|
+
|
|
47
|
+
// Get initial timeblocks from algorithm
|
|
48
|
+
const timeblocks = getAvailableTimeblocks(restaurantData, testDate, reservations, guests, [], null, true);
|
|
49
|
+
console.log('Timeblocks from algorithm (admin mode):', Object.keys(timeblocks));
|
|
50
|
+
|
|
51
|
+
// Apply max arrivals filter
|
|
52
|
+
const filtered = filterTimeblocksByMaxArrivals(restaurantData, testDate, timeblocks, reservations, guests);
|
|
53
|
+
console.log('\nAfter max arrivals filter:', Object.keys(filtered));
|
|
54
|
+
|
|
55
|
+
// Debug each time slot
|
|
56
|
+
console.log('\n--- Detailed Analysis ---');
|
|
57
|
+
for (const time of Object.keys(timeblocks)) {
|
|
58
|
+
const maxArrivalsConfig = restaurantData['max-arrivals-lunch'];
|
|
59
|
+
const maxArrivals = maxArrivalsConfig ? maxArrivalsConfig[time] : null;
|
|
60
|
+
|
|
61
|
+
const currentArrivals = reservations
|
|
62
|
+
.filter(r => r.date === testDate && r.time === time)
|
|
63
|
+
.reduce((sum, r) => sum + (parseInt(r.guests, 10) || 0), 0);
|
|
64
|
+
|
|
65
|
+
const isInFiltered = filtered.hasOwnProperty(time);
|
|
66
|
+
|
|
67
|
+
console.log(`\n${time}:`);
|
|
68
|
+
console.log(` Max arrivals setting: ${maxArrivals || 'NOT SET'}`);
|
|
69
|
+
console.log(` Current arrivals: ${currentArrivals}`);
|
|
70
|
+
console.log(` New reservation: ${guests} guests`);
|
|
71
|
+
console.log(` Total after adding: ${currentArrivals + guests}`);
|
|
72
|
+
console.log(` Passes filter: ${isInFiltered ? 'YES' : 'NO'}`);
|
|
73
|
+
|
|
74
|
+
if (maxArrivals !== null && maxArrivals !== undefined) {
|
|
75
|
+
console.log(` Logic: ${currentArrivals} + ${guests} = ${currentArrivals + guests} ${currentArrivals + guests <= maxArrivals ? '<=' : '>'} ${maxArrivals}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log('\n=== END TEST ===');
|