Files
xenia-pos-local/local_backend/migrations/versions/0020_online_reservations.py
T
bonaminandClaude Opus 5.5 70c8f2bb57 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>
2026-11-15 19:31:44 +02:00

39 lines
1.8 KiB
Python

"""reservations: online bookings with food ordered ahead (plan phase 3S, S.6)
Revision ID: 0020_online_reservations
Revises: 0019_online_order_site_side
Create Date: 2026-11-16 21:30:00
"""
from alembic import op
import sqlalchemy as sa
from core.timeutil import UTCDateTime
revision = '0020_online_reservations'
down_revision = '0019_online_order_site_side'
branch_labels = None
depends_on = None
def upgrade() -> None:
with op.batch_alter_table('reservations', schema=None) as batch_op:
batch_op.add_column(sa.Column('online_order_cloud_id', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('online_ref', sa.String(), nullable=True))
batch_op.add_column(sa.Column('items_json', sa.Text(), nullable=True))
batch_op.add_column(sa.Column('total', sa.Float(), nullable=True))
batch_op.add_column(sa.Column('online_price_diff', sa.Text(), nullable=True))
batch_op.add_column(sa.Column('fire_at', UTCDateTime(), nullable=True))
batch_op.add_column(sa.Column('order_id', sa.Integer(), nullable=True))
batch_op.add_column(sa.Column('response_note', sa.Text(), nullable=True))
batch_op.create_index(batch_op.f('ix_reservations_online_order_cloud_id'), ['online_order_cloud_id'], unique=False)
batch_op.create_foreign_key('fk_reservations_order_id_orders', 'orders', ['order_id'], ['id'])
def downgrade() -> None:
with op.batch_alter_table('reservations', schema=None) as batch_op:
batch_op.drop_constraint('fk_reservations_order_id_orders', type_='foreignkey')
batch_op.drop_index(batch_op.f('ix_reservations_online_order_cloud_id'))
for c in ('response_note', 'order_id', 'fire_at', 'online_price_diff', 'total', 'items_json', 'online_ref', 'online_order_cloud_id'):
batch_op.drop_column(c)