0521c385d2
* feat(transactions): per-row underlag status + attach-document dialog
- New "Matcha mot underlag" dialog on /transactions (inbox pick or fresh
upload), the tx→doc mirror of the Documents view's matcher
- Per-row Underlag/Underlag saknas badges on booked history rows, driven
by computeJeUnderlagStatus — same posted-only, exemption-aware scope as
the worklist count so badge and count never disagree
- attach-document route + commit dispatcher now propagate the doc onto
the verifikation when the tx is already booked (BFL 5 kap 6 §), with a
409 guard for docs consumed by a different verifikation, idempotent
re-attach (no same-value rewrite under period lock), and an honest 409
when the period-lock trigger blocks the propagation
- Booking-dialog doc links also pin the doc to the transaction row
(first linked doc wins) via the link route's new transaction_id param
messages/{sv,en}.json also carries the strings for the pending-ops
expiry UI that lands in the next commit.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat(pending-operations): auto-expire stale staged operations after 30 days
- New daily cron (02:30 UTC, vercel.json + both docker crontabs) flips
>30-day-old pending ops to rejected with the dispatcher's
{ auto_rejected: true, reason: 'expired' } result_data shape — rows are
never deleted, the table is the audit trail
- /pending renders an "Utgick automatiskt" badge + detail line for these,
orders terminal tabs by resolved_at so a fresh expiry sweep isn't
buried, and adds a first-time-reviewer explainer
- Origin labels spell out where a proposal came from (AI chat, MCP key,
API, cron) instead of the raw actor_label
- agent_chat actor type added to PendingOperationActorType/AuditLogEntry
(DB CHECK already widened in 20260519090000) and to the agent filter
- ApprovalCard notes that ignoring a proposal is safe
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs(mcp): surface the client telemetry marker in connect instructions
Tag the connector URLs shown in ApiKeysPanel, the connect-claude doc and
the gnubok-mcp README with ?client=<surface> (claude-connector /
claude-code) and GNUBOK_CLIENT=claude-desktop for the npm bridge.
Telemetry-only — the server already reads the param/header; this just
lets us measure which Claude surface connected.
The claude mcp add copy blocks quote the URL: an unquoted ? in the query
string trips zsh globbing ("no matches found").
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* review: fix stale-closure badge flip + zod-validate link route body (PR #712)
- handleDocumentAttached read journal_entry_id off the render-time
transactions snapshot; if the list changed while the attach dialog was
open the optimistic badge flip was silently skipped. Read it off the
dialog's own subject (attachDocTx) instead.
- POST /api/documents/[id]/link now validates the body against the new
LinkDocumentSchema (uuid-strict, all four fields) instead of a bare
presence check on journal_entry_id — same canonical VALIDATION_ERROR
envelope. Test fixtures switched to real UUIDs accordingly.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import { NEEDS_DOC_SOURCE_TYPES } from '@/lib/worklist/categories'
|
|
|
|
/**
|
|
* Row-level underlag status for a booked transaction's journal entry.
|
|
*
|
|
* - 'has' — the verifikation has at least one current-version document
|
|
* - 'missing' — the verifikation's source type requires underlag (BFL 5 kap
|
|
* 7§), has none, and is not exempted via journal_entry_no_doc_required
|
|
* - 'none' — no statement either way (system-generated source types,
|
|
* exempted entries) — render no badge
|
|
*
|
|
* Mirrors countVerifikatMissingDocument in lib/worklist/categories.ts at row
|
|
* granularity so the per-row "Underlag saknas" badge and the worklist count
|
|
* never disagree on what counts as missing. Contract: callers must pass only
|
|
* POSTED entries (filter journal_entries on status = 'posted', like the
|
|
* worklist does) — reversed/corrected entries must render no badge at all,
|
|
* never 'missing'.
|
|
*/
|
|
export type JeUnderlagStatus = 'has' | 'missing' | 'none'
|
|
|
|
const NEEDS_DOC = new Set<string>(NEEDS_DOC_SOURCE_TYPES)
|
|
|
|
export function computeJeUnderlagStatus(
|
|
entries: Array<{ id: string; source_type: string | null }>,
|
|
jeIdsWithDocs: ReadonlySet<string>,
|
|
exemptJeIds: ReadonlySet<string>,
|
|
): Record<string, JeUnderlagStatus> {
|
|
const result: Record<string, JeUnderlagStatus> = {}
|
|
for (const entry of entries) {
|
|
if (jeIdsWithDocs.has(entry.id)) {
|
|
result[entry.id] = 'has'
|
|
} else if (
|
|
entry.source_type != null &&
|
|
NEEDS_DOC.has(entry.source_type) &&
|
|
!exemptJeIds.has(entry.id)
|
|
) {
|
|
result[entry.id] = 'missing'
|
|
} else {
|
|
result[entry.id] = 'none'
|
|
}
|
|
}
|
|
return result
|
|
}
|