// LedgerScreen — per-entity account tree with balances
function TreeNode({ node, depth, expanded, onToggle }) {
const indent = depth * 18;
const isBranch = node.kind === "branch";
return (
isBranch && onToggle(node.path)}>
{isBranch ? : }
{node.path.split(":").slice(-1)[0]}
{node.path}
);
}
function LedgerScreen({ entity }) {
const data = window.AKEFIN_DATA.accountsByEntity;
const [expanded, setExpanded] = React.useState(new Set(["Personal:Assets", "Personal:Expenses", "9TFox:Assets", "9TFox:Income"]));
const toggle = (path) => setExpanded(prev => {
const next = new Set(prev);
next.has(path) ? next.delete(path) : next.add(path);
return next;
});
const entities = entity === "all" ? ["personal", "tfox", "finacode"] : [entity];
return (
Ledger
Read-only · synced from ~/akefin/ledger/ · git rev e4a82c1
PULL
EXPORT
{entities.map(e => {
const map = window.AKEFIN_DATA.entities.find(x => x.id === e);
const accounts = data[e] || [];
return (
{map.label}
{accounts.length} accounts · {e}-2026-03.ldgr
ACCOUNT
FULL PATH
BALANCE
{accounts.map(node => {
if (node.kind === "leaf") {
const parent = node.path.split(":").slice(0, -1).join(":");
if (parent && parent.includes(":") && !expanded.has(parent.split(":").slice(0,2).join(":"))) {
return null;
}
}
const depth = node.path.split(":").length - 1;
return (
);
})}
);
})}
);
}
Object.assign(window, { LedgerScreen });