lot.assignSplit
Put a split in a lot, cutting it if it would overfill the lot; without a lot, FIFO chooses.
Puts a split in a lot. Given lot, the split joins it, and is cut in two if it would overfill the lot; the cut-off
rest stays in no lot (rest). Without lot, GnuCash's FIFO policy chooses the earliest open lot the split reduces,
or opens a new one (newLots). A split joins only a lot of its own account, and a closed lot refuses with conflict.
Examples
Example: with a copy of the reports/investment-lots example book open as book.gnucash.
JSON-RPC
Request:
{"jsonrpc":"2.0","id":1,"method":"lot.assignSplit","params":{"split":"d0000000000000000000000000000001"}}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"pieces": [
{
"split": "d0000000000000000000000000000001",
"lot": "…"
}
],
"rest": null,
"newLots": [
"…"
]
}
}
Request:
{"jsonrpc":"2.0","id":2,"method":"lot.assignSplit","params":{"split":"d0000000000000000000000000000007"}}
Response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"pieces": [
{
"split": "d0000000000000000000000000000007",
"lot": "…"
}
],
"rest": null,
"newLots": []
}
}
Command line
red-ale exec --book book.gnucash --script - <<'EOF'
lot.assignSplit {"split":"d0000000000000000000000000000001"}
lot.assignSplit {"split":"d0000000000000000000000000000007"}
EOF
It prints:
[
{
"pieces": [
{
"split": "d0000000000000000000000000000001",
"lot": "…"
}
],
"rest": null,
"newLots": [
"…"
]
},
{
"pieces": [
{
"split": "d0000000000000000000000000000007",
"lot": "…"
}
],
"rest": null,
"newLots": []
}
]
MCP tool call
Tool call:
{"name":"lot.assignSplit","arguments":{"split":"d0000000000000000000000000000001"}}
Result:
{
"structuredContent": {
"pieces": [
{
"split": "d0000000000000000000000000000001",
"lot": "…"
}
],
"rest": null,
"newLots": [
"…"
]
}
}
Tool call:
{"name":"lot.assignSplit","arguments":{"split":"d0000000000000000000000000000007"}}
Result:
{
"structuredContent": {
"pieces": [
{
"split": "d0000000000000000000000000000007",
"lot": "…"
}
],
"rest": null,
"newLots": []
}
}
Effect: write, on the Book.
Params
Params of lot.assignSplit.
split(Guid, required): The split.lot(Guid or null): The lot; without it, FIFO chooses and opens lots as needed.
Result
The result of lot.assignSplit.
pieces(array of Piece, required): Each piece and its lot.rest(Guid or null): When the split was cut to close the chosen lot: the new split holding the rest, in no lot.newLots(array of Guid, required): Lots FIFO opened.