scrub.checkAndRepair
GnuCash's Check & Repair: orphans, then imbalances, then (if asked) lots.
GnuCash's Check & Repair: the orphan scrub, then the imbalance scrub, over a transaction, an account (with
subaccounts) or the whole book. With lots: true it also runs the lot scrub on each account, which GnuCash 5.17 does
only when an environment variable is set, hence the default of false. Run it on a book you did not make before
trusting its balances; it can add Imbalance and Orphan accounts, so look at repairs, then move the amounts
to where they belong.
Examples
Example: with a copy of the gnucash/taxreport example book open as book.gnucash.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"scrub.checkAndRepair","params":{}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"repairs": [
{
"kind": "accountCreated",
"name": "Imbalance-USD",
"commodity": "CURRENCY::USD",
"…": "…"
},
{
"kind": "balanceSplitAdded",
"…": "…"
},
"…"
]
}
}
Command line
red-ale exec --book book.gnucash scrub.checkAndRepair
It prints:
{
"repairs": [
{
"kind": "accountCreated",
"name": "Imbalance-USD",
"commodity": "CURRENCY::USD",
"…": "…"
},
{
"kind": "balanceSplitAdded",
"…": "…"
},
"…"
]
}
MCP tool call
Tool call:
{"name":"scrub.checkAndRepair","arguments":{}}
Result:
{
"structuredContent": {
"repairs": [
{
"kind": "accountCreated",
"name": "Imbalance-USD",
"commodity": "CURRENCY::USD",
"…": "…"
},
{
"kind": "balanceSplitAdded",
"…": "…"
},
"…"
]
}
}
Effect: destructive, on the Book.
Params
Params of scrub.checkAndRepair.
transaction(Guid or null): Check this transaction only (the register's Check & Repair).account(AccountRef or null): Check the transactions with a split in this account.subaccounts(boolean): Withaccount: its sub-accounts too.lots(boolean): Also run the lot scrub on each account checked, sub-accounts first. Off by default, as in GnuCash 5.17, which runs it only when theGNC_AUTO_SCRUB_LOTSenvironment variable is set.
Result
What a scrub did.
repairs(array of RepairWire, required): Every change, in the order made. Empty when there was nothing to repair.