Method

customer.create

Create a customer; its ID comes from the book's counter unless given.

Creates a customer: someone you send invoices to. It needs a company name and a currency, the currency of all its documents; everything else (address, default billing term, tax table, discount, credit limit) is optional.

Leave id out and the customer is numbered from the book's gncCustomer counter (000001, 000002, …); see counter.set to change the counter or its format. As in GnuCash, IDs are labels, not keys: nothing stops two customers having the same one, and the GUID is what identifies a customer. terms and taxTable take a GUID or the name of a visible billing term or tax table.

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":"customer.create","params":{"name":"Globex","currency":"EUR","terms":"Net30","discount":"10"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "guid": "…",
    "id": "000002",
    "name": "Globex",
    "currency": "CURRENCY::EUR",
    "terms": "3416d941790749378beeb338b8357a72",
    "discount": {
      "num": "10",
      "denom": "1"
    },
    "active": true,
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash customer.create '{"name":"Globex","currency":"EUR","terms":"Net30","discount":"10"}'

It prints:

{
  "guid": "…",
  "id": "000002",
  "name": "Globex",
  "currency": "CURRENCY::EUR",
  "terms": "3416d941790749378beeb338b8357a72",
  "discount": {
    "num": "10",
    "denom": "1"
  },
  "active": true,
  "…": "…"
}

MCP tool call

Tool call:

{"name":"customer.create","arguments":{"name":"Globex","currency":"EUR","terms":"Net30","discount":"10"}}

Result:

{
  "structuredContent": {
    "guid": "…",
    "id": "000002",
    "name": "Globex",
    "currency": "CURRENCY::EUR",
    "terms": "3416d941790749378beeb338b8357a72",
    "discount": {
      "num": "10",
      "denom": "1"
    },
    "active": true,
    "…": "…"
  }
}

Effect: write, on the Book.

Params

Params of customer.create. name and currency are required.

  • name (string or null): Company name.
  • id (string or null): Customer number. On create, absent or empty takes the next number from the book's gncCustomer counter.
  • currency (CommodityId or null): The currency of the customer's documents.
  • addr (AddressParams or null): Billing address.
  • shipAddr (AddressParams or null): Shipping address.
  • notes (string or null): Notes.
  • terms (BillTermRef or null): Default billing term for new invoices, by GUID or name; null for none.
  • taxTable (TaxTableRef or null): Tax table, by GUID or name; null for none.
  • taxTableOverride (boolean or null): New invoice lines use taxTable rather than the book's default.
  • taxIncluded (TaxIncludedWire or null): Whether prices include tax by default.
  • discount (Amount or null): Default discount percentage for new invoice lines, 0 to 100.
  • credit (Amount or null): Credit limit.
  • active (boolean or null): Active; false deactivates.

Result

A customer.

  • guid (Guid, required): A GUID: 32 hexadecimal digits.
  • id (string, required)
  • name (string, required)
  • addr (AddressInfo, required): An address. Empty strings are unset fields.
  • shipAddr (AddressInfo, required): An address. Empty strings are unset fields.
  • notes (string, required)
  • currency (CommodityId or null)
  • terms (Guid or null)
  • taxTable (Guid or null)
  • taxTableOverride (boolean, required)
  • taxIncluded (TaxIncludedWire, required): Whether prices include tax by default for the contact's documents.
  • 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.
  • credit (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.
  • active (boolean, required)