Overview
The Ruby Invoicing Framework

What can it do?

The Ruby Invoicing Framework Gem is stable and solid:

Stuff you need to do yourself

To begin with, it should be sufficient if you create the necessary database tables and model classes, as described in Getting Started, and then write a few lines of business logic. For example, you might create a script which you run on the first day of each month, which invoices all of your customers for their use of your application during that month. It would look something like this:

Customers.all.each do |customer|
  invoice = Invoice.new(
    :recipient_id => customer.id,
    :currency => customer.price_plan.currency,
    :status => 'closed',
    :period_start => Time.now,
    :period_end => 1.month.from_now,
    :due_date => 14.days.from_now
  )
  
  invoice.line_items << MonthlySubscriptionCharge.new(
    :net_amount => customer.price_plan.price_now
  )
  
  invoice.save!
end

Simple! No need to say more than necessary. The amount of tax and the sum of the invoice are calculated automatically.

Of course, your site doesn’t need to use a monthly subscription model – a pay-by-use model or a pay-once purchase model can be used just as easily. And of course you can mix different types of charges and different types of invoice as you please.

Displaying invoices to your customers is even easier. In a Rails application, for example, you might have a controller action a bit like the following:

class BillingController < ApplicationController

  def invoice
    invoice = Invoice.find(params[:id])

    unless invoice.customer_id == current_user.customer_id
      raise ActiveRecord::RecordNotFound, "Access denied"
    end

    respond_to do |format|
      format.html { render :layout => true, :text => invoice.render_html }
      format.xml  { render :xml => invoice.render_ubl }
    end
  end
end

And that’s it! You don’t even need a template, as the render_html method already lays it out nicely for you. (You can use it in a template if you prefer, and you can arbitrarily customise the output of render_html.) And you get interoperability for free via the OASIS UBL standard.

Of course there is a lot more to to discover. Read Getting Started to get the basics set up, and then you can start reading the API documentation to get the in-depth details.