Order cashflow dependencies
A cashflow can read another cashflow's value in the same period with ctx.get(). Add the referenced cashflow to dependsOn so the engine knows the required order.
import { cashflow, currencies, defineModel, entity, inflow, outflow, periods, schedule } from "deccf";
const company = entity.asset();
const gross = cashflow({
owner: company,
direction: inflow,
schedule: schedule.monthly(),
amount: 1_000,
});
const fee = cashflow({
owner: company,
direction: outflow,
schedule: schedule.monthly(),
dependsOn: [gross],
amount: (ctx) => ctx.get(gross).amount * 0.05,
});
const model = defineModel({
name: "gross-and-net-revenue",
currency: currencies.SEK,
timeline: periods.monthly({ from: "2026-01", count: 12 }),
entities: { company },
flows: { gross, fee },
});
return model;The compiler orders dependencies before a run. Missing references and cycles cause validation errors. ctx.get(flowRef) returns the current period's Money value.
ctx.sum(flowRef, from?, to?) sums a flow across period indexes. The interval endpoints are inclusive. A callback cannot read future periods that have not run. For a running value, use a field with next and ctx.previous().
When a callback reads another object or input, pass its reference rather than its name as a string.