Declare allocations and fund needs
An object-array input describes user-editable records once. repeat() instantiates a component for each row, and its stable ID follows that person's entities, salary, and other outputs. This same input schema can power a UI with dynamic add/remove cards.
import * as deccf from "deccf";
import { household, inputs } from "deccf/domainpacks/household";
import { personalAccountPlan } from "deccf/domainpacks/accountplan";
const input = Object.freeze({ ...deccf.input, ...inputs });
const members = input.objectArray([
{ id: input.id("anna"), name: input.str("Anna"), role: input.familyRole("adult"), dateOfBirth: input.date("1990-05-21"), salary: input.money(46_000, deccf.currencies.SEK) },
{ id: input.id("erik"), name: input.str("Erik"), role: input.familyRole("adult"), dateOfBirth: input.date("1989-08-12"), salary: input.money(39_000, deccf.currencies.SEK) },
]);
const family = household();
const member = deccf.entity.party({
owner: family,
attributes: { id: members.item.data.id, role: members.item.data.role, dateOfBirth: members.item.data.dateOfBirth },
});
const people = deccf.repeat(members, deccf.component({ entities: { member }, outputs: { person: member } }));
const adults = people.where({ role: "adult" });
const budget = household.householdBudget({
household: family,
members: people.outputs.person,
funding: {
from: adults.outputs.person,
method: deccf.proportional({ weights: adults.column("salary") }),
posting: personalAccountPlan.ownerContribution(),
},
});
const model = deccf.defineModel({
name: "Proportional household budget",
currency: deccf.currencies.SEK,
timeline: deccf.periods.monthly({ from: "2026-01", count: 24 }),
preconditions: { members },
entities: { family },
components: { people, budget },
});
return model;The family role and the Consumer Agency budget belong to the Household pack. Repeating the rows, calculating proportional shares, moving funds, and exposing component outputs are engine capabilities. Add a member by adding one row or by creating a new card in the Calculator; the engine binds the same template again for that stable ID.
allocation() can calculate shares without posting them. transfer() moves money between owners under a posting policy. funding() combines allocation and transfers when a declared need must actually be funded. These declarations share one allocation solver, so limits, priority, proportional weights, and shortfall behavior are consistent.
The Calculator examples Household budget · fixed contributions (available in Marketplace) and Household budget · proportional funding (available in Marketplace) show both contribution rules with Swedish tax and annual closings.
Next: Read and value results.