|
|
|
|
@ -61,6 +61,17 @@ describe('clientLedger — outstanding + per-payment allocations', () => {
|
|
|
|
|
expect(led.outstanding.find((o) => o.docId === inv.id)).toBeUndefined()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('excludes a draft proforma from outstanding but still includes a sent one', async () => {
|
|
|
|
|
const db = openDb(':memory:')
|
|
|
|
|
const { clientId, inv, pf } = await buildFixture(db)
|
|
|
|
|
const draftPf = await createDraft(db, 'u1', {
|
|
|
|
|
docType: 'PROFORMA', clientId, lines: [{ moduleId: inv.payload.lines[0]!.itemId, qty: 1, kind: 'yearly' }],
|
|
|
|
|
}) // left as 'draft' — never issued/sent
|
|
|
|
|
const led = await clientLedger(db, clientId)
|
|
|
|
|
expect(led.outstanding.find((o) => o.docId === draftPf.id)).toBeUndefined()
|
|
|
|
|
expect(led.outstanding.find((o) => o.docId === pf.id)).toMatchObject({ docId: pf.id, docNo: pf.docNo })
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('attaches allocations to each payment', async () => {
|
|
|
|
|
const db = openDb(':memory:')
|
|
|
|
|
const { clientId, inv, payment } = await buildFixture(db)
|
|
|
|
|
|