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:
@@ -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)}
|
||||
/>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user