class BankAccountStatement::Inputs::TXT::CPBKGB22::Business::Base

Public Instance Methods

account() click to toggle source
# File lib/bank-account-statement/inputs/TXT/CPBKGB22/Business/base.rb, line 12
def account
  {
    :id   => _bank_account_ids[:account_id],
    :type => self.class::ACCOUNT_TYPE,
  }
end
currency() click to toggle source
# File lib/bank-account-statement/inputs/TXT/CPBKGB22/Business/base.rb, line 19
def currency
  :GBP
end
transactions() click to toggle source
# File lib/bank-account-statement/inputs/TXT/CPBKGB22/Business/base.rb, line 23
def transactions
  _transaction_rows.map { |r|
    begin
      posted_at = Date.parse(r[:date])
    rescue ArgumentError
      next # annotation line
    end
    
    a= _transaction_amount(r[:deposit], r[:withdrawal])
    
    {
      :posted_at => posted_at,
      :type      => _transaction_type(r[:desc], a),
      :name      => r[:desc].strip,
      :amount    => a,
    }
  }.compact
end

Private Instance Methods

_clean_str(str) click to toggle source
# File lib/bank-account-statement/inputs/TXT/CPBKGB22/Business/base.rb, line 44
def _clean_str(str)
  str.strip
end
_transaction_amount(deposit, withdrawal) click to toggle source
# File lib/bank-account-statement/inputs/TXT/CPBKGB22/Business/base.rb, line 48
def _transaction_amount(deposit, withdrawal)
  d = _clean_amount(deposit)
  w = _clean_amount(withdrawal)
  
  w != 0 ? (w * -1) : d
end
_transaction_type(name, amount) click to toggle source
# File lib/bank-account-statement/inputs/TXT/CPBKGB22/Business/base.rb, line 55
def _transaction_type(name, amount)
  case name
  when /^DD /
    :DIRECTDEBIT
  when /^SO /
    :REPEATPMT
  else
    amount >= 0 ? :CREDIT : :DEBIT
  end
end