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
28 lines
1004 B
TypeScript
28 lines
1004 B
TypeScript
import { NextResponse } from 'next/server'
|
|
import { validateBalanceContinuity } from '@/lib/reports/continuity-check'
|
|
import { withRouteContext } from '@/lib/api/with-route-context'
|
|
import { getErrorMessage as getUserErrorMessage } from '@/lib/errors/get-error-message'
|
|
|
|
/**
|
|
* GET: Validate IB/UB continuity for a fiscal period.
|
|
* Query param: period_id (required)
|
|
*/
|
|
export const GET = withRouteContext('report.continuity_check', async (request, { supabase, companyId }) => {
|
|
const { searchParams } = new URL(request.url)
|
|
const periodId = searchParams.get('period_id')
|
|
|
|
if (!periodId) {
|
|
return NextResponse.json({ error: 'period_id is required' }, { status: 400 })
|
|
}
|
|
|
|
try {
|
|
const result = await validateBalanceContinuity(supabase, companyId, periodId)
|
|
return NextResponse.json({ data: result })
|
|
} catch (err) {
|
|
return NextResponse.json(
|
|
{ error: err instanceof Error ? getUserErrorMessage(err) : 'Failed to validate continuity' },
|
|
{ status: 400 }
|
|
)
|
|
}
|
|
})
|