Files
accounted/app/api/bookkeeping/accounts/bas-catalog/route.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

32 lines
1.2 KiB
TypeScript

import { NextResponse } from 'next/server'
import { withRouteContext } from '@/lib/api/with-route-context'
import { BAS_REFERENCE } from '@/lib/bookkeeping/bas-reference'
/**
* GET /api/bookkeeping/accounts/bas-catalog
*
* The full BAS 2026 catalogue (~1,276 accounts), projected to the fields the
* AccountCombobox needs to search and render. This lets the manual bookkeeping
* flow surface accounts by name even when they aren't in the company's chart
* yet: selecting one routes through the existing activate-on-commit rail
* (ACCOUNTS_NOT_IN_CHART → ActivateAccountsDialog → /accounts/activate).
*
* The payload is static reference data for the deploy and identical for every
* company, so it's cached hard on the client. Wrapped in withRouteContext so it
* stays behind auth (MFA on hosted) like every other bookkeeping route.
*/
export const GET = withRouteContext('bookkeeping.accounts.bas_catalog', async () => {
const data = BAS_REFERENCE.map((a) => ({
account_number: a.account_number,
account_name: a.account_name,
account_class: a.account_class,
account_group: a.account_group,
description: a.description,
}))
return NextResponse.json(
{ data },
{ headers: { 'Cache-Control': 'private, max-age=86400' } },
)
})