BANAL version 0.03

Chapter 4: Recurring and Memorized Transactions

A recurrence entry allows you to periodically create entries in an existing database (including the recurrence database itself).

There are two types of recurrence entries:

4.1: Adding a Recurrence Entry

Adding a recurrence entry is identical to adding an entry for any other database (eg. Expense). However, being the most complicated database, it deserves special attention.

The fields and their meanings are:

4.2: Commands in a Recurrence Entry

The basics of the Commands field in a recurrence entry are simple. Let's look at creating an invoice as an example. Use bk invoices -F to obtain the field names. A basic set of commands to make an invoice every month would look like:

Invoice = makeDate("CLI-%y-%m");
Client = 'someclient';
$tmp = 'Services invoice. Pay up by ';
Date = makeDate("%Y.%m%d");
Description = $tmp . incrDate( Date , 90);
From = makeDate("%Y.%m01");
To = makeDate("%Y.%m%l");

You can use the makeDate function to create dates based on the running date (which may or may not be the same as the current date). See the section on makeDate (4.2.1) for details.

There are some important caveat:

  1. Do not embedded Perl style comment in the commands. The only current exception is if they are placed after all valid command statements.

  2. Do keep whitespace (spaces, tabs, newlines) around all use of field names. Otherwise they will not be recognized as such.

  3. The only legal field names are the ones in the database entry.

4.2.1: makeDate

The makeDate function take a string with embedded directives that will be parsed and substituted as appropriate. You would use it in a statement similar to:
$value = makeDate("some string %d with directives");

Directive are always in the format '%c', where c is any character. The directives are:

An example (run on February 10, 1997):

makeDate("%j: Happy b-day mom, %Y.%m%d")

would give:

41: Happy b-day mom, 1997.0210

4.2.2: incrDate

The incrDate function take a date in the normail format (YYYY.MMDD) and increases/decreases it based on the intervals specified. The incrments are days, months and years (in that order). You would use it in a statement similar to:
$value = incrDate("1997.0901", 1, 2, 3);

This would increase the supplied date (Sept. 1, 1997) by 1 day, 2 months and 3 years.

You may also use negative values.

4.2.3: Extra Commands on the command line

When using the runbatch (2.5) command you may wish to specify additional argument on the command line. These commands are run before any memorized or recurring transactions' commands are processed (and they are redone for each transaction).

A useful example would be for creating an invoice and overriding the Client name. You could specify: Client = 'SGI' (with appropriate shell quoting, of course). And then have a line in the Commands field (note the space between Client and ';') such as:

Client = 'Bruce' if not Client ;