Em dashes (—) and en dashes (–) had spread across comments, docs, tests, and a few UI strings, reading as AI-generated boilerplate rather than house style. Replaced each with punctuation matching its context: colon for explanatory clauses, comma for asides, plain hyphen for numeric/legal ranges (e.g. "21-23§"), "to"/"till" for date ranges, parentheses for paired-dash asides. messages/en.json and messages/sv.json were fixed by hand together to keep sv/en in sync. Left untouched where the dash is the functional subject rather than decorative punctuation: date-range-parser.ts's separator regex, charset-repair.ts's CP1252 byte-mapping table (and its test), the SIE encoding mojibake docs, generic-csv.ts's minus-sign normalizer, the agent system-prompt files that already instruct against em dashes, and a golden iXBRL test fixture compared byte-for-byte. Also fixes two bugs surfaced along the way: an off-by-one in ApiKeysPanel's scope-label split (a leftover from an earlier partial pass), and a charset-repair test that had lost the literal en-dash it exists to verify. Regenerated the agent atom seed migration (skills:generate) since 27 SKILL.md files changed. Added a CLAUDE.md rule against em/en dashes, with an explicit carve-out for the functional-dash cases above. Co-authored-by: Claude Sonnet 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
|
|
}
|