Class: SepaFileParser::Pain008::PaymentInformation

Inherits:
Object
  • Object
show all
Defined in:
lib/sepa_file_parser/pain008/payment_information.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_data) ⇒ PaymentInformation

Returns a new instance of PaymentInformation.



9
10
11
# File 'lib/sepa_file_parser/pain008/payment_information.rb', line 9

def initialize(xml_data)
  @xml_data = xml_data
end

Instance Attribute Details

#xml_dataObject (readonly)

Returns the value of attribute xml_data.



7
8
9
# File 'lib/sepa_file_parser/pain008/payment_information.rb', line 7

def xml_data
  @xml_data
end

Class Method Details

.parse(xml) ⇒ Object



39
40
41
# File 'lib/sepa_file_parser/pain008/payment_information.rb', line 39

def self.parse(xml)
  self.new(Nokogiri::XML(xml).xpath('PmtInf'))
end

Instance Method Details

#accountObject



21
22
23
24
25
26
27
# File 'lib/sepa_file_parser/pain008/payment_information.rb', line 21

def 
  @account ||= SepaFileParser::Account.from_pain_data(
                 xml_data,
                 entries.first.currency,
                 'Cdtr',
               )
end

#entriesObject



29
30
31
32
33
# File 'lib/sepa_file_parser/pain008/payment_information.rb', line 29

def entries
  @entries ||= xml_data.xpath('DrctDbtTxInf').map do |x|
                 SepaFileParser::PainEntry.new(x)
               end
end

#identificationObject



13
14
15
# File 'lib/sepa_file_parser/pain008/payment_information.rb', line 13

def identification
  @identification ||= xml_data.xpath('PmtInfId/text()').text
end

#requested_collection_dateObject



17
18
19
# File 'lib/sepa_file_parser/pain008/payment_information.rb', line 17

def requested_collection_date
  @requested_collection_date ||= Time.parse(xml_data.xpath('ReqdColltnDt/text()').text)
end

#sourceObject



35
36
37
# File 'lib/sepa_file_parser/pain008/payment_information.rb', line 35

def source
  xml_data.to_s
end