feat(cloud): table bookings online, with food ordered ahead
Plan phase 3S, step S.6.
- New order types "reservation" (a table only, no items) and "preorder" (a table with food,
priced at the online_preorder sales point); online_orders.party_size (migration 0005).
- services/ordering.py: the venue's booking settings (ordering.reservations in the snapshot):
hours (none = any time), time grid, notice, days ahead (≤ 90), party size; res_slots per
venue day, res_days, res_check (order.service_unavailable, order.party_invalid,
order.time_invalid). The public menu's ordering summary gains `reservations`
{enabled, with_food, party_max, days}; GET /api/orders/{site}/reservation-slots?day=.
- Bookings need a phone; a plain booking refuses items (order.items_not_allowed).
- Status steps for bookings: pending_acceptance → accepted | rejected; accepted → delivered
(arrived) | cancelled (by the venue); ordinary orders unchanged.
- Order app: "Book a table" (people, day, time, optional food at the pre-order prices),
booking summary at checkout, a booking tracking page (waiting, confirmed, welcome;
declined / cancelled with the reason). en/el.
- Tests: tests/test_reservations.py (3), order-app logic test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,3 +61,23 @@ test('slots by day in the venue time zone, tracking steps, refusals', () => {
|
||||
assert.deepEqual(refusal({ response: { status: 429, data: {} } }), ['rate', {}])
|
||||
assert.deepEqual(refusal(new Error('x')), ['failed', {}])
|
||||
})
|
||||
|
||||
test('booking a table, with or without food (S.6)', async () => {
|
||||
const { bookingBody, bookingProblems } = await import('../src/logic.js')
|
||||
const form = { name: 'Eleni', phone: '6977777777', notes: '' }
|
||||
const booking = { party: 4, when: '2026-11-16T18:00:00+00:00' }
|
||||
assert.deepEqual(bookingProblems(form, booking, 8), [])
|
||||
assert.deepEqual(bookingProblems({ ...form, name: ' ' }, { party: 9, when: null }, 8), ['name', 'party', 'when'])
|
||||
assert.deepEqual(bookingBody(form, booking, [], null), {
|
||||
order_type: 'reservation', customer_name: 'Eleni', customer_phone: '6977777777', customer_notes: null,
|
||||
party_size: 4, requested_for: booking.when, items: [], total: undefined,
|
||||
})
|
||||
const food = bookingBody(form, booking, [{ productId: 1, qty: 2, options: [], unit: 2.6 }], { total: 5.2 })
|
||||
assert.equal(food.order_type, 'preorder')
|
||||
assert.deepEqual(food.items, [{ product_id: 1, quantity: 2, options: [], unit_price: 2.6 }])
|
||||
assert.equal(food.total, 5.2)
|
||||
assert.deepEqual(trackSteps('reservation', 'accepted'), { steps: ['pending_acceptance', 'accepted', 'delivered'], at: 1, done: false })
|
||||
assert.equal(trackSteps('preorder', 'cancelled').done, true)
|
||||
assert.equal(trackSteps('preorder', 'cancelled').at, -1)
|
||||
assert.equal(priceFor({ sold_at: ['online_preorder'], prices: { online_preorder: 2.6 } }, 'preorder'), 2.6)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user