report.importConfigurations
Import GnuCash's saved report configurations from the text of its saved-reports-2.8 file, read as data, never run.
Imports the saved report configurations from GnuCash's saved-reports-2.8 file (or saved-reports-2.4 if there is no
2.8 one), given as its text. The server never reads a path: the CLI's --file reads the file on your side. The text
is data, never run, although it is Scheme.
Each entry becomes a saved configuration with GnuCash's GUID and name, configuring the template it names, storing only
the options that differ from the template's defaults. Entries go in file order, each on its own, so one that cannot be
imported does not stop the others. skipped says why for each: malformed, untranslated (a report red-ale does not
have), exists (importing twice adds nothing), conflict (the name is taken) or invalid-option. Options the template
does not have are listed in ignored. With dryRun nothing is written.
Examples
Example: with no book.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"report.importConfigurations","params":{"text":"(let ()\n (define (options-gen)\n (let\n (\n (options (gnc:report-template-new-options/report-guid \"d8b63264186b11e19038001558291366\" \"Net Worth Linechart\"))\n (new-embedded-report-ids '()) ;; only used with Multicolumn View Reports\n )\n; Section: General\n\n(let ((option (gnc:lookup-option options\n \"General\"\n \"Step Size\")))\n ((lambda (o) (if o (gnc:option-set-value o 'QuarterDelta))) option))\n\n\n options\n )\n )\n (gnc:define-report\n 'version 1\n 'name \"Quarterly net worth\"\n 'report-guid \"5e1f0a2b3c4d4e5f8a9b0c1d2e3f4a5b\"\n 'parent-type \"d8b63264186b11e19038001558291366\"\n 'options-generator options-gen\n 'menu-path (list gnc:menuname-custom)\n 'renderer (gnc:report-template-renderer/report-guid \"d8b63264186b11e19038001558291366\" \"Net Worth Linechart\")\n )\n)\n","dryRun":true}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"dryRun": true,
"imported": [
{
"line": 1,
"configuration": {
"guid": "5e1f0a2b3c4d4e5f8a9b0c1d2e3f4a5b",
"name": "Quarterly net worth",
"kind": "saved",
"…": "…"
},
"options": {
"General": {
"Step Size": "QuarterDelta"
}
},
"ignored": []
}
],
"skipped": []
}
}
Command line
red-ale exec report.importConfigurations '{"text":"(let ()\n (define (options-gen)\n (let\n (\n (options (gnc:report-template-new-options/report-guid \"d8b63264186b11e19038001558291366\" \"Net Worth Linechart\"))\n (new-embedded-report-ids '\''()) ;; only used with Multicolumn View Reports\n )\n; Section: General\n\n(let ((option (gnc:lookup-option options\n \"General\"\n \"Step Size\")))\n ((lambda (o) (if o (gnc:option-set-value o '\''QuarterDelta))) option))\n\n\n options\n )\n )\n (gnc:define-report\n '\''version 1\n '\''name \"Quarterly net worth\"\n '\''report-guid \"5e1f0a2b3c4d4e5f8a9b0c1d2e3f4a5b\"\n '\''parent-type \"d8b63264186b11e19038001558291366\"\n '\''options-generator options-gen\n '\''menu-path (list gnc:menuname-custom)\n '\''renderer (gnc:report-template-renderer/report-guid \"d8b63264186b11e19038001558291366\" \"Net Worth Linechart\")\n )\n)\n","dryRun":true}'
It prints:
{
"dryRun": true,
"imported": [
{
"line": 1,
"configuration": {
"guid": "5e1f0a2b3c4d4e5f8a9b0c1d2e3f4a5b",
"name": "Quarterly net worth",
"kind": "saved",
"…": "…"
},
"options": {
"General": {
"Step Size": "QuarterDelta"
}
},
"ignored": []
}
],
"skipped": []
}
MCP tool call
Tool call:
{"name":"report.importConfigurations","arguments":{"text":"(let ()\n (define (options-gen)\n (let\n (\n (options (gnc:report-template-new-options/report-guid \"d8b63264186b11e19038001558291366\" \"Net Worth Linechart\"))\n (new-embedded-report-ids '()) ;; only used with Multicolumn View Reports\n )\n; Section: General\n\n(let ((option (gnc:lookup-option options\n \"General\"\n \"Step Size\")))\n ((lambda (o) (if o (gnc:option-set-value o 'QuarterDelta))) option))\n\n\n options\n )\n )\n (gnc:define-report\n 'version 1\n 'name \"Quarterly net worth\"\n 'report-guid \"5e1f0a2b3c4d4e5f8a9b0c1d2e3f4a5b\"\n 'parent-type \"d8b63264186b11e19038001558291366\"\n 'options-generator options-gen\n 'menu-path (list gnc:menuname-custom)\n 'renderer (gnc:report-template-renderer/report-guid \"d8b63264186b11e19038001558291366\" \"Net Worth Linechart\")\n )\n)\n","dryRun":true}}
Result:
{
"structuredContent": {
"dryRun": true,
"imported": [
{
"line": 1,
"configuration": {
"guid": "5e1f0a2b3c4d4e5f8a9b0c1d2e3f4a5b",
"name": "Quarterly net worth",
"kind": "saved",
"…": "…"
},
"options": {
"General": {
"Step Size": "QuarterDelta"
}
},
"ignored": []
}
],
"skipped": []
}
}
Effect: write, on the Configuration only.
Params
Params of report.importConfigurations and report.importStyleSheets.
text(string, required): The file's text: GnuCash'ssaved-reports-2.8(elsesaved-reports-2.4), orstylesheets-2.0, from its user data directory. It is read as data and never run.dryRun(boolean): Report what would be imported without writing the Configuration.
Result
The result of report.importConfigurations.
dryRun(boolean, required): True when nothing was written.imported(array of ImportedConfiguration, required): The configurations imported (or that would be), in file order.skipped(array of SkippedEntry, required): The entries skipped, in file order.