Class: CamtParser::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/camt_parser/general/entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml_data) ⇒ Entry

Returns a new instance of Entry.


3
4
5
6
# File 'lib/camt_parser/general/entry.rb', line 3

def initialize(xml_data)
  @xml_data = xml_data
  @amount = @xml_data.xpath('Amt/text()').text
end

Instance Method Details

#additional_informationObject Also known as: description


60
61
62
# File 'lib/camt_parser/general/entry.rb', line 60

def additional_information
  @additional_information ||= @xml_data.xpath('AddtlNtryInf/text()').text
end

#amountObject


8
9
10
# File 'lib/camt_parser/general/entry.rb', line 8

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

#amount_in_centsObject


12
13
14
# File 'lib/camt_parser/general/entry.rb', line 12

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

#bank_referenceObject

May be missing


32
33
34
# File 'lib/camt_parser/general/entry.rb', line 32

def bank_reference # May be missing
  @bank_reference ||= @xml_data.xpath('AcctSvcrRef/text()').text
end

#batch_detailObject


69
70
71
# File 'lib/camt_parser/general/entry.rb', line 69

def batch_detail
  @batch_detail ||= @xml_data.xpath('NtryDtls/Btch').empty? ? nil : CamtParser::BatchDetail.new(@xml_data.xpath('NtryDtls/Btch'))
end

#booked?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'lib/camt_parser/general/entry.rb', line 56

def booked?
  @booked ||= @xml_data.xpath('Sts/text()').text.upcase == 'BOOK'
end

#booking_dateObject


28
29
30
# File 'lib/camt_parser/general/entry.rb', line 28

def booking_date
  @booking_date ||= Date.parse(@xml_data.xpath('BookgDt/Dt/text()').text)
end

#chargesObject


65
66
67
# File 'lib/camt_parser/general/entry.rb', line 65

def charges
  @charges ||= CamtParser::Charges.new(@xml_data.xpath('Chrgs'))
end

#credit?Boolean

Returns:

  • (Boolean)

40
41
42
# File 'lib/camt_parser/general/entry.rb', line 40

def credit?
  !debit
end

#currencyObject


16
17
18
# File 'lib/camt_parser/general/entry.rb', line 16

def currency
  @currency ||= @xml_data.xpath('Amt/@Ccy').text
end

#debitObject


20
21
22
# File 'lib/camt_parser/general/entry.rb', line 20

def debit
  @debit ||= @xml_data.xpath('CdtDbtInd/text()').text.upcase == 'DBIT'
end

#debit?Boolean

Returns:

  • (Boolean)

44
45
46
# File 'lib/camt_parser/general/entry.rb', line 44

def debit?
  debit
end

#reversal?Boolean

Returns:

  • (Boolean)

52
53
54
# File 'lib/camt_parser/general/entry.rb', line 52

def reversal?
  @reversal ||= @xml_data.xpath('RvslInd/text()').text.downcase == 'true'
end

#signObject


48
49
50
# File 'lib/camt_parser/general/entry.rb', line 48

def sign
  credit? ? 1 : -1
end

#transactionsObject


36
37
38
# File 'lib/camt_parser/general/entry.rb', line 36

def transactions
  @transactions ||= parse_transactions
end

#value_dateObject


24
25
26
# File 'lib/camt_parser/general/entry.rb', line 24

def value_date
  @value_date ||= Date.parse(@xml_data.xpath('ValDt/Dt/text()').text)
end