Method

importMap.delete

Delete Import map or online entries, one by one, by kind, or every invalid one.

Deletes import map entries: named ones (entries, each an account, a kind and a key), every entry of a kind on an account (leave out the key), or every invalid one (invalid: true), as GnuCash's import map editor does. Give either entries or invalid, not both. A bayes token is kept once per target account; target picks one, otherwise the token goes for all of them. It is destructive: the matcher forgets what it learned.

Examples

Removing the invalid entries, then one learned description, which is then gone:

Example: with a copy of the synthetic/import-map example book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"importMap.delete","params":{"invalid":true}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "deleted": [
      {
        "account": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "kind": "bayes",
        "key": "Coffee",
        "target": null,
        "count": 1,
        "valid": false
      }
    ]
  }
}

Request:

{"jsonrpc":"2.0","id":2,"method":"importMap.delete","params":{"entries":[{"account":"Assets:Checking","kind":"desc","key":"Corner Grocer"}]}}

Response:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "deleted": [
      {
        "kind": "desc",
        "key": "Corner Grocer",
        "…": "…"
      }
    ]
  }
}

Request:

{"jsonrpc":"2.0","id":3,"method":"importMap.delete","params":{"entries":[{"account":"Assets:Checking","kind":"desc","key":"Corner Grocer"}]}}

Response:

{
  "jsonrpc": "2.0",
  "id": 3,
  "error": {
    "code": 2000,
    "message": "…",
    "data": {
      "help": "error/not-found",
      "…": "…"
    }
  }
}

Command line

red-ale exec --book book.gnucash --script - <<'EOF'
importMap.delete {"invalid":true}
importMap.delete {"entries":[{"account":"Assets:Checking","kind":"desc","key":"Corner Grocer"}]}
importMap.delete {"entries":[{"account":"Assets:Checking","kind":"desc","key":"Corner Grocer"}]}
EOF

It fails with exit status 2, printing on standard error:

{
  "error": {
    "code": 2000,
    "message": "…",
    "data": {
      "help": "error/not-found",
      "…": "…"
    }
  }
}

MCP tool call

Tool call:

{"name":"importMap.delete","arguments":{"invalid":true}}

Result:

{
  "structuredContent": {
    "deleted": [
      {
        "account": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "kind": "bayes",
        "key": "Coffee",
        "target": null,
        "count": 1,
        "valid": false
      }
    ]
  }
}

Tool call:

{"name":"importMap.delete","arguments":{"entries":[{"account":"Assets:Checking","kind":"desc","key":"Corner Grocer"}]}}

Result:

{
  "structuredContent": {
    "deleted": [
      {
        "kind": "desc",
        "key": "Corner Grocer",
        "…": "…"
      }
    ]
  }
}

Tool call:

{"name":"importMap.delete","arguments":{"entries":[{"account":"Assets:Checking","kind":"desc","key":"Corner Grocer"}]}}

Result:

{
  "isError": true,
  "structuredContent": {
    "error": {
      "code": 2000,
      "name": "not-found",
      "message": "…",
      "data": {
        "help": "error/not-found",
        "…": "…"
      }
    }
  }
}

Effect: destructive, on the Book.

Params

Params of importMap.delete: entries or invalid, not both.

  • entries (array of EntryParam or null): The entries to delete.
  • invalid (boolean): Instead of entries: every invalid entry in the book, as the editor's "Delete invalid mappings".

Result

The entries deleted.

  • deleted (array of ImportMapEntry, required): Each as it was listed.