Guide

Depreciate an asset

Spread the cost of equipment over its useful life with a monthly scheduled transaction that moves an equal amount into a depreciation expense.

Equipment loses value as it is used. Rather than count the whole price as an expense the day you buy it, accountants spread it over the years it will last. This is depreciation. The simplest way is the straight line: if a 1,200.00 machine will last 12 months, 100.00 a month is charged as an expense.

The books keep the machine at what you paid, in one account, and the total depreciation so far in a second asset account ("accumulated depreciation"). Together they give the machine's current worth. Each month's charge goes to a depreciation expense account, which reduces your profit.

Steps

  1. Create the accounts (Set up accounts): Equipment and Accumulated depreciation (both ASSET), Depreciation (EXPENSE) and the bank account you paid from.
  2. Record the purchase: Equipment +, bank -, for the price.
  3. Schedule the charge with scheduledTransaction.create: a monthly schedule from the first date, and a template transaction with two splits, Depreciation as a debitFormula of 100 and Accumulated depreciation as a creditFormula of 100. Add end to stop after 12 occurrences.
  4. Check the dates with scheduledTransaction.occurrences, which lists future occurrences of a schedule without creating anything.
  5. Create what is due each time you open the book: scheduledTransaction.sinceLastRun proposes every missed occurrence and changes nothing; scheduledTransaction.apply with the proposal's id creates the transactions. See Schedule a transaction.
  6. Check the expense with account.balance.

A declining-balance method changes the formula each period, or is entered by hand with transaction.post from your own calculation.

Example

Buy the machine, schedule the charge, see that three months are due on 15 October, and create them.

Example: with a new, empty book open as book.gnucash, at 2024-10-15T12:00:00Z.

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":"Equipment","type":"ASSET","commodity":"USD"}}

Response:

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

Request:

{"jsonrpc":"2.0","id":3,"method":"account.create","params":{"name":"Accumulated depreciation","type":"ASSET","commodity":"USD"}}

Response:

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

Request:

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

Response:

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

Request:

{"jsonrpc":"2.0","id":5,"method":"transaction.post","params":{"datePosted":"2024-08-01","description":"Buy machine","splits":[{"account":"Equipment","value":"1200.00"},{"account":"Checking","value":"-1200.00"}]}}

Response:

{
  "jsonrpc": "2.0",
  "id": 5,
  "result": {
    "balanced": true,
    "…": "…"
  }
}

Request:

{"jsonrpc":"2.0","id":6,"method":"scheduledTransaction.create","params":{"name":"Depreciate machine","startDate":"2024-08-01","schedule":[{"mult":1,"periodType":"month"}],"end":{"occurrences":12},"templateTransactions":[{"description":"Depreciation","splits":[{"account":"Depreciation","debitFormula":"100"},{"account":"Accumulated depreciation","creditFormula":"100"}]}]}}

Response:

{
  "jsonrpc": "2.0",
  "id": 6,
  "result": {
    "name": "Depreciate machine",
    "enabled": true,
    "startDate": "2024-08-01",
    "…": "…"
  }
}

Request:

{"jsonrpc":"2.0","id":7,"method":"scheduledTransaction.occurrences","params":{"schedule":[{"mult":1,"periodType":"month"}],"startDate":"2024-08-01","count":3}}

Response:

{
  "jsonrpc": "2.0",
  "id": 7,
  "result": {
    "occurrences": [
      {
        "date": "2024-08-01",
        "…": "…"
      },
      {
        "date": "2024-09-01",
        "…": "…"
      },
      {
        "date": "2024-10-01",
        "…": "…"
      }
    ]
  }
}

Request:

{"jsonrpc":"2.0","id":8,"method":"scheduledTransaction.sinceLastRun","params":{}}

Response:

{
  "jsonrpc": "2.0",
  "id": 8,
  "result": {
    "id": "slr-1",
    "summary": {
      "toCreate": 3,
      "…": "…"
    },
    "…": "…"
  }
}

Request:

