Notes to self

InvoicePrinter 2.1 with Ruby 3 support

Ruby 3 was released three months ago, so it was a time to support it in InvoicePrinter, a pure Ruby library for generating PDF invoices.

InvoicePrinter 2.1 dependencies were upgraded to Prawn 2.4 and Ruby 3 by following the separation of positional and keyword arguments. If you pass a hash to InvoicePrinter::Document or InvoicePrinter::Document::Item, you now need to use double splat in front of it:

InvoicePrinter::Document.new(
  **params
)

This tells Ruby you are indeed passing a hash for keyword arguments.

Apart from Ruby 3 support, I improved the single line note. The note field was cut if it was longer than one line. The issue is now fixed by supporting a multi-line note. Here is how it looks like.

Finally, this release removes address fields that got deprecated with a warning in 2.0 release.

Instead of providing addresses in a granual fields as:

provider_street: '5th Avenue',
provider_street_number: '1',
provider_postcode: '747 05',
provider_city: 'NYC',

You now have to do it as follows:

provider_address = <<ADDRESS
  Rolnická 1
  747 05  Opava
  Kateřinky
ADDRESS

invoice = InvoicePrinter::Document.new(
  number: 'NO. 198900000001',
  provider_name: 'John White',
  provider_lines: provider_address,

Since the library doesn’t want to be concerned with formatting the address fields, it’s better to support addresses in a more flexible way by having a multiline field.

I released 2.1.0.rc1 for you to try and the final 2.1.0 will follow shortly. If you are missing something in InvoicePrinter, it’s a good time to open a feature request for 2.2 too.

Work with me

I have some availability for contract work. I can be your fractional CTO, a Ruby on Rails engineer, or consultant. Write me at strzibny@strzibny.name.

RSS