import { UNIT_LABELS } from "../lib/types"; import { computeLineAmount } from "../lib/invoice"; import { formatAmount, formatDate } from "../lib/format"; import type { InvoicePdfProps } from "../pdf/InvoiceDocument"; const money = (n: number) => `₹${formatAmount(n)}`; /** On-screen preview that mirrors the exported PDF layout. */ export function InvoicePreview(props: InvoicePdfProps) { const { vendor, bank, logoDataUri, signatureDataUri, number, invoiceDate, dueDate, clientName, clientAddress, clientGstin, poNumber, placeOfSupplyStateCode, items, subtotal, discount, taxType, taxRate, cgst, sgst, igst, total, amountInWords, notes, } = props; const isTaxInvoice = taxType !== "none"; const contact = [vendor.vendorEmail, vendor.vendorPhone].filter(Boolean).join(" · "); return (
{vendor.vendorAddress}
{contact ?{contact}
: null} {vendor.vendorPan ?PAN: {vendor.vendorPan}
: null}GSTIN: {vendor.vendorGstin || "NA"}
Billed To
PO Number
| Description | Unit Price | Qty | Total |
|---|---|---|---|
| {item.description || "—"} | {item.mode === "rate" ? `${money(item.rate)} ${UNIT_LABELS[item.unit]}` : "—"} | {item.mode === "rate" ? item.quantity : 1} | {money(computeLineAmount(item))} |
Amount in words: {amountInWords}
{notes ? (Notes
Pay To
Computer-generated invoice; no signature is required.
> )}