@lacspace/commission
Commission & 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.
npm i @lacspace/commissionUsage
import { commission, split } from "@lacspace/commission";
// tiered marketplace take-rate, capped
const fee = commission({ type: "tiered", cap: 100000, tiers: [
{ upTo: 500000, rate: 0.10 },
{ rate: 0.08 },
] }, 800000);
// pay 3 sellers exactly — no paisa created or lost
const shares = split(100000, [{ id: "a", weight: 1 }, { id: "b", weight: 1 }, { id: "c", weight: 1 }]);
// 33334 | 33333 | 33333Exports 2
commissionsplitKeywords
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/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.
@lacspace/ledgerA tiny double-entry ledger & wallet — balanced transactions, per-account balances and a trial balance that always sums to zero. Integer minor units, immutable ops, crypto-random ids. Isomorphic.