feat(backend,waiter,manager): moves between tables and orders on the record
Owner 2026-11-23 (plan 6F.4). services/moves.py: every table transfer, lines moved and orders merged
is an order_moves row with its lines (order_move_items: line, quantity then); OrderItem.split_from_id
links a split part to its line, so a part carries the moves made before the split; combining moves
the removed lines' moves to the kept one. Alembic 0048: the tables, the column, and a backfill from
the audit notes written before (note='backfill'). A split part now also keeps the line's price change,
kitchen state, course, cost and names (it used to restart as pending at the menu price).
GET /api/orders/{id}/moves (the order's path, each line's); GET /api/reports/moves (+ export).
Waiter: a moved order's banner (T2 -> T5), moved lines marked, a line's Move history. Manager: the
order's Moves tab, each moved line's path, Reports -> Moves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import { parseNumber, useTranslation } from '@xenia/i18n'
|
||||
import PriceReason from '../components/PriceReason'
|
||||
import { priceReasonText } from '../logic/priceRules'
|
||||
import PriceHistory from '../components/PriceHistory'
|
||||
import MoveHistory, { MovedOrderBanner } from '../components/MoveHistory'
|
||||
import { usePriceRules } from '../hooks/usePriceRules'
|
||||
import { fade } from '../logic/colour'
|
||||
import SeatsHint from '../components/SeatsHint'
|
||||
@@ -265,7 +266,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, onClose }) {
|
||||
function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCancel, onCombine, canCancel, cancelNeedsApproval, priceAdjAllowed, priceNeedsApproval, canMove, onAdjustPrice, canSeePriceHistory, onPriceHistory, movedLine, onMoveHistory, onClose }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const { items, singleStacked, multiSelect } = target
|
||||
const label = multiSelect
|
||||
@@ -273,6 +274,21 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
|
||||
: items[0]?.product?.name || `#${items[0]?.product_id}`
|
||||
|
||||
const actionRows = [
|
||||
// 6F.4: where this line has been (tables, orders), however many moves
|
||||
...(!multiSelect && movedLine ? [{
|
||||
key: 'move_history',
|
||||
color: 'var(--x-info)',
|
||||
iconBg: 'rgb(var(--x-info-rgb) / 0.15)',
|
||||
label: t('moves.lineTitle'),
|
||||
sub: t('moves.lineSub'),
|
||||
icon: (
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M4 7h11l-3-3M20 17H9l3 3" stroke="var(--x-info)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
),
|
||||
onClick: onMoveHistory,
|
||||
enabled: true,
|
||||
}] : []),
|
||||
// 6F.3: who changed this line's price, when, from what, why (ordering.prices.view_changes)
|
||||
...(!multiSelect && canSeePriceHistory && items[0]?.price_adjustment ? [{
|
||||
key: 'price_history',
|
||||
@@ -1166,6 +1182,8 @@ export default function TableDetailPage() {
|
||||
const [customerCountOpen, setCustomerCountOpen] = useState(false)
|
||||
const [showDiscountModal, setShowDiscountModal] = useState(false)
|
||||
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 }
|
||||
const [cancelConfirm, setCancelConfirm] = useState(null) // null | { mode: 'items', ids: [...] } | { mode: 'order' }
|
||||
const [paidSelectedIds, setPaidSelectedIds] = useState([])
|
||||
|
||||
@@ -1331,6 +1349,14 @@ export default function TableDetailPage() {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [order?.id, order?.items?.length])
|
||||
|
||||
// 6F.4: the order's path and its moved lines (a transfer changes the table, a move the items)
|
||||
useEffect(() => {
|
||||
if (!order?.id) { setMoves({ order: [], items: {} }); return }
|
||||
client.get(`/api/orders/${order.id}/moves`)
|
||||
.then(r => setMoves({ order: r.data?.order ?? [], items: r.data?.items ?? {} }))
|
||||
.catch(() => {})
|
||||
}, [order?.id, order?.items?.length, order?.table_id])
|
||||
|
||||
// Handle ?action= param from table list long-press quick actions
|
||||
useEffect(() => {
|
||||
const action = searchParams.get('action')
|
||||
@@ -1903,6 +1929,7 @@ export default function TableDetailPage() {
|
||||
|
||||
{activeTab === 'active' && (
|
||||
<>
|
||||
<MovedOrderBanner moves={moves.order} onOpen={() => setMoveSheet({ title: t('moves.orderTitle'), moves: moves.order })} />
|
||||
<OrderSummary
|
||||
order={{ ...order, items: displayActiveItems }}
|
||||
selectable={canInteract && !paying}
|
||||
@@ -1910,6 +1937,7 @@ export default function TableDetailPage() {
|
||||
onToggle={toggleItem}
|
||||
waiterMap={waiterMap}
|
||||
priceEventsMap={priceEventsMap}
|
||||
movedItems={moves.items}
|
||||
onLongPressItem={(item) => {
|
||||
if (selectedIds.length > 1) {
|
||||
const items = displayActiveItems.filter(i => selectedIds.includes(i.id))
|
||||
@@ -2236,6 +2264,12 @@ export default function TableDetailPage() {
|
||||
setPriceAdjustItem(item)
|
||||
}}
|
||||
canSeePriceHistory={seesPriceChanges && !isOffline}
|
||||
movedLine={!!moves.items[itemActionTarget.items[0]?.id]}
|
||||
onMoveHistory={() => {
|
||||
const item = itemActionTarget.items[0]
|
||||
setItemActionTarget(null)
|
||||
setMoveSheet({ title: t('moves.lineTitle'), subtitle: item.product_name || item.product?.name, moves: moves.items[item.id] ?? [], itemId: item.id })
|
||||
}}
|
||||
onPriceHistory={() => {
|
||||
const item = itemActionTarget.items[0]
|
||||
setItemActionTarget(null)
|
||||
@@ -2285,6 +2319,7 @@ export default function TableDetailPage() {
|
||||
)}
|
||||
|
||||
{historyItem && <PriceHistory orderId={order.id} item={historyItem} onClose={() => setHistoryItem(null)} />}
|
||||
{moveSheet && <MoveHistory {...moveSheet} onClose={() => setMoveSheet(null)} />}
|
||||
|
||||
{/* Cancel confirmation */}
|
||||
{cancelConfirm && (
|
||||
|
||||
Reference in New Issue
Block a user