@lacspace/invoice
Invoice model, numbering and tax-rollup engine — per-line and total calculation, tax grouped by rate, sequential invoice numbers, payment tracking and a render-ready row structure for PDF/XLSX. Integer minor units, zero-dependency, isomorphic.
npm i @lacspace/invoiceUsage
import { createInvoice, recordPayment, invoiceNumber } from "@lacspace/invoice";
let inv = createInvoice({
number: invoiceNumber(123), // "INV-2026-000123"
currency: "NPR",
seller: { name: "Lacspace", taxId: "PAN123" },
buyer: { name: "Sita Rai" },
lines: [{ description: "Dhaka Topi", qty: 2, unitPrice: 120000, taxRate: 0.13 }],
});
// inv.taxSummary groups tax by rate; inv.totals.balanceDue in integer paisa
inv = recordPayment(inv, 271200); // status -> "paid", balanceDue -> 0Exports 8
createInvoicerecordPaymentmarkVoidmarkIssuedisOverdueinvoiceNumberrenderRowsInvoiceErrorKeywords
More in Commerce & Ledger
Headless, framework-agnostic shopping-cart engine — pure, immutable & serializable. Add/merge lines, set quantities, compute tax/discount/shipping totals in integer minor units. Isomorphic (Node, edge, browser).
@lacspace/inventoryStock-tracking engine that prevents overselling — reserve, release, commit & restock over a plain { onHand, reserved } state. Immutable, bring-your-own-store, throws before it oversells. Isomorphic.
@lacspace/commissionCommission & payout calculation engine — flat, percentage and marginal-tiered rules with min/cap, plus exact proportional split with remainder distribution. Integer minor units, zero floats. Isomorphic.
@lacspace/settlementSettlement, netting & reconciliation for multi-party payouts — net signed ledger entries per account, reconcile expected vs actual, and list payable positive balances. Integer minor units, pure functions. Isomorphic.
@lacspace/couponDiscount & coupon engine — percent, fixed and free-shipping codes with validity windows, minimum-subtotal, discount caps and usage limits. Integer minor units, no float drift. Zero-dependency, isomorphic.
@lacspace/taxVAT & sales-tax done right — exact integer minor-unit arithmetic (no float cents bugs), add/extract tax, inclusive & exclusive prices, compound taxes, half-up/bankers rounding. Isomorphic.