feat(waiter): where each line came from; QR lines marked, the QR message opens the table (platform-v2 step 4.8b)
- order_items.source (Alembic 0025): waiter | counter | qr | online, set by the server (orders.add_priced_items: the phone / manager 'waiter', the counter 'counter'; the QR menu's lines 'qr', online orders 'online'; a split line keeps its source); lines of existing online orders backfilled 'online'; in the order's item output. - Waiter: lines the guests sent from the QR menu (or an online order) carry a "📱 QR" / "🌐 Online" mark; the qr_order message's banner has "Open the table", and in the bell's list the message opens it. - Tests: source per channel, migration 0025, QR placement marks 'qr'; waiter e2e +1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -460,13 +460,14 @@ def store_online_orders(db, orders: list[dict], booked: list | None = None, at_t
|
||||
return out
|
||||
|
||||
|
||||
def add_cloud_items(db, order_id: int, opener_id: int, items: list) -> list:
|
||||
def add_cloud_items(db, order_id: int, opener_id: int, items: list, source: str = "online") -> list:
|
||||
"""The cloud's lines as order items, at the cloud's prices (what the customer pays)."""
|
||||
from models.order import OrderItem
|
||||
out = []
|
||||
for item in items:
|
||||
row = OrderItem(
|
||||
order_id=order_id,
|
||||
source=source,
|
||||
product_id=item.get("product_id"),
|
||||
added_by=opener_id,
|
||||
quantity=item.get("quantity", 1),
|
||||
|
||||
@@ -51,7 +51,7 @@ def place(db, cloud_order: dict, opener_id: int):
|
||||
db.add(order)
|
||||
db.flush()
|
||||
_audit(db, order.id, "ORDER_OPENED", waiter_id=opener_id, note="QR menu")
|
||||
items = add_cloud_items(db, order.id, opener_id, json.loads(cloud_order.get("items_json") or "[]"))
|
||||
items = add_cloud_items(db, order.id, opener_id, json.loads(cloud_order.get("items_json") or "[]"), source="qr")
|
||||
db.flush()
|
||||
ids = [i.id for i in items]
|
||||
_audit(db, order.id, EVENT, waiter_id=opener_id, item_ids=ids, amount=cloud_order.get("total"), note=cloud_order.get("public_ref"))
|
||||
|
||||
Reference in New Issue
Block a user