feat: add option to exclude year-end closing entries in SIE export and related reports (#567)
This commit is contained in:
@@ -1735,6 +1735,7 @@ export default function ImportPage() {
|
||||
const [userId, setUserId] = useState('')
|
||||
const [isSandbox, setIsSandbox] = useState(false)
|
||||
const [exportPeriodId, setExportPeriodId] = useState<string | null>(null)
|
||||
const [exportExcludeClosing, setExportExcludeClosing] = useState(true)
|
||||
const t = useTranslations('import')
|
||||
const router = useRouter()
|
||||
const hasCloudBackup = ENABLED_EXTENSION_IDS.has('cloud-backup')
|
||||
@@ -2042,10 +2043,21 @@ export default function ImportPage() {
|
||||
hideFuturePeriods
|
||||
label={t('export_sie_period_label')}
|
||||
/>
|
||||
<label className="flex items-start gap-2 text-sm text-muted-foreground cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="mt-0.5 h-4 w-4 rounded border-border"
|
||||
checked={exportExcludeClosing}
|
||||
onChange={(e) => setExportExcludeClosing(e.target.checked)}
|
||||
/>
|
||||
<span>{t('export_sie_exclude_closing_label')}</span>
|
||||
</label>
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (exportPeriodId) {
|
||||
window.open(`/api/reports/sie-export?period_id=${exportPeriodId}`, '_blank')
|
||||
const params = new URLSearchParams({ period_id: exportPeriodId })
|
||||
if (exportExcludeClosing) params.set('exclude_closing', 'true')
|
||||
window.open(`/api/reports/sie-export?${params.toString()}`, '_blank')
|
||||
}
|
||||
}}
|
||||
disabled={!exportPeriodId || isSandbox}
|
||||
|
||||
@@ -10,6 +10,7 @@ export const GET = withRouteContext(
|
||||
|
||||
const { searchParams } = new URL(request.url)
|
||||
const periodId = searchParams.get('period_id')
|
||||
const excludeClosing = searchParams.get('exclude_closing') === 'true'
|
||||
|
||||
if (!periodId) {
|
||||
return errorResponseFromCode('REPORT_PERIOD_REQUIRED', log, { requestId })
|
||||
@@ -32,6 +33,7 @@ export const GET = withRouteContext(
|
||||
fiscal_period_id: periodId,
|
||||
company_name: company.company_name || 'Unknown',
|
||||
org_number: company.org_number,
|
||||
exclude_year_end_closing: excludeClosing,
|
||||
})
|
||||
|
||||
return new NextResponse(sieContent, {
|
||||
|
||||
@@ -53,6 +53,8 @@ export const GET = withApiV1<{ params: Promise<{ companyId: string }> }>(
|
||||
})
|
||||
if (!period.ok) return period.response
|
||||
|
||||
const excludeClosing = new URL(request.url).searchParams.get('exclude_closing') === 'true'
|
||||
|
||||
const { data: company, error: companyErr } = await ctx.supabase
|
||||
.from('company_settings')
|
||||
.select('company_name, org_number')
|
||||
@@ -71,6 +73,7 @@ export const GET = withApiV1<{ params: Promise<{ companyId: string }> }>(
|
||||
fiscal_period_id: period.period.id,
|
||||
company_name: (company as { company_name: string | null }).company_name || 'Unknown',
|
||||
org_number: (company as { org_number: string | null }).org_number,
|
||||
exclude_year_end_closing: excludeClosing,
|
||||
}),
|
||||
{ log: ctx.log, requestId: ctx.requestId, reportName: 'sie-export' },
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user