feat(backend,waiter,terminal,manager): +1 on a sent line and changing a line's quantity

Owner 2026-11-23 (plan 6F.5). Product flag one_more_enabled (off by default; product editor).
POST /api/orders/{id}/items/{item}/again: a new line like the old one (choices, removed, note,
course), priced now, sent to the kitchen like any new line. Waiter app and the counter's table
panel: +1 beside such lines; the first tap arms it, more taps count up, 'Send +N' sends, 4 s idle
disarms (no stray sends).
POST /api/orders/{id}/items/{item}/quantity: venue setting orders.quantity_change (off | add_only |
add_and_remove, default off), key ordering.items.change_quantity (owner, store manager; Alembic 0049
grants it); up only changes the line, down cuts a cancelled part ('quantity lowered', split_from_id)
and prints a cancellation only when asked (the dialog presets yes while the kitchen hasn't finished).
Waiter: 'Change quantity' in a line's actions (now -> new, -/+). cut_part() now shared with split.
GET /api/orders/{id} items carry the product's one_more_enabled / unit_type, deal ids, split_from_id,
cancel_reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 08:26:46 +02:00
co-authored by Claude Opus 5.5
parent 0a353c5f97
commit 72e175ab73
35 changed files with 813 additions and 35 deletions
+6
View File
@@ -749,6 +749,12 @@ try {
r.check(`${st6} Operation: prices by hand "before sending only", a reason asked, a quick reason added`,
pcMode === 'before_sending' && await settingValue2('orders.price_change_reason') === 'true' && reasonsNow.includes('E2E: birthday'))
await page.getByTestId('setting-orders.price_change').selectOption('anytime')
// 6F.5: changing a sent line's quantity
await page.getByTestId('setting-orders.quantity_change').selectOption('add_only')
let qMode = ''
for (let i = 0; i < 30 && qMode !== 'add_only'; i++) { await sleep(150); qMode = await settingValue2('orders.quantity_change') }
r.check(`${st6} Operation: quantity changes "only add"`, qMode === 'add_only')
await page.getByTestId('setting-orders.quantity_change').selectOption('off')
await page.getByTestId('settings-price-changes').getByRole('switch').first().click()
await sleep(500)
await page.getByTestId('flag-new').click()
+69
View File
@@ -360,6 +360,75 @@ try {
await setting(boss, 'orders.close_with_unpaid', 'false')
}
// ── 6F.5: "+1" on a sent line, and changing a line's quantity ─────────────────────
{
await api('PUT', `/api/products/${plain.id}`, { token: boss, body: { one_more_enabled: true } })
const mariaKeys = (await api('GET', `/api/waiters/${maria.id}/permissions`, { token: boss })).keys
await api('PUT', `/api/waiters/${maria.id}/permissions`, { token: boss,
body: { keys: [...new Set([...mariaKeys, 'ordering.items.change_quantity', 'ordering.orders.cancel'])] } })
await setting(boss, 'orders.quantity_change', 'add_and_remove')
const busyNow = new Set((await api('GET', '/api/orders/', { token: boss })).map(o => o.table_id))
const tm = (await api('GET', '/api/tables/', { token: boss })).find(x => x.is_active !== false && !busyNow.has(x.id))
const om = await api('POST', '/api/orders/', { token: tokenA, body: { table_id: tm.id } })
await api('POST', `/api/orders/${om.id}/items`, { token: tokenA, body: { lines: [{ product_id: plain.id, quantity: 1 }] } })
const count = async () => (await api('GET', `/api/orders/${om.id}`, { token: boss })).items.filter(i => i.status !== 'cancelled').length
await a.goto(`${APP}/tables/${tm.id}`)
await a.reload()
await a.getByTestId('one-more-tap').first().waitFor({ timeout: 10_000 })
// one stray tap sends nothing: it arms, then goes back after 4 s
await a.getByTestId('one-more-tap').first().click()
r.check('6F.5: one tap on +1 only arms it ("Send +1" shows)', await shown(a, 'one-more-send', 3000) && await count() === 1)
await a.screenshot({ path: path.join(OUT, 'waiter-one-more.png') })
await sleep(4600)
r.check('6F.5: …and with no second tap it goes back, nothing sent', !(await a.getByTestId('one-more-send').count()) && await count() === 1)
// tap, tap, Send → 2 more as a new line, sent like any new line
await a.getByTestId('one-more-tap').first().click()
await a.getByTestId('one-more-tap').first().click()
await a.getByTestId('one-more-send').first().click()
const again = await waitFor(async () => {
const o = await api('GET', `/api/orders/${om.id}`, { token: boss })
const live = o.items.filter(i => i.status === 'active')
return live.length === 2 && live[1].quantity === 2 && live[1].product_id === plain.id && o
}, 10_000, 500)
const newLine = again && again.items.filter(i => i.status === 'active')[1]
r.check('6F.5: +1, +1, Send: a new line of 2 for the kitchen (pending, like any new line)', !!newLine && newLine.kds_status === 'pending'
&& newLine.id !== again.items[0].id, JSON.stringify(again?.items?.map(i => [i.id, i.status, i.quantity, i.kds_status, i.printed])))
// change the first line's quantity: 1 → 3 (nothing printed), then 3 → 2 (one cancelled)
const first = again.items.filter(i => i.status === 'active')[0]
const openQty = async () => {
await a.goto(`${APP}/tables/${tm.id}`)
await a.locator('.order-item').first().waitFor({ timeout: 10_000 })
await a.locator('.order-item').first().click()
await a.getByRole('button', { name: 'ACTIONS', exact: true }).last().click()
await a.getByText('Change quantity').first().click({ timeout: 10_000 })
await a.getByTestId('quantity-sheet').waitFor({ timeout: 5000 })
}
await openQty()
await a.getByTestId('quantity-more').click()
await a.getByTestId('quantity-more').click()
r.check('6F.5: the dialog shows now 1 → new 3', (await a.getByTestId('quantity-now').textContent()) === '1' && (await a.getByTestId('quantity-new').textContent()) === '3')
await a.getByTestId('quantity-save').click()
const up = await waitFor(async () => (await api('GET', `/api/orders/${om.id}`, { token: boss })).items.find(i => i.id === first.id)?.quantity === 3, 10_000, 500)
r.check('6F.5: the line is now 3 (no new line, nothing sent again)', !!up && await count() === 2)
await openQty()
await a.getByTestId('quantity-less').click()
r.check('6F.5: lowering asks about a cancellation ticket', await a.getByTestId('quantity-ticket').isVisible())
await a.screenshot({ path: path.join(OUT, 'waiter-quantity.png') })
await a.getByTestId('quantity-save').click()
const down = await waitFor(async () => {
const o = await api('GET', `/api/orders/${om.id}`, { token: boss })
const part = o.items.find(i => i.status === 'cancelled' && i.split_from_id === first.id)
return o.items.find(i => i.id === first.id)?.quantity === 2 && part?.quantity === 1 && part
}, 10_000, 500)
r.check('6F.5: lowered to 2: one cancelled, kept apart ("quantity lowered")', !!down && down.cancel_reason === 'quantity lowered', JSON.stringify(down))
await setting(boss, 'orders.quantity_change', 'off')
await api('PUT', `/api/products/${plain.id}`, { token: boss, body: { one_more_enabled: false } })
await api('PUT', `/api/waiters/${maria.id}/permissions`, { token: boss, body: { keys: mariaKeys } })
await setting(boss, 'orders.close_with_unpaid', 'true')
await api('POST', `/api/orders/${om.id}/close`, { token: boss })
await setting(boss, 'orders.close_with_unpaid', 'false')
}
// ── 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 } })