feat(backend,terminal): tables at the counter, shared live with the waiter phones (platform-v2 3.3c)

- POS: GET /api/pos/tables (the cashier's zones as in the waiter app, each open order's
  totals, people, ready items, flags, reservation), POST /api/pos/tables/{id}/items (into
  the table's order or a new one via orders.open_order + add_items), POST
  /api/pos/orders/{id}/pay (chosen items, cash/card/split, drawer on cash), POST
  /api/pos/orders/{id}/close (only when nothing is unpaid). Quote takes order_id so the
  order's items count for cart conditions (shared pos_cart.order_cart, used by add_items).
- New codes pos.table_not_found, pos.table_not_yours, pos.items_changed, pos.order_unpaid.
- Fix: item cancels (DELETE item, cancel-items) now broadcast order_updated, so phones and
  kitchen screens see them at once.
- Terminal: Sale | Tables switch, zone list, table cards by zone, TablePanel (order lines,
  new lines, send, pay selected/all, cancel with approval, close), generic PaymentDialog.
- Tests: test_pos_tables.py (8), terminal unit, terminal.mjs +17 with a live phone socket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 02:15:54 +02:00
co-authored by Claude Opus 5.5
parent bff82a332a
commit 988d413d8e
19 changed files with 1452 additions and 218 deletions
+7 -10
View File
@@ -508,16 +508,8 @@ def add_items(
if order.source == "online":
order_channel = "online"
# Snapshot existing cart items for condition evaluation
existing_cart = [
{
"product_id": i.product_id,
"category_id": i.product.primary_category_id if i.product else None,
"category_ids": i.product.category_ids if i.product else [],
"quantity": i.quantity,
"unit_price": i.unit_price,
}
for i in order.items if i.status == "active"
]
from services.pos_cart import order_cart
existing_cart = order_cart(order) # the counter's table quote starts from the same (3.3c)
for item_in in body.items:
product = db.query(Product).filter(Product.id == item_in.product_id).first()
@@ -800,6 +792,8 @@ def cancel_item(
_audit(db, order_id, "ITEM_CANCELLED", waiter_id=user.id, item_ids=cancelled_ids, note=_approval_note(approval))
db.commit()
broadcast_sync("order_updated", {"order_id": order_id, "table_id": order.table_id, "status": order.status,
"action": "items_cancelled", "item_ids": cancelled_ids})
should_print = print_cancellation if is_manager else True
if should_print:
@@ -1197,6 +1191,9 @@ def cancel_items_bulk(
if cancelled_ids:
_audit(db, order_id, "ITEM_CANCELLED", waiter_id=user.id, item_ids=cancelled_ids, note=_approval_note(approval))
db.commit()
if cancelled_ids:
broadcast_sync("order_updated", {"order_id": order_id, "table_id": order.table_id, "status": order.status,
"action": "items_cancelled", "item_ids": cancelled_ids})
should_print = body.print_cancellation if is_manager else True
if should_print and cancelled_ids: