Method

employee.create

Create an employee; its ID comes from the book's counter unless given.

Creates an employee: the owner of expense vouchers. It needs a name and a currency. GnuCash keeps an employee's name as the name of its address, so name overrides addr.name.

rate is the hourly rate and workday the hours per day; creditCardAccount, if given, must be a CREDIT account, which card-paid voucher lines are charged to when the voucher is posted. GnuCash's engine accepts any account here and only its dialog offers credit cards; red-ale refuses the rest.

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":"employee.create","params":{"name":"John Roe","currency":"EUR","rate":"30.00"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "guid": "…",
    "name": "John Roe",
    "rate": {
      "num": "3000",
      "denom": "100"
    },
    "creditCardAccount": null,
    "active": true,
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash employee.create '{"name":"John Roe","currency":"EUR","rate":"30.00"}'

It prints:

{
  "guid": "…",
  "name": "John Roe",
  "rate": {
    "num": "3000",
    "denom": "100"
  },
  "creditCardAccount": null,
  "active": true,
  "…": "…"
}

MCP tool call

Tool call:

{"name":"employee.create","arguments":{"name":"John Roe","currency":"EUR","rate":"30.00"}}

Result:

{
  "structuredContent": {
    "guid": "…",
    "name": "John Roe",
    "rate": {
      "num": "3000",
      "denom": "100"
    },
    "creditCardAccount": null,
    "active": true,
    "…": "…"
  }
}

A card account that is not a credit card is refused:

Example: with a copy of the synthetic/business-editable example book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"employee.create","params":{"name":"John Roe","currency":"EUR","creditCardAccount":"1d8f8d4a358c4a169b3421d953b40369"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": 2001,
    "message": "the credit card account must be of type CREDIT, not PAYABLE",
    "data": {
      "help": "error/invalid"
    }
  }
}

Command line

red-ale exec --book book.gnucash employee.create '{"name":"John Roe","currency":"EUR","creditCardAccount":"1d8f8d4a358c4a169b3421d953b40369"}'

It fails with exit status 2, printing on standard error:

{
  "error": {
    "code": 2001,
    "message": "the credit card account must be of type CREDIT, not PAYABLE",
    "data": {
      "help": "error/invalid"
    }
  }
}

MCP tool call

Tool call:

{"name":"employee.create","arguments":{"name":"John Roe","currency":"EUR","creditCardAccount":"1d8f8d4a358c4a169b3421d953b40369"}}

Result:

{
  "isError": true,
  "structuredContent": {
    "error": {
      "code": 2001,
      "name": "invalid",
      "message": "the credit card account must be of type CREDIT, not PAYABLE",
      "data": {
        "help": "error/invalid"
      }
    }
  }
}

Effect: write, on the Book.

Params

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

  • name (string or null): The employee's name, which GnuCash keeps as the address name; it overrides addr.name.
  • id (string or null): Employee number. On create, absent or empty takes the next number from the book's gncEmployee counter.
  • username (string or null): User name.
  • currency (CommodityId or null): The currency of the employee's expense vouchers.
  • addr (AddressParams or null): Payment address.
  • language (string or null): Language.
  • acl (string or null): Access control list (stored only).
  • workday (Amount or null): Working hours per day.
  • rate (Amount or null): Hourly rate.
  • creditCardAccount (AccountRef or null): The company credit card account (type CREDIT) card-paid expenses are charged to; null for none.
  • active (boolean or null): Active; false deactivates.

Result

An employee.

  • guid (Guid, required): A GUID: 32 hexadecimal digits.
  • id (string, required)
  • name (string, required): The address name.
  • username (string, required)
  • addr (AddressInfo, required): An address. Empty strings are unset fields.
  • language (string, required)
  • acl (string, required)
  • workday (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.
  • rate (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.
  • currency (CommodityId or null)
  • creditCardAccount (Guid or null)
  • active (boolean, required)