@happychef/algorithm 1.2.10 → 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.
Files changed (46) hide show
  1. package/.github/workflows/ci-cd.yml +133 -2
  2. package/BRANCH_PROTECTION_SETUP.md +167 -0
  3. package/CHANGELOG.md +8 -8
  4. package/RESERVERINGEN_GIDS.md +986 -986
  5. package/assignTables.js +424 -398
  6. package/changes/2025/December/PR2___change.md +14 -14
  7. package/changes/2025/December/PR3_add__change.md +20 -20
  8. package/changes/2025/December/PR4___.md +16 -0
  9. package/changes/2025/December/PR5___.md +16 -0
  10. package/changes/2025/December/PR6__del_.md +18 -0
  11. package/changes/2025/December/PR7_add__change.md +22 -0
  12. package/changes/2026/January/PR8_add__change.md +39 -0
  13. package/changes/2026/January/PR9_add__change.md +20 -0
  14. package/filters/maxArrivalsFilter.js +114 -114
  15. package/filters/maxGroupsFilter.js +221 -221
  16. package/filters/timeFilter.js +89 -89
  17. package/getAvailableTimeblocks.js +158 -158
  18. package/grouping.js +162 -162
  19. package/index.js +42 -42
  20. package/isDateAvailable.js +80 -80
  21. package/isDateAvailableWithTableCheck.js +171 -171
  22. package/isTimeAvailable.js +25 -25
  23. package/package.json +27 -27
  24. package/processing/dailyGuestCounts.js +73 -73
  25. package/processing/mealTypeCount.js +133 -133
  26. package/processing/timeblocksAvailable.js +167 -167
  27. package/reservation_data/counter.js +64 -64
  28. package/restaurant_data/exceptions.js +149 -149
  29. package/restaurant_data/openinghours.js +123 -123
  30. package/simulateTableAssignment.js +709 -699
  31. package/tableHelpers.js +178 -178
  32. package/tables/time/parseTime.js +19 -19
  33. package/tables/time/shifts.js +7 -7
  34. package/tables/utils/calculateDistance.js +13 -13
  35. package/tables/utils/isTableFreeForAllSlots.js +14 -14
  36. package/tables/utils/isTemporaryTableValid.js +39 -39
  37. package/test/test_counter.js +194 -194
  38. package/test/test_dailyCount.js +81 -81
  39. package/test/test_datesAvailable.js +106 -106
  40. package/test/test_exceptions.js +172 -172
  41. package/test/test_isDateAvailable.js +330 -330
  42. package/test/test_mealTypeCount.js +54 -54
  43. package/test/test_timesAvailable.js +88 -88
  44. package/test-meal-stop-fix.js +147 -147
  45. package/test-meal-stop-simple.js +93 -93
  46. package/test.js +336 -336
