Commit Graph
8 Commits
Author SHA1 Message Date
bonaminandClaude Opus 5.5 d5b8492512 feat: delivery areas drawn on a map: the customer pins the address (plan 6R.G)
- services/fees.py: the site's engine (shapes matched by the pin), shared cases
- checkout: price_cart(pin=), delivery_areas with kind (+ geometry for shapes),
  venue_point in the public menu (postcodes and rules stay on the cloud)
- orders: quote / create take lat / lng; online_orders.lat / lng (Alembic 0007),
  sent to the site with the pending orders
- order app: PinMap (Leaflet + OpenStreetMap tiles), 'Pin it on the map' first
  when the venue drew areas, the browser's location offered; lat / lng sent
- tests: cloud test_fees (pinned quote and order), order-app logic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:56:13 +02:00
bonaminandClaude Opus 5.5 2835b5dc68 feat(cloud): the QR menu at the table, ordering only with a table's QR code
Plan phase 3S, step S.7.
- services/qr.py: the snapshot's `qr` {ordering, tables: [{id, label, token_hash}]} (sha256
  of each table's token; the cloud never holds the tokens). A table order (dine_in) needs
  the venue's ordering on, the site's menu_mode "order" and a valid table token: otherwise
  order.service_unavailable / 403 order.table_invalid (a forged, old or typed-in table is
  refused). The order keeps the table's id and label (online_orders.table_id, migration 0006).
- Public menu: ?t=<token> → `table` {id, label} or `table_invalid`; `table_ordering`; `qr`
  never leaves the cloud.
- Heartbeat returns `apps_url` (new setting PUBLIC_APPS_URL: where /menu/ and /order/ are
  served) so sites can print table QR codes that open the right address.
- Menu app: the table from its QR code (kept for the visit), a "Table 5" banner, ordering
  only at a real table (otherwise read-only, with a notice for an invalid code); checkout
  without a typed table number; prices are the QR menu's (sales point qr_table — it showed
  in-store prices since S.1 removed digital_price) and only products sold there; the
  confirmation page for table orders (in the kitchen); the delivery/takeaway leftovers
  removed (they have their own app since S.4); test ids for e2e.
- Tests: tests/test_qr.py (3); test_checkout's typed-table case moved there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 01:26:33 +02:00
bonaminandClaude Opus 5.5 3459c80611 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>
2026-11-15 19:31:21 +02:00
bonaminandClaude Opus 5.5 9ccb47cfd1 feat(cloud): online orders keep the delivery area's id for the site's fee check
The site checks the cloud's delivery fee with its own engine when it pulls an order (plan
phase 3S, step S.5) and needs the area by id: a name can change between a menu push and
the order. New column online_orders.delivery_area_id (migration 0004), set from the priced
cart, and in the pending-orders payload (C-4, additive).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:38:00 +02:00
bonaminandClaude Opus 5.5 b25bfcda3e feat(cloud): the online ordering app (takeaway, delivery) with hours, time slots and rate limits (platform-v2 3S, S.4)
- connect_frontend/order-app at /order/{site}: menu per service at that service's prices,
  extras, basket (kept per tab), checkout priced by the cloud (fee, area by list or
  postcode, minimum), name/phone/address/notes (remembered), as soon as possible or a time
  slot, tracking page with steps, lines and totals; en/el; tokens in index.css. Logic in
  src/logic.js, unit-tested; built and served by the connect image (npm test in the build).
- services/ordering.py: the venue's services, hours (past midnight), preparation, slot grid,
  days ahead, ASAP; takeaway/delivery orders checked (order.service_unavailable,
  order.closed, order.time_invalid) and need a phone; GET /api/orders/{site}/slots; the
  public menu carries the ordering summary.
- services/ratelimit.py: per-caller limits on quote, order and track (429 rate.limited).
- online_orders.requested_for (0003, unreleased) stored as UTC; every datetime sent with its
  offset (the database keeps no zone: a 12:00 Athens slot came back as 12:00 unzoned).
- Tracking returns what was ordered, the totals, the type and the time.
- Tests: test_ordering.py (5), checkout/fees updated; order-app unit (4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 13:39:00 +02:00
bonaminandClaude Opus 5.5 96f16e948d feat(cloud): delivery fees and minimum orders at checkout (platform-v2 3S, S.3)
- 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>
2026-11-15 12:28:15 +02:00
bonaminandClaude Opus 5.5 5bdd19d9fb feat(cloud): the cloud prices online orders itself; sites only touch their own data (platform-v2 3S, S.2)
- 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>
2026-11-15 11:38:37 +02:00
bonaminandClaude Sonnet 4.6 cd8a6c53cf feat(connect): Phase 3 — cloud API routes for Xenia Connect
Adds four new routers, three schema files, and one new model.
All new endpoints use new URL prefixes — no existing routes touched.

routers/menu.py
  GET  /api/menu/{site_slug}     — public menu snapshot (no auth)
  POST /api/menu/sync            — upsert snapshot (site API key)

routers/orders.py
  POST /api/orders/{site_slug}         — customer places order (public)
  GET  /api/orders/status/{public_ref} — customer tracks order (public)
  GET  /api/orders/pending/{site_id}   — local backend polls (site key)
  POST /api/orders/{id}/synced         — mark synced (site key)
  PATCH /api/orders/{id}/status        — update status with transition
                                         validation (site key)

routers/manager_auth.py
  POST /api/manager/register  — create manager account (admin JWT)
  POST /api/manager/login     — returns manager JWT
  POST /api/manager/refresh   — refreshes manager JWT
  Shared _get_current_manager dependency used by remote_dashboard

routers/remote_dashboard.py
  GET  /api/remote/sites                           — manager JWT
  GET  /api/remote/sites/{id}/snapshot             — manager JWT
  GET  /api/remote/sites/{id}/orders               — manager JWT
  GET  /api/remote/sites/{id}/orders/pending       — manager JWT
  PATCH /api/remote/sites/{id}/orders/{oid}/status — manager JWT
  POST /api/remote/snapshot                        — site API key
                                                     (stats push)

models/stats_snapshot.py (NEW)
  stats_snapshots table — one row per site, holds serialized
  operational stats; created by create_all on startup

config.py / .env.example
  MANAGER_JWT_SECRET and MANAGER_JWT_EXPIRE_HOURS (default 72h)
  added as separate settings from the admin SECRET_KEY

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-01 00:05:48 +03:00