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>
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
/**
|
|
* OCR-nummer for Skatteverket Skattekonto payments.
|
|
*
|
|
* Companies pay tax (skatt + arbetsgivaravgifter + F-skatt + slutlig skatt etc.)
|
|
* to Bankgiro 5050-1055 with an OCR reference. The reference identifies which
|
|
* Skattekonto receives the credit; Skatteverket applies it to the most recent
|
|
* declared liability.
|
|
*
|
|
* Format (per Skatteverket "OCR-nummer för inbetalning till skattekontot"):
|
|
* - 10-digit organisationsnummer (AB) or 10-digit personnummer (EF)
|
|
* stripped of dashes/spaces
|
|
* - Followed by a single Luhn check digit
|
|
* - Total: 11 digits
|
|
*
|
|
* Examples:
|
|
* 556012-3456 → "5560123456" + check digit "6" = "55601234566"
|
|
* 880225-1234 → "8802251234" + check digit → 11 digits
|
|
*
|
|
* Reference: https://www.skatteverket.se/foretag/skatterochavdrag/skattekonto/betalainochavskattekonto/sabetalardupaskattekontot.4.18e1b10334ebe8bc80004499.html
|
|
*/
|
|
|
|
import { luhnCheckDigit } from '@/lib/bankgiro/luhn'
|
|
|
|
/** Bankgiro number for all payments to Skattekontot. */
|
|
export const SKATTEKONTO_BANKGIRO = '5050-1055'
|
|
|
|
/**
|
|
* Generate the standard Skattekontot OCR reference for a company.
|
|
*
|
|
* Accepts org_number/personnummer in any common Swedish format
|
|
* ("556012-3456", "5560123456", "19880225-1234", "198802251234").
|
|
*
|
|
* For 12-digit personnummer (with century prefix), the leading century digits
|
|
* are stripped: Skatteverket's Skattekonto-OCR uses the 10-digit form.
|
|
*/
|
|
export function generateSkattekontoOcr(orgOrPersonnummer: string): string {
|
|
const digits = orgOrPersonnummer.replace(/\D/g, '')
|
|
|
|
let base: string
|
|
if (digits.length === 10) {
|
|
base = digits
|
|
} else if (digits.length === 12) {
|
|
// Strip century prefix (1900s = "19", 2000s = "20")
|
|
base = digits.slice(2)
|
|
} else {
|
|
throw new Error(
|
|
`Ogiltigt org/personnummer för Skattekonto-OCR: "${orgOrPersonnummer}" (förväntat 10 eller 12 siffror)`
|
|
)
|
|
}
|
|
|
|
const checkDigit = luhnCheckDigit(base)
|
|
return base + checkDigit.toString()
|
|
}
|