Method

account.openingBalanceAccount

Find the account GnuCash would put a currency's opening balances in: by its flag, then by name.

Finds the account GnuCash would put a currency's opening balances in: the equity account flagged as the opening balance account for that currency, else one named like GnuCash's Opening Balances account. It returns account: null when there is none. GnuCash creates the account when it is missing; red-ale only looks, because a read never writes. To make one, create an EQUITY account with openingBalance: true.

Examples

Example: with a new, empty book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"account.openingBalanceAccount","params":{"currency":"USD"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "account": null,
    "foundBy": null,
    "featureUsed": false
  }
}

Request:

{"jsonrpc":"2.0","id":2,"method":"account.create","params":{"name":"Opening Balances","type":"EQUITY","commodity":"USD","openingBalance":true}}

Response:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": "…"
}

Request:

{"jsonrpc":"2.0","id":3,"method":"account.openingBalanceAccount","params":{"currency":"USD"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "account": {
      "fullName": "Opening Balances",
      "openingBalance": true,
      "…": "…"
    },
    "featureUsed": true,
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash --script - <<'EOF'
account.openingBalanceAccount {"currency":"USD"}
account.create {"name":"Opening Balances","type":"EQUITY","commodity":"USD","openingBalance":true}
account.openingBalanceAccount {"currency":"USD"}
EOF

It prints:

[
  {
    "account": null,
    "foundBy": null,
    "featureUsed": false
  },
  "…",
  {
    "account": {
      "fullName": "Opening Balances",
      "openingBalance": true,
      "…": "…"
    },
    "featureUsed": true,
    "…": "…"
  }
]

MCP tool call

Tool call:

{"name":"account.openingBalanceAccount","arguments":{"currency":"USD"}}

Result:

{
  "structuredContent": {
    "account": null,
    "foundBy": null,
    "featureUsed": false
  }
}

Tool call:

{"name":"account.create","arguments":{"name":"Opening Balances","type":"EQUITY","commodity":"USD","openingBalance":true}}

Result:

{
  "content": [
    {
      "type": "text",
      "text": "\"…\""
    }
  ]
}

Tool call:

{"name":"account.openingBalanceAccount","arguments":{"currency":"USD"}}

Result:

{
  "structuredContent": {
    "account": {
      "fullName": "Opening Balances",
      "openingBalance": true,
      "…": "…"
    },
    "featureUsed": true,
    "…": "…"
  }
}

Effect: read.

Params

Params of account.openingBalanceAccount.

  • currency (CommodityId, required): The currency.

Result

The result of account.openingBalanceAccount.

  • account (AccountInfo or null): The account; null when GnuCash would create one.
  • foundBy (FoundByWire or null): How it was found.
  • featureUsed (boolean, required): The book declares GnuCash's opening balance account Book feature.