@@ -1,194 +1,194 @@
1
- // test.js
2
-
3
- const { getGuestCountAtHour } = require('../reservation_data/counter');
4
-
5
- // Sample reservations
6
- const reservations = [
7
- { guests: "1", time: "10:01", date: "2025-01-16" },
8
- { guests: "1", time: "11:59", date: "2025-01-16" },
9
- { guests: "34", time: "13:00", date: "2025-01-16" },
10
- { guests: "40", time: "13:00", date: "2025-01-16" },
11
- ];
12
-
13
- // Data including exceptions
14
- const data = {
15
- "_id": "demo",
16
- "general-settings": {
17
- "zitplaatsen": 10,
18
- "duurReservatie": "10"
19
- },
20
- "openinghours-breakfast": {
21
- "schemeSettings": {
22
- "Monday": {
23
- "enabled": true,
24
- "startTime": "07:00",
25
- "endTime": "09:00",
26
- "maxCapacityEnabled": true,
27
- "maxCapacity": "12",
28
- "shiftsEnabled": false,
29
- "shifts": []
30
- },
31
- "Wednesday": {
32
- "enabled": true,
33
- "startTime": "07:00",
34
- "endTime": "10:00",
35
- "maxCapacityEnabled": true,
36
- "maxCapacity": "12",
37
- "shiftsEnabled": false,
38
- "shifts": []
39
- }
40
- },
41
- },
42
- "openinghours-lunch": {
43
- "schemeSettings": {
44
- "Thursday": {
45
- "enabled": false, // Disabled lunch on Thursday
46
- "startTime": "13:00",
47
- "endTime": "14:00",
48
- "maxCapacityEnabled": true,
49
- "maxCapacity": "10",
50
- "shiftsEnabled": false,
51
- "shifts": []
52
- }
53
- },
54
- },
55
- "openinghours-dinner": {
56
- "schemeSettings": {
57
- "Thursday": {
58
- "enabled": true,
59
- "startTime": "16:00",
60
- "endTime": "17:30",
61
- "maxCapacityEnabled": true,
62
- "maxCapacity": "10",
63
- "shiftsEnabled": false,
64
- "shifts": []
65
- },
66
- "Friday": {
67
- "enabled": true,
68
- "startTime": "16:00",
69
- "endTime": "17:00",
70
- "maxCapacityEnabled": true,
71
- "maxCapacity": "10",
72
- "shiftsEnabled": false,
73
- "shifts": []
74
- },
75
- "Saturday": {
76
- "enabled": false, // Disabled day
77
- "startTime": "16:00",
78
- "endTime": "18:00",
79
- "maxCapacityEnabled": true,
80
- "maxCapacity": "10",
81
- "shiftsEnabled": false,
82
- "shifts": []
83
- }
84
- },
85
- },
86
- // Exceptions included in the data
87
- "exceptions": [
88
- {
89
- "title": "Opening 4 tot 10 December",
90
- "type": "Uitzondering",
91
- "timeframe": "breakfast",
92
- "startDate": "2024-12-04",
93
- "endDate": "2024-12-10",
94
- "startHour": "07:00",
95
- "endHour": "09:00",
96
- "maxSeats": "333",
97
- "daysOfWeek": [
98
-
99
- ],
100
- },
101
- {
102
- "title": "Opening 4 tot 10 December",
103
- "type": "Uitzondering",
104
- "timeframe": "breakfast",
105
- "startDate": "2024-12-04",
106
- "endDate": "2024-12-10",
107
- "startHour": "07:00",
108
- "endHour": "09:00",
109
- "maxSeats": "444",
110
- "daysOfWeek": [
111
-
112
- ],
113
- },
114
- {
115
- "title": "Opening 4 tot 10 December",
116
- "type": "Sluiting",
117
- "timeframe": "breakfast",
118
- "startDate": "2024-12-04",
119
- "endDate": "2024-12-10",
120
- "startHour": "07:00",
121
- "endHour": "09:00",
122
- "maxSeats": "333",
123
- "daysOfWeek": [
124
-
125
- ],
126
- },
127
- {
128
- "title": "Closure on December 2nd",
129
- "type": "Sluiting",
130
- "timeframe": "dinner",
131
- "startDate": "2024-12-02",
132
- "endDate": "2024-12-04",
133
- "daysOfWeek": [
134
-
135
- ]
136
- },
137
- {
138
- "title": "Uitzondering on December 4th",
139
- "type": "Uitzondering",
140
- "timeframe": "breakfast",
141
- "startDate": "2024-12-04",
142
- "endDate": "2024-12-04",
143
- "startHour": "07:00",
144
- "endHour": "08:00",
145
- "maxSeats": "12",
146
- "daysOfWeek": [
147
- "woensdag"
148
- ]
149
- }
150
- ]
151
- };
152
-
153
- // Test cases
154
- console.log('--- Reservation Guest Count Tests ---');
155
-
156
- // Test 1: Guests at 12:00
157
- console.log('Test 1 - Guests at 12:00:', getGuestCountAtHour(data, reservations, '12:00'));
158
- // Expected Output: 1 (Guest from 11:00 reservation)
159
-
160
- // Test 2: Guests at 11:00
161
- console.log('Test 2 - Guests at 11:00:', getGuestCountAtHour(data, reservations, '11:00'));
162
- // Expected Output: 2 (Guests from 10:00 and 11:00 reservations)
163
-
164
- // Test 3: Guests at 10:00
165
- console.log('Test 3 - Guests at 10:00:', getGuestCountAtHour(data, reservations, '10:00'));
166
- // Expected Output: 1 (Guest from 10:00 reservation)
167
-
168
- // Test 4: Guests at 12:00 (Original reservations)
169
- console.log('Test 4 - Guests at 12:00:', getGuestCountAtHour(data, reservations.slice(2), '12:00'));
170
- // Expected Output: 35
171
-
172
- // Test 5: Guests at 13:00
173
- console.log('Test 5 - Guests at 13:00:', getGuestCountAtHour(data, reservations.slice(2), '13:00'));
174
- // Expected Output: 75 (35 from 12:00 reservation and 40 from 13:00 reservation)
175
-
176
- // Test 6: Guests at 14:00
177
- console.log('Test 6 - Guests at 14:00:', getGuestCountAtHour(data, reservations.slice(2), '14:00'));
178
- // Expected Output: 40
179
-
180
- // Test 7: Guests at 14:00 (All reservations)
181
- console.log('Test 7 - Guests at 14:00:', getGuestCountAtHour(data, reservations, '14:00'));
182
- // Expected Output: 40
183
-
184
- // Test 8: Guests at 11:59
185
- console.log('Test 8 - Guests at 11:59:', getGuestCountAtHour(data, reservations, '11:59'));
186
- // Expected Output: 1
187
-
188
- // Test 9: Guests at 12:00 (New scenario)
189
- console.log('Test 9 - Guests at 12:00:', getGuestCountAtHour(data, reservations, '12:00'));
190
- // Expected Output: 1
191
-
192
- // Test 10: Guests at 13:59
193
- console.log('Test 10 - Guests at 13:59:', getGuestCountAtHour(data, reservations, '13:59'));
194
- // Expected Output: 75
1
+ // test.js
2
+
3
+ const { getGuestCountAtHour } = require('../reservation_data/counter');
4
+
5
+ // Sample reservations
6
+ const reservations = [
7
+ { guests: "1", time: "10:01", date: "2025-01-16" },
8
+ { guests: "1", time: "11:59", date: "2025-01-16" },
9
+ { guests: "34", time: "13:00", date: "2025-01-16" },
10
+ { guests: "40", time: "13:00", date: "2025-01-16" },
11
+ ];
12
+
13
+ // Data including exceptions
14
+ const data = {
15
+ "_id": "demo",
16
+ "general-settings": {
17
+ "zitplaatsen": 10,
18
+ "duurReservatie": "10"
19
+ },
20
+ "openinghours-breakfast": {
21
+ "schemeSettings": {
22
+ "Monday": {
23
+ "enabled": true,
24
+ "startTime": "07:00",
25
+ "endTime": "09:00",
26
+ "maxCapacityEnabled": true,
27
+ "maxCapacity": "12",
28
+ "shiftsEnabled": false,
29
+ "shifts": []
30
+ },
31
+ "Wednesday": {
32
+ "enabled": true,
33
+ "startTime": "07:00",
34
+ "endTime": "10:00",
35
+ "maxCapacityEnabled": true,
36
+ "maxCapacity": "12",
37
+ "shiftsEnabled": false,
38
+ "shifts": []
39
+ }
40
+ },
41
+ },
42
+ "openinghours-lunch": {
43
+ "schemeSettings": {
44
+ "Thursday": {
45
+ "enabled": false, // Disabled lunch on Thursday
46
+ "startTime": "13:00",
47
+ "endTime": "14:00",
48
+ "maxCapacityEnabled": true,
49
+ "maxCapacity": "10",
50
+ "shiftsEnabled": false,
51
+ "shifts": []
52
+ }
53
+ },
54
+ },
55
+ "openinghours-dinner": {
56
+ "schemeSettings": {
57
+ "Thursday": {
58
+ "enabled": true,
59
+ "startTime": "16:00",
60
+ "endTime": "17:30",
61
+ "maxCapacityEnabled": true,
62
+ "maxCapacity": "10",
63
+ "shiftsEnabled": false,
64
+ "shifts": []
65
+ },
66
+ "Friday": {
67
+ "enabled": true,
68
+ "startTime": "16:00",
69
+ "endTime": "17:00",
70
+ "maxCapacityEnabled": true,
71
+ "maxCapacity": "10",
72
+ "shiftsEnabled": false,
73
+ "shifts": []
74
+ },
75
+ "Saturday": {
76
+ "enabled": false, // Disabled day
77
+ "startTime": "16:00",
78
+ "endTime": "18:00",
79
+ "maxCapacityEnabled": true,
80
+ "maxCapacity": "10",
81
+ "shiftsEnabled": false,
82
+ "shifts": []
83
+ }
84
+ },
85
+ },
86
+ // Exceptions included in the data
87
+ "exceptions": [
88
+ {
89
+ "title": "Opening 4 tot 10 December",
90
+ "type": "Uitzondering",
91
+ "timeframe": "breakfast",
92
+ "startDate": "2024-12-04",
93
+ "endDate": "2024-12-10",
94
+ "startHour": "07:00",
95
+ "endHour": "09:00",
96
+ "maxSeats": "333",
97
+ "daysOfWeek": [
98
+
99
+ ],
100
+ },
101
+ {
102
+ "title": "Opening 4 tot 10 December",
103
+ "type": "Uitzondering",
104
+ "timeframe": "breakfast",
105
+ "startDate": "2024-12-04",
106
+ "endDate": "2024-12-10",
107
+ "startHour": "07:00",
108
+ "endHour": "09:00",
109
+ "maxSeats": "444",
110
+ "daysOfWeek": [
111
+
112
+ ],
113
+ },
114
+ {
115
+ "title": "Opening 4 tot 10 December",
116
+ "type": "Sluiting",
117
+ "timeframe": "breakfast",
118
+ "startDate": "2024-12-04",
119
+ "endDate": "2024-12-10",
120
+ "startHour": "07:00",
121
+ "endHour": "09:00",
122
+ "maxSeats": "333",
123
+ "daysOfWeek": [
124
+
125
+ ],
126
+ },
127
+ {
128
+ "title": "Closure on December 2nd",
129
+ "type": "Sluiting",
130
+ "timeframe": "dinner",
131
+ "startDate": "2024-12-02",
132
+ "endDate": "2024-12-04",
133
+ "daysOfWeek": [
134
+
135
+ ]
136
+ },
137
+ {
138
+ "title": "Uitzondering on December 4th",
139
+ "type": "Uitzondering",
140
+ "timeframe": "breakfast",
141
+ "startDate": "2024-12-04",
142
+ "endDate": "2024-12-04",
143
+ "startHour": "07:00",
144
+ "endHour": "08:00",
145
+ "maxSeats": "12",
146
+ "daysOfWeek": [
147
+ "woensdag"
148
+ ]
149
+ }
150
+ ]
151
+ };
152
+
153
+ // Test cases
154
+ console.log('--- Reservation Guest Count Tests ---');
155
+
156
+ // Test 1: Guests at 12:00
157
+ console.log('Test 1 - Guests at 12:00:', getGuestCountAtHour(data, reservations, '12:00'));
158
+ // Expected Output: 1 (Guest from 11:00 reservation)
159
+
160
+ // Test 2: Guests at 11:00
161
+ console.log('Test 2 - Guests at 11:00:', getGuestCountAtHour(data, reservations, '11:00'));
162
+ // Expected Output: 2 (Guests from 10:00 and 11:00 reservations)
163
+
164
+ // Test 3: Guests at 10:00
165
+ console.log('Test 3 - Guests at 10:00:', getGuestCountAtHour(data, reservations, '10:00'));
166
+ // Expected Output: 1 (Guest from 10:00 reservation)
167
+
168
+ // Test 4: Guests at 12:00 (Original reservations)
169
+ console.log('Test 4 - Guests at 12:00:', getGuestCountAtHour(data, reservations.slice(2), '12:00'));
170
+ // Expected Output: 35
171
+
172
+ // Test 5: Guests at 13:00
173
+ console.log('Test 5 - Guests at 13:00:', getGuestCountAtHour(data, reservations.slice(2), '13:00'));
174
+ // Expected Output: 75 (35 from 12:00 reservation and 40 from 13:00 reservation)
175
+
176
+ // Test 6: Guests at 14:00
177
+ console.log('Test 6 - Guests at 14:00:', getGuestCountAtHour(data, reservations.slice(2), '14:00'));
178
+ // Expected Output: 40
179
+
180
+ // Test 7: Guests at 14:00 (All reservations)
181
+ console.log('Test 7 - Guests at 14:00:', getGuestCountAtHour(data, reservations, '14:00'));
182
+ // Expected Output: 40
183
+
184
+ // Test 8: Guests at 11:59
185
+ console.log('Test 8 - Guests at 11:59:', getGuestCountAtHour(data, reservations, '11:59'));
186
+ // Expected Output: 1
187
+
188
+ // Test 9: Guests at 12:00 (New scenario)
189
+ console.log('Test 9 - Guests at 12:00:', getGuestCountAtHour(data, reservations, '12:00'));
190
+ // Expected Output: 1
191
+
192
+ // Test 10: Guests at 13:59
193
+ console.log('Test 10 - Guests at 13:59:', getGuestCountAtHour(data, reservations, '13:59'));
194
+ // Expected Output: 75
@@ -1,81 +1,81 @@
1
- // dailyGuestCountsTests.js
2
-
3
- const { getDailyGuestCounts } = require('../processing/dailyGuestCounts');
4
-
5
- // Sample data including overlapping meal times
6
- const data = {
7
- "_id": "demo",
8
- "general-settings": {
9
- "zitplaatsen": 10,
10
- "duurReservatie": "1000"
11
- },
12
- "openinghours-breakfast": {
13
- "schemeSettings": {
14
- "Monday": {
15
- "enabled": true,
16
- "startTime": "07:00",
17
- "endTime": "11:00", // Extended breakfast to overlap with lunch
18
- "maxCapacityEnabled": true,
19
- "maxCapacity": "0",
20
- "shiftsEnabled": false,
21
- "shifts": []
22
- }
23
- },
24
- "storedNumber": {
25
- "$numberInt": "0"
26
- }
27
- },
28
- "openinghours-lunch": {
29
- "schemeSettings": {
30
- "Monday": {
31
- "enabled": true,
32
- "startTime": "11:00", // Lunch starts earlier to overlap with breakfast and dinner
33
- "endTime": "14:00",
34
- "maxCapacityEnabled": true,
35
- "maxCapacity": "0",
36
- "shiftsEnabled": false,
37
- "shifts": []
38
- }
39
- },
40
- "storedNumber": {
41
- "$numberInt": "0"
42
- }
43
- },
44
- "openinghours-dinner": {
45
- "schemeSettings": {
46
- "Monday": {
47
- "enabled": true,
48
- "startTime": "14:00", // Dinner starts earlier to overlap with lunch
49
- "endTime": "16:00",
50
- "maxCapacityEnabled": true,
51
- "maxCapacity": "0",
52
- "shiftsEnabled": false,
53
- "shifts": []
54
- }
55
- },
56
- "storedNumber": {
57
- "$numberInt": "0"
58
- }
59
- },
60
- // Any exceptions
61
- "exceptions": [
62
- // Add exceptions here if needed
63
- ]
64
- };
65
-
66
- // Sample reservations
67
- const reservations = [
68
- // Breakfast reservations
69
-
70
- { guests: "10", time: "13:00", date: "2024-12-02" },
71
-
72
- ];
73
-
74
- console.log('--- Daily Guest Counts Tests ---');
75
-
76
- const dateStr = '2024-12-02';
77
-
78
- const combinedGuestCounts = getDailyGuestCounts(data, dateStr, reservations);
79
-
80
- console.log('Combined Guest Counts for All Meals on', dateStr, ':');
81
- console.log(JSON.stringify(combinedGuestCounts, null, 2));
1
+ // dailyGuestCountsTests.js
2
+
3
+ const { getDailyGuestCounts } = require('../processing/dailyGuestCounts');
4
+
5
+ // Sample data including overlapping meal times
6
+ const data = {
7
+ "_id": "demo",
8
+ "general-settings": {
9
+ "zitplaatsen": 10,
10
+ "duurReservatie": "1000"
11
+ },
12
+ "openinghours-breakfast": {
13
+ "schemeSettings": {
14
+ "Monday": {
15
+ "enabled": true,
16
+ "startTime": "07:00",
17
+ "endTime": "11:00", // Extended breakfast to overlap with lunch
18
+ "maxCapacityEnabled": true,
19
+ "maxCapacity": "0",
20
+ "shiftsEnabled": false,
21
+ "shifts": []
22
+ }
23
+ },
24
+ "storedNumber": {
25
+ "$numberInt": "0"
26
+ }
27
+ },
28
+ "openinghours-lunch": {
29
+ "schemeSettings": {
30
+ "Monday": {
31
+ "enabled": true,
32
+ "startTime": "11:00", // Lunch starts earlier to overlap with breakfast and dinner
33
+ "endTime": "14:00",
34
+ "maxCapacityEnabled": true,
35
+ "maxCapacity": "0",
36
+ "shiftsEnabled": false,
37
+ "shifts": []
38
+ }
39
+ },
40
+ "storedNumber": {
41
+ "$numberInt": "0"
42
+ }
43
+ },
44
+ "openinghours-dinner": {
45
+ "schemeSettings": {
46
+ "Monday": {
47
+ "enabled": true,
48
+ "startTime": "14:00", // Dinner starts earlier to overlap with lunch
49
+ "endTime": "16:00",
50
+ "maxCapacityEnabled": true,
51
+ "maxCapacity": "0",
52
+ "shiftsEnabled": false,
53
+ "shifts": []
54
+ }
55
+ },
56
+ "storedNumber": {
57
+ "$numberInt": "0"
58
+ }
59
+ },
60
+ // Any exceptions
61
+ "exceptions": [
62
+ // Add exceptions here if needed
63
+ ]
64
+ };
65
+
66
+ // Sample reservations
67
+ const reservations = [
68
+ // Breakfast reservations
69
+
70
+ { guests: "10", time: "13:00", date: "2024-12-02" },
71
+
72
+ ];
73
+
74
+ console.log('--- Daily Guest Counts Tests ---');
75
+
76
+ const dateStr = '2024-12-02';
77
+
78
+ const combinedGuestCounts = getDailyGuestCounts(data, dateStr, reservations);
79
+
80
+ console.log('Combined Guest Counts for All Meals on', dateStr, ':');
81
+ console.log(JSON.stringify(combinedGuestCounts, null, 2));