Module: Invoicing::LedgerItem::RenderUBL

Extended by:
ActiveSupport::Concern
Defined in:
lib/invoicing/ledger_item/render_ubl.rb

Overview

Included into ActiveRecord model object when acts_as_ledger_item is invoked.

Defined Under Namespace

Classes: UBLOutputBuilder

Instance Method Summary collapse

Instance Method Details

#render_ubl(options = {}) ⇒ Object

Renders this invoice or credit note into a complete XML document conforming to the OASIS Universal Business Language (UBL) open standard for interchange of business documents (specification). This format, albeit a bit verbose, is increasingly being adopted as an international standard. It can represent some very complicated multi-currency, multi-party business relationships, but is still quite usable for simple cases.

It is recommended that you present machine-readable UBL data in your application in the same way as you present human-readable invoices in HTML. For example, in a Rails controller, you could use:

class AccountsController < ApplicationController
  def show
    @ledger_item = LedgerItem.find(params[:id])
    # ... check whether current user has access to this document ...
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @ledger_item.render_ubl }
    end
  end
end


31
32
33
# File 'lib/invoicing/ledger_item/render_ubl.rb', line 31

def render_ubl(options={})
  UBLOutputBuilder.new(self, options).build
end