feat(waiter): close with unpaid items as a setting, combine lines, seats (platform-v2 step 4.8a)

The owner's choices for 4.8 (2026-11-18), all configurable:
- Setting orders.close_with_unpaid (default off): when off, the server refuses to close
  an order with unpaid items (pos.order_unpaid) and the phone's CLOSE takes the payment
  first ("instant-pay close"); when on, CLOSE confirms and the items stay unpaid. Manager
  Settings → Operation, next to "auto-close after full payment" (unchanged).
- POST /api/orders/{id}/items/combine: unpaid lines of the same item (choices, note,
  price, course, kitchen state; no discount / deal / tab) become one line; the phone
  offers "Combine into one line" for selected lines or a grouped line. The grouping
  views (identical / same item) stay as they were.
- Seats: the table's seats next to its name on the cards (waiter Settings → Layout, on by
  default) and in the guests dialog, where more guests than seats only shows a hint.
- The table screen's last English-only labels (ADD, PAY, CLOSE, ACTIONS, SERVED, CLEAR,
  ALL) are keys too.
- Tests: test_close_and_combine.py (5), waiter e2e +5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 09:54:37 +02:00
co-authored by Claude Opus 5.5
parent beb53c65bb
commit 198f8ff571
18 changed files with 376 additions and 39 deletions
+15
View File
@@ -0,0 +1,15 @@
import { useTranslation } from '@xenia/i18n'
// The table's seats next to the number of guests (plan step 4.8): a suggestion, never a limit
// — a table for 4 may seat 5 with a chair from another table.
export default function SeatsHint({ seats, count }) {
const { t } = useTranslation('waiter')
if (!seats) return null
const over = count > seats
return (
<p data-testid="seats-hint" data-over={over ? 'true' : 'false'}
style={{ textAlign: 'center', fontSize: 13, margin: '-12px 0 16px', color: over ? 'var(--x-warning)' : 'var(--muted)', fontWeight: over ? 600 : 400 }}>
{over ? t('seats.over', { count, seats }) : t('seats.table', { count: seats })}
</p>
)
}
+26 -6
View File
@@ -1,6 +1,7 @@
import { useRef, useState, useEffect } from 'react'
import { useFormat, useTranslation } from '@xenia/i18n'
import useThemeStore from '../store/themeStore'
import useTableViewStore from '../store/tableViewStore'
import useTableColourStore from '../store/tableColourStore'
import { assetUrl } from '../config/server'
import { fade } from '../logic/colour'
@@ -283,6 +284,25 @@ function Amount({ value, size = 22, color }) {
)
}
// ─── Seats (plan step 4.8) ───────────────────────────────────────────────────
// The table's seats next to its name: a suggestion for seating, never a limit. Shown unless the
// waiter turned it off (Settings → Layout).
function SeatCount({ table }) {
const { t } = useTranslation('waiter')
const show = useTableViewStore(s => s.showSeats)
if (!show || !table.seat_count) return null
return (
<span data-testid="table-seats" title={t('seats.table', { count: table.seat_count })}
style={{ marginLeft: 5, fontSize: '0.55em', fontWeight: 700, opacity: 0.6, verticalAlign: 'middle', whiteSpace: 'nowrap' }}>
<svg width="0.9em" height="0.9em" viewBox="0 0 24 24" fill="none" style={{ verticalAlign: '-0.1em', marginRight: 1 }}>
<circle cx="12" cy="7" r="4" stroke="currentColor" strokeWidth="2.4" />
<path d="M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" />
</svg>
{table.seat_count}
</span>
)
}
// ─── Card variants ────────────────────────────────────────────────────────────
// 1x1 — square-ish, 4 per row. Badges top (up to 2 + +N), name center, KDS badge bottom (replaces status).
@@ -311,7 +331,7 @@ function Card1x1({ table, _order, flags, _waiterObjects, cfg, statusKey, kdsBadg
letterSpacing: -0.5, color: cfg.nameText, lineHeight: 1,
position: 'relative', zIndex: 2,
}}>
{table.label || `T${table.number}`}
{table.label || `T${table.number}`}<SeatCount table={table} />
</div>
{/* bottom strip: KDS badge if present, else status */}
@@ -353,7 +373,7 @@ function Card2x1({ table, _order, flags, _waiterObjects, cfg, statusKey, kdsBadg
letterSpacing: -0.5, color: cfg.nameText, lineHeight: 1, flexShrink: 0,
position: 'relative', zIndex: 2,
}}>
{table.label || `T${table.number}`}
{table.label || `T${table.number}`}<SeatCount table={table} />
</div>
<div style={{
@@ -397,7 +417,7 @@ function Card2x2({ table, order, flags, _waiterObjects, cfg, statusKey, kdsBadge
fontSize: 'clamp(22px, 5.5vw, 36px)', fontWeight: 800,
lineHeight: 1.05, color: cfg.nameText, letterSpacing: -0.5,
}}>
{table.label || `T${table.number}`}
{table.label || `T${table.number}`}<SeatCount table={table} />
</span>
<div style={{ marginTop: 5 }}>
<StatusPill label={t(STATUS_LABELS[statusKey])} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} small />
@@ -448,7 +468,7 @@ function Card4x1({ table, order, flags, _waiterObjects, cfg, statusKey, kdsBadge
letterSpacing: -0.5, color: cfg.nameText, lineHeight: 1, flexShrink: 0,
position: 'relative', zIndex: 2,
}}>
{table.label || `T${table.number}`}
{table.label || `T${table.number}`}<SeatCount table={table} />
</div>
{/* separator dot */}
@@ -506,7 +526,7 @@ function Card4x2({ table, order, flags, waiterObjects, groupName, cfg, statusKey
fontWeight: 800, fontSize: 'clamp(30px, 7vw, 44px)',
letterSpacing: -1.5, lineHeight: 1, color: cfg.nameText,
}}>
{table.label || `T${table.number}`}
{table.label || `T${table.number}`}<SeatCount table={table} />
</div>
{groupName && (
<div style={{
@@ -604,7 +624,7 @@ function Card4x3({ table, order, flags, waiterObjects, groupName, cfg, statusKey
fontWeight: 800, fontSize: 'clamp(28px, 6vw, 40px)',
letterSpacing: -1.5, lineHeight: 1, color: cfg.nameText,
}}>
{table.label || `T${table.number}`}
{table.label || `T${table.number}`}<SeatCount table={table} />
</div>
{groupName && (
<div style={{
+7 -3
View File
@@ -17,6 +17,7 @@ import { money } from '../i18n'
import { LineError, estimate, wireLine } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
import { fade } from '../logic/colour'
import SeatsHint from '../components/SeatsHint'
// A cart item whose option is not on the menu any more (4.4: lines go by id)
const lineErrorText = (err, t) => t('add.optionGone', { product: err.product, what: err.what })
@@ -71,7 +72,7 @@ function GlobalCourseModal({ courses, selected, onSelect, onClose }) {
// ─── Customer count modal ─────────────────────────────────────────────────────
function CustomerCountModal({ value, onChange, onClose }) {
function CustomerCountModal({ value, seats, onChange, onClose }) {
const { t } = useTranslation('waiter')
const [count, setCount] = useState(value ?? 0)
const QUICK = [1, 2, 3, 4, 5, 6]
@@ -84,6 +85,7 @@ function CustomerCountModal({ value, onChange, onClose }) {
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 20px' }}>
{t('detail.guests.question')}
</p>
<SeatsHint seats={seats} count={count} />
{/* Quick pick */}
<div style={{ display: 'flex', gap: 8, justifyContent: 'center', marginBottom: 20 }}>
@@ -181,6 +183,7 @@ export default function AddItemsPage() {
const [searchQuery, setSearchQuery] = useState('')
const [quickToast, setQuickToast] = useState(null) // { product, count }
const [customerCount, setCustomerCount] = useState(null) // number of people at table
const [seats, setSeats] = useState(null) // the table's seats: a suggestion (4.8)
const [customerCountOpen, setCustomerCountOpen] = useState(false)
const [courses, setCourses] = useState([])
const [quickNotes, setQuickNotes] = useState(null) // null = not yet fetched; use drawer's fallback
@@ -206,7 +209,7 @@ export default function AddItemsPage() {
const statusRes = await client.get(`/api/tables/${tableId}/status`)
setOrderId(statusRes.data.active_order_id)
const tbl = statusRes.data.table
if (tbl) setTableLabel(tbl.label || `T${tbl.number}`)
if (tbl) { setTableLabel(tbl.label || `T${tbl.number}`); setSeats(tbl.seat_count ?? null) }
// Load existing customer count from the active order
if (statusRes.data.active_order_id) {
const { data: o } = await client.get(`/api/orders/${statusRes.data.active_order_id}`)
@@ -215,7 +218,7 @@ export default function AddItemsPage() {
} catch {
// Offline — read table label from IDB snapshot
const tbl = await db.pos_tables.get(Number(tableId))
if (tbl) setTableLabel(tbl.label || `T${tbl.number}`)
if (tbl) { setTableLabel(tbl.label || `T${tbl.number}`); setSeats(tbl.seat_count ?? null) }
// orderId stays null — offline orders don't need a pre-existing server order
}
}
@@ -934,6 +937,7 @@ export default function AddItemsPage() {
{customerCountOpen && (
<CustomerCountModal
value={customerCount}
seats={seats}
onChange={v => setCustomerCount(v)}
onClose={() => setCustomerCountOpen(false)}
/>
+9 -1
View File
@@ -172,7 +172,7 @@ const ORDER_ITEM_LAYOUT_OPTIONS = [
function LayoutTab() {
const { t } = useTranslation('waiter')
const { density, setDensity, chipStyle, setChipStyle, kdsDisplayStyle, setKdsDisplayStyle, orderItemLayout, setOrderItemLayout, mergePersist, setMergePersist } = useTableViewStore()
const { density, setDensity, chipStyle, setChipStyle, kdsDisplayStyle, setKdsDisplayStyle, orderItemLayout, setOrderItemLayout, mergePersist, setMergePersist, showSeats, setShowSeats } = useTableViewStore()
const { dark, toggle } = useThemeStore()
return (
@@ -217,6 +217,14 @@ function LayoutTab() {
</section>
{/* Card density */}
{/* Seats on the table cards (4.8) */}
<section>
<h2 style={sectionTitle}>{t('settings.seats.title')}</h2>
<div style={{ marginTop: 14 }}>
<ToggleRow label={t('settings.seats.label')} desc={t('settings.seats.desc')} checked={showSeats !== false} onChange={() => setShowSeats(!(showSeats !== false))} />
</div>
</section>
<section>
<h2 style={sectionTitle}>{t('settings.density.title')}</h2>
<p style={sectionSub}>{t('settings.density.sub')}</p>
+60 -18
View File
@@ -15,6 +15,7 @@ import usePaymentSettingsStore from '../store/paymentSettingsStore'
import useTableViewStore from '../store/tableViewStore'
import { useTranslation } from '@xenia/i18n'
import { fade } from '../logic/colour'
import SeatsHint from '../components/SeatsHint'
const fmtPrice = money
@@ -24,6 +25,11 @@ const MERGE_OFF = 'off'
const MERGE_IDENTICAL = 'identical' // same product + options + price
const MERGE_SAME_ITEM = 'same_item' // same product + same effective unit price
// The real order lines behind what's on screen (a grouped line stands for several)
function combineIds(items) {
return items.flatMap(i => i._sourceIds ?? [i.id]).filter(id => typeof id === 'number')
}
// Returns a stable string key for grouping under MERGE_IDENTICAL
function identicalKey(item) {
const effPrice = ((item.unit_price ?? 0) + (item.price_adjustment ?? 0)).toFixed(4)
@@ -243,7 +249,7 @@ function PriceAdjustModal({ item, onConfirm, onClose }) {
// ─── Item action modal (long-press) ──────────────────────────────────────────
function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCancel, canCancel, cancelNeedsApproval, priceAdjAllowed, priceNeedsApproval, canMove, onAdjustPrice, onClose }) {
function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCancel, onCombine, canCancel, cancelNeedsApproval, priceAdjAllowed, priceNeedsApproval, canMove, onAdjustPrice, onClose }) {
const { t } = useTranslation('waiter')
const { items, singleStacked, multiSelect } = target
const label = multiSelect
@@ -295,6 +301,22 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
onClick: onMoveToTable,
enabled: true,
}] : []),
// 4.8: lines of the same item ordered at different times become one (the server checks
// they really are the same: choices, note, price, kitchen state)
...(canMove && combineIds(items).length > 1 && items.every(i => i.product_id === items[0].product_id && i.status === 'active') ? [{
key: 'combine',
color: 'var(--x-info)',
iconBg: 'rgb(var(--x-info-rgb) / 0.15)',
label: t('detail.item.combine'),
sub: t('detail.item.combineSub', { count: combineIds(items).length }),
icon: (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
<path d="M4 6h10M4 12h16M4 18h10M17 4l3 2-3 2M17 16l3 2-3 2" stroke="var(--x-info)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
),
onClick: onCombine,
enabled: true,
}] : []),
...(canMove && singleStacked && !multiSelect ? [{
key: 'split',
color: 'var(--x-info)',
@@ -578,7 +600,7 @@ function ActionsSheet({ order, _tableId, isStandalone, onClose, onTransfer, onMe
<div className="modal-overlay modal-overlay--top" onClick={onClose}>
<div className="modal-sheet modal-sheet--top" onClick={e => e.stopPropagation()} style={{ gap: 0 }}>
<div className="modal-handle" />
<h2 className="modal-title" style={{ marginBottom: 16 }}>ACTIONS</h2>
<h2 className="modal-title" style={{ marginBottom: 16 }}>{t('detail.btn.actions')}</h2>
{actions.map((a, i) => (
<button
key={i}
@@ -1009,7 +1031,7 @@ function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, o
// ─── Customer count modal ─────────────────────────────────────────────────────
function CustomerCountModal({ value, onChange, onClose }) {
function CustomerCountModal({ value, seats, onChange, onClose }) {
const { t } = useTranslation('waiter')
const [count, setCount] = useState(value ?? 0)
const QUICK = [1, 2, 3, 4, 5, 6]
@@ -1021,6 +1043,7 @@ function CustomerCountModal({ value, onChange, onClose }) {
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 20px' }}>
{t('detail.guests.question')}
</p>
<SeatsHint seats={seats} count={count} />
<div style={{ display: 'flex', gap: 8, justifyContent: 'center', marginBottom: 20 }}>
{QUICK.map(n => (
<button key={n} onClick={() => setCount(n)} style={{
@@ -1057,6 +1080,7 @@ export default function TableDetailPage() {
const navigate = useNavigate()
const [table, setTable] = useState(null)
const [closeUnpaidAllowed, setCloseUnpaidAllowed] = useState(false) // 4.8: venue setting
const [order, setOrder] = useState(null)
const [loading, setLoading] = useState(true)
const [paying, setPaying] = useState(false)
@@ -1246,7 +1270,10 @@ export default function TableDetailPage() {
useEffect(() => {
getVenueSettings()
.then(r => setCardEnabled(r.data?.['payments.card_enabled']?.value === 'true'))
.then(r => {
setCardEnabled(r.data?.['payments.card_enabled']?.value === 'true')
setCloseUnpaidAllowed(r.data?.['orders.close_with_unpaid']?.value === 'true')
})
.catch(() => {})
}, [])
@@ -1648,7 +1675,7 @@ export default function TableDetailPage() {
}}
>
<span style={{ fontSize: 14 }}>⚡</span>
<span>ACTIONS</span>
<span>{t('detail.btn.actions')}</span>
</button>
)}
</div>
@@ -1867,7 +1894,7 @@ export default function TableDetailPage() {
border: 'none', cursor: 'pointer',
fontSize: 13, fontWeight: 700, letterSpacing: 0.5,
}}
>CLEAR</button>
>{t('detail.btn.clear')}</button>
{/* ALL */}
{!allActiveSelected && (
@@ -1881,7 +1908,7 @@ export default function TableDetailPage() {
border: 'none', cursor: 'pointer',
fontSize: 13, fontWeight: 700, letterSpacing: 0.5,
}}
>ALL</button>
>{t('detail.btn.all')}</button>
)}
{/* SERVED — mark selected as served */}
@@ -1896,7 +1923,7 @@ export default function TableDetailPage() {
cursor: 'pointer',
fontSize: 13, fontWeight: 700, letterSpacing: 0.5,
}}
>SERVED</button>
>{t('detail.btn.served')}</button>
{/* ACTIONS — opens item action modal */}
<button
@@ -1913,7 +1940,7 @@ export default function TableDetailPage() {
border: 'none', cursor: 'pointer',
fontSize: 13, fontWeight: 700, letterSpacing: 0.5,
}}
>ACTIONS</button>
>{t('detail.btn.actions')}</button>
</div>
)}
</>
@@ -1957,7 +1984,7 @@ export default function TableDetailPage() {
border: 'none', cursor: 'pointer',
fontSize: 13, fontWeight: 700, letterSpacing: 0.5,
}}
>CLEAR</button>
>{t('detail.btn.clear')}</button>
<button
onClick={() => doMarkServed(paidSelectedIds)}
@@ -1970,7 +1997,7 @@ export default function TableDetailPage() {
cursor: 'pointer',
fontSize: 13, fontWeight: 700, letterSpacing: 0.5,
}}
>SERVED</button>
>{t('detail.btn.served')}</button>
<button
onClick={() => {
@@ -2029,7 +2056,7 @@ export default function TableDetailPage() {
onClick={() => navigate(addItemsPath)}
style={{ borderRadius: 999, flex: 1 }}
>
<span style={{ marginRight: 6 }}>+</span>ADD
<span style={{ marginRight: 6 }}>+</span>{t('detail.btn.add')}
</button>
{canPay && (
@@ -2042,7 +2069,7 @@ export default function TableDetailPage() {
>
{paying ? '…' : (
<>
<span>€ PAY</span>
<span>{t('detail.btn.pay')}</span>
{selectedIds.length > 0 && (
<span style={{
background: 'rgb(var(--x-scrim-rgb) / 0.25)', color: 'var(--x-on-colour)',
@@ -2060,14 +2087,16 @@ export default function TableDetailPage() {
className="btn btn--danger"
onClick={() => {
if (isOffline) return
if (!allPaid) setConfirmPayAndClose(true)
// unpaid items: take the payment first ("instant-pay close"), unless the venue lets
// an order close with unpaid items (they are written off; 4.8 setting)
if (!allPaid && !closeUnpaidAllowed) setConfirmPayAndClose(true)
else setConfirmClose(true)
}}
disabled={isOffline}
style={{ borderRadius: 999, flex: 1, opacity: isOffline ? 0.4 : 1 }}
title={isOffline ? t('detail.notOffline') : undefined}
>
<span style={{ marginRight: 6 }}>✕</span>CLOSE
<span style={{ marginRight: 6 }}>✕</span>{t('detail.btn.close')}
</button>
)}
</div>
@@ -2168,6 +2197,18 @@ export default function TableDetailPage() {
setItemActionTarget(null)
setCancelConfirm({ mode: 'items', ids })
}}
onCombine={async () => {
const ids = combineIds(itemActionTarget.items)
setItemActionTarget(null)
try {
await client.post(`/api/orders/${order.id}/items/combine`, { item_ids: ids })
setSelectedIds([])
setVirtualItems(null)
await load()
} catch (err) {
setError(apiError(err, t('detail.err.combine')))
}
}}
onClose={() => setItemActionTarget(null)}
/>
)}
@@ -2217,6 +2258,7 @@ export default function TableDetailPage() {
{customerCountOpen && (
<CustomerCountModal
value={customerCount}
seats={table?.seat_count}
onChange={async (v) => {
setCustomerCount(v)
if (order) {
@@ -2288,14 +2330,14 @@ export default function TableDetailPage() {
<div className="modal-handle" />
<h2 className="modal-title">{t('detail.close.title')}</h2>
<p style={{ color: 'var(--x-ink-2)', textAlign: 'center', marginBottom: 24 }}>
{t('detail.close.body')}
{allPaid ? t('detail.close.body') : t('detail.close.unpaid', { count: activeItems.length })}
</p>
<div style={{ display: 'flex', gap: 12 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={() => setConfirmClose(false)}>
{t('common.cancel')}
</button>
<button className="btn btn--danger" style={{ flex: 1 }} onClick={closeOrder}>
CLOSE
<button className="btn btn--danger" style={{ flex: 1 }} onClick={closeOrder} data-testid="close-confirm">
{t('detail.btn.close')}
</button>
</div>
</div>
+2
View File
@@ -18,6 +18,7 @@ const useTableViewStore = create(
activeZoneTab: 'all',
chipStyle: 'icon_short', // 'full' | 'short' | 'icon_full' | 'icon_short' | 'icon'
tabSwitcherStyle: 'text', // 'text' | 'icon'
showSeats: true, // the table's seats on its card (4.8)
// Footer nav settings
// navStyle: 'triple' | 'icon_navbar'
@@ -35,6 +36,7 @@ const useTableViewStore = create(
setActiveZoneTab: (activeZoneTab) => set({ activeZoneTab }),
setChipStyle: (chipStyle) => set({ chipStyle }),
setTabSwitcherStyle: (tabSwitcherStyle) => set({ tabSwitcherStyle }),
setShowSeats: (showSeats) => set({ showSeats }),
setNavStyle: (navStyle) => set({ navStyle }),
setNavItems: (navItems) => set({ navItems }),
setTripleItems: (tripleItems) => set({ tripleItems }),