Somewhere around 2010-2011 I built an invoice generator using lots of XML. At that time I still thought that XML was awesome. Anyway, I have been using the generator for some time and actually do not consider replacing it yet. Today I cleaned up my old code, made it installable and uploaded to GitHub.
How it works
Other than calculating the line totals and the grand total the generator is pretty dumb. But even that requires specific XSLT extensions.
There are some things I do not like about this generator:
- XSLT tools mandate usage of "old" (X)HTML DOCTYPE declarations. Part of the problem is described in this StackOverflow thread.
- Calculations, like calculating VAT, are hard. They require specific XSLT extensions and are very verbose.
- Localization requires multiple copies of XSL stylesheet. Keeping them in sync is maintenance trouble.
- Input is XML. JSON is much less verbose. But this is not the biggest issue as there is not much input data.
If I was to build a new invoice generator today, I would probably use some proper programming language and an HTML template library to generate the intermediate markup (skip the xslt step above) and then feed it into the wkhtmltopdf utility.