Method

scheduledTransaction.fromTransaction

Make a scheduled transaction from a transaction, as GnuCash's Schedule from transaction does.

Makes a scheduled transaction from an existing transaction, as GnuCash's Schedule from transaction does. The transaction is not changed. The scheduled transaction has one template transaction with the transaction's description, number, notes and currency; each split keeps its memo, action and account, and its value becomes a formula (a positive value as the debit formula, otherwise the credit formula).

frequency is daily (the default), weekly, biWeekly, monthly, quarterly or yearly. The first occurrence is the first one of that frequency after the transaction's date, not the transaction's own date, unless you give startDate. yearly is stored as every 12 months, as GnuCash stores it.

Examples

Example: with a new, empty book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"account.create","params":{"name":"Checking","type":"BANK","commodity":"USD"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "…"
}

Request:

{"jsonrpc":"2.0","id":2,"method":"account.create","params":{"name":"Rent","type":"EXPENSE","commodity":"USD"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": "…"
}

Request:

{"jsonrpc":"2.0","id":3,"method":"transaction.post","params":{"datePosted":"2024-05-01","description":"Rent","splits":[{"account":"Rent","value":"750.00"},{"account":"Checking","value":"-750.00"}]}}

Response:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "guid": "00ed0000000000000000000000000005",
    "…": "…"
  }
}

Request:

{"jsonrpc":"2.0","id":4,"method":"scheduledTransaction.fromTransaction","params":{"transaction":"00ed0000000000000000000000000005","frequency":"monthly"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "name": "Rent",
    "startDate": "2024-06-01",
    "schedule": [
      {
        "mult": 1,
        "periodType": "month",
        "start": "2024-06-01",
        "…": "…"
      }
    ],
    "templateTransactions": [
      {
        "description": "Rent",
        "splits": [
          {
            "accountName": "Rent",
            "debitFormula": "750.00",
            "…": "…"
          },
          {
            "accountName": "Checking",
            "creditFormula": "750.00",
            "…": "…"
          }
        ],
        "…": "…"
      }
    ],
    "…": "…"
  }
}

Command line

red-ale exec --book book.gnucash --script - <<'EOF'
account.create {"name":"Checking","type":"BANK","commodity":"USD"}
account.create {"name":"Rent","type":"EXPENSE","commodity":"USD"}
transaction.post {"datePosted":"2024-05-01","description":"Rent","splits":[{"account":"Rent","value":"750.00"},{"account":"Checking","value":"-750.00"}]}
scheduledTransaction.fromTransaction {"transaction":"00ed0000000000000000000000000005","frequency":"monthly"}
EOF

It prints:

[
  "…",
  "…",
  {
    "guid": "00ed0000000000000000000000000005",
    "…": "…"
  },
  {
    "name": "Rent",
    "startDate": "2024-06-01",
    "schedule": [
      {
        "mult": 1,
        "periodType": "month",
        "start": "2024-06-01",
        "…": "…"
      }
    ],
    "templateTransactions": [
      {
        "description": "Rent",
        "splits": [
          {
            "accountName": "Rent",
            "debitFormula": "750.00",
            "…": "…"
          },
          {
            "accountName": "Checking",
            "creditFormula": "750.00",
            "…": "…"
          }
        ],
        "…": "…"
      }
    ],
    "…": "…"
  }
]

MCP tool call

Tool call:

{"name":"account.create","arguments":{"name":"Checking","type":"BANK","commodity":"USD"}}

Result:

{
  "content": [
    {
      "type": "text",
      "text": "\"…\""
    }
  ]
}

Tool call:

{"name":"account.create","arguments":{"name":"Rent","type":"EXPENSE","commodity":"USD"}}

Result:

{
  "content": [
    {
      "type": "text",
      "text": "\"…\""
    }
  ]
}

Tool call:

{"name":"transaction.post","arguments":{"datePosted":"2024-05-01","description":"Rent","splits":[{"account":"Rent","value":"750.00"},{"account":"Checking","value":"-750.00"}]}}

Result:

{
  "structuredContent": {
    "guid": "00ed0000000000000000000000000005",
    "…": "…"
  }
}

Tool call:

{"name":"scheduledTransaction.fromTransaction","arguments":{"transaction":"00ed0000000000000000000000000005","frequency":"monthly"}}

Result:

{
  "structuredContent": {
    "name": "Rent",
    "startDate": "2024-06-01",
    "schedule": [
      {
        "mult": 1,
        "periodType": "month",
        "start": "2024-06-01",
        "…": "…"
      }
    ],
    "templateTransactions": [
      {
        "description": "Rent",
        "splits": [
          {
            "accountName": "Rent",
            "debitFormula": "750.00",
            "…": "…"
          },
          {
            "accountName": "Checking",
            "creditFormula": "750.00",
            "…": "…"
          }
        ],
        "…": "…"
      }
    ],
    "…": "…"
  }
}

Effect: write, on the Book.

Params

Params of scheduledTransaction.fromTransaction.

  • transaction (Guid, required): The transaction to copy; it is not changed.
  • name (string or null): The name; the transaction's description by default.
  • frequency (FrequencyWire): How often; daily by default.
  • startDate (Date or null): The first occurrence; the frequency's first after the transaction's date by default.
  • end (End or null): The end; never by default.
  • autoCreate (boolean or null): Create due instances without asking; false by default.
  • notify (boolean or null): And say so; true with autoCreate by default.
  • advanceCreateDays (integer (int32) or null): Days ahead to create; 0 by default.
  • advanceRemindDays (integer (int32) or null): Days ahead to remind; 0 by default.

Result

A scheduled transaction, with every field GnuCash's file holds.

  • guid (Guid, required): Identity.
  • name (string, required): The name; names need not be unique.
  • enabled (boolean, required): Disabled ones are left out of Since Last Run and the forecasts.
  • startDate (Date, required): The first possible occurrence.
  • end (End, required): The end, as stored.
  • lastOccurrence (Date or null): The last occurrence acted on (created, ignored or postponed), or null if never run.
  • instanceCount (integer (int32), required): The Instance count: the value of i for the next instance.
  • autoCreate (boolean, required): Create due instances without asking.
  • notify (boolean, required): And say so.
  • advanceCreateDays (integer (int32), required): Days ahead to create.
  • advanceRemindDays (integer (int32), required): Days ahead to remind, after that.
  • schedule (array of Recurrence, required): The Schedule, as stored.
  • nextOccurrence (Date or null): The next occurrence after the last (or the first), or null when it has ended or never occurs.
  • deferredInstances (array of DeferredInstance, required): The state saved before each postponed instance, in file order.
  • templateAccount (Guid or null): The template account's GUID, or null when there is none.
  • templateTransactions (array of TemplateTransaction or null): The template transactions, in the template account's split order; absent in scheduledTransaction.list.
  • variables (array of string, required): Every variable the formulas name, i and the exchange-rate variables, sorted bytewise.
  • warnings (array of WarningInfo or null): What GnuCash's editor would have asked to confirm; only from methods that write.