Class: DoubleEntry::Reporting::Aggregate Private
- Inherits:
-
Object
- Object
- DoubleEntry::Reporting::Aggregate
- Defined in:
- lib/double_entry/reporting/aggregate.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #account ⇒ Object readonly private
- #code ⇒ Object readonly private
- #currency ⇒ Object readonly private
- #filter ⇒ Object readonly private
- #function ⇒ Object readonly private
- #options ⇒ Object readonly private
- #range ⇒ Object readonly private
Instance Method Summary collapse
- #amount(force_recalculation = false) ⇒ Object private
- #formatted_amount(value = amount()) ⇒ Object private
-
#initialize(function, account, code, options) ⇒ Aggregate
constructor
private
A new instance of Aggregate.
Constructor Details
#initialize(function, account, code, options) ⇒ Aggregate
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Aggregate.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/double_entry/reporting/aggregate.rb', line 7 def initialize(function, account, code, ) @function = function.to_s fail AggregateFunctionNotSupported unless %w(sum count average).include?(@function) @account = account @code = code ? code.to_s : nil @options = @range = [:range] @filter = [:filter] @currency = DoubleEntry::Account.currency(account) end |
Instance Attribute Details
#account ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def account @account end |
#code ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def code @code end |
#currency ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def currency @currency end |
#filter ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def filter @filter end |
#function ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def function @function end |
#options ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def @options end |
#range ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def range @range end |
Instance Method Details
#amount(force_recalculation = false) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 25 26 |
# File 'lib/double_entry/reporting/aggregate.rb', line 19 def amount(force_recalculation = false) if force_recalculation clear_old_aggregates calculate else retrieve || calculate end end |
#formatted_amount(value = amount()) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 31 32 33 34 35 |
# File 'lib/double_entry/reporting/aggregate.rb', line 28 def formatted_amount(value = amount()) value ||= 0 if function == 'count' value else Money.new(value, currency) end end |