e11f70b347
* refactor: optimize page loading and data fetching * fix: resolve recurring production runtime errors * feat: add MCP company and customer updates * fix: handle year-end tax adjustments * feat: harden annual report compliance * fix: expand invoice logo and font support * fix: sanitize API route error responses * fix: sanitize user-facing error messages * feat: persist onboarding and tax assessment notices * fix: reduce cloud backup audit churn * feat: refine invoice editor layout * fix: show saved tax adjustments in INK2 * fix: complete annual report API mappings * docs: record operational safeguards and decisions * fix: harden annual report review findings * fix: adjust column span for description based on VAT registration * New css class name
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import { withRouteContext } from '@/lib/api/with-route-context'
|
|
import { errorResponse, errorResponseFromCode } from '@/lib/errors/get-structured-error'
|
|
import { buildCanonicalAnnualReport } from '@/lib/bokslut/arsredovisning/model'
|
|
import { getAnnualReportCapabilities } from '@/lib/bokslut/arsredovisning/capabilities'
|
|
|
|
export const GET = withRouteContext(
|
|
'period.arsredovisning_data',
|
|
async (_request, ctx, { params }: { params: Promise<{ id: string }> }) => {
|
|
const { id } = await params
|
|
const { supabase, companyId, log, requestId } = ctx
|
|
try {
|
|
const model = await buildCanonicalAnnualReport(supabase, companyId, id, {
|
|
stage: 'draft',
|
|
includeIxbrl: false,
|
|
})
|
|
return NextResponse.json({
|
|
data: model.report,
|
|
compliance: {
|
|
profile: model.profile,
|
|
disclosures: model.disclosures,
|
|
eligibility: model.eligibility,
|
|
validation: model.validation,
|
|
capabilities: getAnnualReportCapabilities(
|
|
model.report.accounting_framework,
|
|
model.eligibility,
|
|
),
|
|
},
|
|
})
|
|
} catch (err) {
|
|
const message = err instanceof Error ? err.message : ''
|
|
if (/not found/i.test(message)) {
|
|
return errorResponseFromCode('PERIOD_NOT_FOUND', log, { requestId })
|
|
}
|
|
return errorResponse(err, log, { requestId })
|
|
}
|
|
},
|
|
)
|