feat(tills): per-till activity log, wash bucket on the booth Z-report, wash-desk printer role

Closes the three known follow-ups of the Tills decision (venue-modules.md):

- Activity log per till: `tillOfEvent(type, payload)` in @parking/shared (money events
  by payload till, other events by their owning module's till, everything else booth),
  applied by `/api/events?till=` in SQL and passed by the hub log, the Drawer "today"
  panel and the booth feed (history + live pushes). The events route admits a role that
  holds a module feed permission without event:read and returns only that module's
  event types — the live-socket rule.
- Booth Z-report: `chargesByModuleMinor` sums the chargeLines on the till's payments by
  module; the ticket bucket excludes them (Bileta = parking only); printed
  "Lavazh (në biletë)" only when any was taken. The wash till's slip prints "Lavazh:".
- Printer role `wash-desk`: the wash till's Z-report and vouchers print there, falling
  back to the booth printer; nothing falls back to the desk. `printerRoleOf()` is the
  one reading of the role field (the entry/booth loaders treated any non-booth role as
  an entry dispenser). Footer label "at wash desk".

Also: `GET /api/carwash/settings` opens to carwash:read OR site:read (new
requireAnyPermission) — the Wash operator job could not load the desk's category and
service pickers. Tests for all four; wiki (shift, printer-roles-failover, venue-modules,
log) updated.

Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
This commit is contained in:
2026-09-06 12:37:26 +02:00
parent ea304bbfd1
commit e14e31a840
27 changed files with 414 additions and 91 deletions
+6 -3
View File
@@ -13,6 +13,7 @@ import { BoothPayModal } from "./BoothPayModal.js";
import { ActiveSessions } from "./ActiveSessions.js";
import { FilterBar, SegGroup, type SegOption } from "./ui/FilterBar.js";
import { EventDetailModal, EventRow } from "./ui/event-detail.js";
import { tillOfEvent } from "@parking/shared";
// The live operator booth view — the real-time heart of the console. Occupancy
// gauge + a streaming entry/exit/payment ticker. Query owns the initial load and
@@ -246,7 +247,7 @@ export function BoothScreen() {
const occQuery = useQuery({ queryKey: qk.occupancy, queryFn: fetchOccupancy });
const eventsQuery = useQuery({
queryKey: [...qk.events, shiftStart ?? "none"],
queryFn: () => fetchEvents(100, shiftStart ?? undefined),
queryFn: () => fetchEvents(100, shiftStart ?? undefined, undefined, "booth"),
enabled: shiftOpen,
});
@@ -275,13 +276,15 @@ export function BoothScreen() {
// Merge: live events first (newest), then the queried history, de-duped by id —
// then clip to the current shift window (the live store spans shifts; the feed
// must not show events from before this shift's start). No shift → no feed.
// must not show events from before this shift's start) and to the BOOTH till (the
// socket also pushes wash-desk events to anyone with carwash:read; they are the wash
// shift's activity, not this one's — tillOfEvent). No shift → no feed.
const seen = new Set(liveFeed.map((e) => e.id));
const history = (eventsQuery.data?.events ?? []).filter((e) => !seen.has(e.id));
const merged = [...liveFeed, ...history].slice(0, 200);
const scoped =
shiftOpen && shiftStart
? merged.filter((e) => e.occurredAt >= shiftStart)
? merged.filter((e) => e.occurredAt >= shiftStart && tillOfEvent(e.type, e.payload) === "booth")
: [];
// Apply the live-feed filters. Source maps to booth (operator-initiated `manual`)
+2 -2
View File
@@ -177,8 +177,8 @@ function StatePanel({ till }: { till: TillId }) {
function TodayPanel({ till }: { till: TillId }) {
const { t } = useTranslation();
const q = useQuery({
queryKey: ["drawer", "today"],
queryFn: () => fetchEvents(1000, startOfToday()),
queryKey: ["drawer", "today", till],
queryFn: () => fetchEvents(1000, startOfToday(), undefined, till),
refetchInterval: 15_000,
});
+10 -1
View File
@@ -1,4 +1,4 @@
import { useState } from "react";
import { Fragment, useState } from "react";
import { useTranslation } from "react-i18next";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { closeShift, fetchShiftReport, openShift, type TillId } from "./api.js";
@@ -161,6 +161,15 @@ function CloseShiftConfirm({
<>
<ConfirmFigure label={t("shift.srcTickets")} value={fmt(x.ticketTotalMinor)} />
<ConfirmFigure label={t("shift.srcSubscriptions")} value={fmt(x.subscriptionTotalMinor)} />
{/* Module money that rode the ticket (a booth-paid wash) — only when any did. */}
{Object.entries(x.chargesByModuleMinor ?? {})
.filter(([, v]) => (v ?? 0) > 0)
.map(([m, v]) => (
<Fragment key={m}>
<ConfirmFigure label={t("shift.srcOnTicket", { module: t(`modules.name.${m}`) })} value={fmt(v ?? 0)} />
<span />
</Fragment>
))}
{/* Abonime is the subscription TOTAL (sales + out-of-window). The 'jashtë orarit'
part is broken out below it; subscription SALES is not (it's the remainder). */}
<span />
+27 -3
View File
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { Fragment, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { keepPreviousData, useQuery } from "@tanstack/react-query";
import {
@@ -91,6 +91,7 @@ function useCurrentShifts(): { current: CurrentShift[]; tills: TillId[]; workabl
subscriptionTotalMinor: x.subscriptionTotalMinor,
subscriptionSalesMinor: x.subscriptionSalesMinor,
subscriptionWindowMinor: x.subscriptionWindowMinor,
chargesByModuleMinor: x.chargesByModuleMinor,
openingFloatMinor: x.openingFloatMinor,
cashAddedMinor: x.cashAddedMinor,
cashRemovedMinor: x.cashRemovedMinor,
@@ -332,6 +333,24 @@ function ShiftCard({ s, showOperator, showTill, open, selected, onClick }: { s:
);
}
/** One figure per module whose money rode this till's tickets (a booth-paid wash) —
* nothing when none did, so booth-only sites see the report they always saw. `spacer`
* keeps a 2-column grid's pairs aligned. */
function ChargeFigures({ charges, cur, spacer }: { charges?: Partial<Record<string, number>>; cur: string | null; spacer?: boolean }) {
const { t } = useTranslation();
const rows = Object.entries(charges ?? {}).filter(([, v]) => (v ?? 0) > 0);
return (
<>
{rows.map(([m, v]) => (
<Fragment key={m}>
<Figure label={t("shift.srcOnTicket", { module: t(`modules.name.${m}`) })} value={money(v ?? 0, cur)} />
{spacer && <span />}
</Fragment>
))}
</>
);
}
function ShiftActivityLog({
shift,
isCurrent,
@@ -356,9 +375,10 @@ function ShiftActivityLog({
const [detailEvent, setDetailEvent] = useState<LedgerEvent | null>(null);
// The current shift's log runs entry→now (no upper bound); a closed shift is bounded.
// Per till: the booth's log has no wash-desk activity in it, and vice versa.
const q = useQuery({
queryKey: ["shift-events", shift.id, shift.endedAt],
queryFn: () => fetchEvents(1000, shift.startedAt, isCurrent ? undefined : shift.endedAt),
queryKey: ["shift-events", shift.id, shift.endedAt, shift.till],
queryFn: () => fetchEvents(1000, shift.startedAt, isCurrent ? undefined : shift.endedAt, shift.till),
refetchInterval: isCurrent ? 5000 : false,
});
const events = q.data?.events ?? [];
@@ -389,6 +409,7 @@ function ShiftActivityLog({
<Figure label={t("shifts.srcSubscriptions")} value={money(shift.subscriptionTotalMinor, cur)} />
{/* Abonime is the subscription TOTAL; only the out-of-window part is broken out. */}
<Figure label={t("shifts.srcSubWindow")} value={money(shift.subscriptionWindowMinor, cur)} sub />
<ChargeFigures charges={shift.chargesByModuleMinor} cur={cur} />
<Figure label={t("shifts.openingFloat")} value={money(shift.openingFloatMinor, cur)} />
<Figure label={t("shifts.cashTaken")} value={money(shift.cashTotalMinor, cur)} />
<Figure label={t("shifts.cashAdded")} value={money(shift.cashAddedMinor, cur)} />
@@ -446,6 +467,7 @@ function EndShiftModal({ shift, onClose, onDone }: { shift: ShiftSummary; onClos
<span />
<Figure label={t("shift.srcTickets")} value={money(report.ticketTotalMinor, report.currency)} />
<Figure label={t("shift.srcSubscriptions")} value={money(report.subscriptionTotalMinor, report.currency)} />
<ChargeFigures charges={report.chargesByModuleMinor} cur={report.currency} spacer />
{/* Abonime is the subscription TOTAL; only the out-of-window part is broken out. */}
<span />
<Figure label={t("shift.srcSubWindow")} value={money(report.subscriptionWindowMinor, report.currency)} sub />
@@ -472,6 +494,7 @@ function EndShiftModal({ shift, onClose, onDone }: { shift: ShiftSummary; onClos
<div className="mt-2 grid grid-cols-2 gap-x-6 gap-y-0.5">
<Figure label={t("shift.srcTickets")} value={money(shift.ticketTotalMinor, cur)} />
<Figure label={t("shift.srcSubscriptions")} value={money(shift.subscriptionTotalMinor, cur)} />
<ChargeFigures charges={shift.chargesByModuleMinor} cur={cur} spacer />
{/* Abonime is the subscription TOTAL; only the out-of-window part is broken out. */}
<span />
<Figure label={t("shift.srcSubWindow")} value={money(shift.subscriptionWindowMinor, cur)} sub />
@@ -513,6 +536,7 @@ function TakingsModal({ till, onClose }: { till: TillId; onClose: () => void })
<span />
<Figure label={t("shift.srcTickets")} value={money(x.ticketTotalMinor, x.currency)} />
<Figure label={t("shift.srcSubscriptions")} value={money(x.subscriptionTotalMinor, x.currency)} />
<ChargeFigures charges={x.chargesByModuleMinor} cur={x.currency} spacer />
{/* Abonime is the subscription TOTAL; only the out-of-window part is broken out. */}
<span />
<Figure label={t("shift.srcSubWindow")} value={money(x.subscriptionWindowMinor, x.currency)} sub />
+8 -2
View File
@@ -1096,6 +1096,9 @@ export interface ShiftSourceSplit {
subscriptionTotalMinor: number;
subscriptionSalesMinor: number;
subscriptionWindowMinor: number;
/** Module money that rode this till's tickets (a booth-paid wash), by module id.
* Inside cash+card, OUTSIDE the ticket bucket. Absent on pre-2026-09 reports. */
chargesByModuleMinor?: Partial<Record<string, number>>;
}
export interface ShiftReport extends ShiftSourceSplit {
@@ -1331,7 +1334,7 @@ export interface DeviceStatus {
category: "access" | "reader" | "camera" | "printer" | "vision";
/** Role/direction token for the footer label (NOT the vendor) — the client
* localises it next to the category, e.g. "Lexuesi hyrje", "Printer kabina". */
roleKind: "entry" | "exit" | "both" | "mixed" | "lane" | "booth" | null;
roleKind: "entry" | "exit" | "both" | "mixed" | "lane" | "booth" | "wash" | null;
state: "ready" | "degraded" | "offline";
detail?: string;
checkedAt: string;
@@ -1351,15 +1354,18 @@ export type { AppLogRecord };
/** Recent ledger events, newest first (default 100, max 1000). Used for the
* booth feed's initial load; live updates then arrive over the WS. `since` (ISO)
* scopes to events at/after that instant — the booth passes the current shift's
* start so the feed shows ONLY this shift's activity. */
* start so the feed shows ONLY this shift's activity. `till` keeps one till's activity
* (the server applies the shared tillOfEvent rule) — a shift's log is per till. */
export function fetchEvents(
limit = 100,
since?: string,
until?: string,
till?: TillId,
): Promise<{ events: import("@parking/shared").LedgerEvent[] }> {
const qs = new URLSearchParams({ limit: String(limit) });
if (since) qs.set("since", since);
if (until) qs.set("until", until);
if (till) qs.set("till", till);
return apiFetch(`/api/events?${qs.toString()}`);
}
+2
View File
@@ -232,6 +232,7 @@ export const en: Catalog = {
mixed: "entry/exit",
lane: "at lane",
booth: "at booth",
wash: "at wash desk",
},
state: {
ready: "ready",
@@ -960,6 +961,7 @@ export const en: Catalog = {
card: "Card:",
srcTickets: "Tickets:",
srcSubscriptions: "Subscriptions:",
srcOnTicket: "{{module}} (on ticket):",
srcSubWindow: "out-of-window",
drawerSection: "— Drawer —",
openingFloat: "Opening cash:",
+2
View File
@@ -235,6 +235,7 @@ export const sq = {
mixed: "hyrje/dalje",
lane: "në korsi",
booth: "në kabinë",
wash: "në lavazh",
},
state: {
ready: "gati",
@@ -974,6 +975,7 @@ export const sq = {
card: "Kartë:",
srcTickets: "Bileta:",
srcSubscriptions: "Abonime:",
srcOnTicket: "{{module}} (në biletë):",
srcSubWindow: "jashtë orarit",
drawerSection: "— Arka —",
openingFloat: "Arka fillestare:",