diff --git a/lib/gnucash/account.rb b/lib/gnucash/account.rb index 58ac448..71f1cd7 100644 --- a/lib/gnucash/account.rb +++ b/lib/gnucash/account.rb @@ -14,6 +14,9 @@ module Gnucash # account. attr_accessor :transactions + # Boolean: whether the account is a placeholder or not + attr_accessor :placeholder + # Create an Account object. # === Arguments # +book+ _Book_:: The Gnucash::Book containing the account @@ -28,6 +31,10 @@ module Gnucash @parent_id = nil if @parent_id == "" @transactions = [] @balances = [] + @placeholder = node.xpath("act:slots/slot").find do |slot| + (slot.xpath("slot:key").first.text == "placeholder" and + slot.xpath("slot:value").first.text == "true") + end end # Return the fully qualified account name diff --git a/spec/gnucash/account_spec.rb b/spec/gnucash/account_spec.rb index 7d6d15d..c13e10b 100644 --- a/spec/gnucash/account_spec.rb +++ b/spec/gnucash/account_spec.rb @@ -3,7 +3,9 @@ module Gnucash before(:all) do # just read the file once @book = Gnucash.open("spec/books/sample.gnucash") + @assets = @book.find_account_by_full_name("Assets") @checking = @book.find_account_by_full_name("Assets::Current Assets::Checking Account") + @income = @book.find_account_by_full_name("Income") @salary = @book.find_account_by_full_name("Income::Salary") end @@ -36,5 +38,12 @@ module Gnucash @checking.balance_on("2007-03-27").should == Value.new(780000) end end + + it "stores whether the account was a placeholder" do + @assets.placeholder.should be_true + @checking.placeholder.should be_false + @income.placeholder.should be_true + @salary.placeholder.should be_false + end end end