@OPENQUOTESTACK/ENGINE

Pricing with a memory. Logic without baggage.

A functional TypeScript pricing engine. Independent of React, HTTP, PostgreSQL, authentication and browser state.

ESM + TYPE DECLARATIONSNODE.JS 20+ / VERIFIED WITH 24AGPL-3.0-ONLY

One calculation.
A useful explanation.

Pass a validated definition and answers. Get structured line items, adjustments, totals, an optional range and the rule metadata that explains each amount.

No implicit clock, locale, randomness or network dependency changes the result. Calendar adjustments use an explicitly supplied date answer.

Read the package API
moving-estimate.tstypescript
import document from "./moving-company.oqs.json";
import { parseEstimator } from "@openquotestack/schema";
import { calculateEstimate } from "@openquotestack/engine";

const result = calculateEstimate(parseEstimator(document), {
  origin: "Boston",
  destination: "Cambridge",
  bedrooms: 3, distance: 22, elevator: true,
  boxes: 0, piano: true, packing: false,
  moving_date: "2026-10-10"
});

result.totalMinor; // 70863
result.currency;   // "USD"
result.lineItems;  // Ordered calculation details

Money deserves precise semantics.

Prices use integer minor units and a declared currency exponent. Exact rational intermediates avoid uncontrolled floating-point calculations. Each rule rounds once, half away from zero.

Percentages choose an explicit base. Tiers are graduated. Bounds apply after rules; ranges describe uncertainty around the final total.

Formatting belongs to the caller. The engine returns monetary data, never a locale-formatted dollar string. Historical estimates retain the definition, effective answers and result used during calculation.

Rule ordering, rounding and formulas
  • Fixed and per-unit charges
  • Conditional fees and shared AND / OR logic
  • Percentages and calendar-day adjustments
  • Graduated tiers
  • Minimum, maximum and ranges
  • Arithmetic AST with + − × ÷

Build from the source.

The package is prepared for external publication. Until published, build it in the OpenQuoteStack monorepo and use its workspace or locally packed output.

Monorepo setup
Terminal / OpenQuoteStack repositorybash
pnpm install --frozen-lockfile
pnpm exec turbo build --filter=@openquotestack/engine
pnpm --filter @openquotestack/engine pack --pack-destination artifacts

OPEN SOURCE / OPEN POSSIBILITIES

Pricing logic
should belong to you.