feat(exit): forgiven exit — open the exit barrier with no payment (barrier:create)
Build & push images / images (push) Successful in 3m23s
Build & push images / images (push) Successful in 3m23s
The owner (or any role the owner grants barrier:create) lets a car out for free.
Exit side only. Every use is signed, attributed, photographed and on the operator's
Z-report; the shift's cash/card/drawer are untouched by construction.
- shared: resource 'barrier' + permission 'barrier:create'; reason codes
exit.forgiven / exit.forgiven.noSession; LedgerPayload.forgoneMinor.
- pay-station: forgive() signs a $0 payment carrying the quoted fee as forgoneMinor
(no tender), refuses a ticket with module charge lines (a wash is not forgiven).
- exit-flow: reopenBarrier(..., { forgiven }) bypasses the walk-back check and stamps
the forgiven reason on the anomaly + vehicle_exit; forgiveExitNoSession() for a car
with no ticket (anomaly under forgiven:<id> + exit snapshot + pulse). Relay driving
shared in #pulseExit.
- route POST /api/barrier/forgive { identity?, note? }: barrier:create + open shift;
the reason is optional (an empty note is signed as '(no reason given)').
- shift-service: forgoneTotalMinor + forgoneCount on the report/summary/signed
shift_z_report (only when > 0), print line 'Dalje të falura (N)'.
- web: 'Forgive & open' in the pay/exit modal for an open transient that owes money;
'Forgive & open exit' on the booth header for the no-ticket case; forgone line on
the X-report, close confirm and history; en/sq. Prints nothing.
- tests: exit-flow, pay-station, shift-service, HTTP route (403 without the
permission, 409 no shift, empty note accepted, ledger sequence, report figures).
- wiki: decisions/forgiven-exit.md (decision + as-built), booth-exit-flow, shift,
index, log.
This commit is contained in:
@@ -28,6 +28,24 @@ async function enter(identity: string, enteredAt: string, payload?: Record<strin
|
||||
await log.append({ type: "vehicle_entry", direction: "entry", identity, occurredAt: enteredAt, payload: payload ?? null });
|
||||
}
|
||||
|
||||
describe("PayStation.forgive (forgiven exit)", () => {
|
||||
it("signs a $0 payment with the quoted fee as forgoneMinor and marks the session paid", async () => {
|
||||
seedTariff(db, { pricePerIncrementMinor: 10000, incrementMin: 60 });
|
||||
await enter("T1", minutesAgo(90));
|
||||
const r = await pay.forgive("T1", { operator: "owner", note: "lost ticket, known customer" });
|
||||
expect(r).toEqual({ ok: true, forgoneMinor: 20000, currency: expect.any(String) });
|
||||
const ev = db.select().from(ledgerEvents).where(eq(ledgerEvents.identity, "T1")).all().find((e) => e.type === "payment")!;
|
||||
expect(ev.payload).toMatchObject({ amountMinor: 0, forgoneMinor: 20000, operator: "owner", reasonCode: "exit.forgiven" });
|
||||
expect((ev.payload as { tender?: string }).tender).toBeUndefined(); // nothing was tendered
|
||||
expect(pay.lookup("T1").paidAt).not.toBeNull();
|
||||
});
|
||||
|
||||
it("throws like quote() for an unknown ticket", async () => {
|
||||
seedTariff(db);
|
||||
await expect(pay.forgive("nope", { operator: "owner", note: "x" })).rejects.toThrow(NoOpenSessionError);
|
||||
});
|
||||
});
|
||||
|
||||
describe("PayStation.quote", () => {
|
||||
it("throws NoOpenSessionError for an unknown ticket", () => {
|
||||
seedTariff(db);
|
||||
|
||||
Reference in New Issue
Block a user