invoice.delete
Delete an unposted document and its lines.
Deletes an unposted document and its lines. Lines that are also on an order stay on the order. A posted document is
refused with conflict: invoice.unpost it first, which deletes its transaction.
GnuCash's own screens can only discard a document that has just been created; red-ale lets you delete any unposted one, so a draft can be undone. Its number is not given back to the counter.
Examples
Example: with a copy of the synthetic/business-editable example book open as book.gnucash.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"invoice.delete","params":{"invoice":"aa210b7131de44c48b8513cd27c00e95"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": 2003,
"message": "document 000001 is posted; unpost it first",
"data": {
"help": "error/conflict"
}
}
}
Request:
{"jsonrpc":"2.0","id":2,"method":"invoice.delete","params":{"invoice":"71803cac5d8e4dceabfd0d56ec5e7521"}}
Response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {}
}
Command line
red-ale exec --book book.gnucash --script - <<'EOF'
invoice.delete {"invoice":"aa210b7131de44c48b8513cd27c00e95"}
invoice.delete {"invoice":"71803cac5d8e4dceabfd0d56ec5e7521"}
EOF
It fails with exit status 2, printing on standard error:
{
"error": {
"code": 2003,
"message": "document 000001 is posted; unpost it first",
"data": {
"help": "error/conflict"
}
}
}
MCP tool call
Tool call:
{"name":"invoice.delete","arguments":{"invoice":"aa210b7131de44c48b8513cd27c00e95"}}
Result:
{
"isError": true,
"structuredContent": {
"error": {
"code": 2003,
"name": "conflict",
"message": "document 000001 is posted; unpost it first",
"data": {
"help": "error/conflict"
}
}
}
}
Tool call:
{"name":"invoice.delete","arguments":{"invoice":"71803cac5d8e4dceabfd0d56ec5e7521"}}
Result:
{
"structuredContent": {}
}
Effect: destructive, on the Book.
Params
Names one document.
invoice(Guid, required): The document.
Result
A result with nothing to report.
Type: Done.