lib/xero_gateway/account.rb in xero_gateway-2.0.4 vs lib/xero_gateway/account.rb in xero_gateway-2.0.5
- old
+ new
@@ -31,45 +31,51 @@
'ZERORATEDOUTPUT' => 'Sales made from overseas (UK only)',
'RROUTPUT' => 'Reduced rate VAT on sales (UK Only)',
'ZERORATED' => 'Zero-rated supplies/sales from overseas (NZ Only)'
} unless defined?(TAX_TYPE)
- attr_accessor :code, :name, :type, :tax_type, :description
+ attr_accessor :account_id, :code, :name, :type, :tax_type, :description, :system_account, :enable_payments_to_account
def initialize(params = {})
params.each do |k,v|
self.send("#{k}=", v)
end
end
def ==(other)
- [:code, :name, :type, :tax_type, :description].each do |field|
+ [:account_id, :code, :name, :type, :tax_type, :description, :system_account, :enable_payments_to_account].each do |field|
return false if send(field) != other.send(field)
end
return true
end
def to_xml
b = Builder::XmlMarkup.new
b.Account {
+ b.AccountID self.account_id
b.Code self.code
b.Name self.name
b.Type self.type
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
}
end
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 "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')
end
end
account
end