Method

account.cascade

Set colour, placeholder or hidden on an account and all its sub-accounts.

Sets the colour, the placeholder flag or the hidden flag on an account and all its sub-accounts at once, as the account tree's "cascade" action does, and returns the GUIDs of the accounts that changed. A colour is #rgb, #rrggbb or rgb(r,g,b); it is stored as rgb(r,g,b). By default sub-accounts that already have a colour keep it; pass replaceColors: true to overwrite them. The account must have sub-accounts (invalid otherwise).

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.cascade","params":{"account":"Root:Asset","color":"#336699","hidden":false}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "changed": [
      "…",
      "…",
      "…",
      "…"
    ]
  }
}

Request:

{"jsonrpc":"2.0","id":2,"method":"account.get","params":{"account":"Root:Asset:Bank"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "color": "rgb(51,102,153)",
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash --script - <<'EOF'
account.cascade {"account":"Root:Asset","color":"#336699","hidden":false}
account.get {"account":"Root:Asset:Bank"}
EOF

It prints:

[
  {
    "changed": [
      "…",
      "…",
      "…",
      "…"
    ]
  },
  {
    "color": "rgb(51,102,153)",
    "…": "…"
  }
]

MCP tool call

Tool call:

{"name":"account.cascade","arguments":{"account":"Root:Asset","color":"#336699","hidden":false}}

Result:

{
  "structuredContent": {
    "changed": [
      "…",
      "…",
      "…",
      "…"
    ]
  }
}

Tool call:

{"name":"account.get","arguments":{"account":"Root:Asset:Bank"}}

Result:

{
  "structuredContent": {
    "color": "rgb(51,102,153)",
    "…": "…"
  }
}

Effect: write, on the Book.

Params

Params of account.cascade.

  • account (AccountRef, required): The account; it must have sub-accounts.
  • color (string or null): Cascade this colour (#rrggbb, #rgb or rgb(r,g,b)); empty cascades no colour.
  • replaceColors (boolean): Replace colours already set (GnuCash's "Replace any existing account colors"); without it only accounts with no colour change.
  • placeholder (boolean or null): Cascade the placeholder flag.
  • hidden (boolean or null): Cascade the hidden flag.

Result

The result of account.cascade.

  • changed (array of Guid, required): The accounts that changed: the account first, then its sub-accounts depth first.