Create a minimal model
A model needs a reporting currency, a timeline, and declarations collected with defineModel(). This example gives one asset a fixed monthly cash inflow for a year.
import { cashflow, currencies, defineModel, entity, inflow, periods, run, schedule } from "deccf";
const building = entity.asset();
const rent = cashflow({
owner: building,
direction: inflow,
schedule: schedule.monthly(),
amount: 10_000,
});
const model = defineModel({
name: "one-year-rent",
currency: currencies.USD,
timeline: periods.monthly({ from: "2026-01", count: 12 }),
entities: { building },
flows: { rent },
});
const result = run(model);
console.log(result.metrics.total); // 120000
return model;entity.asset() creates an entity that can group cashflows. cashflow() defines a signed series, and schedule.monthly() places it in every model period. defineModel() connects the declarations; run() returns the result object.
In this repository, an example under examples/ can import from ../src/index.js. Installed projects use the public package path deccf.
Validate without running
import { cashflow, compileModel, currencies, defineModel, entity, inflow, periods, schedule } from "deccf";
const building = entity.asset();
const rent = cashflow({ owner: building, direction: inflow, schedule: schedule.monthly(), amount: 10_000 });
const model = defineModel({
name: "one-year-rent",
currency: currencies.USD,
timeline: periods.monthly({ from: "2026-01", count: 12 }),
entities: { building },
flows: { rent },
});
const plan = compileModel(model);
console.log(plan.dates.length); // 12
return model;The compiler checks that referenced entities and cashflows belong to the model, schedules fit the timeline, and flow dependencies have no cycles.
Next: Add cashflows.