// Shared number/date formatting for printed invoices. /** `Rs. 12,450.00` — thousands separator, exactly 2 decimals. */ export const fmtMoney = (n: number) => `Rs. ${n.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` /** Quantity: up to 3 decimals, trailing zeros dropped. */ export const fmtQty = (n: number) => n.toLocaleString('en-US', { maximumFractionDigits: 3 }) /** `dd/MM/yyyy` */ export function fmtDate(v: string | null | undefined) { if (!v) return '—' const d = new Date(v) const dd = String(d.getDate()).padStart(2, '0') const mm = String(d.getMonth() + 1).padStart(2, '0') return `${dd}/${mm}/${d.getFullYear()}` } export const invoiceNo = (id: string) => `INV-${id.substring(0, 8).toUpperCase()}`