gnucash 1.0.3 → 1.1.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.
@@ -2,17 +2,23 @@ module Gnucash
2
2
  # Represent a GnuCash account object
3
3
  class Account
4
4
  # _String_: The name of the account (unqualified)
5
- attr_accessor :name
5
+ attr_reader :name
6
+
7
+ # _String_: The account description
8
+ attr_reader :description
6
9
 
7
10
  # _String_: The account type (such as "EXPENSE")
8
- attr_accessor :type
11
+ attr_reader :type
9
12
 
10
13
  # _String_: The GUID of the account
11
- attr_accessor :id
14
+ attr_reader :id
12
15
 
13
16
  # _Array_: List of _AccountTransaction_ transactions associated with this
14
17
  # account.
15
- attr_accessor :transactions
18
+ attr_reader :transactions
19
+
20
+ # Boolean: whether the account is a placeholder or not
21
+ attr_reader :placeholder
16
22
 
17
23
  # Create an Account object.
18
24
  # === Arguments
@@ -23,11 +29,16 @@ module Gnucash
23
29
  @node = node
24
30
  @name = node.xpath('act:name').text
25
31
  @type = node.xpath('act:type').text
32
+ @description = node.xpath('act:description').text
26
33
  @id = node.xpath('act:id').text
27
34
  @parent_id = node.xpath('act:parent').text
28
35
  @parent_id = nil if @parent_id == ""
29
36
  @transactions = []
30
37
  @balances = []
38
+ @placeholder = node.xpath("act:slots/slot").find do |slot|
39
+ (slot.xpath("slot:key").first.text == "placeholder" and
40
+ slot.xpath("slot:value").first.text == "true")
41
+ end
31
42
  end
32
43
 
33
44
  # Return the fully qualified account name
@@ -2,7 +2,7 @@ module Gnucash
2
2
  # Class to link a transaction object to an Account.
3
3
  class AccountTransaction
4
4
  # _Gnucash::Value_: The transaction value for the linked account
5
- attr_accessor :value
5
+ attr_reader :value
6
6
 
7
7
  # Construct an AccountTransaction object.
8
8
  # This method is used internally when building a Transaction object.
@@ -5,16 +5,16 @@ module Gnucash
5
5
  # Represent a GnuCash Book
6
6
  class Book
7
7
  # _Array_ of _Gnucash::Account_ objects in the book
8
- attr_accessor :accounts
8
+ attr_reader :accounts
9
9
 
10
10
  # _Array_ of _Gnucash::Transaction_ objects in the book
11
- attr_accessor :transactions
11
+ attr_reader :transactions
12
12
 
13
13
  # _String_ in "YYYY-MM-DD" format of the first transaction in the book
14
- attr_accessor :start_date
14
+ attr_reader :start_date
15
15
 
16
16
  # _String_ in "YYYY-MM-DD" format of the last transaction in the book
17
- attr_accessor :end_date
17
+ attr_reader :end_date
18
18
 
19
19
  # Construct a Book object.
20
20
  # Normally called internally by Gnucash.open()
@@ -5,16 +5,16 @@ module Gnucash
5
5
  # with an individual account.
6
6
  class Transaction
7
7
  # _String_: The date of the transaction, in ISO format ("YYYY-MM-DD")
8
- attr_accessor :date
8
+ attr_reader :date
9
9
 
10
10
  # _String_: The GUID of the transaction
11
- attr_accessor :id
11
+ attr_reader :id
12
12
 
13
13
  # _String_: The description of the transaction
14
- attr_accessor :description
14
+ attr_reader :description
15
15
 
16
16
  # _Array_ of _Hash_ with keys +account+ and +value+
17
- attr_accessor :splits
17
+ attr_reader :splits
18
18
 
19
19
  # Create a new Transaction object
20
20
  # === Arguments
@@ -5,7 +5,7 @@ module Gnucash
5
5
  include Comparable
6
6
 
7
7
  # _Fixnum_:: The raw, undivided integer value
8
- attr_accessor :val
8
+ attr_reader :val
9
9
 
10
10
  # Create a new Value object with value 0
11
11
  def self.zero
@@ -1,4 +1,4 @@
1
1
  module Gnucash
2
2
  # gem version
3
- VERSION = "1.0.3"
3
+ VERSION = "1.1.0"
4
4
  end
@@ -3,7 +3,9 @@ module Gnucash
3
3
  before(:all) do
4
4
  # just read the file once
5
5
  @book = Gnucash.open("spec/books/sample.gnucash")
6
+ @assets = @book.find_account_by_full_name("Assets")
6
7
  @checking = @book.find_account_by_full_name("Assets::Current Assets::Checking Account")
8
+ @income = @book.find_account_by_full_name("Income")
7
9
  @salary = @book.find_account_by_full_name("Income::Salary")
8
10
  end
9
11
 
@@ -11,6 +13,10 @@ module Gnucash
11
13
  @salary.name.should == "Salary"
12
14
  end
13
15
 
16
+ it "gives access to the account description" do
17
+ @checking.description.should == "Checking Account"
18
+ end
19
+
14
20
  it "gives access to the fully-qualified account name" do
15
21
  @checking.full_name.should == "Assets::Current Assets::Checking Account"
16
22
  end
@@ -36,5 +42,12 @@ module Gnucash
36
42
  @checking.balance_on("2007-03-27").should == Value.new(780000)
37
43
  end
38
44
  end
45
+
46
+ it "stores whether the account was a placeholder" do
47
+ @assets.placeholder.should be_true
48
+ @checking.placeholder.should be_false
49
+ @income.placeholder.should be_true
50
+ @salary.placeholder.should be_false
51
+ end
39
52
  end
40
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnucash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-28 00:00:00.000000000 Z
12
+ date: 2013-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri