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:
@@ -104,28 +104,48 @@ export function previewBody(form) {
|
||||
}
|
||||
|
||||
/** Online ordering settings (S.4) → the form: hours as editable rows per day. */
|
||||
const toDays = hours => DAYS.map(d => (hours?.[String(d)] ?? []).map(([from, to]) => ({ from, to })))
|
||||
function toHours(anyTime, days) {
|
||||
const hours = {}
|
||||
if (!anyTime) {
|
||||
days.forEach((ranges, d) => {
|
||||
const clean = ranges.filter(r => r.from && r.to && r.from !== r.to).map(r => [r.from, r.to])
|
||||
if (clean.length) hours[String(d)] = clean
|
||||
})
|
||||
}
|
||||
return hours
|
||||
}
|
||||
const int = (v, dflt) => (Number.isFinite(Number(v)) && String(v).trim() !== '' ? Math.round(Number(v)) : dflt)
|
||||
|
||||
/** Table bookings online (S.6): the defaults the backend has. */
|
||||
export const RES_DEFAULTS = { enabled: false, with_food: false, hours: {}, slot_minutes: 30, days_ahead: 30, notice_minutes: 60, party_max: 10, fire_minutes: 20 }
|
||||
|
||||
export function orderingToForm(o) {
|
||||
const hours = o?.hours ?? {}
|
||||
const r = { ...RES_DEFAULTS, ...(o?.reservations ?? {}) }
|
||||
return {
|
||||
services: o?.services ?? [], anyTime: Object.keys(hours).length === 0,
|
||||
days: DAYS.map(d => (hours[String(d)] ?? []).map(([from, to]) => ({ from, to }))),
|
||||
days: toDays(hours),
|
||||
prep_minutes: String(o?.prep_minutes ?? 20), slot_minutes: String(o?.slot_minutes ?? 15),
|
||||
days_ahead: String(o?.days_ahead ?? 0), asap: o?.asap ?? true,
|
||||
res: {
|
||||
enabled: !!r.enabled, with_food: !!r.with_food, anyTime: Object.keys(r.hours ?? {}).length === 0, days: toDays(r.hours),
|
||||
slot_minutes: String(r.slot_minutes), days_ahead: String(r.days_ahead), notice_minutes: String(r.notice_minutes),
|
||||
party_max: String(r.party_max), fire_minutes: String(r.fire_minutes),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/** The form → PUT /api/connect/fees/ordering. A day without ranges is closed (unless any time). */
|
||||
export function orderingBody(form) {
|
||||
const hours = {}
|
||||
if (!form.anyTime) {
|
||||
form.days.forEach((ranges, d) => {
|
||||
const clean = ranges.filter(r => r.from && r.to && r.from !== r.to).map(r => [r.from, r.to])
|
||||
if (clean.length) hours[String(d)] = clean
|
||||
})
|
||||
}
|
||||
const int = (v, dflt) => (Number.isFinite(Number(v)) && String(v).trim() !== '' ? Math.round(Number(v)) : dflt)
|
||||
const r = form.res ?? orderingToForm(null).res
|
||||
return {
|
||||
services: form.services, hours, prep_minutes: int(form.prep_minutes, 20), slot_minutes: int(form.slot_minutes, 15),
|
||||
services: form.services, hours: toHours(form.anyTime, form.days), prep_minutes: int(form.prep_minutes, 20), slot_minutes: int(form.slot_minutes, 15),
|
||||
days_ahead: int(form.days_ahead, 0), asap: !!form.asap,
|
||||
reservations: {
|
||||
enabled: !!r.enabled, with_food: !!r.enabled && !!r.with_food, hours: toHours(r.anyTime, r.days),
|
||||
slot_minutes: int(r.slot_minutes, 30), days_ahead: int(r.days_ahead, 30), notice_minutes: int(r.notice_minutes, 60),
|
||||
party_max: int(r.party_max, 10), fire_minutes: int(r.fire_minutes, 20),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user