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:
@@ -18,7 +18,7 @@ import { useCan, useModule } from '@xenia/access'
|
||||
import { EmptyState, IconButton, Input, Spinner, useToast } from '@xenia/ui'
|
||||
import { useLiveEvent } from '../../device/context'
|
||||
import { playChime } from './chime'
|
||||
import { addLine, categoriesWithProducts, defaultSelection, needsChoices, productsIn, searchProducts, toLine, unitOf } from './logic/cart'
|
||||
import { addLine, categoriesWithProducts, forSalesPoint, salesPointFor, defaultSelection, needsChoices, productsIn, searchProducts, toLine, unitOf } from './logic/cart'
|
||||
import { findOnline, ONLINE_LISTS } from './logic/online'
|
||||
import { zoneCounts } from './logic/tables'
|
||||
import OnlinePanel from './OnlinePanel'
|
||||
@@ -91,10 +91,14 @@ function Counter({ menu, t }) {
|
||||
const setCart = atTable ? setTableCart : setSaleCart
|
||||
const leaveTable = () => { setTableId(null); setTableCart([]) }
|
||||
|
||||
// what's sold for this order (phase 3S): eating in at a table, or the sale's order type,
|
||||
// each product at that sales point's price
|
||||
const point = salesPointFor(atTable ? 'here' : orderType)
|
||||
const sellable = useMemo(() => forSalesPoint(menu.products, point), [menu.products, point])
|
||||
const byId = useMemo(() => new Map(menu.products.map(p => [p.id, p])), [menu.products])
|
||||
const categories = useMemo(() => categoriesWithProducts(menu.categories, menu.products), [menu])
|
||||
const shown = useMemo(() => (query.trim() ? searchProducts(menu.products, query) : productsIn(menu.products, category)),
|
||||
[menu.products, query, category])
|
||||
const categories = useMemo(() => categoriesWithProducts(menu.categories, sellable), [menu.categories, sellable])
|
||||
const shown = useMemo(() => (query.trim() ? searchProducts(sellable, query) : productsIn(sellable, category)),
|
||||
[sellable, query, category])
|
||||
const counts = useMemo(() => zoneCounts(tables.data?.tables ?? []), [tables.data])
|
||||
|
||||
const tap = product => {
|
||||
|
||||
@@ -221,3 +221,16 @@ export function splitPayments(methods, totals) {
|
||||
export const DISCOUNTS = [0, 5, 10, 15, 20, 25, 50, 100]
|
||||
|
||||
const round2 = n => Math.round(n * 100) / 100
|
||||
|
||||
/** The counter's sales point for an order type (phase 3S; backend pos_cart.point_for). */
|
||||
export function salesPointFor(orderType) {
|
||||
return orderType === 'takeaway' ? 'in_store_takeaway' : 'in_store'
|
||||
}
|
||||
|
||||
/** The menu's products sold at a sales point, each with that sales point's price (GET
|
||||
* /api/pos/menu sends `sold_at` and `prices`; older answers: everything, `price`). */
|
||||
export function forSalesPoint(products, point) {
|
||||
return products
|
||||
.filter(p => !p.sold_at || p.sold_at.includes(point))
|
||||
.map(p => (p.prices?.[point] != null ? { ...p, price: p.prices[point] } : p))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user