Class: SepaFileParser::PainEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/sepa_file_parser/general/pain_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_data) ⇒ PainEntry

Returns a new instance of PainEntry.



8
9
10
11
12
13
14
15
# File 'lib/sepa_file_parser/general/pain_entry.rb', line 8

def initialize(xml_data)
  @xml_data = xml_data

  @amount = [
    xml_data.xpath('Amt/InstdAmt').first,
    xml_data.xpath('InstdAmt').first,
  ].find { |a| a != nil }.text
end

Instance Attribute Details

#xml_dataObject (readonly)

Returns the value of attribute xml_data.



6
7
8
# File 'lib/sepa_file_parser/general/pain_entry.rb', line 6

def xml_data
  @xml_data
end

Instance Method Details

#accountObject



33
34
35
36
37
38
39
# File 'lib/sepa_file_parser/general/pain_entry.rb', line 33

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

#amountObject



17
18
19
# File 'lib/sepa_file_parser/general/pain_entry.rb', line 17

def amount
  SepaFileParser::Misc.to_amount(@amount)
end

#amount_in_centsObject



21
22
23
# File 'lib/sepa_file_parser/general/pain_entry.rb', line 21

def amount_in_cents
  SepaFileParser::Misc.to_amount_in_cents(@amount)
end

#currencyString

Returns:



26
27
28
29
30
31
# File 'lib/sepa_file_parser/general/pain_entry.rb', line 26

def currency
  @currency ||= [
    xml_data.xpath('Amt/InstdAmt/@Ccy').first,
    xml_data.xpath('InstdAmt/@Ccy').first,
  ].find { |a| a != nil }.text
end

#remittance_informationObject



41
42
43
# File 'lib/sepa_file_parser/general/pain_entry.rb', line 41

def remittance_information
  @remittance_information ||= xml_data.xpath('RmtInf/Ustrd').text
end