fix(vat): recover ruta 05 for null-rate custom accounts (#1296)

This commit is contained in:
Mattsson
2026-07-30 11:28:50 +02:00
committed by GitHub
parent 392e847c1e
commit 6318501b71
7 changed files with 154 additions and 33 deletions
@@ -28,7 +28,11 @@ interface SupabaseShape {
function buildSupabase(
linesResult: { data: unknown; error: unknown },
fiscalPeriodResult: { data: unknown; error: unknown } = { data: null, error: null },
chartAccounts: Array<{ account_number: string; default_vat_rate: number }> = []
chartAccounts: Array<{
account_number: string
account_name?: string
default_vat_rate: number | null
}> = []
): SupabaseShape {
const chartResult = { data: chartAccounts, error: null }
return {
@@ -253,6 +257,18 @@ describe('GET /api/reports/vat-declaration/ruta/[ruta]/sources: ruta 05 accounts
expect(accounts).toContain('3001') // static mapping still there
})
it('drills into a null-rate account when its number and label resolve the rate (#1289)', async () => {
const supabase = buildSupabase({ data: [], error: null }, { data: null, error: null }, [{
account_number: '3011',
account_name: 'Försäljning tjänster inom Sverige, 25 % moms',
default_vat_rate: null,
}])
authOk(supabase)
expect((await get('05')).status).toBe(200)
expect(rpcAccounts(supabase)).toContain('3011')
})
it('leaves other rutor on the static mapping alone', async () => {
const supabase = buildSupabase({ data: [], error: null }, { data: null, error: null }, [
{ account_number: '3013', default_vat_rate: 0.06 },