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-0.15.0 app/models/kaui/invoice.rb
kaui-0.14.2 app/models/kaui/invoice.rb
kaui-0.14.1 app/models/kaui/invoice.rb
kaui-0.14.0 app/models/kaui/invoice.rb
kaui-0.12.0 app/models/kaui/invoice.rb