Files
accounted/lib/reports/sru/format.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

27 lines
985 B
TypeScript

/**
* Field formatters shared by the SRU generators (INK2 and NE-bilaga). SRU is a
* Skatteverket line format: dates are YYYYMMDD, times HHMMSS, amounts are hela
* kronor with the öre truncated and no separators.
*/
/** Format a Date as YYYYMMDD (local time, as the files are stamped on the user's clock). */
export function sruDate(date: Date): string {
const y = date.getFullYear()
const m = String(date.getMonth() + 1).padStart(2, '0')
const d = String(date.getDate()).padStart(2, '0')
return `${y}${m}${d}`
}
/** Format a Date as HHMMSS. */
export function sruTime(date: Date): string {
const h = String(date.getHours()).padStart(2, '0')
const m = String(date.getMinutes()).padStart(2, '0')
const s = String(date.getSeconds()).padStart(2, '0')
return `${h}${m}${s}`
}
/** Format an integer amount: hela kronor, no decimals/thousands separators, öre truncated. */
export function sruAmount(amount: number): string {
return Math.trunc(amount).toString()
}