- a ticket that doesn't print is a problem for whoever sent it and the managers: GET /api/print-problems (the order, table, dishes, printer, since when, tries, last error, who sent it) and three ways out: print again, send to another printer, handled (services/print_problems.py; print_jobs.resolved_by / redirected_to, Alembic 0036); live event print.problems from the print paths - phone: the red printer button opens the problems sheet, the table page warns (usePrintProblems replaces the 8 s poll); counter POS: a red button under the modes with the shared panel (@xenia/ordering PrintProblemsPanel + pure rules); manager: a card on the overview (top), the Tables page and the order page - manager: Settings -> Printing (printers with reachability, test print, network scan; ticket layout + test ticket, beep, fonts with previews, dot leader, dividers) and Management -> Prep zones (cards + zone dialog with the ticket language, printers, copies, sorting, category order, kitchen screen) rebuilt in src/pages/printing; v1 PrintFontsTab, PrepZonesConfigPage, PendingPrints and /api/orders/pending-prints removed - access: printer add/edit/delete/scan need core.settings.manage, prep zone changes catalog.menu.manage (were any dashboard user) - tests: test_print_problems.py, @xenia/ordering printProblems, manager printing.test.mjs, e2e print_problems.mjs (done-when) + manager.mjs printing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""Printing problems (plan step 6.10, services/print_problems.py): the tickets that didn't
|
|
print, for whoever may act on their orders (the managers see all), and the three ways out:
|
|
print again, send to another printer, mark as handled. Live event: `print.problems`."""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from pydantic import BaseModel
|
|
from sqlalchemy.orm import Session
|
|
|
|
from core.access.deps import require_any
|
|
from database import get_db
|
|
from services import print_problems as svc
|
|
|
|
router = APIRouter()
|
|
_STAFF = require_any("ordering.orders.open", "core.dashboard.access")
|
|
|
|
|
|
@router.get("")
|
|
def list_problems(db: Session = Depends(get_db), user=Depends(_STAFF)):
|
|
"""{problems: [...oldest first], printers: [{id, name}]} (the printers a ticket can go to)."""
|
|
return {"problems": svc.problems(db, user), "printers": svc.printers(db)}
|
|
|
|
|
|
@router.post("/{job_id}/retry")
|
|
def retry(job_id: int, db: Session = Depends(get_db), user=Depends(_STAFF)):
|
|
return svc.retry(db, job_id, user)
|
|
|
|
|
|
class RedirectBody(BaseModel):
|
|
printer_id: int
|
|
|
|
|
|
@router.post("/{job_id}/redirect")
|
|
def redirect(job_id: int, body: RedirectBody, db: Session = Depends(get_db), user=Depends(_STAFF)):
|
|
return svc.redirect(db, job_id, body.printer_id, user)
|
|
|
|
|
|
@router.post("/{job_id}/handled")
|
|
def handled(job_id: int, db: Session = Depends(get_db), user=Depends(_STAFF)):
|
|
return svc.handled(db, job_id, user)
|