Invoice System with Markdown, Bash and JS

After starting to do some freelance working, I finally needed to write some invoices. As I‘m assuming that I will have to do this work again many times in the future, an automated solution is needed.

There are many nice and versatile web tools out there, even ones specifically made for Switzerland. But they all come with a subscription license and I'd like to have as much control as possible.

So I started with a simple collection of Bash and JS scripts to automate the creation of my invoices. For now this does not include any customer management tools at all.

The source code is on GitHub: https://github.com/manuelerdoes/oergel_invoice_system

The final product

At the end of the process there is a 2 page PDF file with a page that contains a summary of all the work that has been done and the prices.

The second page contains a standard Swiss QR invoice.

first page


second page

The first page

For the first page all the needed data is pulled from a text file, that the user creates for each client. Also a CSV the user can provide, gets pulled. It contains all the positions that are being charged. A JS script parses the CSV file into a Markdown table. After that the main Bash script generates a Markdown file out of all the data.

The second page

A JS script makes a request to an API that generates Swiss QR invoices for free (only small amounts of requests). It then generates a PDF that contains the invoice.

Merging

A command line tool called cpdf then merges the two PDF files together. The newly created PDF opens automatically and gets copied to a specified folder for the current client.

Manually changing the content

Even though the main Bash script automatically creates the final PDF, there is also the possibility to change the contents of the first page. The Markdown file that gets created in the first step is not automatically deleted. So the user can change it by hand and then run the command to create a PDF.

Next steps

The goal of the project is to fulfil all my client management needs. I want to be able to write down all the work I do directly into the tool. It should then be able to automatically create invoices and send them per email to the recipient.