- services/fees.py: the site's fee engine, byte-identical (the site's tests check it);
tests/fixtures/fee_cases.json: the shared cases, run here too.
- checkout: the snapshot's fees (areas, rules) at the venue's time zone; refused
order.area_not_served / order.minimum_not_met {minimum, subtotal}; quote and order take
area_id / postcode and return area_name, fee_rules; the order stores delivery_area.
- GET /api/menu/{site}: delivery_areas [{id, name}] for the customer; the rules and
postcodes are never sent to the browser.
- Alembic 0003 (unreleased) gains online_orders.delivery_area.
- Tests: test_fees.py (22 shared cases + checkout fees, refusals, public menu, clock).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- services/checkout.py: orders and quotes priced from the site's snapshot per sales point
(prices map; older snapshots: digital_price less discount); refused: unavailable or
not sold there, bad quantity/option/type, empty, order.price_changed when the browser's
unit price or total differs. Nothing the browser says about money is stored.
- POST /api/orders/{site}/quote; delivery needs phone + address.
- Fixes: pending orders, menu sync and stats snapshot acted on the site_id given, not the
authenticated site (a site could read another's orders or overwrite its menu/stats).
- Order refs are unique per site (a second site's first order failed); tracking by a
random token GET /api/orders/track/{token}; old /status/{ref} only while unambiguous.
- Alembic 0003: online_orders sales_point, table_label, tracking_token; table rebuilt.
- menu-app: tracking link uses the token, shows the order number; tells the customer when
the menu changed or the order failed.
- Tests: test_checkout.py (6), 0003 data migration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds three new tables created automatically by create_all on next
startup, plus an additive migration for an existing table:
models/menu_snapshot.py (NEW)
- menu_snapshots: one row per site, holds the full serialized
category+product JSON; upserted on each sync from local_backend
models/online_order.py (NEW)
- online_orders: full order lifecycle from customer submission
through delivery; tracks sync state so local_backend can poll
for unprocessed orders (synced_to_local=0)
models/manager_account.py (NEW)
- manager_accounts + manager_site_access (M2M join table): remote
manager login accounts with per-site access control
models/site.py (MODIFIED)
- order_counter column added; incremented atomically when each
online order is created to generate "ORD-XXXX" public_ref values
main.py (MODIFIED)
- imports all three new models so create_all registers their tables
- _run_migrations() added (same pattern as local_backend) for the
additive order_counter column on the existing sites table
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>