Class: FinModeling::CashChangeCalculation

Inherits:
CompanyFilingCalculation show all
Includes:
CanCacheClassifications, CanCacheSummaries, CanClassifyRows
Defined in:
lib/finmodeling/cash_change_calculation.rb

Constant Summary collapse

BASE_FILENAME =
File.join(FinModeling::BASE_PATH, "summaries/cash_")
ALL_STATES =
[ :c, :i, :d, :f ]
NEXT_STATES =
{ nil => [ :c             ],
:c  => [ :c, :i, :d, :f ],
:i  => [     :i, :d, :f ],
:d  => [     :i, :d, :f ],
:f  => [         :d, :f ] }

Instance Attribute Summary

Attributes inherited from CompanyFilingCalculation

#calculation

Instance Method Summary collapse

Methods inherited from CompanyFilingCalculation

#initialize, #label, #leaf_items, #leaf_items_sum, #periods, #write_constructor

Constructor Details

This class inherits a constructor from FinModeling::CompanyFilingCalculation

Instance Method Details

#summary(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/finmodeling/cash_change_calculation.rb', line 17

def summary(args)
  summary_cache_key = args[:period].to_pretty_s
  summary = lookup_cached_summary(summary_cache_key)
  return summary if !summary.nil? && false # FIXME: get rid of "and false"

  mapping = Xbrlware::ValueMapping.new
  mapping.policy[:unknown]          = :flip
  mapping.policy[:credit]           = :flip 
  mapping.policy[:debit]            = :no_action 
  mapping.policy[:netincome]        = :no_action 
  mapping.policy[:taxes]            = :no_action
  mapping.policy[:proceedsfromdebt] = :no_action

  find_and_tag_special_items(args)

  summary = super(:period => args[:period], :mapping => mapping)
  if !lookup_cached_classifications(BASE_FILENAME, summary.rows) || true # FIXME: get rid of "or true"
    lookahead = [4, summary.rows.length-1].min
    classify_rows(ALL_STATES, NEXT_STATES, summary.rows, FinModeling::CashChangeItem, lookahead)
    save_cached_classifications(BASE_FILENAME, summary.rows)
  end

  save_cached_summary(summary_cache_key, summary)

  return summary
end