Class: XeroGateway::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/xero_gateway/account.rb

Constant Summary collapse

TYPE =
{
  'CURRENT' =>        '',
  'FIXED' =>          '',
  'PREPAYMENT' =>     '',
  'EQUITY' =>         '',
  'DEPRECIATN' =>     '',
  'DIRECTCOSTS' =>    '',
  'EXPENSE' =>        '',
  'OVERHEADS' =>      '',
  'CURRLIAB' =>       '',
  'LIABILITY' =>      '',
  'TERMLIAB' =>       '',
  'OTHERINCOME' =>    '',
  'REVENUE' =>        '',
  'SALES' =>          ''
}
ACCOUNT_CLASS =
{
  'ASSET' =>      '',
  'EQUITY' =>     '',
  'EXPENSE' =>    '',
  'LIABILITY' =>  '',
  'REVENUE' =>    '',
}
TAX_TYPE =
{
  'NONE' =>             'No GST',
  'EXEMPTINPUT' =>      'VAT on expenses exempt from VAT (UK only)',
  'INPUT' =>            'GST on expenses',
  'SRINPUT' =>          'VAT on expenses',
  'ZERORATEDINPUT' =>   'Expense purchased from overseas (UK only)',
  'RRINPUT' =>          'Reduced rate VAT on expenses (UK Only)', 
  'EXEMPTOUTPUT' =>     'VAT on sales exempt from VAT (UK only)',
  'ECZROUTPUT' =>       'EC Zero-rated output',
  'OUTPUT' =>           'OUTPUT (old rate)',
  'OUTPUT2' =>          'OUTPUT2',
  'SROUTPUT' =>         'SROUTPUT',
  'ZERORATEDOUTPUT' =>  'Sales made from overseas (UK only)',
  'RROUTPUT' =>         'Reduced rate VAT on sales (UK Only)',
  'ZERORATED' =>        'Zero-rated supplies/sales from overseas (NZ Only)'
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Account

Returns a new instance of Account.



48
49
50
51
52
# File 'lib/xero_gateway/account.rb', line 48

def initialize(params = {})
  params.each do |k,v|
    self.send("#{k}=", v)
  end
end

Instance Attribute Details

#account_classObject

Returns the value of attribute account_class.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def 
  @account_class
end

#account_idObject

Returns the value of attribute account_id.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def 
  @account_id
end

#codeObject

Returns the value of attribute code.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def code
  @code
end

#currency_codeObject

Returns the value of attribute currency_code.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def currency_code
  @currency_code
end

#descriptionObject

Returns the value of attribute description.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def description
  @description
end

#enable_payments_to_accountObject

Returns the value of attribute enable_payments_to_account.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def 
  @enable_payments_to_account
end

#nameObject

Returns the value of attribute name.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def name
  @name
end

#system_accountObject

Returns the value of attribute system_account.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def 
  @system_account
end

#tax_typeObject

Returns the value of attribute tax_type.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def tax_type
  @tax_type
end

#typeObject

Returns the value of attribute type.



46
47
48
# File 'lib/xero_gateway/account.rb', line 46

def type
  @type
end

Class Method Details

.from_xml(account_element) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/xero_gateway/account.rb', line 75

def self.from_xml()
   = Account.new
  .children.each do |element|
    case(element.name)
      when "AccountID" then . = element.text
      when "Code" then .code = element.text
      when "Name" then .name = element.text
      when "Type" then .type = element.text
      when "Class" then . = element.text
      when "TaxType" then .tax_type = element.text
      when "Description" then .description = element.text
      when "SystemAccount" then . = element.text
      when "EnablePaymentsToAccount" then . = (element.text == 'true')
      when "CurrencyCode" then .currency_code = element.text
    end
  end      
  
end

Instance Method Details

#==(other) ⇒ Object



54
55
56
57
58
59
# File 'lib/xero_gateway/account.rb', line 54

def ==(other)
  [:account_id, :code, :name, :type, :account_class, :tax_type, :description, :system_account, :enable_payments_to_account].each do |field|
    return false if send(field) != other.send(field)
  end
  return true
end

#to_xml(b = Builder::XmlMarkup.new, options = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/xero_gateway/account.rb', line 61

def to_xml(b = Builder::XmlMarkup.new, options={})
  b.tag!(options[:name] ? options[:name] : 'Account') {
    b.AccountID self.
    b.Code self.code
    b.Name self.name
    b.Type self.type
    b.TaxType self.tax_type
    b.Description self.description
    b.SystemAccount self. unless self..nil?
    b.EnablePaymentsToAccount self.
    b.CurrencyCode currency_code if currency_code
  }
end