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
+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)}
/>