Scheduled Transactions

From GnuCash
Jump to: navigation, search

Scheduled transactions is made to help entering repetitive money operations, like subscriptions, insurances or taxes. By using scheduled transactions, you only have to enter the concerned transaction once, set a few parameters like start date, frequency and a little description, and then GnuCash will tell you whenever a scheduled transaction is ready to create, and create it for you.

In GnuCash, there are two ways of creating scheduled transactions, from the ledger or from the scheduled transactions editor.

Creating from the Ledger

  1. Enter the first occurrence of your to-schedule transaction in the ledger.
  2. Once the transaction has been entered, right-click on it and choose "Schedule...".
  3. A window dialog box will appear titled "Make a Scheduled Transaction".
  4. Fill in the necessary fields, such as:
    1. Name
    2. Frequency
    3. Start Date
    4. End

Creating from the Editor

  1. Select Actions > Scheduled Transactions > Scheduled Transaction Editor from the menu.
  2. The Scheduled Transactions window will appear. Press the "New" button
  3. A window dialog box will appear titled "Edit a Scheduled Transaction".
  4. Fill in the necessary fields, such as:
    1. Name
    2. Frequency
    3. Start Date
    4. End

Variables and Formulas

Variables and Formulas were introduced to serve the mortgage/loan druid in 2002. Variables and Formulas work only in cells like Deposit and Withdrawal (or Debit and Credit if you have formal account names turned on) that require something that evaluates to a number.

  1. Any text string [not followed by parens] entered in the template transaction will be recognized as a variable, and you will be prompted to provide a value when the scheduled transaction is created.
  2. Any text string followed by parens, optionally with arguments, will have the string "gnc:" prepended to it and evaluated in the scheme environment.
    Arguments are separated with :. See fin.scm for examples of providing functions.
  3. There is a magic variable 'i', which stands for the current instance-count of the scheduled transaction. 1 for the first, 2 for the second, &c. It might be 0-based.
  • I'd like to have a variable which decrements each month, in order to automatically calculate sum-of-digits depreciation.
In any case, if you know the starting point, "(42 - i)" should work.

[1]

Bank Account Interest

Q: Is there any way for Gnucash to calculate the interest on a bank account, and automatically enter the interest as an interest income? One will have to enter the initial account balance, interest rate, compound method (monthly) etc, to make this happen. Or does one have to enter manually the interest say, each month?

A: Scheduled Transactions can be used here. For the case of simple compounded interest, you can add the following function[s] to `fin.scm`:

;; a: amount
;; r: interest rate
;; n: frequency per year
;; t: time in years

  (define (futureValue a r n t)
    (* a (expt (+ 1 (/ r n)) (* n t))))

  (define (gnc:computeInterestIncrement amount interest periods i)
    (let ((thisVal (futureValue amount interest periods i))
          (prevVal (futureValue amount interest periods (- i 1))))
      (- thisVal prevVal)
    )
  )

and use it in the scheduled transaction template-transaction;

The credit-formula would then look like:
computeInterestIncrement( 5000.00 : 0.03125 : 12 : i )

If the formula was simple, then you could just enter it directly in the template transaction; unfortunately, the basic compounding-interest formula [1] involves exponentiation, which can't be handled in the current expression parser, so one must resort to defining it in scheme... also, note that you'll need to do the `i`th value minus the `i-1`th value in order to get the current increment. Luckily, the variable `i` is pre-bound to the current 1-based iteration count value, which is useful.

I'll definitely move this function into the distribution going forward, and may -- eventually -- have this be a "stock" scheduled transaction template.

[1]: a(1+(r_{n}/n))^(nt) as per http://www.riskglossary.com/articles/compounding.htm

[2]

formulas or scripts for periodic savings

Q: I want to schedule a function that puts (Earnings of the month - Expenses of the month) from Normal account to Patrimony account.

A: If you can express the amounts of the splits in the transaction as a simple expression (optionally with variables), then the scheduled-transaction subsystem will prompt you for the value of those variables when the transaction comes-due. So, for instance, if you wanted to have the formula...

   earnings - expenses

... then gnucash would prompt you for the values of both "earnings" and "expenses" when it needs to create the transaction.

It was unclear from your example where the 10% and 20% came into the computation -- those seemed like your own personal restrictions, not really enforced (or enforceable) by gnucash. But if you wanted to have a template transaction with formulae like...

   account 1 credit: (earnings * 0.10) + (earnings * 0.20) + (earnings * 0.70)
   account 2 debit:  (earnings * 0.10)
   account 3 debit:  (earnings * 0.20)
   account 4 debit:  (earnings * 0.70)

...then gnucash would only prompt for the single value "earnings" and compute the full transaction from that.

What it _cannot_ do, however, is sum or obtain the values from existing accounts ... so it would not be able to compute "all expenses in the last month".

[3]

Splitting Expenses Monthly

Q: I live in a house with five other people, and we share expenses. Some people are excluded from some of the expences. At the end of the month, we figure out who owes money to whom. Does anyone have any suggestions as to how I might do this?

A: I would not try to do it in the form "sum monthly expenses and divide", but instead handle it on a per-expense basis.

If the transactions aren't actually SXes and you're entering them manually, just create the split for payment of the expense as normal, then one split for each individual's share. If someone is acting as treasurer for the house, then that individual might have "Assets:Money Owed to Me:«other person»" accounts for each other person in addition to their own Expenses:«Expense» account. The value of the Asset accounts is how much each person owes, and you can take its balance periodically with a normal transaction report. Note that accounts might change if the books are from the perspective of the "house" instead of a person, but the idea is the same.

If the expenses are indeed regular and you want to setup an SX for them, then the SX can contain the same splits. As a bit of a bonus, you can use variables and formulae to write these transaction templates to make data-entry easier.

A good example is a phone bill, where the local/unmetered "base" expense is shared evenly, but each individual's long-distance portion is enumerated:

| Phone | Assets:Checking               | <A> |     |
| Mike  | Expenses:Phone                |     | <B> |
| Bob   | Assets:Money Owed To Me:Bob   |     | <C> |
| Sally | Assets:Money Owed To Me:Sally |     | <D> |

Where:
<A> := base + sally_ld + bob_ld + mike_ld
<B> := base/3 + mike_ld
<C> := base/3 + bob_ld
<D> := base/3 + sally_ld

Then, the SX since-last-run dialog will prompt you for the four values: base, {bob,sally,mike}_ld, and construct the transaction appropriately.

[4]

Related FAQs