{"jsonrpc":"2.0","id":9,"method":"scheduledTransaction.apply","params":{"proposal":"slr-1"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 9,
  "result": {
    "created": [
      {
        "index": 0,
        "date": "2024-08-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      },
      {
        "index": 1,
        "date": "2024-09-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      },
      {
        "index": 2,
        "date": "2024-10-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      }
    ],
    "ignored": [],
    "postponed": [],
    "reminders": [],
    "schedules": [
      "…"
    ],
    "imbalanceSplits": [],
    "warnings": []
  }
}

Command line

red-ale exec --book book.gnucash --script - <<'EOF'
account.create {"name":"Checking","type":"BANK","commodity":"USD"}
account.create {"name":"Equipment","type":"ASSET","commodity":"USD"}
account.create {"name":"Accumulated depreciation","type":"ASSET","commodity":"USD"}
account.create {"name":"Depreciation","type":"EXPENSE","commodity":"USD"}
transaction.post {"datePosted":"2024-08-01","description":"Buy machine","splits":[{"account":"Equipment","value":"1200.00"},{"account":"Checking","value":"-1200.00"}]}
scheduledTransaction.create {"name":"Depreciate machine","startDate":"2024-08-01","schedule":[{"mult":1,"periodType":"month"}],"end":{"occurrences":12},"templateTransactions":[{"description":"Depreciation","splits":[{"account":"Depreciation","debitFormula":"100"},{"account":"Accumulated depreciation","creditFormula":"100"}]}]}
scheduledTransaction.occurrences {"schedule":[{"mult":1,"periodType":"month"}],"startDate":"2024-08-01","count":3}
scheduledTransaction.sinceLastRun {}
scheduledTransaction.apply {"proposal":"slr-1"}
EOF

It prints:

[
  "…",
  "…",
  "…",
  "…",
  {
    "balanced": true,
    "…": "…"
  },
  {
    "name": "Depreciate machine",
    "enabled": true,
    "startDate": "2024-08-01",
    "…": "…"
  },
  {
    "occurrences": [
      {
        "date": "2024-08-01",
        "…": "…"
      },
      {
        "date": "2024-09-01",
        "…": "…"
      },
      {
        "date": "2024-10-01",
        "…": "…"
      }
    ]
  },
  {
    "id": "slr-1",
    "summary": {
      "toCreate": 3,
      "…": "…"
    },
    "…": "…"
  },
  {
    "created": [
      {
        "index": 0,
        "date": "2024-08-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      },
      {
        "index": 1,
        "date": "2024-09-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      },
      {
        "index": 2,
        "date": "2024-10-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      }
    ],
    "ignored": [],
    "postponed": [],
    "reminders": [],
    "schedules": [
      "…"
    ],
    "imbalanceSplits": [],
    "warnings": []
  }
]

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":"Equipment","type":"ASSET","commodity":"USD"}}

Result:

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

Tool call:

{"name":"account.create","arguments":{"name":"Accumulated depreciation","type":"ASSET","commodity":"USD"}}

Result:

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

Tool call:

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

Result:

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

Tool call:

{"name":"transaction.post","arguments":{"datePosted":"2024-08-01","description":"Buy machine","splits":[{"account":"Equipment","value":"1200.00"},{"account":"Checking","value":"-1200.00"}]}}

Result:

{
  "structuredContent": {
    "balanced": true,
    "…": "…"
  }
}

Tool call:

{"name":"scheduledTransaction.create","arguments":{"name":"Depreciate machine","startDate":"2024-08-01","schedule":[{"mult":1,"periodType":"month"}],"end":{"occurrences":12},"templateTransactions":[{"description":"Depreciation","splits":[{"account":"Depreciation","debitFormula":"100"},{"account":"Accumulated depreciation","creditFormula":"100"}]}]}}

Result:

{
  "structuredContent": {
    "name": "Depreciate machine",
    "enabled": true,
    "startDate": "2024-08-01",
    "…": "…"
  }
}

Tool call:

{"name":"scheduledTransaction.occurrences","arguments":{"schedule":[{"mult":1,"periodType":"month"}],"startDate":"2024-08-01","count":3}}

Result:

{
  "structuredContent": {
    "occurrences": [
      {
        "date": "2024-08-01",
        "…": "…"
      },
      {
        "date": "2024-09-01",
        "…": "…"
      },
      {
        "date": "2024-10-01",
        "…": "…"
      }
    ]
  }
}

Tool call:

{"name":"scheduledTransaction.sinceLastRun","arguments":{}}

Result:

{
  "structuredContent": {
    "id": "slr-1",
    "summary": {
      "toCreate": 3,
      "…": "…"
    },
    "…": "…"
  }
}

Tool call:

{"name":"scheduledTransaction.apply","arguments":{"proposal":"slr-1"}}

Result:

{
  "structuredContent": {
    "created": [
      {
        "index": 0,
        "date": "2024-08-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      },
      {
        "index": 1,
        "date": "2024-09-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      },
      {
        "index": 2,
        "date": "2024-10-01",
        "transactions": [
          "…"
        ],
        "…": "…"
      }
    ],
    "ignored": [],
    "postponed": [],
    "reminders": [],
    "schedules": [
      "…"
    ],
    "imbalanceSplits": [],
    "warnings": []
  }
}

The Depreciation account then has a balance of 300.00 and Accumulated depreciation of -300.00, and the machine is worth 1,200.00 less 300.00.