Sha256: 56feb77370e0a131cbbb8a95285321742eeda61d2b26c0e6c2ece511abf24bc5

Contents?: true

Size: 890 Bytes

Versions: 25

Compression:

Stored size: 890 Bytes

Contents

class Kaui::Invoice < KillBillClient::Model::Invoice

  def self.build_from_raw_invoice(raw_invoice)
    result = Kaui::Invoice.new
    KillBillClient::Model::InvoiceAttributes.instance_variable_get('@json_attributes').each do |attr|
      result.send("#{attr}=", raw_invoice.send(attr))
    end
    result
  end

  def self.list_or_search(search_key = nil, offset = 0, limit = 10, options = {})
    if search_key.present?
      find_in_batches_by_search_key(search_key, offset, limit, options)
    else
      find_in_batches(offset, limit, options)
    end
  end

  [:amount, :balance, :credits].each do |type|
    define_method "#{type}_to_money" do
      Kaui::Base.to_money(send(type), currency)
    end
  end

  def refund_adjustment_to_money
    Kaui::Base.to_money(refund_adj, currency)
  end

  def credit_adjustment_to_money
    Kaui::Base.to_money(credit_adj, currency)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
kaui-2.1.0 app/models/kaui/invoice.rb
kaui-2.0.4 app/models/kaui/invoice.rb
kaui-2.0.3 app/models/kaui/invoice.rb
kaui-2.0.2 app/models/kaui/invoice.rb
kaui-2.0.1 app/models/kaui/invoice.rb
kaui-2.0.0 app/models/kaui/invoice.rb
kaui-1.4.1 app/models/kaui/invoice.rb
kaui-1.4.0 app/models/kaui/invoice.rb
kaui-1.3.0 app/models/kaui/invoice.rb
kaui-1.2.0 app/models/kaui/invoice.rb
kaui-1.1.0 app/models/kaui/invoice.rb
kaui-1.0.0 app/models/kaui/invoice.rb
kaui-0.16.2 app/models/kaui/invoice.rb
kaui-0.16.1 app/models/kaui/invoice.rb
kaui-0.16.0 app/models/kaui/invoice.rb
kaui-0.15.5 app/models/kaui/invoice.rb
kaui-0.15.4 app/models/kaui/invoice.rb
kaui-0.15.3 app/models/kaui/invoice.rb
kaui-0.15.2 app/models/kaui/invoice.rb
kaui-0.15.1 app/models/kaui/invoice.rb