Class: BankAccountStatement::Inputs::HTML::CPBKGB22::Personal::Current::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/base.rb

Direct Known Subclasses

V_2011_05_07, V_2015_03_03

Constant Summary collapse

ACCOUNT_TYPE =
:CHECKING

Constants inherited from Base

Base::FILE_EXT

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods inherited from Base

formats, inherited, #parse

Constructor Details

This class inherits a constructor from BankAccountStatement::Inputs::HTML::Base

Instance Method Details

#accountObject



24
25
26
27
28
29
# File 'lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/base.rb', line 24

def 
  {
    :id   => [:account_id],
    :type => self.class::ACCOUNT_TYPE,
  }
end

#balanceObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/base.rb', line 51

def balance
  r = _transaction_rows.last
  
  {
    :ledger => {
      :balanced_at => Date.parse(r[self.class::TH[:date]]),
      :amount      => _clean_amount(r[self.class::TH[:balance]]),
    },
  }
end

#bankObject



18
19
20
21
22
# File 'lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/base.rb', line 18

def bank
  {
    :id => [:bank_id].tr('-', ''),
  }
end

#currencyObject



31
32
33
# File 'lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/base.rb', line 31

def currency
  :GBP
end

#transactionsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/bank-account-statement/inputs/HTML/CPBKGB22/Personal/Current/base.rb', line 35

def transactions
  _transaction_rows.map { |r|
    a = _transaction_amount(
      r[self.class::TH[:deposit]],
      r[self.class::TH[:withdrawal]]
    )
    
    {
      :posted_at => Date.parse(r[self.class::TH[:date]]),
      :type      => _transaction_type(r[self.class::TH[:desc]], a),
      :name      => r[self.class::TH[:desc]].strip,
      :amount    => a,
    }
  }
end