Founder test on a real company (2026-09-05): a supplier created from "Webhallen Oktober · Dataskärmar till kontoret" kept that text as its name, and the SCB facts fetched for the party were nowhere on the supplier page. - Företagsuppgifter on /suppliers/[id] and /customers/[id]: legal name, org number, VAT number, country, then the SCB facts under one source line, with "Hämta uppgifter" or "Hitta i företagsregistret" as the one action. The registry helpers move out of the dossier into RegistryFacts so the three surfaces share them. - The enrich route makes the registry's legal name the displayed name of the party and of supplier and customer rows that still carry the party's old name; all-capitals names are set in title case (lib/parties/registry-name.ts). Names a person set stay. - legacyLedgerKey: a party confirmed under the pre-2026-09-04 key keeps its vouchers, so a rebuild attaches the new key instead of offering the same company again. - GET /api/parties/[id] reports whether SCB is configured. Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
18 lines
922 B
TypeScript
18 lines
922 B
TypeScript
import { NextResponse } from 'next/server'
|
|
import { withRouteContext } from '@/lib/api/with-route-context'
|
|
import { errorResponseFromCode } from '@/lib/errors/get-structured-error'
|
|
import { getDossier } from '@/lib/parties/register'
|
|
import { isScbConfigured } from '@/lib/parties/scb/config'
|
|
|
|
/** GET /api/parties/[id]: the dossier for one party (facts, identities, decisions, vouchers). */
|
|
export const GET = withRouteContext<{ params: Promise<{ id: string }> }>(
|
|
'parties.get',
|
|
async (_request, { supabase, companyId, log, requestId }, { params }) => {
|
|
const { id } = await params
|
|
if (!/^[0-9a-f-]{36}$/i.test(id)) return errorResponseFromCode('NOT_FOUND', log, { requestId })
|
|
const dossier = await getDossier(supabase, companyId, id)
|
|
if (!dossier) return errorResponseFromCode('NOT_FOUND', log, { requestId })
|
|
return NextResponse.json({ data: dossier, scbConfigured: isScbConfigured() })
|
|
},
|
|
)
|