feat(booth): cancel wrongly-printed ticket (signed void) + refused-vs-anomaly display; fix CI uv
CI / check (push) Failing after 56s
CI / check (push) Failing after 56s
Cancel a misprinted/test/wrong-vehicle ticket via a SIGNED `void` event — the
vehicle_entry is never edited/deleted (append-only). VoidFlow appends void{
voidedEntryRef, voidReason, operator, reasonCode:"void.ticketCancelled" }; route
POST /api/tickets/void gated event:void + open shift; reason REQUIRED. Refuses a
subscription / already-exited / already-voided / paid ticket (refund out of scope).
The void folds the session CLOSED everywhere it's counted — occupancy (count +
reserved spots), pay-station (lookup/activeSessions), exit-flow (#sessionFor), and
reports (excluded from entries) — so a voided car stops occupying a spot, can't be
paid/exited, and doesn't inflate "cars entered". No barrier action. Booth UI: a
"Cancel ticket" action in the pay/exit lookup modal (transient + unpaid + open;
gated on event:void) with a preset-or-free reason prompt.
Reclassify the Live feed: refused-action events (exitRefused/entryRefused/
permitRefused — e.g. a double card-scan, at-capacity subscriber, exit on a closed
session) are benign warnings, not red anomalies. event-detail.tsx now shows them as
amber REFUZUAR/REFUSED, reserving red ANOMALI for genuine red-flags. Display-only —
no ledger change, so historical events reclassify too.
CI: install uv + sync vision deps before the Turbo run. @parking/vision's lint/
typecheck/test shell to `uv run …`, but CI set up only Node+pnpm, so `uv run ruff`
failed ("uv not found") and broke the whole Turbo run. The Python checks pass once
uv provisions the toolchain.
- new: void-flow.ts (+ tests, 8) ; occupancy void-fold test
- shared: reason code void.ticketCancelled ; both web catalogs (sq/en parity)
- wiki: parking-session (ticket-void folds + guards, refused/anomaly split), log
Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
type PayStation,
|
||||
} from "../pay-station.js";
|
||||
import type { ExitFlow } from "../exit-flow.js";
|
||||
import type { VoidFlow } from "../void-flow.js";
|
||||
import { NoShiftOpenError, type ShiftService } from "../shift-service.js";
|
||||
import { printPaymentReceipt } from "../booth-print.js";
|
||||
|
||||
@@ -36,6 +37,10 @@ interface VoucherBody {
|
||||
interface ReceiptBody {
|
||||
identity: string;
|
||||
}
|
||||
interface VoidBody {
|
||||
identity: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export async function payRoutes(
|
||||
app: FastifyInstance,
|
||||
@@ -43,6 +48,7 @@ export async function payRoutes(
|
||||
payStation: PayStation,
|
||||
exitFlow: ExitFlow,
|
||||
shift: ShiftService,
|
||||
voidFlow: VoidFlow,
|
||||
): Promise<void> {
|
||||
// Reads (lookup, active sessions, quote) need session/payment read; the booth
|
||||
// money actions (pay, exit, voucher, receipt, reopen) need payment:create. A
|
||||
@@ -50,6 +56,7 @@ export async function payRoutes(
|
||||
// sessions. Read-only callers (a viewer role) get the reads but not the actions.
|
||||
const guard = requirePermission("payment:create");
|
||||
const readGuard = requirePermission("session:read");
|
||||
const voidGuard = requirePermission("event:void");
|
||||
|
||||
// Money-path gate: a shift must be open site-wide before any payment/exit/voucher/
|
||||
// re-open is processed, so every taking is attributed to a shift (one operator's
|
||||
@@ -125,6 +132,28 @@ export async function payRoutes(
|
||||
},
|
||||
);
|
||||
|
||||
// Cancel (void) a wrongly-printed transient ticket. Appends a SIGNED `void` event
|
||||
// referencing the entry, with the operator + a REQUIRED reason — the entry itself is
|
||||
// never edited/deleted (append-only). The session projection folds the void to CLOSED,
|
||||
// so the voided car stops counting inside and can't be paid/exited. Opens NO barrier
|
||||
// (the misprinted ticket's car never entered). Gated on event:void + an open shift
|
||||
// (the booth accountability period). Refusals (subscription / already exited / already
|
||||
// voided / already paid) → 409. See void-flow.ts, wiki/concepts/append-only-event-chain.md.
|
||||
app.post<{ Body: VoidBody }>(
|
||||
"/api/tickets/void",
|
||||
{ preHandler: [voidGuard, requireShift] },
|
||||
async (req, reply) => {
|
||||
const identity = (req.body?.identity ?? "").trim();
|
||||
const reason = (req.body?.reason ?? "").trim();
|
||||
if (!identity) return reply.code(400).send({ error: "identity required" });
|
||||
if (!reason) return reply.code(400).send({ error: "a cancellation reason is required" });
|
||||
const operator = req.user?.username ?? "unknown";
|
||||
const res = await voidFlow.voidTicket({ identity, reason, operator });
|
||||
if (!res.ok) return reply.code(409).send({ error: res.reason });
|
||||
return reply.code(201).send(res);
|
||||
},
|
||||
);
|
||||
|
||||
// Quote: what does this session owe right now? (No side effect.)
|
||||
app.get<{ Querystring: QuoteQuery }>(
|
||||
"/api/pay/quote",
|
||||
|
||||
Reference in New Issue
Block a user