November 17, 2008

Crafting offers and invoice documents with Kraft

Author: Ben Martin

Kraft helps you keep track of business offers and invoices and can generate PDF files to help you easily issue these routine documents to third parties. Since Kraft is a KDE application, it can draw contact information directly from your KDE address book, so you don't have to duplicate or sync your contacts in order to generate an invoice.

Kraft is in the standard Ubuntu Intrepid repository and is available as a 1-Click install for openSUSE 11. There is no package for Fedora 9. I'll build from source using version 0.30 on a 64-bit Fedora 9 machine.

Kraft requires a database on a MySQL server and the ability to talk to a MySQL database with Qt. Make sure you install qt3-MySQL on a Fedora 9 or openSUSE 11 machine. For Ubuntu Intrepid the package is libqt3-mt-mysql. Kraft also requires the Google CTemplate library. There are .deb and .rpm files for the CTemplate library, but unfortunately these are compiled for a 32-bit machine, so I compiled the CTemplate library from sources too. I ran into an issue compiling the CTemplate library with ccache installed and had to temporarily remove ccache.

$ tar xzvf /.../ctemplate-0.91.tar.gz
$ cd ./ctemplate-*
$ ./configure
$ make
$ sudo make install

$ tar xjf /.../kraft-0.30.tar.bz2
$ cd ./kraft-*
$ ./configure
$ make
$ sudo make install

If you are planning on printing documents created with Kraft then you'll also need to install trml2pdf from the same project site. I used version 1.1.

$ su -l
# cd /tmp
# tar xjf /.../trml2pdf-1.1\(2\).tar.bz2
# cd /tmp/trml2pdf-*/
# cp -a trml2pdf /usr/local/share/trml2pdf
# ln -s /usr/local/share/trml2pdf/ /usr/local/bin/trml2pdf

Kraft requires a database on a MySQL server that it has the exclusive use of, and will set up the schema of that database automatically when you first run Kraft. Below I create a new database for Kraft and start it up to see the setup screen shown below.

$ mysql
Server version: 5.0.51a Source distribution
mysql> create database kraft;
Query OK, 1 row affected (0.00 sec)
mysql> Bye

$ kraft

Once you restart Kraft the database tables should be set up for you. Check the system page by clicking on System in the left side of the screenshot shown above. You should see the version (currently 11) of your Kraft database schema. If you see something like version 0, then you might not have all the privileges required to set up your MySQL database. The below MySQL commands should give user ben the privileges required for the database kraft.

# mysql -p
mysql> GRANT ALL ON kraft.* TO ben@"localhost";

If all is well and you click on Documents -> Create Document, you can make a new offer, acceptance of offer, or invoice; naturally I started with an offer. The second screen of the Create Document wizard presents the contacts from your KDE address book and asks who the new document pertains to. The third and final page of the Create Document wizard lets you customize the header, body, and footer of the document. An outline of the entire document is shown at the right of the window so you can see what it will look like and select which part of the document you want to edit.

In the first screenshot below I'm editing the header of the new Offer document. The contact information was automatically drawn from my KDE address book and the main part of interest in the header is the lead-in text to appear before the Positions.

The below screenshot shows the Positions editing screen. Clicking on the little spanner lets you move each item up or down or lock its current position. The flag lets you change what category of item you are describing; choices are Discount, Material, Plants, or Work (hourly rate). I choose to add a discount to the offer right off the bat, which was a mistake because the offer was a fixed number of hours times rate. On the other hand, if you click Add Discount Item from the Positions window, you can add a fixed percentage discount, but you are limited to applying the discount to all items in a category.

If you right-click an Offer document you can choose Follow Document from the context menu, which lets you create a followup to the existing document. For the offer you can create an acceptance of order or an invoice document. I decided to create an acceptance of order. Each of the documents uses the same editing interface shown in the above two screenshots. The type of document is printed in the top right when you're using the default templates.

The search box shown above the document list allows you to limit which documents are shown. Any information that is in the treeview display can be used to search; for example, you can type in some text from the whiteboard, a partial date, or a client name.

Kraft is very euro-centric, so you'll find a few minor things like Web site defaults to German rather than redirecting to the English version based on your Web browser's preferences, and sometimes there are strange translations or both English and German text. The biggest issue you will have is that the VAT is fixed at 19% and you'll have to edit the source code to change it. You'll find the value in DocumentMan::vat() inside the kraft/src/documentman.cpp file. I changed this to the 10% GST rate for Australia for testing; my invoices used the new VAT/GST rate after I recompiled.

One issue that remains here is that the VAT/GST rate might change over time, so having it buried in the code is not a great idea. Worse, picking an existing or old invoice and printing it after the recompile used the current VAT. If an invoice has been issued and the VAT has subsequently changed, you might like to be able to select the current or old value for VAT for old invoices, such as when you are creating a second copy of an older invoice at the request of a client and you don't want it to change its VAT.

Kraft takes some of the drudgery out of tracking work offers and invoicing. If you are a KDE user, being able to use a single contact manager for issuing your invoices will cut down on your mail merging worries. But Kraft's handling of VAT/GST could be improved.


  • Office Software
Click Here!