Class: Camt::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/camt/statement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_node, country_code) ⇒ Statement

Returns a new instance of Statement.



6
7
8
9
# File 'lib/camt/statement.rb', line 6

def initialize(xml_node, country_code)
  @node = xml_node
  @country_code = country_code
end

Instance Attribute Details

#country_codeObject (readonly)

Returns the value of attribute country_code.



4
5
6
# File 'lib/camt/statement.rb', line 4

def country_code
  @country_code
end

#nodeObject (readonly)

Returns the value of attribute node.



4
5
6
# File 'lib/camt/statement.rb', line 4

def node
  @node
end

Instance Method Details

#created_atObject



19
20
21
# File 'lib/camt/statement.rb', line 19

def created_at
  @created_at ||= Time.parse(node.at('./CreDtTm').text)
end

#dateObject



34
35
36
# File 'lib/camt/statement.rb', line 34

def date
  @date ||= Date.parse(node.at('./Ntry[1]/ValDt/Dt | ./Ntry[1]/ValDt/DtTm').text)
end

#electronic_sequence_numberObject



15
16
17
# File 'lib/camt/statement.rb', line 15

def electronic_sequence_number
  @electronic_sequence_number ||= node.at('./ElctrncSeqNb').text
end

#end_balanceObject



42
43
44
# File 'lib/camt/statement.rb', line 42

def end_balance
  @end_balance ||= get_end_balance
end

#idObject



11
12
13
# File 'lib/camt/statement.rb', line 11

def id
  @id ||= node.at('./Id').text
end

#local_accountObject Also known as: iban



23
24
25
# File 'lib/camt/statement.rb', line 23

def 
  @local_account ||= node.at('./Acct/Id').text.strip
end

#local_currencyObject



29
30
31
32
# File 'lib/camt/statement.rb', line 29

def local_currency
  @local_currency ||= node.at('./Acct/Ccy').try(:text) ||
      node.at('./Bal/Amt').attribute("Ccy").value
end

#start_balanceObject



38
39
40
# File 'lib/camt/statement.rb', line 38

def start_balance
  @start_balance ||= get_start_balance
end

#transactionsObject



46
47
48
# File 'lib/camt/statement.rb', line 46

def transactions
  @transactions ||= node.xpath('./Ntry').map { |node| parse_Ntry(node) }
end