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
@@ -0,0 +1,29 @@
// Printing problems as plain data (plan step 6.10).
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { actionRequest, byPrinter, itemsText, minutesSince, otherPrinters, placeOf, problemsOf } from '../src/printProblems.js'
const p = (job, order, printer, extra = {}) => ({
job_id: job, order_id: order, table_name: null, printer: { id: printer, name: `P${printer}` },
items: [{ name: 'Burger', quantity: 2, unit_type: 'piece' }, { name: 'Freddo', quantity: 1, unit_type: 'piece' }],
since: '2026-11-19T10:00:00', ...extra,
})
test('what a ticket holds, where it belongs, how long it waits', () => {
const a = p(1, 7, 1, { table_name: 'T5' })
assert.equal(itemsText(a), '2× Burger, Freddo')
assert.equal(placeOf(a), 'T5')
assert.equal(placeOf(p(2, 8, 1)), '#8')
assert.equal(minutesSince(a, Date.parse('2026-11-19T10:07:30Z')), 7) // a time without a zone is UTC
assert.equal(minutesSince({ ...a, since: '2026-11-19T10:00:00+02:00' }, Date.parse('2026-11-19T08:03:00Z')), 3)
})
test('per order, per printer, the printers to send to, the requests', () => {
const list = [p(1, 7, 1), p(2, 7, 2), p(3, 8, 1)]
assert.deepEqual(problemsOf(list, 7).map(x => x.job_id), [1, 2])
assert.deepEqual(byPrinter(list).map(x => [x.printer.id, x.count]), [[1, 2], [2, 1]])
assert.deepEqual(otherPrinters(list[0], [{ id: 1 }, { id: 2 }, { id: 3 }]).map(x => x.id), [2, 3])
assert.deepEqual(actionRequest('redirect', list[0], 3), ['/api/print-problems/1/redirect', { printer_id: 3 }])
assert.deepEqual(actionRequest('handled', list[0]), ['/api/print-problems/1/handled', {}])
assert.deepEqual(actionRequest('retry', list[0]), ['/api/print-problems/1/retry', {}])
})