feat: printing problems shown and handled; printing set-up on v2 (platform-v2 step 6.10)

- 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>
This commit is contained in:
2026-11-19 01:40:07 +02:00
co-authored by Claude Opus 5.5
parent 070c9cf625
commit f31bdf42aa
57 changed files with 2557 additions and 2221 deletions
+12
View File
@@ -2026,6 +2026,9 @@ def _do_route_and_print(order_id: int, item_ids: List[int], db: Session, ephemer
db.commit()
for pj, printer_name in failing: # after the commit: notify() commits too
_notify_print_failing(db, pj, printer_name)
if failing: # 6.10: the apps show the problem at once
from services.print_problems import announce
announce(order_id)
return results
@@ -2208,6 +2211,7 @@ def _retry_sweep():
logger.warning("print.job.abandoned job=%s order=%s attempts=%s reason=order_closed",
pj.id, pj.order_id, pj.retry_count)
_notify_print_failed(db, pj)
_announce(pj.order_id)
continue
item_ids = json.loads(pj.item_ids or "[]")
@@ -2223,6 +2227,7 @@ def _retry_sweep():
pj.succeeded_at = now
db.commit()
logger.info("print.job.resolved job=%s reason=items_printed_or_removed", pj.id)
_announce(pj.order_id)
continue
printer = db.query(Printer).filter(Printer.id == pj.printer_id, Printer.is_active == True).first() # noqa: E712
@@ -2268,6 +2273,8 @@ def _retry_sweep():
db.commit()
if not success:
_notify_print_failing(db, pj, printer.name)
else:
_announce(pj.order_id) # 6.10: printed on a retry, the warning clears
except Exception as e:
logger.exception("Unexpected error processing PrintJob %s: %s", job_id, e)
@@ -2275,6 +2282,11 @@ def _retry_sweep():
db.close()
def _announce(order_id) -> None:
from services.print_problems import announce
announce(order_id)
def _alert_after_failures(db) -> int:
from models.settings import PosSettings
row = db.query(PosSettings).filter(PosSettings.key == "print.alert_after_failures").first()