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:
@@ -1,5 +1,6 @@
|
||||
from core.timeutil import venue_date, utcnow
|
||||
import json
|
||||
from core import sales_points
|
||||
from datetime import datetime, timezone
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from fastapi.responses import JSONResponse
|
||||
@@ -57,6 +58,7 @@ def _serialize_product(p: Product) -> dict:
|
||||
return {
|
||||
"name": p.name, "base_price": p.base_price, "is_available": p.is_available,
|
||||
"lifecycle_status": p.lifecycle_status, "sort_order": p.sort_order,
|
||||
"sold_at": sales_points.sold_at(p),
|
||||
"quick_options": quick_options, "options": options,
|
||||
"ingredients": ingredients, "preference_sets": preference_sets,
|
||||
}
|
||||
@@ -183,6 +185,8 @@ def import_catalog(payload: dict, db: Session = Depends(get_db), user: User = De
|
||||
existing.is_available = prod_data.get("is_available", True)
|
||||
existing.lifecycle_status = prod_data.get("lifecycle_status", "active")
|
||||
existing.sort_order = prod_data.get("sort_order", 0)
|
||||
if "sold_at" in prod_data: # phase 3S; older bundles: unchanged
|
||||
existing.sold_at = sales_points.dump(prod_data["sold_at"])
|
||||
db.flush()
|
||||
product = existing
|
||||
else:
|
||||
@@ -192,6 +196,7 @@ def import_catalog(payload: dict, db: Session = Depends(get_db), user: User = De
|
||||
is_available=prod_data.get("is_available", True),
|
||||
lifecycle_status=prod_data.get("lifecycle_status", "active"),
|
||||
sort_order=prod_data.get("sort_order", 0),
|
||||
sold_at=sales_points.dump(prod_data.get("sold_at", sales_points.ALL)),
|
||||
)
|
||||
db.add(product)
|
||||
db.flush()
|
||||
|
||||
Reference in New Issue
Block a user