Result format
run() returns a frozen JavaScript object. JSON.stringify(result) calls result.toJSON() automatically. Hash fields are not included.
Serialized top-level fields
results_version: the current format version,0.24.engine: engine name and version.warnings: currently always an empty array.moneyValue:"nominal"by default, or"today"for monetary outputs expressed in base-date purchasing power.amountStorage:"calendar-year"or"fiscal-year"when annual monetary storage was selected; omitted for default"period"storage.inflation: the effective annual decimal inflation rate, including input overrides; defaults to zero.moneyValueBaseDate: the first resolved timeline date, including a timeline input override.inputs.preconditions: declared preconditions with name, shape, type, value, and origin. Curve preconditions also include the effectiveseries.pointsandseries.interpolation. The field is omitted if the model has no preconditions. The reporting currency is selected in the model or through therun()options.deterministic: status, metrics, time series, annual rollup, optional labeled category hierarchy, account postings, and optional state transitions or journal entries.scenarios:not_runwith an empty summary list.monte_carlo:not_run, zero trials, and empty summaries.graph.entities: symbol, family, and optional parent.graph.agreements: each agreement's subject and parties by role.graph.accounts: account name, side (owedordue), optional type (asset,liability,equity,income,expense, ortransfer), owner, and category. Labeled account categories also includecategory_label. Each freshly calculated account also includesopening_balance: {amount, currency}: its actual initial signed ledger balance before the first model period, after applying input overrides.statements.statementsandslices: empty collections.timings: measured durations for preparation, the main run, metrics, result construction, and the full call.
These fields describe an ordinary run() result. They do not mean statements, slices, scenario aggregation, or Monte Carlo were run. A runMonteCarlo() result includes the same complete base calculation and additionally publishes the simulation statistics in summaries and monte_carlo. Its base calculation uses the same input overrides and central distribution values. In a Monte Carlo result, monte_carlo.status is "ok"; its trials, seed and metrics describe the simulation. runScenarios() returns one such ordinary or Monte Carlo result per scenario.
Authoritative account openings
graph.accounts[].opening_balance uses the same calculation currency and signed ledger convention as account.<name>.balance: debit increases and credit decreases the balance, including liability/equity accounts. It is the opening before any first-period posting, not that period's ending balance. Input overrides apply before the opening is observed. The inert opening also remains available in saved consumer calculation results.
For example, enter a cash account with an initial amount in the model editor:
const owner = deccf.entity.party();
const bank = deccf.account({
owner,
type: "asset",
category: deccf.category("personal.assets.cash.bank"),
initial: deccf.money(1000, deccf.currencies.SEK),
});
return deccf.defineModel({
currency: deccf.currencies.SEK,
timeline: deccf.periods.monthly({ from: "2027-01", count: 2 }),
entities: { owner },
accounts: { bank },
});Its opening observation is {amount: 1000, currency: "SEK"}. Older saved results may omit this optional field and remain readable by existing reports. The indirect cash flow statement needs it for the first simulated period, or a real preceding period balance for a later selection; otherwise it asks for a new calculation rather than guessing an opening.
Runtime timings
timings uses integer microsecond ticks from the monotonic performance.now() clock. mainTicks includes model preparation and the period-by-period calculation; setupTicks and simulationTicks show those parts separately. resultConstructionTicks covers assembling the output, including its metric calculations. totalTicks measures the complete run() call, and totalMs reports the same duration in milliseconds. These measured values vary by device and load and do not affect the model's calculations.
Metric durations appear under timings.metrics. engine.steps includes built-in metrics such as model.total, model.npv, model.irr, and model.wal. model.steps lists each metric declared directly on the model. domainPacks groups each pack-provided metric by pack name. Every group has a totalTicks, and metrics.totalTicks sums all of these metric calculation steps.
Each item returned by runScenarios() includes its own result timings. Scenario results may be ordinary run results or Monte Carlo summaries when trials and seed are supplied. The returned array also has a timings property with scenario-by-scenario measurements and totals, including total milliseconds. When serializing the scenario array, include that property explicitly because JSON array serialization omits custom array properties: JSON.stringify({ scenarios, timings: scenarios.timings }). runMonteCarlo() returns timings for its full call and for each trial, including total metric time and summary construction time.
Deterministic metrics
deterministic.metrics contains model.total, model.npv, model.irr, model.wal_years, and run.periods_per_year. If supplied, the discount rate is also present as run.annual_discount_rate. Custom model metrics use the key metric.<name>; callbacks that return undefined are omitted. Each custom metric also has a time series at deterministic.series["metric.<name>"]. That series includes its owner, calculation window length, output frequency, annual aggregation rule, fiscal-year start month, and optional display label and unit.
Money values serialize as { amount, currency }, with an additional date when an explicit valuation date was supplied; scalar metrics remain numbers. With moneyValue: "today", an explicit date takes priority over the series date or a custom metric's last evaluated window date. Structured calculations convert their typed Money leaves while preserving numbers, rates, ages and text. model.total sums converted cashflows; base-date model.npv keeps its value. Inputs and financial callbacks retain nominal amounts. See Show money in today's value. irr can be null. The serialized weighted average life metric is named model.wal_years.
Time series
Each series has an index with calendar, start, periods, and values. Metric series use the declared periodLength and frequency in model periods, intersected with an optional metric schedule; periods without an emitted value contain null. A schedule can restrict a final report to its final date without evaluating its metric callback in earlier periods. annual_rollup.series publishes model metrics using their annualAggregation rule and fiscal year. Its metric indexes use calendar: "fiscal-year" and include display-ready periodLabels such as FY 2025/26. Company metrics can therefore use different fiscal periods in the same result. Serialized monetary values use { amount, currency }; field series are numeric. Common series names include:
flow.<name>andoption.<name>model.net_cash_flowmetric.<name>entity.<family>.<name>.net_cash_flow<family>.<entity>.<field>- Component outputs are available through
result.component(reference); repeated outputs are keyed by their stable row IDs.
Account balances are published separately as account.<name>.balance; they are not included in model net cashflow. For posting cashflows, net cashflow comes from the cash account's signed postings. The engine uses cashAccount, or infers it when exactly one posted account has type asset. A posting cashflow also inherits the owner when all posted accounts share one. If a flow has more than one category, its series attribute category is null; use result.category(ref) to summarize its posted movements. Category summaries include both categories on basic cashflows and those inherited from posted accounts, including balance-sheet accounts. Annual rollups sum flows, options, and model net cashflow; component calculation outputs are reported separately and are not counted as cashflows.
deterministic.categories lists labeled category paths used by accounts and cashflows. Each entry contains path, label, and an optional parent_path. Account postings include category_label when the category reference has a label. A category such as business.class_1_assets.group_11_byggnader_och_mark can therefore be shown by a report using only the returned result; its result.category(ref) value includes all descendant account categories.
Annual monetary storage
With amountStorage: "calendar-year" or "fiscal-year", monetary deterministic.series and compatibility series contain one observation per stored year. Flows sum, account balances keep their last observation, and monetary metrics use their annualAggregation ("last" by default). Money-valued metrics and numeric metrics with unit: "money" are compacted; other numeric, text and field series keep their calculation periods. Monetary annual_rollup.series entries reuse the compacted series. Any purchasing-power conversion is applied to original observations before they are summed.
Read each compacted series' own index, rather than pairing its values with result.dates. The index includes calendar ("annual" or "fiscal-year"), start, periods, dates, inclusive periodEnds, display periodLabels, and sourceCalendar. Dates describe the actual covered source periods, including partial first and last years. A weekly or quarterly period crossing a year boundary stays entirely in the group containing its start date. Fiscal series use their owner's fiscal start month, or January for ownerless data; a metric can declare its own fiscal start. Different owners may therefore have different indexes.
Annual account_postings aggregate amounts by account, flow, side, owner, currency and flow role. date is the covered start, period is that start's original calculation index, periodEnd is the inclusive covered end and periodLabel identifies the year. Account categories and transaction versus period-close roles remain available. Report groups have an equivalent index; their periods sum amounts and retain the final balance, with periodEnd and periodLabel on each row.
The global dates, reference accessors, nonmonetary observations, structured deterministic.calculations, final metrics and Monte Carlo summaries retain their calculation detail and meaning. Annual storage reduces saved monetary output; the size reduction depends on how much authored record data the model publishes. Native reports offer annual views. Select an owner when fiscal calendars differ; calendar-year-only reports cannot split a stored fiscal total across calendar years. See Store monetary results by year for examples.
JavaScript accessors
Compatibility fields and methods are available directly on the result:
model,currency,dates,metrics,series,transitions,eventsflow(ref),option(ref),field(ref),account(ref),state(entityRef),category(categoryRef),entity(entityRef),component(componentRef)toJSON()
Accessors take declaration references, not string names. metrics includes total, npv, irr, and wal. category() sums a category path and its descendants; for postings, signs follow the account's reporting type. entity() sums cashflows and options for the entity and descendants. account(ref) returns period-ending balances, while the serialized account series uses account.<name>.balance. component(ref) returns its declared outputs; repeated components return an items record keyed by stable input row IDs.
flow(ref), option(ref), field(ref), and compatibility series expose numeric arrays in the model currency or field units. Use deterministic.series when you need a currency object for each value.
Published calculation records
A named calculation can opt into saved and displayed results with publish: true. Publication is off unless requested. Published calculations appear at deterministic.calculations[compiledName] with index, values, the declared resultType, and optional owner and unit. The index includes every actual simulation date. Inactive dates and missing optional values contain null. Nested Money values use {amount, currency}; records and keyed maps retain their structure. Calculation result arrays are not supported.
Values are captured during their actual simulation periods. A Monte Carlo result includes the same published ordinary baseline as the deterministic run; these records are not trial means or percentiles. Local result.calculation(reference) access remains available independently of publication.
The presentation editor can select an actual published calculation or projection, or use results.calculation("compiledName"). Private calculations cannot be selected. Use RecordTable for record rows and Breakdown for numeric contributions. See published records and breakdowns.
To display sampled amounts in DataCards, RecordChart, RecordTable or Breakdown, wrap a published source with values, metrics field mappings and an optional percentile (default 50). The wrapper uses actual sampled summary percentiles for existing fields while preserving the published record structure. Missing percentiles stay unavailable, and deterministic-only runs show the published values. See the sampled calculation source contract and examples.