Sha256: fd0e25042f54e08cc6186eb3c0b1051f9f97bf8a42cad17cf64b2c38f7fc505d

Contents?: true

Size: 890 Bytes

Versions: 19

Compression:

Stored size: 890 Bytes

Contents

module XeroGateway
  class Payment
    include Money
    include Dates

    # Any errors that occurred when the #valid? method called.
    attr_reader :errors

    # All accessible fields
    attr_accessor :date, :amount
        
    def initialize(params = {})
      @errors ||= []
            
      params.each do |k,v|
        self.send("#{k}=", v)
      end
    end
    
    def self.from_xml(payment_element)
      payment = Payment.new
      payment_element.children.each do | element |
        case element.name
          when 'Date' then    payment.date = parse_date_time(element.text)
          when 'Amount' then  payment.amount = BigDecimal.new(element.text)
        end    
      end
      payment
    end 
    
    def ==(other)
      [:date, :amount].each do |field|
        return false if send(field) != other.send(field)
      end
      return true
    end
    

  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
xero_gateway-float-2.0.16 lib/xero_gateway/payment.rb
xero_gateway-float-2.0.15 lib/xero_gateway/payment.rb
xero_gateway-2.0.18 lib/xero_gateway/payment.rb
xero_gateway-2.0.17 lib/xero_gateway/payment.rb
xero_gateway-2.0.16 lib/xero_gateway/payment.rb
xero_gateway-2.0.15 lib/xero_gateway/payment.rb
xero_gateway-2.0.14 lib/xero_gateway/payment.rb
xero_gateway-2.0.13 lib/xero_gateway/payment.rb
xero_gateway-2.0.12 lib/xero_gateway/payment.rb
xero_gateway-2.0.11 lib/xero_gateway/payment.rb
xero_gateway-2.0.10 lib/xero_gateway/payment.rb
xero_gateway-2.0.9 lib/xero_gateway/payment.rb
xero_gateway-2.0.8 lib/xero_gateway/payment.rb
xero_gateway-2.0.7 lib/xero_gateway/payment.rb
xero_gateway-2.0.6 lib/xero_gateway/payment.rb
xero_gateway-2.0.5 lib/xero_gateway/payment.rb
xero_gateway-2.0.4 lib/xero_gateway/payment.rb
xero_gateway-2.0.3 lib/xero_gateway/payment.rb
xero_gateway-2.0.2 lib/xero_gateway/payment.rb