* feat: add Bankgirot LB-fil support for salary payments and tax payments - Implemented `generateBgLb` for salary batch payments, producing opening, payment, and closing records. - Added tests for `generateBgLb` to ensure correct record generation and validation. - Created `generateBankgiroPaymentBgLb` for single tax payments to Skatteverket, including validation and formatting. - Added tests for `generateBankgiroPaymentBgLb` to verify record structure and data integrity. - Introduced `generateSkattekontoOcr` for generating valid OCR references for Skattekonto payments, with tests for various input formats. - Updated database schema to track payment file formats and timestamps for salary runs and AGI declarations. - Created a new table for logging salary payslip deliveries to ensure compliance with audit requirements. * feat: add write permission check and company ID validation for payment file generation * feat: add write permission check for salary payment file generation
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { generateSkattekontoOcr, SKATTEKONTO_BANKGIRO } from '../skattekonto-ocr'
|
|
import { luhnValidate } from '@/lib/bankgiro/luhn'
|
|
|
|
describe('generateSkattekontoOcr', () => {
|
|
it('produces 11-digit OCR with valid Luhn check digit for AB org-number', () => {
|
|
const ocr = generateSkattekontoOcr('556012-3456')
|
|
expect(ocr).toHaveLength(11)
|
|
expect(ocr.startsWith('5560123456')).toBe(true)
|
|
expect(luhnValidate(ocr)).toBe(true)
|
|
})
|
|
|
|
it('accepts org-number without dash', () => {
|
|
expect(generateSkattekontoOcr('5560123456')).toBe(generateSkattekontoOcr('556012-3456'))
|
|
})
|
|
|
|
it('accepts 12-digit personnummer by stripping century prefix', () => {
|
|
const ocr12 = generateSkattekontoOcr('198802251234')
|
|
const ocr10 = generateSkattekontoOcr('880225-1234')
|
|
expect(ocr12).toBe(ocr10)
|
|
})
|
|
|
|
it('rejects malformed numbers', () => {
|
|
expect(() => generateSkattekontoOcr('123')).toThrow(/Ogiltigt/)
|
|
expect(() => generateSkattekontoOcr('')).toThrow(/Ogiltigt/)
|
|
expect(() => generateSkattekontoOcr('abcdefghij')).toThrow(/Ogiltigt/)
|
|
})
|
|
|
|
it('exports correct Bankgiro for Skattekontot', () => {
|
|
expect(SKATTEKONTO_BANKGIRO).toBe('5050-1055')
|
|
})
|
|
})
|