invoice.totals
A document's subtotal, tax and total, per tax account and per entry, as GnuCash computes them.
Gives a document's subtotal, tax and total, the tax per tax account and each line's value, discount and tax, worked out as GnuCash does: exactly, with each line's value rounded to the currency's smallest unit, but each account's tax summed unrounded over the lines and rounded once. So the tax total can differ by a cent from the sum of the lines' taxes.
Figures are signed as printed on the document. It works on posted and unposted documents alike, and a posted document's total is what invoice.post put in the A/R or A/P split.
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.totals","params":{"invoice":"aa210b7131de44c48b8513cd27c00e95"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"subtotal": {
"num": "125000",
"denom": "100"
},
"tax": {
"num": "12300",
"denom": "100"
},
"total": {
"num": "137300",
"denom": "100"
},
"taxes": [
{
"accountName": "Liabilities:Tax",
"amount": {
"num": "12050",
"denom": "100"
},
"…": "…"
},
{
"accountName": "Liabilities:Levy",
"amount": {
"num": "250",
"denom": "100"
},
"…": "…"
}
],
"entries": [
"…"
]
}
}
Command line
red-ale exec --book book.gnucash invoice.totals '{"invoice":"aa210b7131de44c48b8513cd27c00e95"}'
It prints:
{
"subtotal": {
"num": "125000",
"denom": "100"
},
"tax": {
"num": "12300",
"denom": "100"
},
"total": {
"num": "137300",
"denom": "100"
},
"taxes": [
{
"accountName": "Liabilities:Tax",
"amount": {
"num": "12050",
"denom": "100"
},
"…": "…"
},
{
"accountName": "Liabilities:Levy",
"amount": {
"num": "250",
"denom": "100"
},
"…": "…"
}
],
"entries": [
"…"
]
}
MCP tool call
Tool call:
{"name":"invoice.totals","arguments":{"invoice":"aa210b7131de44c48b8513cd27c00e95"}}
Result:
{
"structuredContent": {
"subtotal": {
"num": "125000",
"denom": "100"
},
"tax": {
"num": "12300",
"denom": "100"
},
"total": {
"num": "137300",
"denom": "100"
},
"taxes": [
{
"accountName": "Liabilities:Tax",
"amount": {
"num": "12050",
"denom": "100"
},
"…": "…"
},
{
"accountName": "Liabilities:Levy",
"amount": {
"num": "250",
"denom": "100"
},
"…": "…"
}
],
"entries": [
"…"
]
}
}
Effect: read.
Params
Params naming one document.
invoice(Guid, required): The invoice, bill or expense voucher.
Result
Result of invoice.totals. Amounts are signed as printed on the document: positive for invoices and bills, and for credit notes too.
subtotal(Amount, required): Σ of the entries' rounded values.tax(Amount, required): Σ oftaxes.total(Amount, required): Subtotal plus tax: what the document is for.taxes(array of AccountAmount, required): Tax per tax account: each account's unrounded taxes summed over the entries, then rounded once.entries(array of EntryTotals, required): Each entry, in document order.