Files
accounted/app/api/reports/salary-journal/route.ts
T
Mattsson e11f70b347 Bug/gh issues fiz (#1103)
* 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
2026-07-21 23:00:15 +02:00

23 lines
1.1 KiB
TypeScript

import { withRouteContext } from '@/lib/api/with-route-context'
import { NextResponse } from 'next/server'
import { generateSalaryJournal } from '@/lib/reports/salary-journal'
import { getErrorMessage } from '@/lib/errors/get-error-message'
/**
* Lönejournal report, per BFNAR 2013:2 behandlingshistorik requirement.
* Monthly/annual per-employee salary register for AGI reconciliation.
*/
export const GET = withRouteContext('report.salary_journal', async (request, { supabase, companyId }) => {
const { searchParams } = new URL(request.url)
const year = parseInt(searchParams.get('year') || new Date().getFullYear().toString())
const monthFrom = searchParams.get('month_from') ? parseInt(searchParams.get('month_from')!) : undefined
const monthTo = searchParams.get('month_to') ? parseInt(searchParams.get('month_to')!) : undefined
try {
const report = await generateSalaryJournal(supabase, companyId, year, monthFrom, monthTo)
return NextResponse.json({ data: report })
} catch (err) {
return NextResponse.json({ error: getErrorMessage(err) }, { status: 500 })
}
})