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.
sims-hq/apps/hq/test/series.test.ts

19 lines
772 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', () => {
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')
})
})