feat(connect): table bookings from the online ordering app; food fired to the kitchen before arrival
Plan phase 3S, step S.6. - Pull: "reservation" / "preorder" orders become Reservations waiting for an answer (status "requested"; services/online_reservations.py), with the food ordered ahead kept on the booking (items_json at the cloud's prices, the site's price check) — no order yet. Migration 0020 (reservations: online_order_cloud_id, online_ref, items_json, total, online_price_diff, fire_at, order_id, response_note). - Confirm → the food's fire time = booking time − fire minutes (setting); the fire worker (connect_orders, every 20 s) turns the food into an order at that time (needs an open business day; waits otherwise): kitchen tickets, KDS (reference and time). Early arrival fires at once. Seating moves the order to the table (refused if the table has an open order). Decline / cancel / no-show with a reason. Every step mirrored to the cloud. - Found: the KDS filter dropped every online order without an online status (SQL NULL in NOT(a AND b)) — made NULL-safe. - Counter: Online → Bookings (requests first, then upcoming), BookingPanel (confirm, decline with reasons, food and when it goes to the kitchen, seat at a free table, cancel, no-show); the Online badge and chime count booking requests. - Manager: Online ordering → Table bookings settings (on, food ahead, hours, slot, notice, days ahead, party size, fire minutes); the dashboard's reservations card confirms / declines online requests; the reservations router delegates online bookings' status steps. - Tests: tests/test_online_bookings.py (8), unit tests (terminal, manager), e2e: order app (book with food → the venue confirms), terminal (request → confirm → the two dishes reach the KDS at the fire time, not before → seated), manager (booking settings). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -203,3 +203,21 @@ test('sales points at the counter: what is sold and at which price (phase 3S)',
|
||||
assert.deepEqual(forSalesPoint([cola, soup, old], 'in_store_takeaway').map(p => [p.id, p.price]), [[1, 2.5], [3, 4]])
|
||||
assert.deepEqual(forSalesPoint([cola, soup, old], 'in_store').map(p => [p.id, p.price]), [[1, 3.5], [2, 6], [3, 4]])
|
||||
})
|
||||
|
||||
test('table bookings at the counter (S.6)', async () => {
|
||||
const { bookingSteps, findBooking, foodState, freeTables, whenLabel } = await import('../src/apps/pos/logic/bookings.js')
|
||||
const data = { requested: [{ id: 1, status: 'requested', lines: [] }], upcoming: [{ id: 2, status: 'pending', lines: [{}], order_id: null }] }
|
||||
assert.equal(findBooking(data, 2).id, 2)
|
||||
assert.equal(findBooking(data, 9), null)
|
||||
assert.deepEqual(bookingSteps(data.requested[0]), ['confirm', 'decline'])
|
||||
assert.deepEqual(bookingSteps(data.upcoming[0]), ['arrive', 'cancel', 'no_show'])
|
||||
assert.deepEqual(bookingSteps({ status: 'arrived' }), [])
|
||||
assert.equal(foodState(data.requested[0]), 'none')
|
||||
assert.equal(foodState(data.upcoming[0]), 'waiting')
|
||||
assert.equal(foodState({ lines: [{}], order_id: 5 }), 'kitchen')
|
||||
assert.deepEqual(freeTables([{ id: 1, order: null }, { id: 2, order: { id: 9 } }]).map(t => t.id), [1])
|
||||
const fmt = { formatDate: d => new Date(d).toISOString().slice(0, 10), formatDateTime: () => 'other day', formatTime: () => '21:30' }
|
||||
const t = (k, p) => `${k}:${p?.time ?? ''}`
|
||||
assert.equal(whenLabel(new Date().toISOString(), fmt, t), 'pos.bookings.today:21:30')
|
||||
assert.equal(whenLabel('2020-01-01T10:00:00Z', fmt, t), 'other day')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user