feat(connect): the site side of online orders: fee line, customer's time, price check
Plan phase 3S, step S.5. - Pull: an online order keeps the customer's time (orders.requested_for, None = as soon as possible) and delivery area; quick options are stored in the site's entry shape; items get their cost snapshot. - The delivery fee is its own order line: a system product (products.system_key "delivery_fee", lifecycle "system", sold nowhere; services/system_products.py), created on first use in the venue's language with the VAT group most products use. Added printed and served, so kitchen tickets and the KDS never see it; paid at the counter with the items, counted in the shift, on the fiscal receipt with its VAT group. Never listed in the catalogue (products list, export, edit endpoints → 404) and never added by hand. - Price check (services/online_check.py): each line priced as the snapshot prices it, at the order's time, and the fee through the same engine with the site's rules and the cloud's area id; differences kept on orders.online_price_diff and shown. The customer pays what the cloud charged. - Counter: time chip (or as soon as possible), area, fee line, price warning; takeaway is its own kind (was shown as "at the venue") and finishes as "collected". KDS cards show the online reference and the time; kitchen tickets print the reference, the type and the time. - Manager: Online ordering → "The fee on the receipt" (name, VAT group; PUT /api/connect/fees/fee-product, fees.vat_group_unknown); the online orders page shows the time, area and price warning. - Migration 0019. Tests: tests/test_online_site_side.py (6), terminal unit test, e2e (terminal: fee, time, warning, paid in full; manager: fee line settings). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ export function nextStep(order) {
|
||||
switch (order.status) {
|
||||
case 'pending_acceptance': return { kind: 'answer' }
|
||||
case 'accepted': return { kind: 'status', to: 'preparing' }
|
||||
case 'preparing': return { kind: 'status', to: order.type === 'delivery' ? 'out_for_delivery' : 'ready' }
|
||||
case 'preparing': return { kind: 'status', to: kindOf(order) === 'delivery' ? 'out_for_delivery' : 'ready' }
|
||||
case 'ready':
|
||||
case 'out_for_delivery': return { kind: 'finish', pay: order.unpaid > 0.004 }
|
||||
default: return null
|
||||
@@ -32,3 +32,25 @@ export function findOnline(board, id) {
|
||||
export function minutesSince(iso, now = Date.now()) {
|
||||
return Math.max(0, Math.floor((now - Date.parse(iso)) / 60_000))
|
||||
}
|
||||
|
||||
/** What kind of online order: 'delivery' | 'takeaway' | 'dine_in' (a QR-menu table order). */
|
||||
export function kindOf(order) {
|
||||
return order?.type === 'delivery' || order?.type === 'takeaway' ? order.type : 'dine_in'
|
||||
}
|
||||
|
||||
/** The word the finish button uses: delivered (delivery), collected (takeaway), served. */
|
||||
export function finishWord(order) {
|
||||
return { delivery: 'delivered', takeaway: 'collected', dine_in: 'served' }[kindOf(order)]
|
||||
}
|
||||
|
||||
/** The site's price check of a pulled order (phase 3S, S.5; GET /board `price_diff`) as rows:
|
||||
* [{ key, name, cloud, site, reason }]; reason: price | not_sold | option (lines),
|
||||
* fee_price | fee_area | fee_minimum (the delivery fee). [] when the prices matched. */
|
||||
export function diffRows(diff) {
|
||||
if (!diff) return []
|
||||
const rows = (diff.lines ?? []).map((l, i) => ({
|
||||
key: `l${i}`, name: l.name, quantity: l.quantity, cloud: l.cloud, site: l.site, reason: l.reason,
|
||||
}))
|
||||
if (diff.fee) rows.push({ key: 'fee', name: null, quantity: 1, cloud: diff.fee.cloud, site: diff.fee.site, reason: `fee_${diff.fee.reason}` })
|
||||
return rows
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ export function orderLines(order) {
|
||||
options: optionNames(i.selected_options),
|
||||
notes: i.notes,
|
||||
kds: i.kds_status ?? 'pending',
|
||||
system: i.system_key ?? null, // a line the system added: 'delivery_fee' (phase 3S)
|
||||
}))
|
||||
return [...lines.filter(l => !l.paid), ...lines.filter(l => l.paid)]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user