Observations while working with taxinvoice.scm and eguile templating

Matthijs Kooijman matthijs at stdin.nl
Tue Jul 6 11:15:26 EDT 2010

Hi all,

I've been to get a pretty invoice template to generate my invoices.
Since the scheme-based templating seemed a bit cumbersome to me, I've
compiled the current SVN version and started fiddling around with the
eguile based templating instead.

So far, I've been using a (nearly) unmodified taxinvoice.scm, with
heaviliy customized taxinvoice.eguile.scm and taxinvoice.css. In the
course of this customization, I'm making a few observations that might
be useful to improve the current taxinvoice template and the templating
system as a whole.

In case you're curious as to the results, the finished invoice is
available here:


These observations are in no particular order.

Duplicate customer name
I've noticed that the customer name is shown up to three times: The
company name, and twice the billing address name. The reason for the
duplicate billing address is that gnc:owner-get-name-and-address returns
this name, but gncAddressGetName returns the same name. both of these
are shown in the form. I've solved this by just using
gnc:owner-get-name-and-address, but I suspect in the original report the
aim was to put the contact name above the company name?

Module includes
In my report I needed the regex module (to replace newlines with —
to put my address in the footer). However, I can't call use-modules from
the eguile template, so I had to modify taxinvoice.scm to include the
regex module instead. Perhaps it should be included by default, or there
is some way to include a module even when not at top level?

Taxable flags
In taxinvoice.eguile.scm, the tax? variable is set to true when tax
should be shown on the invoice. For this, it checks to see if the
taxtable of every entry is equal to "". However, it does not check the
taxable flag of the entries. This is not normally a problem, but if you
have an entry for which you selected a taxtable and then unchecked the
taxable checkbox, then this check won't be sufficient (the entry will
still have a taxtable, but it's not used). The check in
taxinvoice.eguile.scm should probably include the taxable flag?

Invalid HTML in error message
When a valid invoice is selected, the display-report function is called
to show the invoice, otherwise an error message is shown. However, the
<html> (etc.) opening tags are created within display-report, while the
closing tags are below the call to display-report. So when an error
message is shown, the HTML generated is invalid: Tags are not opened but
they are closed.

This is probably because the html head tag includes the invoice number
in the title. Perhaps it is better to move the closing of the html tags
into display-report as well, so they are at least consistent. The error
message could then create its own html opening and closing tags, or
perhaps just remain broken (but at least it would be balanced).

Page footer
I've been trying to get a footer on my invoice. Initial attempts using
position: fixed did not work at all in gkhtml and only on screen with
webkit (the print version would put the footer directly below the page

I've now created the following HTML and CSS to get a working footer.
Tested on webkit only.

  <div class="footer">
      <?scm:d coyname ?> &mdash; <?scm:d (nl->mdash coyaddr) ?>

  .footer {
    position: absolute;
    left: 0cm;
    right: 0cm;
    /* 29.7cm page height - 2cm bottom margin - 2cm footer height.
     * Unfortunately, the bottom property doesn't seem to work with
     * webkit */
    top: 25.7cm ;

    text-align: center;

By default, the on-screen version takes up the entire width of the
window, which is usually wider than a typical print version. To make the
screen and print versions match better, I've added the following CSS.
Note that this assumes A4 paper size in portrait mode, so it's probably
not very suited to include by default.

  @media screen {
    html, body {
      width: 21cm;
    /* Give footer a width seperately, since it is absolutely position */
    .footer {
      width: 21cm;

Word wrapping in table
By default, some of the headings in the entries table (like Unit Price)
were wordwrapped. This also happened for dates, which were wrapped on
the hyphens in the data (e.g., you would get 2010-\n06-01). This looks
very ugly. The following CSS fixes this (needs an extra class="date" on
the data cells in the table:

  table.entries th, table.entries td.date {
    /* Prevent wordwrapping dates and headers */
    white-space: nowrap;

I guess this might be applicable to all cells in the table, except for
the entry descriptions.

I hope some of these observations can be used by others doing similar
things, or can be used to improve Gnucash. Comments are welcome.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20100706/76893a45/attachment-0001.bin>

More information about the gnucash-devel mailing list