import { describe, it, expect } from 'vitest' import { openDb } from '../src/db' import { nextDocNo, seedSeries } from '../src/series' describe('hq doc series', () => { it('starts at 0001 per type+fy and increments', () => { const db = openDb(':memory:') expect(nextDocNo(db, 'QUOTATION', '2026-27')).toBe('QT/26-27-0001') expect(nextDocNo(db, 'QUOTATION', '2026-27')).toBe('QT/26-27-0002') expect(nextDocNo(db, 'INVOICE', '2026-27')).toBe('INV/26-27-0001') expect(nextDocNo(db, 'QUOTATION', '2027-28')).toBe('QT/27-28-0001') }) it('seeds from the last APEX number at cutover', () => { const db = openDb(':memory:') seedSeries(db, 'INVOICE', '2026-27', 412) expect(nextDocNo(db, 'INVOICE', '2026-27')).toBe('INV/26-27-0413') }) })