Files
accounted/lib/bokslut/accruals/templates.ts
T
f266c386f3 chore: repo-wide bloat sweep, remove dead code and fold duplicate helpers (#2150)
* chore: repo-wide bloat sweep, remove dead code and fold duplicate helpers

Remove 33 dead files, ~270 unreferenced exports/types, 13 dead i18n
namespaces and 4 unused dependencies; fold byte-identical helper copies
into one canonical home each (lib/utils chunk/sleep/utcDateStamp,
lib/dates/iso, lib/invariants/uuid, lib/xml/escape, lib/reports/sru/format,
lib/pdf/number-text, lib/browser/panel-request, lib/api/v1/body +
v1ValidationError rolled out to ~55 v1 routes, booking-template schemas).

No behaviour change: v1 bodies and status codes, MCP tool schemas, DB
writes and money math are untouched. Naive ore rounding was deliberately
not swapped for roundOre; see DECISIONS.md 2026-09-02 for the full list
of things left alone on purpose.

tsc, lint, 19588 unit tests and check:guards green; antipattern baseline
ratcheted (naive-ore-round 622 -> 620, hand-rolled-invariant 115 -> 113).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test(transactions): import RawTransaction from @/types after the ingest re-export removal

CI's type ratchet (check:types, full tsconfig) caught the one test file
that still imported the type through lib/transactions/ingest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 11:51:16 +02:00

90 lines
2.9 KiB
TypeScript

/**
* Pre-filled patterns the wizard offers as one-click templates. Each names
* the engine side (prepaid / accrued / deferred revenue / ...) that the
* wizard maps onto the proposeManual* / proposeAccrued* helpers in
* accrual-detector.ts. The wizard renders these as "Lägg till" buttons.
*
* BAS account choices follow the standard 2026 chart:
* - 17xx förutbetalda kostnader (prepaid expenses, asset side)
* - 29xx upplupna kostnader (accrued expenses + förutbetalda intäkter)
* - 2970 förutbetalda intäkter (deferred revenue specifically)
*
* Adding a new template means: 1) extend this array, 2) the wizard picks
* it up automatically.
*/
export type PeriodiseringTemplateKind =
| 'prepaid_rent'
| 'prepaid_insurance'
| 'prepaid_subscription'
| 'deferred_revenue'
| 'accrued_interest_expense'
| 'accrued_utilities'
export interface PeriodiseringTemplate {
kind: PeriodiseringTemplateKind
/** Swedish label for the wizard card. */
name: string
/** One-sentence Swedish description / typical use case. */
hint: string
/** Engine that builds the AccrualProposal. */
side: 'prepaid' | 'accrued' | 'deferred_revenue' | 'accrued_interest' | 'accrued_utility'
/** Default BAS accounts pre-filled in the form. */
prepaid_account?: string
expense_account?: string
deferred_account?: string
revenue_account?: string
accrued_account?: string
}
export const PERIODISERING_TEMPLATES: PeriodiseringTemplate[] = [
{
kind: 'prepaid_rent',
name: 'Förutbetald hyra',
hint: 'Hyra som löper över årsskiftet (t.ex. lokalhyra för januari betald i december).',
side: 'prepaid',
prepaid_account: '1710',
expense_account: '5010',
},
{
kind: 'prepaid_insurance',
name: 'Förutbetald försäkring',
hint: 'Försäkringspremie för kommande räkenskapsår, betald i förskott.',
side: 'prepaid',
prepaid_account: '1710',
expense_account: '6310',
},
{
kind: 'prepaid_subscription',
name: 'Förutbetald prenumeration',
hint: 'Mjukvara, licens eller medlemskap som löper över årsskiftet.',
side: 'prepaid',
prepaid_account: '1710',
expense_account: '5800',
},
{
kind: 'deferred_revenue',
name: 'Förutbetald intäkt',
hint: 'Kund har betalat för en tjänst eller prenumeration som avser nästa räkenskapsår.',
side: 'deferred_revenue',
deferred_account: '2970',
revenue_account: '3000',
},
{
kind: 'accrued_interest_expense',
name: 'Upplupen ränta',
hint: 'Räntekostnad som löpt under perioden men ännu inte fakturerats av banken.',
side: 'accrued_interest',
accrued_account: '2940',
expense_account: '8410',
},
{
kind: 'accrued_utilities',
name: 'Upplupna förbrukningar',
hint: 'El, vatten, sophämtning eller bredband: kostnaden har uppstått men fakturan dröjer.',
side: 'accrued_utility',
accrued_account: '2990',
expense_account: '5020',
},
]