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
+38 -1
View File
@@ -15,7 +15,7 @@ const vite = await startViteNative({ port: 5181, backendUrl: backend.url })
const APP = 'http://localhost:5181'
const TOKEN_KEY = 'xenia:dev:token'
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
const r = reporter('waiter: sign-in v2, lock, approvals (4.2), keys (4.3), server prices (4.4), languages (4.5), table history (4.7), look (4.6)')
const r = reporter('waiter: sign-in v2, lock, approvals (4.2), keys (4.3), server prices (4.4), languages (4.5), table history (4.7), look (4.6), owner choices (4.8)')
const errors = []
let failures = 0
@@ -274,6 +274,43 @@ try {
await a.getByTestId('menu-language-en').click()
await waitFor(async () => (await navText()).includes('Tables'), 8000, 300)
// ── 4.8: the owner's choices: combine lines, close with unpaid items, seats ─────────
const t6 = free.find(t => t.id !== t4.id && t.id !== t5.id)
const o6 = await api('POST', '/api/orders/', { token: tokenA, body: { table_id: t6.id } })
for (let i = 0; i < 3; i++) await api('POST', `/api/orders/${o6.id}/items`, { token: tokenA, body: { lines: [{ product_id: plain.id, quantity: 2 }] } })
await a.goto(`${APP}/tables/${t6.id}`)
await a.locator('.order-item').first().waitFor({ timeout: 10_000 })
for (let i = 0; i < 3; i++) await a.locator('.order-item').nth(i).click()
await a.getByRole('button', { name: 'ACTIONS', exact: true }).last().click()
await a.getByText('Combine into one line').click()
const combined = await waitFor(async () => {
const o = await api('GET', `/api/orders/${o6.id}`, { token: boss })
const live = o.items.filter(i => i.status === 'active')
return live.length === 1 && live[0].quantity === 6 && o
}, 10_000, 500)
r.check('4.8: three lines of the same item (2 + 2 + 2) combined into one line of 6', !!combined)
// closing with an unpaid item: by default the payment comes first; the venue may allow closing
await a.goto(`${APP}/tables/${t6.id}`)
await a.getByRole('button', { name: /CLOSE/ }).last().click()
r.check('4.8: CLOSE with unpaid items asks for the payment first (default)', await a.getByText('Confirm payment and close').isVisible().catch(() => false))
await a.keyboard.press('Escape').catch(() => {})
await setting(boss, 'orders.close_with_unpaid', 'true')
await a.goto(`${APP}/tables/${t6.id}`)
await a.getByRole('button', { name: /CLOSE/ }).last().click()
await a.getByTestId('close-confirm').click({ timeout: 10_000 })
const closed = await waitFor(async () => (await api('GET', `/api/orders/${o6.id}`, { token: boss })).status === 'closed', 10_000, 500)
r.check('4.8: with "close with unpaid items" on, CLOSE closes and the item stays unpaid', !!closed)
await setting(boss, 'orders.close_with_unpaid', 'false')
// seats: a suggestion on the card and in the guests dialog
await api('PUT', `/api/tables/${t6.id}`, { token: boss, body: { seat_count: 4 } })
await a.goto(`${APP}/tables`)
r.check("4.8: the table's seats show on its card", await shown(a, 'table-seats', 10_000))
await a.goto(`${APP}/tables/${t6.id}/add?new=1`)
await a.getByTitle('Number of guests').click()
for (let i = 0; i < 6; i++) await a.locator('.qty-btn').last().click()
r.check('4.8: more guests than seats is allowed, with a hint (not a limit)', await a.getByTestId('seats-hint').getAttribute('data-over') === 'true')
await a.goto(`${APP}/tables`)
// ── 4.6: the look on the shared tokens: the venue's colour and light / dark reach the phone ──
const accentOf = () => a.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--x-accent-rgb').trim())
r.check('4.6: the venue colour (default amber) is on the phone', await a.evaluate(() => document.documentElement.dataset.venueTheme) === 'amber')