feat: sales points, offerings and prices per sales point (platform-v2 phase 3S, step S.1)
- core/sales_points.py: in_store, in_store_takeaway, qr_table, online_takeaway, online_delivery, online_preorder (+ old channel names mapped). - Alembic 0017: orders.sales_point (backfilled), products.sold_at (from digital_visible), digital_price/digital_discount -> item price modifiers for the QR menu and online, order_channel conditions -> sales points; drops the three digital columns. - Every order records its sales point; the pricing engine's channel is it; items not sold there are refused (order.not_sold_here, pos.line_invalid not_sold_here). - POS menu: only what the counter sells, prices per counter sales point; the screen shows the order type's products and prices. Waiter app asks for in-person products. - Cloud snapshot: products sold by the customer apps, priced by the engine. - Manager: product "Where it's sold" tab; pricing condition shows sales points. - Products API, catalogue export/import carry sold_at. - Tests: test_sales_points.py (8, incl. the migration), access +1, terminal +1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -468,7 +468,9 @@ def open_order(body: OrderCreate, db: Session = Depends(get_db), user: User = De
|
||||
if existing:
|
||||
raise HTTPException(status_code=400, detail="Table already has an open order")
|
||||
|
||||
order = Order(table_id=body.table_id, order_type=order_type, opened_by=user.id, business_day_id=active_day.id)
|
||||
from core.sales_points import for_order
|
||||
order = Order(table_id=body.table_id, order_type=order_type, opened_by=user.id, business_day_id=active_day.id,
|
||||
sales_point=for_order(order_type))
|
||||
db.add(order)
|
||||
db.flush()
|
||||
db.add(OrderWaiter(order_id=order.id, waiter_id=user.id))
|
||||
@@ -505,11 +507,9 @@ def add_items(
|
||||
# Build pricing context once for the whole batch
|
||||
now = utcnow()
|
||||
active_pg_ids = build_active_price_group_ids(db, now)
|
||||
# Determine order channel
|
||||
_channel_map = {"online": "online", "takeaway": "takeaway", "delivery": "takeaway"}
|
||||
order_channel = _channel_map.get(order.order_type, "pos")
|
||||
if order.source == "online":
|
||||
order_channel = "online"
|
||||
# The order's sales point (phase 3S): what the pricing engine's channel condition sees
|
||||
from core.sales_points import is_sold_at, of_order
|
||||
order_channel = of_order(order)
|
||||
# Snapshot existing cart items for condition evaluation
|
||||
from services.pos_cart import order_cart
|
||||
existing_cart = order_cart(order) # the counter's table quote starts from the same (3.3c)
|
||||
@@ -518,6 +518,8 @@ def add_items(
|
||||
product = db.query(Product).filter(Product.id == item_in.product_id).first()
|
||||
if not product or not product.is_available:
|
||||
raise HTTPException(status_code=400, detail=f"Product {item_in.product_id} not available")
|
||||
if not is_sold_at(product, order_channel):
|
||||
raise XeniaError("order.not_sold_here", name=product.name)
|
||||
|
||||
# Priceless service items: print-once, NOT persisted (ephemeral)
|
||||
# Priced service items: saved as real order items AND printed in a SERVICE section
|
||||
|
||||
Reference in New Issue
Block a user