Method

order.create

Create an order for a customer, vendor or job.

Creates an open order for a customer, vendor or job: a list of lines promised to or by someone, which invoice lines can join. It takes the next number from the gncOrder counter unless you give id. An order has no totals and no posting.

Order lines use the invoice side whoever owns the order, because GnuCash's order screen is a customer-document screen. Only a customer invoice's line can join an 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","reference":"PO-9"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "guid": "…",
    "id": "000001",
    "owner": {
      "kind": "customer",
      "guid": "5b22073fa4e34411b07c14a77147ce6b"
    },
    "closed": false,
    "reference": "PO-9",
    "entryCount": 0,
    "entries": [],
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash order.create '{"owner":"5b22073fa4e34411b07c14a77147ce6b","reference":"PO-9"}'

It prints:

{
  "guid": "…",
  "id": "000001",
  "owner": {
    "kind": "customer",
    "guid": "5b22073fa4e34411b07c14a77147ce6b"
  },
  "closed": false,
  "reference": "PO-9",
  "entryCount": 0,
  "entries": [],
  "…": "…"
}

MCP tool call

Tool call:

{"name":"order.create","arguments":{"owner":"5b22073fa4e34411b07c14a77147ce6b","reference":"PO-9"}}

Result:

{
  "structuredContent": {
    "guid": "…",
    "id": "000001",
    "owner": {
      "kind": "customer",
      "guid": "5b22073fa4e34411b07c14a77147ce6b"
    },
    "closed": false,
    "reference": "PO-9",
    "entryCount": 0,
    "entries": [],
    "…": "…"
  }
}

Effect: write, on the Book.

Params

Params of order.create. owner is required.

  • owner (Guid or null): A customer, vendor or job. It can change only while the order has no lines.
  • id (string or null): Order number. On create, absent or empty takes the next number from the book's gncOrder counter.
  • dateOpened (Date or null): Date opened; stored as noon local time. Defaults to today.
  • notes (string or null): Notes.
  • reference (string or null): Reference.
  • active (boolean or null): Active; false deactivates.

Result

An order with its lines, in GnuCash's order.

  • guid (Guid, required): A GUID: 32 hexadecimal digits.
  • id (string, required)
  • owner (OwnerInfo, required): An owner: a customer, vendor, employee or job.
  • dateOpened (Timestamp, required): An instant, RFC 3339; written in UTC with a Z suffix.
  • closed (boolean, required)
  • dateClosed (Timestamp or null)
  • notes (string, required)
  • reference (string, required)
  • active (boolean, required)
  • entryCount (integer (uint), required)
  • entries (array of EntryInfo, required): Its lines.