DECCF · Cash Flow Modeler and Calculator

Run one model with different inputs

Declare a precondition once, then pass an inline run configuration to each run. The model itself does not need to change.

import { cashflow, category, currencies, defineModel, entity, inflow, input, periods, run, schedule } from "deccf";

const growth = input.rate(0.02);
const company = entity.asset();
const revenue = cashflow({
  owner: company,
  direction: inflow,
  category: category("business.sales"),
  schedule: schedule.monthly({ from: "2026-01", to: "2027-12" }),
  amount: (ctx) => 10_000 * (1 + ctx.get(growth)) ** (ctx.time.index / 12),
});
const model = defineModel({
  name: "first-model",
  currency: currencies.USD,
  timeline: periods.monthly({ from: "2026-01", count: 24 }),
  preconditions: { growth },
  entities: { company },
  flows: { revenue },
});

const slow = run(model, { deterministic: { inputs: { growth: 0.01 } } });
const fast = run(model, { deterministic: { inputs: { growth: 0.04 } } });
return model;

Keys in deterministic.inputs match names in the model's preconditions map. Values can be JavaScript numbers, strings (including text read from a file), Money values, or date strings for input.date() preconditions. A wrapped value may use { value, source }. To replace a curve, use { series: { points: [{ date, value }], interpolation } }.

You can also use deterministic.parameters with keys such as "inputs.growth"; that form only accepts scalar values. Curves use deterministic.inputs. The compatibility option overrides takes a Map keyed by input references.

A precondition can only be overridden once in a run. Do not set the same input through overrides, parameters, and inputs at the same time. Unknown names, invalid types, out-of-domain values, and invalid shapes raise a ModelError.

runScenarios() accepts scenarios with a name and overrides: Map, keyed by the model's input references. For several object-based input sets, call run() separately; each call returns a new result and leaves the model unchanged. For the interactive batch workflow in the Calculator, see Create scenarios in the Calculator.