import { describe, it, expect } from 'vitest' import { documentHtml, rupeesInWords } from '../src/templates' const doc = { id: 'd1', docType: 'INVOICE', docNo: 'INV/26-27-0001', fy: '2026-27', clientId: 'c1', docDate: '2026-07-10', status: 'draft', refDocId: null, taxablePaise: 10_000_00, cgstPaise: 900_00, sgstPaise: 900_00, igstPaise: 0, roundOffPaise: 0, payablePaise: 11_800_00, payload: { lines: [{ itemId: 'm1', name: 'POS Billing — yearly', hsn: '998313', qty: 1, unitCode: 'NOS', unitPricePaise: 10_000_00, grossPaise: 10_000_00, discountPaise: 0, taxablePaise: 10_000_00, taxRateBp: 1800, cgstPaise: 900_00, sgstPaise: 900_00, igstPaise: 0, cessPaise: 0, lineTotalPaise: 11_800_00 }], totals: {} }, } as never const client = { id: 'c1', code: 'CL0001', name: 'Acme', stateCode: '32', address: 'Kochi', contacts: [], status: 'active', notes: '' } as never const company = { 'company.name': 'Tecnostac', 'company.gstin': '', 'company.address': '', 'company.phone': '', 'company.email': '', 'company.bank': 'HDFC ****1234' } describe('document html', () => { it('renders number, SAC, Indian-grouped totals and TAX INVOICE title', () => { const html = documentHtml(doc, client, company) expect(html).toContain('INV/26-27-0001') expect(html).toContain('TAX INVOICE') expect(html).toContain('998313') // SAC column expect(html).toContain('₹11,800.00') // formatINR grouping expect(html).toContain('HDFC ****1234') // bank block on invoices }) it('titles a quotation QUOTATION and omits the bank block', () => { const html = documentHtml({ ...(doc as object), docType: 'QUOTATION', docNo: 'QT/26-27-0001' } as never, client, company) expect(html).toContain('QUOTATION') expect(html).not.toContain('HDFC') }) it('renders per-line content bullets when present and nothing when absent', () => { const withContent = { ...(doc as object), payload: { lines: (doc as never as { payload: { lines: unknown[] } }).payload.lines, lineContents: [['Bulk SMS gateway', 'DLT template registration']], totals: {} }, } as never const html = documentHtml(withContent, client, company) expect(html).toContain('