Class: IntacctRB::Account

Inherits:
Base show all
Defined in:
lib/intacctrb/account.rb

Instance Attribute Summary

Attributes inherited from Base

#current_user, #data, #intacct_action, #object, #response, #sent_xml

Instance Method Summary collapse

Methods inherited from Base

#initialize, #intacct_id

Constructor Details

This class inherits a constructor from IntacctRB::Base

Instance Method Details

#get_list(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/intacctrb/account.rb', line 3

def get_list(options = {})
  send_xml('get_list') do |xml|
    xml.function(controlid: "f4") {
      xml.get_list(object: "glaccount", maxitems: (options[:max_items] || 0),
        start: (options[:start] || 0), showprivate:"true") {
        filter_xml(xml, options)
        if options[:fields]
          xml.fields {
            fields.each do |field|
              xml.field field.to_s
            end
          }
        end
      }
    }
  end

  if successful?
    @data = []
    @response.xpath('//glaccount').each do ||
      @data << OpenStruct.new({
        id: .at("glaccountno").content,
        name: .at("title").content,
        normal_balance: .at("normalbalance").content,
        account_type: .at("accounttype").content,
        closing_type: .at("closingtype").content,
        updated_at: .at("whenmodified").content,
        status: .at("status").content
      })
    end
    @data
  else
    false
  end
end