lib/xero_gateway/account.rb in xero_gateway-2.0.13 vs lib/xero_gateway/account.rb in xero_gateway-2.0.14

- old
+ new

@@ -33,11 +33,11 @@ '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 :account_id, :code, :name, :type, :tax_type, :description, :system_account, :enable_payments_to_account + attr_accessor :account_id, :code, :name, :type, :tax_type, :description, :system_account, :enable_payments_to_account, :currency_code def initialize(params = {}) params.each do |k,v| self.send("#{k}=", v) end @@ -48,22 +48,21 @@ return false if send(field) != other.send(field) end return true end - def to_xml - b = Builder::XmlMarkup.new - - b.Account { + def to_xml(b = Builder::XmlMarkup.new, options={}) + b.tag!(options[:name] ? options[:name] : '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 + b.CurrencyCode currency_code if currency_code } end def self.from_xml(account_element) account = Account.new @@ -75,9 +74,10 @@ 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') + when "CurrencyCode" then account.currency_code = element.text end end account end