account.tree
The account tree as nested nodes, in the book's order or GnuCash's display order.
Gives the account tree as nested nodes, children inside each node, for the whole book or for the subtree under
under. With sorted the siblings come in GnuCash's display order (by code, then type, then name) instead of the
order the book stores them. Pitfall: GnuCash 5.17's own type order puts BANK after TRADING, and red-ale reproduces it
so the two agree.
Examples
Example: with a copy of the reports/test-data example book open as book.gnucash.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"account.tree","params":{"under":"Root:Asset"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"fullName": "Root:Asset",
"type": "ASSET",
"children": [
{
"fullName": "Root:Asset:Bank",
"children": [],
"…": "…"
},
{
"fullName": "Root:Asset:GBP Bank",
"…": "…"
},
{
"fullName": "Root:Asset:Wallet",
"…": "…"
}
],
"…": "…"
}
}
Command line
red-ale exec --book book.gnucash account.tree '{"under":"Root:Asset"}'
It prints:
{
"fullName": "Root:Asset",
"type": "ASSET",
"children": [
{
"fullName": "Root:Asset:Bank",
"children": [],
"…": "…"
},
{
"fullName": "Root:Asset:GBP Bank",
"…": "…"
},
{
"fullName": "Root:Asset:Wallet",
"…": "…"
}
],
"…": "…"
}
MCP tool call
Tool call:
{"name":"account.tree","arguments":{"under":"Root:Asset"}}
Result:
{
"structuredContent": {
"fullName": "Root:Asset",
"type": "ASSET",
"children": [
{
"fullName": "Root:Asset:Bank",
"children": [],
"…": "…"
},
{
"fullName": "Root:Asset:GBP Bank",
"…": "…"
},
{
"fullName": "Root:Asset:Wallet",
"…": "…"
}
],
"…": "…"
}
}
Effect: read.
Params
Params of account.tree.
under(AccountRef or null): The top of the tree; the root by default.sorted(boolean): Order siblings as GnuCash displays them (code, type, name) instead of the book's order.excludeHidden(boolean): Leave out hidden accounts and everything below them.
Result
A node of the account tree.
guid(Guid, required): GUID.name(string, required): Name.fullName(string, required): Full name.type(string, required): Account type.code(string or null): Account code.commodity(CommodityId or null): Commodity held.placeholder(boolean, required): Placeholder.hidden(boolean, required): Hidden itself.children(array of TreeNode, required): Sub-accounts.