You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
820 B
TypeScript
19 lines
820 B
TypeScript
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', async () => {
|
|
const db = openDb(':memory:')
|
|
expect(await nextDocNo(db, 'QUOTATION', '2026-27')).toBe('QT/26-27-0001')
|
|
expect(await nextDocNo(db, 'QUOTATION', '2026-27')).toBe('QT/26-27-0002')
|
|
expect(await nextDocNo(db, 'INVOICE', '2026-27')).toBe('INV/26-27-0001')
|
|
expect(await nextDocNo(db, 'QUOTATION', '2027-28')).toBe('QT/27-28-0001')
|
|
})
|
|
it('seeds from the last APEX number at cutover', async () => {
|
|
const db = openDb(':memory:')
|
|
await seedSeries(db, 'INVOICE', '2026-27', 412)
|
|
expect(await nextDocNo(db, 'INVOICE', '2026-27')).toBe('INV/26-27-0413')
|
|
})
|
|
})
|