BANAL version 0.10
Chapter 4: Advanced Topics
This chapter deals with fairly advanced topics including how the
database (tables) files are setup and why certain design decisions
were made.
4.1: How the Tax field behaves
The Tax field in the Charge table is no longer a special category.
Properties of the various taxes are now properly configurable in the
setting table. See the settings section (2.3.2) for more
details.
4.2: Why Date fields are formatted as YYYY.MMDD
Dates are a pain. The reason we chose the YYYY.MMDD format for dates is
simple. We wanted to be able to do numeric-style comparisons. With
the date format as it is we are able to do searches on dates such as:
Date ge 1997 and Paid lt 1997.0401
This search (when used with the bk invoices command) will return
a list of all invoices that were generated in 1997 or later and were
paid before April 1st. If you can show us a date format that is able
to do the same without lots of fussing and is also not error prone,
please let me know.
NOTE: I guess YYYY/MM/DD would have have worked too. Using a string
comparison, though.
4.3: BANAL Tables
The templates for the tables are in the templates directory and there
is a script in bin called tablegen which will generate a working set
of books from the templates and corresponding data. There are also some
sample books in the sample directory including an empty set if you
do not wish to generate your starting books.
Here are a couple of noteworthy pieces of information for people making
or interested in BANAL tables:
- The first field in each file is a unique ID field. The field
name is the same as the table's. The first character is uppercase
and all other characters are lowercase.
- Any values with tabspaces (\t) or newlines (\n) will have them
changed to the two character strings, '\T' and '\N', respectively.
These strings will be changed back as needed (editting, running a
transaction) but not when being listed.
- KEYWORDS are placed in the Field Description. These keywords
are seperate from the rest of the description by the string '@@'. The
current keywords are:
- /^[A-Z][a-z]* ID/
-
means that this references an ID from another table. (NOTE: This
is a regular expression)
- CATEGORIZED
-
means that valid values come from the Category table.
- MULTILINE
-
means that you may enter a value that spans multiple lines.
- REQUIRED
-
means that the field must be set when adding/editting.
- YYYY.MMDD
-
in the description means it is a date field.
- NEG_OK
-
indicates that this field may have a negative value.
The tables that are distributed with this version include:
- Category
-
The category table is quite special. Any other table that wants to
define a field that can only contain specific values places these
values in this table.
- Charge
-
A charge is a billable item. It may be a good or a service and may be
registered against a project.
- Client
-
A client is a person that you are able to register invoices, projects
and other items against. There are also optional fields to specify
where to send the billings.
- Employee
-
Employee entries are used for tracking timesheets, expenses, leads for
clients and projects.
- Expense
-
The expense table is used for tracking your expenditures.
- Invoice
-
An invoice hold the main information pertaining to each invoice. It will
reference zero or more 'Charge' entries which contain itemized details of
the invoice.
- Procedure
-
A table for tracking information on have things are done in your
workplace.
- Project
-
A project may be used to track income and expenses for a particular job
that may span more than one invoice (or no invoices for an internal
project).
- Recurrence
-
Use this table for registering recurring (and memorized) transactions.
- Setting
-
This table stores all of the configurable information for BANAL.
- Supplier
-
Use this table to track suppliers and assign expenses to them.
- Timesheet
-
Use the timesheet entry for tracking time spent on various projects.
4.3.1: Adding your own tables
You can easily add your own table by creating a RDB file in your
books directory. The RDB file must start with a capital letter
and be followed by lowercase letters (eg. Todo.rdb). The only
mandatory field is the first one in a record. It must be the
same name as the RDB file (without the .rdb extension - eg. Todo).
The next time you start the bkd server it will notice the
new file and generate a modify and list command for it.
You can either copy an existing database and modify it as desired
or you may copy a .tpl file in the templates directory and have
tablegen generate your books (remember, you can include initial
data in a .dat file).
Details on RDB template files and the RDB header can be obtained
from the full RDB documentation.
4.4: Foreign Currencies
The support for foreign currencies is very simple. There are two new
fields in the Invoice table, Currency and Exchange. If you wish to
create an invoice in a non-local currency then just assign these fields.
Generation of invoices and financial statements will handle the different
currencies appropriately. You can specify an estimated exchange rate at
the time that you create the invoice and, later, update it to the true
exchange rate when you receive payment.