class CamtParser::Transaction
Public Class Methods
new(xml_data, debit, amount = nil, currency = nil)
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 3 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 104 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 10 def amount CamtParser::Misc.to_amount(@amount) end
amount_in_cents()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 14 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 76 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 38 def bic credit? ? debitor.bic : creditor.bic end
credit?()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 42 def credit? !debit end
creditor()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 22 def creditor @creditor ||= CamtParser::Creditor.new(@xml_data) end
creditor_identifier()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 96 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 88 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 18 def currency @currency end
debit()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 50 def debit @debit end
debit?()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 46 def debit? debit end
debitor()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 26 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 80 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 34 def iban credit? ? debitor.iban : creditor.iban end
mandate_reference()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 84 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 30 def name credit? ? debitor.name : creditor.name end
payment_information()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 100 def payment_information # May be missing @payment_information ||= @xml_data.xpath('Refs/PmtInfId/text()').text end
reason_code()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 108 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 72 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 58 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 54 def sign credit? ? 1 : -1 end
swift_code()
click to toggle source
# File lib/camt_parser/general/transaction.rb, line 68 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 92 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 114 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 122 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