Method

lot.computeGains

Recompute a lot's capital gains, recording them in gains transactions.

Recomputes a lot's capital gains: for each selling split, the gain is its value less the basis of the shares it sells, and it is recorded in a two-split gains transaction, Realized Gain/Loss, in the lot and in the gains account (or gainsAccount). A gain of zero records nothing, and a gains transaction that is already right is not rewritten. Unlike lot.scrub it does not move splits between lots.

Examples

Example: with a copy of the reports/lots-baseline example book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"lot.computeGains","params":{"lot":"10000000000000000000000000000000"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "lotsCreated": [],
    "transactionsCreated": [],
    "transactionsChanged": [],
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash lot.computeGains '{"lot":"10000000000000000000000000000000"}'

It prints:

{
  "lotsCreated": [],
  "transactionsCreated": [],
  "transactionsChanged": [],
  "…": "…"
}

MCP tool call

Tool call:

{"name":"lot.computeGains","arguments":{"lot":"10000000000000000000000000000000"}}

Result:

{
  "structuredContent": {
    "lotsCreated": [],
    "transactionsCreated": [],
    "transactionsChanged": [],
    "…": "…"
  }
}

Effect: write, on the Book.

Params

Params of lot.computeGains.

  • lot (Guid, required): The lot.
  • gainsAccount (AccountRef or null): The account new gains transactions credit, used when its commodity is the transaction currency; by default the lot account's gains account (Orphaned Gains-<CUR> unless one is set).

Result

What a scrub or gains computation changed.

  • lotsCreated (array of Guid, required): Lots made.
  • lotsDeleted (array of Guid, required): Lots deleted.
  • transactionsCreated (array of Guid, required): Transactions made: gains transactions.
  • transactionsChanged (array of Guid, required): Transactions changed: cut or merged splits, updated gains.
  • transactionsDeleted (array of Guid, required): Transactions deleted: gains transactions of merged splits.
  • accountsCreated (array of Guid, required): Accounts made: Orphaned Gains-<CUR>.