class CamtParser::Format052::Report

Attributes

xml_data[R]

Public Class Methods

new(xml_data) click to toggle source
# File lib/camt_parser/052/report.rb, line 7
def initialize(xml_data)
  @xml_data = xml_data
end
parse(xml) click to toggle source
# File lib/camt_parser/052/report.rb, line 66
def self.parse(xml)
  self.new Nokogiri::XML(xml).xpath('Report')
end

Public Instance Methods

account() click to toggle source
# File lib/camt_parser/052/report.rb, line 19
def account
  @account ||= CamtParser::Account.new(xml_data.xpath('Acct').first)
end
closing_balance() click to toggle source
# File lib/camt_parser/052/report.rb, line 50
def closing_balance
  @closing_balance ||= begin
    bal = xml_data.xpath('Bal/Tp//Cd[contains(text(), "CLBD")]').first.ancestors('Bal')
    date = bal.xpath('Dt/Dt/text()').text
    credit = bal.xpath('CdtDbtInd/text()').text == 'CRDT'
    currency = bal.xpath('Amt').attribute('Ccy').value
    CamtParser::AccountBalance.new bal.xpath('Amt/text()').text, currency, date, credit
  end
end
closing_or_intermediary_balance()
Alias for: closing_balance
entries() click to toggle source
# File lib/camt_parser/052/report.rb, line 23
def entries
  @entries ||= xml_data.xpath('Ntry').map{ |x| CamtParser::Entry.new(x) }
end
from_date_time() click to toggle source
# File lib/camt_parser/052/report.rb, line 31
def from_date_time
  @from_date_time ||= (x = xml_data.xpath('FrToDt/FrDtTm')).empty? ? nil : Time.parse(x.first.content)
end
generation_date() click to toggle source
# File lib/camt_parser/052/report.rb, line 15
def generation_date
  @generation_date ||= Time.parse(xml_data.xpath('CreDtTm/text()').text)
end
identification() click to toggle source
# File lib/camt_parser/052/report.rb, line 11
def identification
  @identification ||= xml_data.xpath('Id/text()').text
end
opening_balance() click to toggle source
# File lib/camt_parser/052/report.rb, line 39
def opening_balance
  @opening_balance ||= begin
    bal = xml_data.xpath('Bal/Tp//Cd[contains(text(), "PRCD")]').first.ancestors('Bal')
    date = bal.xpath('Dt/Dt/text()').text
    credit = bal.xpath('CdtDbtInd/text()').text == 'CRDT'
    currency = bal.xpath('Amt').attribute('Ccy').value
    CamtParser::AccountBalance.new bal.xpath('Amt/text()').text, currency, date, credit
  end
end
opening_or_intermediary_balance()
Alias for: opening_balance
source() click to toggle source
# File lib/camt_parser/052/report.rb, line 62
def source
  xml_data.to_s
end
to_date_time() click to toggle source
# File lib/camt_parser/052/report.rb, line 35
def to_date_time
  @to_date_time ||= (x = xml_data.xpath('FrToDt/ToDtTm')).empty? ? nil : Time.parse(x.first.content)
end