import { describe, it, expect } from 'vitest' import { openDb } from '../src/db' import { createModule, setPrice, priceOn } from '../src/repos-modules' describe('module catalog', () => { it('resolves the dated price row', () => { const db = openDb(':memory:') const m = createModule(db, 'u1', { code: 'POS', name: 'POS Billing' }) setPrice(db, 'u1', { moduleId: m.id, kind: 'yearly', pricePaise: 1_20_000_00, effectiveFrom: '2026-04-01' }) setPrice(db, 'u1', { moduleId: m.id, kind: 'yearly', pricePaise: 1_50_000_00, effectiveFrom: '2026-08-01' }) expect(priceOn(db, m.id, 'yearly', 'standard', '2026-07-10')).toBe(1_20_000_00) expect(priceOn(db, m.id, 'yearly', 'standard', '2026-09-01')).toBe(1_50_000_00) expect(priceOn(db, m.id, 'monthly', 'standard', '2026-09-01')).toBeNull() }) })