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:
@@ -7,9 +7,12 @@
|
||||
// useModule('kds') · useCan('catalog.menu.manage') · useCan([a, b]) (any) · useCan([a, b], { all: true })
|
||||
// <Can perm="…" fallback={…}> · <RequireModule module="…">
|
||||
//
|
||||
// SALES_POINTS, IN_PERSON, DIGITAL where an order is sold (phase 3S)
|
||||
//
|
||||
// UI hiding only: the backend checks every request (CS-14).
|
||||
|
||||
export { AccessProvider } from './AccessProvider.jsx'
|
||||
export { useAccess, useModule, useCan, can } from './hooks.js'
|
||||
export { Can, RequireModule, ModuleOff, NoAccess } from './guards.jsx'
|
||||
export { OverrideHost } from './OverrideHost.jsx'
|
||||
export { SALES_POINTS, IN_PERSON, DIGITAL, normalizeSalesPoints } from './salesPoints.js'
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Sales points (plan phase 3S): where an order is sold. The same fixed list as the backend's
|
||||
// core/sales_points.py; labels are common:salesPoints.<key>.name / .hint.
|
||||
export const SALES_POINTS = ['in_store', 'in_store_takeaway', 'qr_table', 'online_takeaway', 'online_delivery', 'online_preorder']
|
||||
export const IN_PERSON = ['in_store', 'in_store_takeaway']
|
||||
export const DIGITAL = ['qr_table', 'online_takeaway', 'online_delivery', 'online_preorder']
|
||||
|
||||
// the order_channel condition's values before phase 3S → sales points (backend LEGACY_CHANNELS)
|
||||
const LEGACY = { pos: ['in_store'], takeaway: ['in_store_takeaway'], online: ['online_takeaway', 'online_delivery', 'online_preorder'], qr: ['qr_table'] }
|
||||
|
||||
/** Sales points from a list that may hold old channel names; unknown values dropped, no duplicates. */
|
||||
export function normalizeSalesPoints(values) {
|
||||
const out = []
|
||||
for (const v of values ?? []) {
|
||||
for (const sp of SALES_POINTS.includes(v) ? [v] : (LEGACY[v] ?? [])) if (!out.includes(sp)) out.push(sp)
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Sales points (phase 3S): the same list and old-value mapping as core/sales_points.py.
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { normalizeSalesPoints, SALES_POINTS } from '../src/salesPoints.js'
|
||||
|
||||
test('sales points: the fixed list and the old channel names', () => {
|
||||
assert.deepEqual(SALES_POINTS, ['in_store', 'in_store_takeaway', 'qr_table', 'online_takeaway', 'online_delivery', 'online_preorder'])
|
||||
assert.deepEqual(normalizeSalesPoints(['pos', 'qr']), ['in_store', 'qr_table'])
|
||||
assert.deepEqual(normalizeSalesPoints(['online', 'online_delivery', 'nope']), ['online_takeaway', 'online_delivery', 'online_preorder'])
|
||||
assert.deepEqual(normalizeSalesPoints(undefined), [])
|
||||
})
|
||||
@@ -50,5 +50,31 @@
|
||||
"noAccessTitle": "Δεν έχετε πρόσβαση σε αυτή τη σελίδα",
|
||||
"noAccessBody": "Ζητήστε την από έναν υπεύθυνο, αν τη χρειάζεστε.",
|
||||
"loadFailed": "Δεν φορτώθηκαν οι ρυθμίσεις του καταστήματος"
|
||||
},
|
||||
"salesPoints": {
|
||||
"in_store": {
|
||||
"name": "Στο κατάστημα",
|
||||
"hint": "Ταμείο και σερβιτόροι, για κατανάλωση εντός"
|
||||
},
|
||||
"in_store_takeaway": {
|
||||
"name": "Πακέτο από το ταμείο",
|
||||
"hint": "Ταμείο, για πακέτο (και τηλεφωνικές παραγγελίες που παραδίδει το κατάστημα)"
|
||||
},
|
||||
"qr_table": {
|
||||
"name": "QR μενού στο τραπέζι",
|
||||
"hint": "Οι πελάτες παραγγέλνουν από το QR μενού στο τραπέζι τους"
|
||||
},
|
||||
"online_takeaway": {
|
||||
"name": "Online, πακέτο",
|
||||
"hint": "Παραγγελία online, παραλαβή από το κατάστημα"
|
||||
},
|
||||
"online_delivery": {
|
||||
"name": "Online, διανομή",
|
||||
"hint": "Παραγγελία online, με παράδοση"
|
||||
},
|
||||
"online_preorder": {
|
||||
"name": "Online, με κράτηση",
|
||||
"hint": "Κράτηση online, το φαγητό έτοιμο με την άφιξη"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@
|
||||
"error": "Κάτι πήγε στραβά στον διακομιστή (αίτημα {{request_id}})."
|
||||
},
|
||||
"order": {
|
||||
"not_found": "Η παραγγελία {{order_id}} δεν βρέθηκε."
|
||||
"not_found": "Η παραγγελία {{order_id}} δεν βρέθηκε.",
|
||||
"not_sold_here": "Το {{name}} δεν πωλείται για αυτό το είδος παραγγελίας."
|
||||
},
|
||||
"notification": {
|
||||
"not_found": "Η ειδοποίηση {{notification_id}} δεν βρέθηκε."
|
||||
|
||||
@@ -50,5 +50,31 @@
|
||||
"noAccessTitle": "You don't have access to this page",
|
||||
"noAccessBody": "Ask a manager if you need it.",
|
||||
"loadFailed": "Can't load the venue's settings"
|
||||
},
|
||||
"salesPoints": {
|
||||
"in_store": {
|
||||
"name": "In the shop",
|
||||
"hint": "Counter and waiters, eating in"
|
||||
},
|
||||
"in_store_takeaway": {
|
||||
"name": "Takeaway at the counter",
|
||||
"hint": "Counter, to take away (and phone orders the venue delivers)"
|
||||
},
|
||||
"qr_table": {
|
||||
"name": "QR menu at the table",
|
||||
"hint": "Customers order from the QR menu at their table"
|
||||
},
|
||||
"online_takeaway": {
|
||||
"name": "Online, takeaway",
|
||||
"hint": "Ordered online, collected at the venue"
|
||||
},
|
||||
"online_delivery": {
|
||||
"name": "Online, delivery",
|
||||
"hint": "Ordered online, delivered"
|
||||
},
|
||||
"online_preorder": {
|
||||
"name": "Online, with a reservation",
|
||||
"hint": "Reserved online, food ready on arrival"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@
|
||||
"error": "Something went wrong on the server (request {{request_id}})."
|
||||
},
|
||||
"order": {
|
||||
"not_found": "Order {{order_id}} not found."
|
||||
"not_found": "Order {{order_id}} not found.",
|
||||
"not_sold_here": "{{name}} isn't sold for this kind of order."
|
||||
},
|
||||
"notification": {
|
||||
"not_found": "Notification {{notification_id}} not found."
|
||||
|
||||
Reference in New Issue
Block a user