ec27228a8e
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>
40 lines
1.8 KiB
TypeScript
40 lines
1.8 KiB
TypeScript
import type { EntityType } from '@/types'
|
|
|
|
/**
|
|
* Employment policy: which employment types an entity type may put on payroll.
|
|
*
|
|
* An enskild firma is not a separate legal person from its owner, so the owner
|
|
* cannot be their own employee and cannot be paid lön: owner compensation is
|
|
* *egna uttag* (BAS 2013), booked against equity, never a salary cost. Board
|
|
* members (styrelse) are an aktiebolag concept and likewise don't exist for an
|
|
* EF. Ordinary employees (employment_type 'employee') are fully allowed for an
|
|
* EF that hires staff and book identically to an aktiebolag (7xxx + 27xx/29xx
|
|
* + 1930, never the 20xx equity accounts).
|
|
*
|
|
* This module is the application-layer mirror of the
|
|
* `enforce_ef_no_owner_employee` database trigger (the load-bearing,
|
|
* all-paths enforcement). Keep the two in sync: the forbidden set below must
|
|
* match the trigger's. See issue #782.
|
|
*/
|
|
export const EF_FORBIDDEN_EMPLOYMENT_TYPES = ['company_owner', 'board_member'] as const
|
|
|
|
/** User-facing Swedish error when an EF tries to put its owner/board on payroll. */
|
|
export const EF_OWNER_EMPLOYMENT_ERROR =
|
|
'En enskild firma kan inte ha sin ägare eller styrelse som anställd. ' +
|
|
'Som ägare tar du ut pengar via eget uttag (konto 2013), inte lön. ' +
|
|
'Lägg bara upp dina anställda (anställningstyp "employee").'
|
|
|
|
/**
|
|
* Whether `employmentType` is permitted for a company of `entityType`.
|
|
* Permissive for everything except owner/board employment on an enskild firma,
|
|
* and for unknown/empty inputs (which the schema's enum check handles).
|
|
*/
|
|
export function isEmploymentTypeAllowedForEntity(
|
|
entityType: EntityType | null | undefined,
|
|
employmentType: string | null | undefined,
|
|
): boolean {
|
|
if (entityType !== 'enskild_firma') return true
|
|
if (!employmentType) return true
|
|
return !(EF_FORBIDDEN_EMPLOYMENT_TYPES as readonly string[]).includes(employmentType)
|
|
}
|