Files
accounted/lib/reports/__tests__/vat-declaration-pdf-template.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

41 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, it, expect } from 'vitest'
import { renderToBuffer } from '@react-pdf/renderer'
import { VatDeclarationPDF } from '../vat-declaration-pdf-template'
import type { CompanySettings } from '@/types'
import { pdfTextStrings } from '@/tests/pdf-text'
function fakeCompany(): CompanySettings {
return {
company_name: 'Testbolaget AB',
org_number: '5566778899',
vat_number: 'SE556677889901',
} as unknown as CompanySettings
}
describe('VatDeclarationPDF sign rendering (issue #1982)', () => {
it('prints a negative ruta with an ASCII minus the bundled font can draw', async () => {
const text = pdfTextStrings(
await renderToBuffer(
VatDeclarationPDF({
rows: [
{ ruta: '05', label: 'Momspliktig försäljning', amount: 100000 },
{ ruta: '10', label: 'Utgående moms 25 %', amount: 25000 },
// A credit-note-heavy period can push a ruta below zero.
{ ruta: '48', label: 'Ingående moms att dra av', amount: -1234 },
{ ruta: '49', label: 'Moms att betala', amount: 26234, isNet: true },
],
period: { start: '2026-04-01', end: '2026-06-30' },
periodLabel: 'April till juni 2026',
company: fakeCompany(),
generatedAt: '2026-08-29T10:00:00Z',
})
)
).join('\n')
expect(text).toContain('-1 234')
expect(text).toContain('26 234')
expect(text).not.toContain(String.fromCharCode(0x12))
expect(text).not.toContain('−')
}, 30_000)
})