gnucash 1.4.0 → 1.5.0
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 +5 -5
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +21 -21
- data/README.md +4 -0
- data/lib/gnucash/account.rb +20 -5
- data/lib/gnucash/version.rb +1 -1
- data/spec/gnucash/account_spec.rb +6 -0
- data/spec/spec_helper.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a58f8fe486b5e15eb9481af7c0ae86645334d0122207bd181d39ac52fa388461
|
4
|
+
data.tar.gz: f844443866e2b33cacbb44f3e78ae24c4ccc34a66bd73ee4beeac6911eddbb47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0d09b83dd1d6a88dc82515edcc798680e314cd8def62e69575dbd8d3feb8e3e0ac238c60091753ca50ad229ff59b9c3cbed507d656673fee5a758bb529b3465
|
7
|
+
data.tar.gz: 5dd6b7dabb61890a3c0b3ec1c072b3a6edc816c1824b30b4b353db07d60366b21ccfb1144293fd82d5a02ca0557ee34df903b0fd06a1212a415bf7f1cc31bf5d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,39 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gnucash (1.
|
4
|
+
gnucash (1.5.0)
|
5
5
|
nokogiri
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.3)
|
11
|
-
docile (1.1
|
11
|
+
docile (1.3.1)
|
12
12
|
json (2.1.0)
|
13
|
-
mini_portile2 (2.
|
14
|
-
nokogiri (1.
|
15
|
-
mini_portile2 (~> 2.
|
16
|
-
rake (12.3.
|
17
|
-
rdoc (6.
|
18
|
-
rspec (3.
|
19
|
-
rspec-core (~> 3.
|
20
|
-
rspec-expectations (~> 3.
|
21
|
-
rspec-mocks (~> 3.
|
22
|
-
rspec-core (3.
|
23
|
-
rspec-support (~> 3.
|
24
|
-
rspec-expectations (3.
|
13
|
+
mini_portile2 (2.4.0)
|
14
|
+
nokogiri (1.10.1)
|
15
|
+
mini_portile2 (~> 2.4.0)
|
16
|
+
rake (12.3.2)
|
17
|
+
rdoc (6.1.1)
|
18
|
+
rspec (3.8.0)
|
19
|
+
rspec-core (~> 3.8.0)
|
20
|
+
rspec-expectations (~> 3.8.0)
|
21
|
+
rspec-mocks (~> 3.8.0)
|
22
|
+
rspec-core (3.8.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-expectations (3.8.2)
|
25
25
|
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-mocks (3.
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-mocks (3.8.0)
|
28
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-support (3.
|
31
|
-
simplecov (0.
|
32
|
-
docile (~> 1.1
|
29
|
+
rspec-support (~> 3.8.0)
|
30
|
+
rspec-support (3.8.0)
|
31
|
+
simplecov (0.16.1)
|
32
|
+
docile (~> 1.1)
|
33
33
|
json (>= 1.8, < 3)
|
34
34
|
simplecov-html (~> 0.10.0)
|
35
35
|
simplecov-html (0.10.2)
|
36
|
-
yard (0.9.
|
36
|
+
yard (0.9.18)
|
37
37
|
|
38
38
|
PLATFORMS
|
39
39
|
ruby
|
data/README.md
CHANGED
@@ -45,6 +45,10 @@ delta = act.balance_on("#{year}-12-31") - act.balance_on("#{year - 1}-12-31")
|
|
45
45
|
puts "You've saved #{delta} this year so far!"
|
46
46
|
```
|
47
47
|
|
48
|
+
To get the balance of an account, use ```act.balance_on("#{year}-12-31")```.
|
49
|
+
To get the total balance of an account with all its children accounts,
|
50
|
+
use ```act.balance_on("#{year}-12-31", recursive: true)```.
|
51
|
+
|
48
52
|
## Contributing
|
49
53
|
|
50
54
|
1. Fork it
|
data/lib/gnucash/account.rb
CHANGED
@@ -99,13 +99,28 @@ module Gnucash
|
|
99
99
|
# Transactions that occur on the given date are included in the returned
|
100
100
|
# balance.
|
101
101
|
#
|
102
|
-
# @param date [String, Date]
|
102
|
+
# @param date [String, Date]
|
103
|
+
# Date on which to query the balance.
|
104
|
+
# @param options [Hash]
|
105
|
+
# Optional parameters.
|
106
|
+
# @option options [Boolean] :recursive
|
107
|
+
# Whether to include children account balances.
|
103
108
|
#
|
104
|
-
# @return [Value]
|
105
|
-
|
109
|
+
# @return [Value]
|
110
|
+
# Balance of the account as of the date given.
|
111
|
+
def balance_on(date, options = {})
|
106
112
|
date = Date.parse(date) if date.is_a?(String)
|
107
|
-
|
108
|
-
|
113
|
+
return_value = Value.new(0)
|
114
|
+
|
115
|
+
if options[:recursive]
|
116
|
+
# Get all child accounts from this account and accumulate the balances of them.
|
117
|
+
@book.accounts.reject { |account| account.parent != self }.each do |child_account|
|
118
|
+
return_value += child_account.balance_on(date, recursive: true)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
return return_value unless @balances.size > 0
|
123
|
+
return return_value if @balances.first[:date] > date
|
109
124
|
return @balances.last[:value] if date >= @balances.last[:date]
|
110
125
|
imin = 0
|
111
126
|
imax = @balances.size - 2
|
data/lib/gnucash/version.rb
CHANGED
@@ -54,6 +54,12 @@ module Gnucash
|
|
54
54
|
it "includes transactions that occur on the given date" do
|
55
55
|
expect(@checking.balance_on("2007-03-27")).to eq Value.new(780000)
|
56
56
|
end
|
57
|
+
|
58
|
+
describe 'with child accounts' do
|
59
|
+
it "returns the balance with the balance of the child accounts" do
|
60
|
+
expect(@assets.balance_on("2007-03-27", recursive: true)).to eq Value.new(790000)
|
61
|
+
end
|
62
|
+
end
|
57
63
|
end
|
58
64
|
|
59
65
|
it "stores whether the account was a placeholder" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnucash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Holtrop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.6
|
152
|
+
rubygems_version: 2.7.6
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Extract data from XML GnuCash data files
|