feat(waiter): what a waiter may do comes from permission keys (platform-v2 step 4.3)

- Payments: ordering.orders.close checked on pay/close and the counter POS
  (waiters have it by default, owner decision); pay-offline always recorded.
- The venue switches waiter_cancellations / price_adjust / revert are gone:
  ordering.orders.cancel, ordering.prices.modify and the new
  ordering.payments.revert (overridable) decide; moves/split/transfer/merge
  need ordering.orders.open; discounts pricing.discounts.apply; chat chat.use.
- Venue role defaults: role_permissions (Alembic 0024), role_template(role, db),
  GET/PUT /api/waiters/roles/{role}/permissions applying the change to everyone
  with the role; manager Settings -> Operation -> "What each role may do".
  0024 also grants the new key to existing owners and store managers.
- Bootstrap `approvable`; @xenia/access useAllowed(key) -> yes/approve/no.
  The waiter shows each action by key, "with a manager's approval (PIN)" where
  allowed; GET /api/orders/cancel-permissions removed.
- Tests: test_waiter_keys.py (11), access allowed(), waiter.mjs +5, manager.mjs +3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 00:54:08 +02:00
co-authored by Claude Opus 5.5
parent a29a167977
commit 8abe4d92d3
32 changed files with 680 additions and 160 deletions
+3 -5
View File
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState, useCallback } from 'react'
import { useAllowed } from '@xenia/access'
import { useNavigate, useSearchParams } from 'react-router-dom'
import TableCard from '../components/TableCard'
import useAuthStore from '../store/authStore'
@@ -310,7 +311,8 @@ export default function TableListPage() {
const [, setOffline] = useState(false)
const [showFilters, setShowFilters] = useState(false)
const [quickModal, setQuickModal] = useState(null)
const [canCancel, setCanCancel] = useState(false)
// plan 4.3: the key, or a manager's PIN when a manager may approve it
const canCancel = useAllowed('ordering.orders.cancel') !== 'no'
const [cancelConfirm, setCancelConfirm] = useState(null)
// Orders tab filters
const [ordersFilter, setOrdersFilter] = useState('all') // status: 'all'|'pending'|'preparing'|'ready'
@@ -443,10 +445,6 @@ export default function TableListPage() {
}
}
useEffect(() => {
client.get('/api/orders/cancel-permissions').then(r => setCanCancel(r.data?.can_cancel === true)).catch(() => {})
}, [])
async function executeCancelOrder(orderId) {
try {
await client.delete(`/api/orders/${orderId}?print_cancellation=true`)