gnucash 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/Gemfile.lock +5 -5
- data/README.md +24 -32
- data/lib/gnucash/account.rb +2 -2
- data/lib/gnucash/value.rb +10 -4
- data/lib/gnucash/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b8e70e39febe1d2afe7ff866b5715f2e18620b1
|
4
|
+
data.tar.gz: 7bfd0b8791a02046d5cd61ccb37023ed1d2b613d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e77495aabd9da8f62edc77c990ec4f547771fe80a9c31cc0ce5736b2e1923d12d1f13d7800bf6dafc2ba1784764aa150f5a326b75af110061ad581f376966d23
|
7
|
+
data.tar.gz: ebbbd48420074fe267d137897ecffbe7dd38c717b1b56763e29e677379b65922b890b2879014e7045a8b7ff63d341fb4a8a4f83f4a12435cb45f84bc2064202c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# ChangeLog
|
2
|
+
|
3
|
+
## v1.2.2
|
4
|
+
|
5
|
+
- Allow mixing Value objects with different divisors - fix #7
|
6
|
+
- Replace Fixnum with Integer to avoid Ruby 2.4 deprecation warnings
|
7
|
+
|
8
|
+
## v1.2.1
|
9
|
+
|
10
|
+
- Determine a transaction split's value in the split account's currency - fix #6
|
11
|
+
|
12
|
+
## v1.2.0
|
13
|
+
|
14
|
+
- use Date objects instead of formatted strings for dates
|
15
|
+
- use a single colon instead of a double colon in account names
|
16
|
+
- use 'require_relative' instead of 'require'
|
17
|
+
|
18
|
+
## v1.1.0
|
19
|
+
|
20
|
+
- store and provide access to the account description
|
21
|
+
- change many attributes to read-only
|
22
|
+
- add 'placeholder' Account attribute
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gnucash (1.
|
4
|
+
gnucash (1.3.0)
|
5
5
|
nokogiri
|
6
6
|
|
7
7
|
GEM
|
@@ -10,9 +10,9 @@ GEM
|
|
10
10
|
diff-lcs (1.3)
|
11
11
|
docile (1.1.5)
|
12
12
|
json (2.1.0)
|
13
|
-
mini_portile2 (2.
|
14
|
-
nokogiri (1.8.
|
15
|
-
mini_portile2 (~> 2.
|
13
|
+
mini_portile2 (2.3.0)
|
14
|
+
nokogiri (1.8.1)
|
15
|
+
mini_portile2 (~> 2.3.0)
|
16
16
|
rake (12.0.0)
|
17
17
|
rdoc (5.1.0)
|
18
18
|
rspec (3.6.0)
|
@@ -47,4 +47,4 @@ DEPENDENCIES
|
|
47
47
|
yard
|
48
48
|
|
49
49
|
BUNDLED WITH
|
50
|
-
1.
|
50
|
+
1.15.0
|
data/README.md
CHANGED
@@ -20,38 +20,30 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
- use a single colon instead of a double colon in account names
|
48
|
-
- use 'require_relative' instead of 'require'
|
49
|
-
|
50
|
-
### v1.1.0
|
51
|
-
|
52
|
-
- store and provide access to the account description
|
53
|
-
- change many attributes to read-only
|
54
|
-
- add 'placeholder' Account attribute
|
23
|
+
```ruby
|
24
|
+
require "gnucash"
|
25
|
+
|
26
|
+
book = Gnucash.open("MyBook.gnucash")
|
27
|
+
|
28
|
+
book.accounts.each do |account|
|
29
|
+
puts "#{account.full_name}: #{account.final_balance}"
|
30
|
+
end
|
31
|
+
|
32
|
+
act = book.find_account_by_full_name("Assets:Checking")
|
33
|
+
balance = Gnucash::Value.zero
|
34
|
+
act.transactions.each do |txn|
|
35
|
+
balance += txn.value
|
36
|
+
$stdout.printf("%s %8s %8s %s\n",
|
37
|
+
txn.date,
|
38
|
+
txn.value,
|
39
|
+
balance,
|
40
|
+
txn.description))
|
41
|
+
end
|
42
|
+
|
43
|
+
year = Date.today.year
|
44
|
+
delta = act.balance_on("#{year}-12-31") - act.balance_on("#{year - 1}-12-31")
|
45
|
+
puts "You've saved #{delta} this year so far!"
|
46
|
+
```
|
55
47
|
|
56
48
|
## Contributing
|
57
49
|
|
data/lib/gnucash/account.rb
CHANGED
@@ -13,8 +13,8 @@ module Gnucash
|
|
13
13
|
# @return [String] The GUID of the account.
|
14
14
|
attr_reader :id
|
15
15
|
|
16
|
-
# @return [Array<AccountTransaction>]
|
17
|
-
# this account.
|
16
|
+
# @return [Array<AccountTransaction>]
|
17
|
+
# List of transactions associated with this account.
|
18
18
|
attr_reader :transactions
|
19
19
|
|
20
20
|
# @return [Boolean] Whether the account is a placeholder or not.
|
data/lib/gnucash/value.rb
CHANGED
@@ -81,27 +81,33 @@ module Gnucash
|
|
81
81
|
|
82
82
|
# Multiply a Value object.
|
83
83
|
#
|
84
|
-
# @param other [Numeric] Multiplier.
|
84
|
+
# @param other [Numeric, Value] Multiplier.
|
85
85
|
#
|
86
86
|
# @return [Numeric] Result of multiplication.
|
87
87
|
def *(other)
|
88
|
+
if other.is_a?(Value)
|
89
|
+
other = other.to_f
|
90
|
+
end
|
88
91
|
if other.is_a?(Numeric)
|
89
92
|
(to_f * other).round(2)
|
90
93
|
else
|
91
|
-
raise "Unexpected argument"
|
94
|
+
raise "Unexpected argument (#{other.inspect})"
|
92
95
|
end
|
93
96
|
end
|
94
97
|
|
95
98
|
# Divide a Value object.
|
96
99
|
#
|
97
|
-
# @param other [Numeric] Divisor.
|
100
|
+
# @param other [Numeric, Value] Divisor.
|
98
101
|
#
|
99
102
|
# @return [Numeric] Result of division.
|
100
103
|
def /(other)
|
104
|
+
if other.is_a?(Value)
|
105
|
+
other = other.to_f
|
106
|
+
end
|
101
107
|
if other.is_a?(Numeric)
|
102
108
|
(to_f / other).round(2)
|
103
109
|
else
|
104
|
-
raise "Unexpected argument"
|
110
|
+
raise "Unexpected argument (#{other.inspect})"
|
105
111
|
end
|
106
112
|
end
|
107
113
|
|
data/lib/gnucash/version.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.3.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: 2017-
|
11
|
+
date: 2017-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
105
|
- ".rspec"
|
106
|
+
- CHANGELOG.md
|
106
107
|
- Gemfile
|
107
108
|
- Gemfile.lock
|
108
109
|
- LICENSE.txt
|
@@ -144,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
145
|
version: '0'
|
145
146
|
requirements: []
|
146
147
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
148
|
+
rubygems_version: 2.5.2
|
148
149
|
signing_key:
|
149
150
|
specification_version: 4
|
150
151
|
summary: Extract data from XML GnuCash data files
|