Sha256: c97b4162affce60f77e7a9bf643ef220a037caa4a7804022ef965d1a8943bec7

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module Recurly
  # Invoices are created through account objects.
  #
  # @example
  #   account = Account.find account_code
  #   account.invoice!
  class Invoice < Resource
    # @macro [attach] scope
    #   @scope class
    #   @return [Pager<Invoice>] A pager that yields +$1+ invoices.
    scope :open,      :state => :open
    scope :collected, :state => :collected
    scope :failed,    :state => :failed
    scope :past_due,  :state => :past_due

    # @return [Account]
    belongs_to :account

    define_attribute_methods %w(
      uuid
      state
      invoice_number
      po_number
      vat_number
      subtotal_in_cents
      tax_in_cents
      total_in_cents
      currency
      created_at
      line_items
      transactions
    )
    alias to_param invoice_number

    def pdf
      find to_param, :format => 'pdf'
    end

    private

    def initialize attributes = {}
      super({ :currency => Recurly.default_currency }.merge attributes)
    end

    # Invoices are only writeable through {Account} instances.
    embedded! true
    undef save
    undef destroy
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
recurly-2.1.4 lib/recurly/invoice.rb
recurly-2.1.3 lib/recurly/invoice.rb
recurly-2.1.2 lib/recurly/invoice.rb
recurly-2.1.1 lib/recurly/invoice.rb