I am happy to announce that DNSimple is now sending PDF invoices to all our customers.
Despite being at one of our yearly team meetings at the gorgeous Hawaii, the entire team wants you to know that we are not only having fun but also working.
This has been one of the most requested features by our customers since we deprecated the old Chargify statements on March in favour of our own invoicing system. From now on every email containing an invoice will have a PDF version attached.
We have also made all previous invoices available in PDF format. You can now download all your existing DNSimple invoices directly in PDF instead of going through the process of doing the conversion yourself.
Over the last month we have been continuously improving our invoicing system. We have been delaying generating the PDF version of invoices in favour of other critical features and fixes, but since those issues have been handled, it was time to ship PDF invoices.
We started looking for the easiest way to create the PDFs and that was generating them from our existing HTML version. That's why we automatically discarded PDF libraries like Prawn.
It wasn't difficult to find
wkhtmltopdf, a tool that allows you to generate PDF files using HTML as source. The only thing we needed was a Ruby wrapper around it. Fortunately there is a gem that does the job: Wicked PDF. In addition to Wicked PDF we used the
wkhtmltopdf-binary gem to get the binaries installed in our servers.
Once all the gems were in place it was really easy to reuse our existing HTML invoice templates to generate the PDF version. It was also a breeze to generate and attach the PDFs to our invoice emails following the instructions described here.
With the PDF invoice generation in place we noticed that our test suite became incredibly slow. We had stubbed out Wicked PDF in the specs for the classes that were directly using it. The problem was that many other specs were sending invoices which in turn was triggering PDF generation.
There wasn't an easy fix for this problem. We ended up creating a wrapper around the gem and stubbing it out in our
spec_helper file. That way we managed to have the stub set up no matter what part of our test suite we are running. This workaround is quite dirty and points out our inability to replace Rails' mailers with a proper double in our specs.
These issues are not new. In fact they are pretty common in any medium to big size Rails application. Hopefully we will be able to find a way to improve our design so we don't face problems like this one again. Personally, I would love to see a more hexagonal DNSimple app tested a la Ian Cooper. Time will tell.
Programmer. Minimalist. Apple fanboy. Currently having fun at DNSimple. I love coffee and my cat.
Configure DNSimple as your secondary DNS provider to improve your domain's availability and redundancy with AXFR zone transfers.
Get a free limited-edition t-shirt featuring the characters of howdns.works and howhttps.works with any new yearly subscription to DNSimple.