class Cmxl::Fields::Transaction
Attributes
Public Instance Methods
Source
# File lib/cmxl/fields/transaction.rb, line 9 def add_meta_data(content) self.details = Cmxl::Fields::StatementDetails.parse(content) unless content.nil? end
Source
# File lib/cmxl/fields/transaction.rb, line 81 def amount to_amount(data['amount']) end
Source
# File lib/cmxl/fields/transaction.rb, line 85 def amount_in_cents to_amount_in_cents(data['amount']) end
Source
# File lib/cmxl/fields/transaction.rb, line 127 def charges_currency supplementary.charges_currency end
Source
# File lib/cmxl/fields/transaction.rb, line 123 def charges_in_cents supplementary.charges_in_cents end
Source
# File lib/cmxl/fields/transaction.rb, line 17 def credit? credit_debit_indicator.include?('C') end
Source
# File lib/cmxl/fields/transaction.rb, line 64 def credit_debit_indicator data['credit_debit_indicator'].to_s end
Source
# File lib/cmxl/fields/transaction.rb, line 21 def debit? credit_debit_indicator.include?('D') end
Source
# File lib/cmxl/fields/transaction.rb, line 133 def description details.description if details end
Fields
from details
Source
# File lib/cmxl/fields/transaction.rb, line 93 def entry_date return if !date || !data['entry_date'] e_date = to_date(data['entry_date'], date.year) # we assume that valuta (date) and entry_date have a close connection. so valuta and entry_date should not be # further apart than one month. this leads to some edge cases # valuta is in january while entry_date is in december => entry_date was done the year before e_date = to_date(data['entry_date'], date.year - 1) if date.month == 1 && e_date.month == 12 # valuta is in december but entry_date is in january => entry_date is actually in the year after valuta e_date = to_date(data['entry_date'], date.year + 1) if date.month == 12 && e_date.month == 1 e_date end
Source
# File lib/cmxl/fields/transaction.rb, line 60 def expected? credit_debit_indicator.include?('E') end
Source
# File lib/cmxl/fields/transaction.rb, line 52 def expected_credit? credit? && expected? end
Source
# File lib/cmxl/fields/transaction.rb, line 56 def expected_debit? debit? && expected? end
Source
# File lib/cmxl/fields/transaction.rb, line 68 def funds_code warn "[DEPRECATION] `funds_code` is deprecated. Please use `credit_debit_indicator` instead. It will be removed in version 3.0." data['credit_debit_indicator'].to_s end
Source
# File lib/cmxl/fields/transaction.rb, line 137 def information details.information if details end
Source
# File lib/cmxl/fields/transaction.rb, line 115 def initial_amount_in_cents supplementary.initial_amount_in_cents end
Fields
from supplementary
Source
# File lib/cmxl/fields/transaction.rb, line 119 def initial_currency supplementary.initial_currency end
Source
# File lib/cmxl/fields/transaction.rb, line 161 def primanota details.primanota if details end
Source
# File lib/cmxl/fields/transaction.rb, line 48 def reversal? credit_debit_indicator.include?('R') end
Source
# File lib/cmxl/fields/transaction.rb, line 30 def reversal_credit? credit? && storno? end
Source
# File lib/cmxl/fields/transaction.rb, line 39 def reversal_debit? debit? && storno? end
Source
# File lib/cmxl/fields/transaction.rb, line 13 def sha Digest::SHA2.new.update(source).to_s end
Source
# File lib/cmxl/fields/transaction.rb, line 43 def storno? warn "[DEPRECATION] `storno?` is deprecated. Please use `reversal?` instead. It will be removed in version 3.0." reversal? end
Source
# File lib/cmxl/fields/transaction.rb, line 25 def storno_credit? warn "[DEPRECATION] `storno_credit?` is deprecated. Please use `reversal_credit?` instead. It will be removed in version 3.0." reversal_credit? end
Source
# File lib/cmxl/fields/transaction.rb, line 34 def storno_debit? warn "[DEPRECATION] `storno_debit?` is deprecated. Please use `reversal_debit?` instead. It will be removed in version 3.0." reversal_debit? end
Source
# File lib/cmxl/fields/transaction.rb, line 73 def storno_flag reversal? ? 'R' : '' end
Source
# File lib/cmxl/fields/transaction.rb, line 157 def sub_fields details.sub_fields if details end
Source
# File lib/cmxl/fields/transaction.rb, line 109 def supplementary @supplementary ||= Cmxl::Fields::TransactionSupplementary.parse(data['supplementary']) end
Source
# File lib/cmxl/fields/transaction.rb, line 165 def to_h { 'sha' => sha, 'date' => date, 'entry_date' => entry_date, 'amount' => amount, 'amount_in_cents' => amount_in_cents, 'sign' => sign, 'debit' => debit?, 'credit' => credit?, 'storno' => reversal?, 'reversal' => reversal?, 'expected' => expected?, 'funds_code' => credit_debit_indicator, 'credit_debit_indicator' => credit_debit_indicator, 'swift_code' => swift_code, 'reference' => reference, 'bank_reference' => bank_reference, 'currency_letter' => currency_letter }.tap do |h| h.merge!(details.to_h) if details h.merge!(supplementary.to_h) if supplementary.source end end
Source
# File lib/cmxl/fields/transaction.rb, line 194 def to_json(*args) to_h.to_json(*args) end