class CamtParser::Transaction
Attributes
xml_data[R]
Public Class Methods
new(xml_data, debit, amount = nil, currency = nil)
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 6 def initialize(xml_data, debit, amount = nil, currency = nil) @xml_data = xml_data @debit = debit @amount = parse_amount || amount @currency = parse_currency || currency end
Public Instance Methods
additional_information()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 111 def additional_information # May be missing @addition_information ||= xml_data.xpath('AddtlTxInf/text()').text end
amount()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 13 def amount CamtParser::Misc.to_amount(@amount) end
amount_in_cents()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 17 def amount_in_cents CamtParser::Misc.to_amount_in_cents(@amount) end
bank_reference()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 83 def bank_reference # May be missing @bank_reference ||= xml_data.xpath('Refs/AcctSvcrRef/text()').text end
bic()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 41 def bic credit? ? debitor.bic : creditor.bic end
credit?()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 49 def credit? !debit end
creditor()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 25 def creditor @creditor ||= CamtParser::Creditor.new(xml_data) end
creditor_identifier()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 103 def creditor_identifier # May be missing @creditor_identifier ||= xml_data.xpath('RltdPties/Cdtr/Id/PrvtId/Othr/Id/text()').text end
creditor_reference()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 95 def creditor_reference # May be missing @creditor_reference ||= xml_data.xpath('RmtInf/Strd/CdtrRefInf/Ref/text()').text end
currency()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 21 def currency @currency end
debit()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 57 def debit @debit end
debit?()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 53 def debit? debit end
debitor()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 29 def debitor @debitor ||= CamtParser::Debitor.new(xml_data) end
end_to_end_reference()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 87 def end_to_end_reference # May be missing @end_to_end_reference ||= xml_data.xpath('Refs/EndToEndId/text()').text end
iban()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 37 def iban credit? ? debitor.iban : creditor.iban end
mandate_reference()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 91 def mandate_reference # May be missing @mandate_reference ||= xml_data.xpath('Refs/MndtId/text()').text end
name()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 33 def name credit? ? debitor.name : creditor.name end
payment_information()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 107 def payment_information # May be missing @payment_information ||= xml_data.xpath('Refs/PmtInfId/text()').text end
postal_address()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 45 def postal_address credit? ? debitor.postal_address : creditor.postal_address end
reason_code()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 115 def reason_code # May be missing @reason_code ||= xml_data.xpath('RtrInf/Rsn/Cd/text()').text end
reference()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 79 def reference @reference ||= xml_data.xpath('Refs/InstrId/text()').text end
remittance_information()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 65 def remittance_information @remittance_information ||= begin if (x = xml_data.xpath('RmtInf/Ustrd')).empty? nil else x.collect(&:content).join(' ') end end end
sign()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 61 def sign credit? ? 1 : -1 end
swift_code()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 75 def swift_code @swift_code ||= xml_data.xpath('BkTxCd/Prtry/Cd/text()').text.split('+')[0] end
transaction_id()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 99 def transaction_id # May be missing @transaction_id ||= xml_data.xpath('Refs/TxId/text()').text end
Private Instance Methods
parse_amount()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 121 def parse_amount if xml_data.xpath('Amt').any? xml_data.xpath('Amt/text()').text elsif xml_data.xpath('AmtDtls').any? xml_data.xpath('AmtDtls//Amt/text()').first.text end end
parse_currency()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 129 def parse_currency if xml_data.xpath('Amt').any? xml_data.xpath('Amt/@Ccy').text elsif xml_data.xpath('AmtDtls').any? xml_data.xpath('AmtDtls//Amt/@Ccy').first.text end end