Apr 02 2020

Invoice Generation

Billing is a core part of a running a freelance or consultancy. Without it, you would not get paid! I am of the opinion that an invoice does not need to look pretty. An invoice only needs to clearly convey the details of the bill. Bonus points are given for a small file size with searchability.

My invoices tend to have a “brutalist” nature. Part of this is because most of my work comes from close friends and family. Branding simply takes the back burner.

How do I begin the creation of my invoice? A text file of course! A text file can be tracked through git and allow for pretty diffs. This is the template that I typically work off of.

From:
  Company Name
  Address 1
  Address 2
  Phone number
  Email

Sold To:
  Company Name
  Address 1
  Address 2

Date: January 01, 2020
Invoice #: 0000
TIN: xx-xxxxxxx
Rate: $xxx.xx/hr

Time    | Description
+-------+------------------------------------------------
0.33h   | Add link to navigation bar with mobile support
0.33h   | Add new listings page
0.33h   | Test and deploy updates
+-------+------------------------------------------------
1.00h   | Total

Amount due: $xxx.xx


Thank you for your business!

We can generate the invoice with enscript and ps2pdf. I wrote a quick script to do this for me. We can run the script given some text file: ./generate_invoice invoice_0000.txt

#!/bin/bash
# Generates a pdf invoice from a text file.
#
# Usage:
# ./generate_invoice invoice_0000.txt

BASE=$(basename -s .txt $@)
echo "${BASE}"
enscript -B $@ -o "${BASE}".ps
ps2pdf "${BASE}".ps out/"${BASE}".pdf
rm "${BASE}".ps

The generated pdf documents are placed into the ./out/ directory of $(cwd). Ideally I would add a -o flag to specify a separate destination. This way I could move the script into the PATH instead. In any case, here is what the generated pdf looks like.

Invoice generated

The next step would be to make another bash script that calls mutt. This would send over the invoice as an attachment to the client. The email could also include the txt file as the body.