double_entry 0.10.1 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a89a7b1a2bfa39a0c51b309f107fc625af9643f0
4
- data.tar.gz: 1ac1862d044333c98bb26e78c6ba7d2c508203b4
3
+ metadata.gz: 6508beca76ce3246851d21126397d9323d5e25e7
4
+ data.tar.gz: 9b759848f69e62ecd9973c19352e9c22f3c913d8
5
5
  SHA512:
6
- metadata.gz: 235592b9bce67bfdbb4aa474e722a9dd54573ad495797fc1338521d6807e7d51648c7d3eb6258bbde8bdfa8b4b04a5fb6993dca63f21aadd123b9d76d4364dd3
7
- data.tar.gz: 28f0afca58a850bca2efc4a28bfa967639f54e383b5b16cc9e5959cef65b5eb8f3d8a72efb0e519f745e9491252fe2ff5c7ca86fa90168e6e41da9a2e1152765
6
+ metadata.gz: 2da0f34279cb0b98bc8d28be724d7ecfd02681af4508450c57d1ddaba0cc488716913aa8d9dcec26c51768b4503b794d9897e6cf36313c85ed44e1fd3c6fae96
7
+ data.tar.gz: 33fa36646e96b139fd532273510bd0462ed8e10f3315c05d62720eff9baa72907f8d97c8f213bf7c8640ef9cd0c6d8c06dece2b3a3dbe68a6aa55a8c362be57f
@@ -47,16 +47,16 @@ module DoubleEntry
47
47
  # get any previously calculated aggregates
48
48
  def retrieve_aggregates
49
49
  fail ArgumentError, "Invalid range type '#{range_type}'" unless %w(year month week day hour).include? range_type
50
- @aggregates = LineAggregate.
51
- where(:function => function).
52
- where(:range_type => 'normal').
53
- where(:account => account.to_s).
54
- where(:code => code.to_s).
55
- where(:filter => filter.inspect).
56
- where(LineAggregate.arel_table[range_type].not_eq(nil)).
57
- each_with_object({}) do |hash, result|
58
- hash[result.key] = formatted_amount(result.amount)
59
- end
50
+ scope = LineAggregate.
51
+ where(:function => function).
52
+ where(:range_type => 'normal').
53
+ where(:account => account.to_s).
54
+ where(:code => code.to_s).
55
+ where(:filter => filter.inspect).
56
+ where(LineAggregate.arel_table[range_type].not_eq(nil))
57
+ @aggregates = scope.each_with_object({}) do |result, hash|
58
+ hash[result.key] = formatted_amount(result.amount)
59
+ end
60
60
  end
61
61
 
62
62
  def all_periods
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module DoubleEntry
4
- VERSION = '0.10.1'
4
+ VERSION = '0.10.2'
5
5
  end
@@ -36,6 +36,27 @@ module DoubleEntry
36
36
  let(:range_type) { 'year' }
37
37
  let(:start) { '2006-08-03' }
38
38
  it { should eq [Money.zero, Money.new(10_00), Money.new(20_00), Money.zero] }
39
+
40
+ describe 'reuse of aggregates' do
41
+ let(:years) { TimeRangeArray.make(range_type, start, finish) }
42
+
43
+ context 'and some aggregates were created previously' do
44
+ before do
45
+ Reporting.aggregate(function.to_s, account, transfer_code, :filter => nil, :range => years[0])
46
+ Reporting.aggregate(function.to_s, account, transfer_code, :filter => nil, :range => years[1])
47
+ allow(Reporting).to receive(:aggregate)
48
+ end
49
+
50
+ it 'only asks Reporting for the non-existent ones' do
51
+ expect(Reporting).not_to receive(:aggregate).with(function.to_s, account, transfer_code, :filter => nil, :range => years[0])
52
+ expect(Reporting).not_to receive(:aggregate).with(function.to_s, account, transfer_code, :filter => nil, :range => years[1])
53
+
54
+ expect(Reporting).to receive(:aggregate).with(function.to_s, account, transfer_code, :filter => nil, :range => years[2])
55
+ expect(Reporting).to receive(:aggregate).with(function.to_s, account, transfer_code, :filter => nil, :range => years[3])
56
+ aggregate_array
57
+ end
58
+ end
59
+ end
39
60
  end
40
61
  end
41
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: double_entry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Sellitti
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2015-07-06 00:00:00.000000000 Z
18
+ date: 2015-07-10 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: money