Licence
MIT
Version
0.3.0
Deps
1
Size
33 kB
Vulns
0
Weekly
0
open-pricing-engine
A configurable, framework-agnostic pricing engine for any business domain.
Install
npm install open-pricing-engine
Usage
import { PricingEngine } from 'open-pricing-engine';
const engine = new PricingEngine({
rules: [
{
name: 'flat-surface',
type: 'area',
unitPrice: 12.5,
unit: 'm2',
minCharge: 25.0,
},
],
});
const result = engine.calculate({
rule: 'flat-surface',
dimensions: { width: 2.0, height: 1.5 },
quantity: 10,
});
// Result:
// {
// rule: 'flat-surface',
// measure: 3.0,
// unitPrice: 12.50,
// subtotal: 37.50,
// adjustments: [],
// adjusted: 37.50,
// quantity: 10,
// total: 375.00
// }
Features
- Config-driven — define pricing rules in JSON
- Multiple pricing strategies — area, linear, volume, weight, time, piece, flat
- Discounts & surcharges — percentage and fixed adjustments, applied as a cascade
- Minimum charge — guaranteed price floor per item
- TypeScript-first — full type safety
- Zod validation — descriptive errors for invalid config
- 100% test coverage
Documentation
Full documentation, roadmap, and contributing guide: GitHub