bank account interest

Josh Sled jsled at
Fri Feb 11 11:26:43 EST 2005

On Thu, 2005-02-10 at 22:38, Haichuan Yang wrote:

> 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?

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

  (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

[1]: a(1+(r_{n}/n))^(nt) as per


-- - `a=jsled;; echo ${a}@${b}`

More information about the gnucash-user mailing list