0.0
No release in over 3 years
Low commit activity in last 3 years
Generate simple invoices using https://invoice-generator.com.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

> 1.17
~> 12.3.3
~> 3.5
>= 0.12.0
~> 2.1.0

Runtime

~> 0.14.0
 Project Readme

InvoiceMaker

A gem to do the basic work of creating a PDF invoice using https://invoice-generator.com. Inspired by the article here: https://gelato.io/blog/minimum-viable-ruby-api-client-with-invoiced-and-httparty.

API documentation lives at https://github.com/Invoiced/invoice-generator-api.

Installation

Add this line to your application's Gemfile:

gem 'invoice_maker'

And then execute:

$ bundle

Or install it yourself as:

$ gem install invoice_maker

Usage

Require the gem, and optionally include the module for simplicity

require 'invoice_maker'

include InvoiceMaker

The gem relies on general options for the invoice being set with the 'set' method. This can include all the line items, or they can be added individually after initial options are set.

The basic data can include any of the options documented in the API documentation referenced above.

data = {
  "from": "My Great Company, Inc. ®\nMy Street Address\nMy City, State 00000",
  "to": "My Great Customer\nATTN: The Dude\nCust Address\nCust Street Address\nCust City, State 11111",
  "logo": "http://placekitten.com/320/140",
  "number": 1,
  "date": "2016-10-24",
  "items": [
    {
      "name": "Some awesome task",
      "quantity": 1,
      "unit_cost": 270.0
    }
  ],
  "notes": "Thank you so much for your business!"
}

Instantiate an object and add the data, followed by adding any line items as necessary.

i = Invoice
i.set(data)

item = {
  "name": "Some additional awesome task",
  "quantity": 2,
  "unit_cost": 270.0
}

i.append_item(item)

Optionally set a destination directory for the generated PDF invoice. Default is "/tmp".

i.dest_dir = "/somedir"

Once all data is set, generate the PDF invoice. The filename will be returned from the call to generate.

fname = i.generate
puts fname

examples/usage.rb is a sample script that loads data from a json file and generates a sample invoice.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake true to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hortoncd/invoice_maker.

License

The gem is available as open source under the terms of the MIT License.