Method

order.addEntry

Add a line to an open order.

Adds a line to an open order. The line uses the invoice side and gets only the engine's defaults, not the owner's discount or tax table. To put a line on an order and a customer invoice at once, use invoice.addEntry with order.

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":"order.create","params":{"owner":"5b22073fa4e34411b07c14a77147ce6b"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "…"
}

Request:

{"jsonrpc":"2.0","id":2,"method":"order.addEntry","params":{"order":"00ed0000000000000000000000000001","description":"Widgets","quantity":"10","price":"2.50","account":"Income"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "guid": "…",
    "description": "Widgets",
    "quantity": {
      "num": "10",
      "denom": "1"
    },
    "invoicePrice": {
      "num": "250",
      "denom": "100"
    },
    "invoice": null,
    "order": "00ed0000000000000000000000000001",
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash --script - <<'EOF'
order.create {"owner":"5b22073fa4e34411b07c14a77147ce6b"}
order.addEntry {"order":"00ed0000000000000000000000000001","description":"Widgets","quantity":"10","price":"2.50","account":"Income"}
EOF

It prints:

[
  "…",
  {
    "guid": "…",
    "description": "Widgets",
    "quantity": {
      "num": "10",
      "denom": "1"
    },
    "invoicePrice": {
      "num": "250",
      "denom": "100"
    },
    "invoice": null,
    "order": "00ed0000000000000000000000000001",
    "…": "…"
  }
]

MCP tool call

Tool call:

{"name":"order.create","arguments":{"owner":"5b22073fa4e34411b07c14a77147ce6b"}}

Result:

{
  "content": [
    {
      "type": "text",
      "text": "\"…\""
    }
  ]
}

Tool call:

{"name":"order.addEntry","arguments":{"order":"00ed0000000000000000000000000001","description":"Widgets","quantity":"10","price":"2.50","account":"Income"}}

Result:

{
  "structuredContent": {
    "guid": "…",
    "description": "Widgets",
    "quantity": {
      "num": "10",
      "denom": "1"
    },
    "invoicePrice": {
      "num": "250",
      "denom": "100"
    },
    "invoice": null,
    "order": "00ed0000000000000000000000000001",
    "…": "…"
  }
}

Effect: write, on the Book.

Params

Params of order.addEntry.

  • order (Guid, required): The open order.
  • date (Date or null): The line's date; stored as noon local time, as GnuCash's register does. Defaults to today.
  • description (string or null): Description.
  • action (string or null): Action: a free unit label such as "Hours".
  • notes (string or null): Notes.
  • quantity (Amount or null): Quantity, as printed on the document; stored negated on a credit note.
  • account (AccountRef or null): The income account (invoices) or expense account (bills, vouchers); null for none.
  • price (Amount or null): Unit price. A new line on a job's document defaults to the job's rate.
  • discount (Amount or null): Invoices only: the discount, a percentage or an amount. Defaults to the customer's discount.
  • discountType (AmountTypeWire or null): Invoices only: whether the discount is a percentage or an amount.
  • discountHow (DiscountHowWire or null): Invoices only: when the discount applies relative to tax.
  • taxable (boolean or null): Invoices and bills: the line is taxed. Defaults to true when a tax table applies.
  • taxIncluded (boolean or null): Invoices and bills: the price includes tax. Defaults from the customer's or vendor's setting.
  • taxTable (TaxTableRef or null): Invoices and bills: the tax table, by GUID or name; null for none. Defaults to the owner's table when it overrides, else the book's default.
  • billable (boolean or null): Bills and vouchers: the cost is to be invoiced on to billTo.
  • billTo (Guid or null): Bills and vouchers: the customer or job to invoice the cost to; null for none.
  • payment (PaymentWire or null): Vouchers only: cash (the employee paid) or card (the company card paid).

Result

A line. Both sides are shown; the one its document uses is invoice* for customer invoices and bill* for bills and vouchers.

  • guid (Guid, required): A GUID: 32 hexadecimal digits.
  • date (Timestamp, required): An instant, RFC 3339; written in UTC with a Z suffix.
  • dateEntered (Timestamp, required): An instant, RFC 3339; written in UTC with a Z suffix.
  • description (string, required)
  • action (string, required)
  • notes (string, required)
  • quantity (Amount, required): As stored: negated on a credit note.
  • documentQuantity (Amount, required): As printed on the document.
  • invoice (Guid or null): The customer invoice it is on.
  • bill (Guid or null): The bill or voucher it is on.
  • order (Guid or null): The order it is on.
  • invoiceAccount (Guid or null)
  • invoicePrice (Amount, required): An exact amount. Read from a decimal string ("12.34"), a rational string ("1234/100") or {num, denom} with string members; written as {num, denom}. Never a JSON number.
  • discount (Amount, required): An exact amount. Read from a decimal string ("12.34"), a rational string ("1234/100") or {num, denom} with string members; written as {num, denom}. Never a JSON number.
  • discountType (AmountTypeWire, required): Percentage or fixed amount.
  • discountHow (DiscountHowWire, required): When a discount applies relative to tax.
  • invoiceTaxable (boolean, required)
  • invoiceTaxIncluded (boolean, required)
  • invoiceTaxTable (Guid or null)
  • billAccount (Guid or null)
  • billPrice (Amount, required): An exact amount. Read from a decimal string ("12.34"), a rational string ("1234/100") or {num, denom} with string members; written as {num, denom}. Never a JSON number.
  • billTaxable (boolean, required)
  • billTaxIncluded (boolean, required)
  • billTaxTable (Guid or null)
  • billable (boolean, required)
  • billTo (OwnerInfo or null)
  • payment (PaymentWire, required): How an employee paid an expense.