reconcile.autoClear
Auto-clear an account: mark cleared the one set of uncleared splits that brings its cleared balance to a figure.
Auto-clears an account: marks cleared (c) the one set of uncleared splits that brings its cleared balance to
clearedBalance. It is reconcile.findAutoClear followed by setting those splits
cleared, in one step. If no set reaches the figure, it is refused with invalid and data.reason unreachable, and
nothing is cleared.
Examples
Example: with a copy of the reports/reconcile example book open as book.gnucash.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"reconcile.autoClear","params":{"account":"Root:Asset:Bank","clearedBalance":"6.00"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"outcome": "found",
"splits": [
{
"split": "d0000000000000000000000000000006",
"…": "…"
}
],
"…": "…"
}
}
Request:
{"jsonrpc":"2.0","id":2,"method":"reconcile.autoClear","params":{"account":"Root:Asset:Bank","clearedBalance":"99.00"}}
Response:
{
"jsonrpc": "2.0",
"id": 2,
"error": {
"code": 2001,
"message": "…",
"data": {
"reason": "unreachable",
"help": "error/invalid"
}
}
}
Command line
red-ale exec --book book.gnucash --script - <<'EOF'
reconcile.autoClear {"account":"Root:Asset:Bank","clearedBalance":"6.00"}
reconcile.autoClear {"account":"Root:Asset:Bank","clearedBalance":"99.00"}
EOF
It fails with exit status 2, printing on standard error:
{
"error": {
"code": 2001,
"message": "…",
"data": {
"reason": "unreachable",
"help": "error/invalid"
}
}
}
MCP tool call
Tool call:
{"name":"reconcile.autoClear","arguments":{"account":"Root:Asset:Bank","clearedBalance":"6.00"}}
Result:
{
"structuredContent": {
"outcome": "found",
"splits": [
{
"split": "d0000000000000000000000000000006",
"…": "…"
}
],
"…": "…"
}
}
Tool call:
{"name":"reconcile.autoClear","arguments":{"account":"Root:Asset:Bank","clearedBalance":"99.00"}}
Result:
{
"isError": true,
"structuredContent": {
"error": {
"code": 2001,
"name": "invalid",
"message": "…",
"data": {
"reason": "unreachable",
"help": "error/invalid"
}
}
}
}
Effect: write, on the Book.
Params
Params of reconcile.findAutoClear and reconcile.autoClear.
account(AccountRef, required): The account; its sub-accounts are not included.clearedBalance(Amount, required): The cleared balance wanted, raw sign (debits positive). Rounded to the account's SCU with banker's rounding.
Result
The result of an auto-clear search.
account(Guid, required): The account.currentClearedBalance(Amount, required): The account's cleared balance before auto-clear: every split notn, raw sign.clearedBalance(Amount, required): The cleared balance asked for, rounded to the account's SCU.outcome(OutcomeWire, required): What the search found.message(string or null): GnuCash's message for an outcome other thanfound.splits(array of ClearedSplit, required): The splits found, in account order; empty unlessfound.