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
+57 -1
View File
@@ -20,6 +20,9 @@ import PriceReason from '../components/PriceReason'
import { priceReasonText } from '../logic/priceRules'
import PriceHistory from '../components/PriceHistory'
import MoveHistory, { MovedOrderBanner } from '../components/MoveHistory'
import QuantityModal from '../components/QuantityModal'
import { useQuantityMode } from '../hooks/useQuantityMode'
import { canChangeQuantity } from '../logic/lines'
import { usePriceRules } from '../hooks/usePriceRules'
import { fade } from '../logic/colour'
import SeatsHint from '../components/SeatsHint'
@@ -266,7 +269,7 @@ function PriceAdjustModal({ item, rules, error, onConfirm, onClose }) {
// ─── Item action modal (long-press) ──────────────────────────────────────────
function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCancel, onCombine, canCancel, cancelNeedsApproval, priceAdjAllowed, priceNeedsApproval, canMove, onAdjustPrice, canSeePriceHistory, onPriceHistory, movedLine, onMoveHistory, onClose }) {
function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCancel, onCombine, canCancel, cancelNeedsApproval, priceAdjAllowed, priceNeedsApproval, canMove, onAdjustPrice, canSeePriceHistory, onPriceHistory, movedLine, onMoveHistory, canChangeQty, onChangeQty, onClose }) {
const { t } = useTranslation('waiter')
const { items, singleStacked, multiSelect } = target
const label = multiSelect
@@ -274,6 +277,22 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
: items[0]?.product?.name || `#${items[0]?.product_id}`
const actionRows = [
// 6F.5: correct how many there are, without sending it to the kitchen again
...(!multiSelect && canChangeQty ? [{
key: 'change_quantity',
color: 'var(--x-accent)',
iconBg: 'rgb(var(--x-accent-rgb) / 0.15)',
label: t('quantity.title'),
sub: t('quantity.actionSub'),
icon: (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
<path d="M5 12h4M7 10v4M15 12h4" stroke="var(--x-accent)" strokeWidth="2" strokeLinecap="round" />
<rect x="2" y="5" width="20" height="14" rx="3" stroke="var(--x-accent)" strokeWidth="2" />
</svg>
),
onClick: onChangeQty,
enabled: true,
}] : []),
// 6F.4: where this line has been (tables, orders), however many moves
...(!multiSelect && movedLine ? [{
key: 'move_history',
@@ -1184,6 +1203,12 @@ export default function TableDetailPage() {
const [priceEventsMap, setPriceEventsMap] = useState({})
const [moves, setMoves] = useState({ order: [], items: {} }) // 6F.4: where the order and its lines came from
const [moveSheet, setMoveSheet] = useState(null) // { title, subtitle, moves, itemId }
// 6F.5: a line's quantity (no new ticket) and "+1" (one more, sent as new)
const quantityMode = useQuantityMode()
const quantityAccess = useAllowed('ordering.items.change_quantity')
const [qtyItem, setQtyItem] = useState(null)
const [qtyError, setQtyError] = useState('')
const [qtyBusy, setQtyBusy] = useState(false)
const [cancelConfirm, setCancelConfirm] = useState(null) // null | { mode: 'items', ids: [...] } | { mode: 'order' }
const [paidSelectedIds, setPaidSelectedIds] = useState([])
@@ -1938,6 +1963,12 @@ export default function TableDetailPage() {
waiterMap={waiterMap}
priceEventsMap={priceEventsMap}
movedItems={moves.items}
onOneMore={canInteract && !paying && !isOffline ? async (item, qty) => {
try {
await client.post(`/api/orders/${order.id}/items/${item.id}/again`, { quantity: qty })
await load()
} catch (err) { setError(apiError(err, t('detail.err.again'))) }
} : undefined}
onLongPressItem={(item) => {
if (selectedIds.length > 1) {
const items = displayActiveItems.filter(i => selectedIds.includes(i.id))
@@ -2027,6 +2058,12 @@ export default function TableDetailPage() {
<>
<OrderSummary
order={{ ...order, items: paidItems }}
onOneMore={canInteract && !paying && !isOffline ? async (item, qty) => { // 6F.5: the beer already paid for
try {
await client.post(`/api/orders/${order.id}/items/${item.id}/again`, { quantity: qty })
await load()
} catch (err) { setError(apiError(err, t('detail.err.again'))) }
} : undefined}
selectable={canInteract}
selectedIds={paidSelectedIds}
waiterMap={waiterMap}
@@ -2265,6 +2302,13 @@ export default function TableDetailPage() {
}}
canSeePriceHistory={seesPriceChanges && !isOffline}
movedLine={!!moves.items[itemActionTarget.items[0]?.id]}
canChangeQty={quantityAccess !== 'no' && !isOffline && canChangeQuantity(itemActionTarget.items[0], quantityMode)}
onChangeQty={() => {
const item = itemActionTarget.items[0]
setItemActionTarget(null)
setQtyError('')
setQtyItem(item)
}}
onMoveHistory={() => {
const item = itemActionTarget.items[0]
setItemActionTarget(null)
@@ -2320,6 +2364,18 @@ export default function TableDetailPage() {
{historyItem && <PriceHistory orderId={order.id} item={historyItem} onClose={() => setHistoryItem(null)} />}
{moveSheet && <MoveHistory {...moveSheet} onClose={() => setMoveSheet(null)} />}
{qtyItem && (
<QuantityModal item={qtyItem} mode={quantityMode} error={qtyError} busy={qtyBusy}
onClose={() => { setQtyItem(null); setQtyError('') }}
onSave={async (quantity, ticket) => {
setQtyBusy(true); setQtyError('')
try {
await client.post(`/api/orders/${order.id}/items/${qtyItem.id}/quantity`, { quantity, print_cancellation: ticket })
setQtyItem(null)
await load()
} catch (err) { setQtyError(apiError(err, t('detail.err.quantity'))) } finally { setQtyBusy(false) }
}} />
)}
{/* Cancel confirmation */}
{cancelConfirm && (