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:
@@ -75,6 +75,42 @@ def fees_payload(db) -> dict:
|
||||
return {"areas": [area_out(a) for a in areas], "rules": [rule_out(r) for r in rules]}
|
||||
|
||||
|
||||
def _clean_hours(v):
|
||||
out = {}
|
||||
for day, ranges in (v or {}).items():
|
||||
if str(day) not in {str(d) for d in range(7)}:
|
||||
raise ValueError("hours are keyed 0 (Monday) to 6 (Sunday)")
|
||||
if not isinstance(ranges, list) or len(ranges) > 4:
|
||||
raise ValueError("at most 4 time ranges a day")
|
||||
clean = []
|
||||
for r in ranges:
|
||||
if not (isinstance(r, (list, tuple)) and len(r) == 2 and all(isinstance(x, str) and HHMM.match(x) for x in r)) or r[0] == r[1]:
|
||||
raise ValueError("a time range is [\"HH:MM\", \"HH:MM\"], start and end different")
|
||||
clean.append([r[0], r[1]])
|
||||
if clean:
|
||||
out[str(day)] = sorted(clean)
|
||||
return out
|
||||
|
||||
|
||||
class ReservationsBody(BaseModel):
|
||||
"""Table bookings online (plan phase 3S, S.6): a table only, or with food ordered ahead
|
||||
(`with_food`). The cloud enforces hours, the time grid, notice, days ahead and party size;
|
||||
`fire_minutes` is the site's: the kitchen gets pre-ordered food that long before arrival."""
|
||||
enabled: bool = False
|
||||
with_food: bool = False
|
||||
hours: dict = Field(default_factory=dict) # like OrderingBody.hours; none = any time
|
||||
slot_minutes: int = Field(default=30, ge=5, le=120)
|
||||
days_ahead: int = Field(default=30, ge=0, le=90)
|
||||
notice_minutes: int = Field(default=60, ge=0, le=7 * 24 * 60) # the earliest booking from now
|
||||
party_max: int = Field(default=10, ge=1, le=100)
|
||||
fire_minutes: int = Field(default=20, ge=0, le=240)
|
||||
|
||||
@field_validator("hours")
|
||||
@classmethod
|
||||
def _hours(cls, v):
|
||||
return _clean_hours(v)
|
||||
|
||||
|
||||
class OrderingBody(BaseModel):
|
||||
"""What the online ordering app offers and when (plan phase 3S, S.4). The cloud enforces
|
||||
it at checkout. hours: {"0".."6" (Mon..Sun): [["HH:MM", "HH:MM"], ...]}; no hours at all =
|
||||
@@ -86,6 +122,7 @@ class OrderingBody(BaseModel):
|
||||
slot_minutes: int = Field(default=15, ge=5, le=120) # the times offered, every N minutes
|
||||
days_ahead: int = Field(default=0, ge=0, le=7) # 0 = today only
|
||||
asap: bool = True # "as soon as possible" offered while open
|
||||
reservations: ReservationsBody = Field(default_factory=ReservationsBody) # S.6
|
||||
|
||||
@field_validator("services")
|
||||
@classmethod
|
||||
@@ -95,20 +132,7 @@ class OrderingBody(BaseModel):
|
||||
@field_validator("hours")
|
||||
@classmethod
|
||||
def _hours(cls, v):
|
||||
out = {}
|
||||
for day, ranges in (v or {}).items():
|
||||
if str(day) not in {str(d) for d in range(7)}:
|
||||
raise ValueError("hours are keyed 0 (Monday) to 6 (Sunday)")
|
||||
if not isinstance(ranges, list) or len(ranges) > 4:
|
||||
raise ValueError("at most 4 time ranges a day")
|
||||
clean = []
|
||||
for r in ranges:
|
||||
if not (isinstance(r, (list, tuple)) and len(r) == 2 and all(isinstance(x, str) and HHMM.match(x) for x in r)) or r[0] == r[1]:
|
||||
raise ValueError("a time range is [\"HH:MM\", \"HH:MM\"], start and end different")
|
||||
clean.append([r[0], r[1]])
|
||||
if clean:
|
||||
out[str(day)] = sorted(clean)
|
||||
return out
|
||||
return _clean_hours(v)
|
||||
|
||||
|
||||
class AreaBody(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user