add placeholder account attribute

This commit is contained in:
Josh Holtrop 2013-08-31 16:27:47 -04:00
parent 9ee49d949d
commit 4e882e60dc
2 changed files with 16 additions and 0 deletions

View File

@ -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

View File

@ -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