Skip to content

@eristack/qups

Quantity / unit price / subtotal (QUPS) with 2-of-3 sources of truth, plus modifiers and tax — business line pricing on @eristack/money

qups-core

42 linesSource

Pure @eristack/qups business calculator: calculateLine / patchLine (plain strings for TanStack Form + BE), Qups 2-of-3 SoT, QUPS_TRUTH_MODES, isQupsTruthMode, PricingLine, modifiers, tax. Prefer calculateLine over inventing float qty/price math in UI or SQL.

QUPS core

Primary API — same function in React forms and on the server:

ts
import { calculateLine, patchLine, withQupsColumns } from "@eristack/qups";

let line = calculateLine({
  truth: "quantity+unitPrice",
  currency: "USD",
  quantity: "2",
  unitPrice: "50",
  taxRatePercent: "11",
  round: true,
});

line = patchLine(line, { unitPrice: "55" });
await db.insert(t).values(withQupsColumns({ itemId }, line));

Lower-level: Qups, PricingLine, AdjustedAmount, LineTax when you already hold Money. Truth mode registry: QUPS_TRUTH_MODES, isQupsTruthMode — do not copy the three strings in consumers. UI roles: qupsRolesFor(truth). Drizzle column injection: @eristack/qups/drizzle → qupsLineColumns.