double_entry 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6508beca76ce3246851d21126397d9323d5e25e7
|
4
|
+
data.tar.gz: 9b759848f69e62ecd9973c19352e9c22f3c913d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
data/lib/double_entry/version.rb
CHANGED
@@ -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.
|
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-
|
18
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: money
|