feat: the menu snapshot carries a price per sales point; pulled orders keep the cloud's sales point and table (platform-v2 3S, S.2)

- services/cloud_sync.menu_snapshot(db) (split out of the push, tested): sold_at + prices
  per customer-app sales point from the pricing engine; digital_price = the QR menu's.
- store_online_orders: sales_point from the cloud (older clouds: from the type), takeaway
  orders typed takeaway, the QR menu's table in front of the customer's note.
- manager e2e: waits for the live connection (html[data-live]) instead of a fixed 1.5 s,
  and for the server to record "read" (two timing races seen in a full run).
- Tests: +2 in test_sales_points.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 11:38:46 +02:00
co-authored by Claude Opus 5.5
parent 1b468fe44b
commit ffeb2b45cb
4 changed files with 115 additions and 58 deletions
+34
View File
@@ -172,3 +172,37 @@ def test_migration_moves_digital_prices_and_visibility(tmp_path):
(1, "add_amount", -1.0, 0, digital), (3, "add_percent", -10.0, 1, digital)]
assert json.loads(old)["channels"] == ["in_store"] + digital[1:]
assert points == {1: "in_store_takeaway", 2: "online_delivery"}
def test_the_cloud_menu_carries_a_price_per_sales_point(db, menu):
"""S.2: the snapshot says where each product is sold online and its price there (the cloud
charges these), from the same price rules as the counter."""
from models.product import ProductCategory
from services.cloud_sync import menu_snapshot
cola = menu["coffee"]
cola.base_price = 3.5
for prod in (cola, menu["burger"]):
if not prod.memberships:
db.add(ProductCategory(product_id=prod.id, category_id=prod.primary_category_id, sort_order=0))
db.commit()
takeaway_price(db, cola, 2.5, channels=("online_takeaway",))
sold_at(db, menu["burger"], ["in_store"]) # not sold by the customer apps
snap, _ = menu_snapshot(db)
products = {p["id"]: p for c in snap["categories"] for p in c["products"]}
assert menu["burger"].id not in products
p = products[cola.id]
assert p["prices"] == {"qr_table": 3.5, "online_takeaway": 2.5, "online_delivery": 3.5, "online_preorder": 3.5}
assert p["digital_price"] == 3.5 and p["sold_at"] == ["qr_table", "online_takeaway", "online_delivery", "online_preorder"]
def test_pulled_orders_take_the_clouds_sales_point_and_table(db, menu, make_user):
from core.timeutil import business_date_of, utcnow
from models.business_day import BusinessDay
from models.order import Order
make_user(role="owner")
db.add(BusinessDay(status="open", opened_at=utcnow(), business_date=business_date_of(utcnow()), opened_by_id=1))
db.commit()
o = db.get(Order, pulled(db, menu, 701, "dine_in", table_label="5", customer_notes="No ice"))
assert (o.sales_point, o.online_customer_notes, o.order_type) == ("qr_table", "Table 5 · No ice", "here")
o = db.get(Order, pulled(db, menu, 702, "takeaway", sales_point="online_takeaway"))
assert (o.sales_point, o.order_type) == ("online_takeaway", "takeaway")