Class: DoubleEntry::Reporting::LineAggregate Private
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- DoubleEntry::Reporting::LineAggregate
- Defined in:
- lib/double_entry/reporting/line_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.
Class Method Summary collapse
- .aggregate(function, account, code, range, named_scopes) ⇒ Object private
-
.aggregate_collection(named_scopes) ⇒ Object
private
a lot of the trickier reports will use filters defined in named_scopes to bring in data from other tables.
Instance Method Summary collapse
- #key ⇒ Object private
Class Method Details
.aggregate(function, account, code, range, named_scopes) ⇒ 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.
6 7 8 9 10 11 12 |
# File 'lib/double_entry/reporting/line_aggregate.rb', line 6 def self.aggregate(function, account, code, range, named_scopes) collection = aggregate_collection(named_scopes) collection = collection.where(:account => account) collection = collection.where(:created_at => range.start..range.finish) collection = collection.where(:code => code) if code collection.send(function, :amount) end |
.aggregate_collection(named_scopes) ⇒ 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.
a lot of the trickier reports will use filters defined in named_scopes to bring in data from other tables.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/double_entry/reporting/line_aggregate.rb', line 16 def self.aggregate_collection(named_scopes) if named_scopes collection = DoubleEntry::Line named_scopes.each do |named_scope| if named_scope.is_a?(Hash) method_name = named_scope.keys[0] collection = collection.send(method_name, named_scope[method_name]) else collection = collection.send(named_scope) end end collection else DoubleEntry::Line end end |
Instance Method Details
#key ⇒ 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.
33 34 35 |
# File 'lib/double_entry/reporting/line_aggregate.rb', line 33 def key "#{year}:#{month}:#{week}:#{day}:#{hour}" end |