Class: XeroGateway::Account
- Inherits:
-
Object
- Object
- XeroGateway::Account
- 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' => '', }
- STATUSES =
{ 'ACTIVE' => '', 'ARCHIVED' => '', }
- 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
-
#account_class ⇒ Object
Returns the value of attribute account_class.
-
#account_id ⇒ Object
Returns the value of attribute account_id.
-
#code ⇒ Object
Returns the value of attribute code.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#enable_payments_to_account ⇒ Object
Returns the value of attribute enable_payments_to_account.
-
#name ⇒ Object
Returns the value of attribute name.
-
#status ⇒ Object
Returns the value of attribute status.
-
#system_account ⇒ Object
Returns the value of attribute system_account.
-
#tax_type ⇒ Object
Returns the value of attribute tax_type.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(params = {}) ⇒ Account
constructor
A new instance of Account.
- #to_xml(b = Builder::XmlMarkup.new, options = {}) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Account
Returns a new instance of Account.
53 54 55 56 57 |
# File 'lib/xero_gateway/account.rb', line 53 def initialize(params = {}) params.each do |k,v| self.send("#{k}=", v) end end |
Instance Attribute Details
#account_class ⇒ Object
Returns the value of attribute account_class.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def account_class @account_class end |
#account_id ⇒ Object
Returns the value of attribute account_id.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def account_id @account_id end |
#code ⇒ Object
Returns the value of attribute code.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def code @code end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def currency_code @currency_code end |
#description ⇒ Object
Returns the value of attribute description.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def description @description end |
#enable_payments_to_account ⇒ Object
Returns the value of attribute enable_payments_to_account.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def enable_payments_to_account @enable_payments_to_account end |
#name ⇒ Object
Returns the value of attribute name.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def name @name end |
#status ⇒ Object
Returns the value of attribute status.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def status @status end |
#system_account ⇒ Object
Returns the value of attribute system_account.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def system_account @system_account end |
#tax_type ⇒ Object
Returns the value of attribute tax_type.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def tax_type @tax_type end |
#type ⇒ Object
Returns the value of attribute type.
51 52 53 |
# File 'lib/xero_gateway/account.rb', line 51 def type @type end |
Class Method Details
.from_xml(account_element) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/xero_gateway/account.rb', line 82 def self.from_xml(account_element) account = Account.new account_element.children.each do |element| case(element.name) when "AccountID" then account.account_id = element.text when "Code" then account.code = element.text when "Name" then account.name = element.text when "Type" then account.type = element.text when "Status" then account.status = element.text when "Class" then account.account_class = element.text when "TaxType" then account.tax_type = element.text when "Description" then account.description = element.text when "SystemAccount" then account.system_account = element.text when "EnablePaymentsToAccount" then account.enable_payments_to_account = (element.text == 'true') when "CurrencyCode" then account.currency_code = element.text end end account end |
Instance Method Details
#==(other) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/xero_gateway/account.rb', line 59 def ==(other) [:account_id, :code, :name, :type, :status, :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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/xero_gateway/account.rb', line 66 def to_xml(b = Builder::XmlMarkup.new, ={}) b.tag!([:name] ? [:name] : 'Account') { b.AccountID self.account_id b.Code self.code b.Name self.name b.Type self.type b.Status self.status b.Class self.account_class b.TaxType self.tax_type b.Description self.description b.SystemAccount self.system_account unless self.system_account.nil? b.EnablePaymentsToAccount self.enable_payments_to_account b.CurrencyCode currency_code if currency_code } end |