Compare commits
No commits in common. "master" and "v1.0.2" have entirely different histories.
@ -2,23 +2,17 @@ module Gnucash
|
||||
# Represent a GnuCash account object
|
||||
class Account
|
||||
# _String_: The name of the account (unqualified)
|
||||
attr_reader :name
|
||||
|
||||
# _String_: The account description
|
||||
attr_reader :description
|
||||
attr_accessor :name
|
||||
|
||||
# _String_: The account type (such as "EXPENSE")
|
||||
attr_reader :type
|
||||
attr_accessor :type
|
||||
|
||||
# _String_: The GUID of the account
|
||||
attr_reader :id
|
||||
attr_accessor :id
|
||||
|
||||
# _Array_: List of _AccountTransaction_ transactions associated with this
|
||||
# account.
|
||||
attr_reader :transactions
|
||||
|
||||
# Boolean: whether the account is a placeholder or not
|
||||
attr_reader :placeholder
|
||||
attr_accessor :transactions
|
||||
|
||||
# Create an Account object.
|
||||
# === Arguments
|
||||
@ -29,16 +23,11 @@ module Gnucash
|
||||
@node = node
|
||||
@name = node.xpath('act:name').text
|
||||
@type = node.xpath('act:type').text
|
||||
@description = node.xpath('act:description').text
|
||||
@id = node.xpath('act:id').text
|
||||
@parent_id = node.xpath('act:parent').text
|
||||
@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
|
||||
|
@ -2,7 +2,7 @@ module Gnucash
|
||||
# Class to link a transaction object to an Account.
|
||||
class AccountTransaction
|
||||
# _Gnucash::Value_: The transaction value for the linked account
|
||||
attr_reader :value
|
||||
attr_accessor :value
|
||||
|
||||
# Construct an AccountTransaction object.
|
||||
# This method is used internally when building a Transaction object.
|
||||
|
@ -5,16 +5,16 @@ module Gnucash
|
||||
# Represent a GnuCash Book
|
||||
class Book
|
||||
# _Array_ of _Gnucash::Account_ objects in the book
|
||||
attr_reader :accounts
|
||||
attr_accessor :accounts
|
||||
|
||||
# _Array_ of _Gnucash::Transaction_ objects in the book
|
||||
attr_reader :transactions
|
||||
attr_accessor :transactions
|
||||
|
||||
# _String_ in "YYYY-MM-DD" format of the first transaction in the book
|
||||
attr_reader :start_date
|
||||
attr_accessor :start_date
|
||||
|
||||
# _String_ in "YYYY-MM-DD" format of the last transaction in the book
|
||||
attr_reader :end_date
|
||||
attr_accessor :end_date
|
||||
|
||||
# Construct a Book object.
|
||||
# Normally called internally by Gnucash.open()
|
||||
|
@ -5,16 +5,13 @@ module Gnucash
|
||||
# with an individual account.
|
||||
class Transaction
|
||||
# _String_: The date of the transaction, in ISO format ("YYYY-MM-DD")
|
||||
attr_reader :date
|
||||
attr_accessor :date
|
||||
|
||||
# _String_: The GUID of the transaction
|
||||
attr_reader :id
|
||||
attr_accessor :id
|
||||
|
||||
# _String_: The description of the transaction
|
||||
attr_reader :description
|
||||
|
||||
# _Array_ of _Hash_ with keys +account+ and +value+
|
||||
attr_reader :splits
|
||||
attr_accessor :description
|
||||
|
||||
# Create a new Transaction object
|
||||
# === Arguments
|
||||
@ -35,7 +32,7 @@ module Gnucash
|
||||
end
|
||||
account.add_transaction(AccountTransaction.new(self, value))
|
||||
{
|
||||
account: account,
|
||||
account_id: account_id,
|
||||
value: value,
|
||||
}
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ module Gnucash
|
||||
include Comparable
|
||||
|
||||
# _Fixnum_:: The raw, undivided integer value
|
||||
attr_reader :val
|
||||
attr_accessor :val
|
||||
|
||||
# Create a new Value object with value 0
|
||||
def self.zero
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Gnucash
|
||||
# gem version
|
||||
VERSION = "1.1.0"
|
||||
VERSION = "1.0.2"
|
||||
end
|
||||
|
@ -3,9 +3,7 @@ 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
|
||||
|
||||
@ -13,10 +11,6 @@ module Gnucash
|
||||
@salary.name.should == "Salary"
|
||||
end
|
||||
|
||||
it "gives access to the account description" do
|
||||
@checking.description.should == "Checking Account"
|
||||
end
|
||||
|
||||
it "gives access to the fully-qualified account name" do
|
||||
@checking.full_name.should == "Assets::Current Assets::Checking Account"
|
||||
end
|
||||
@ -42,12 +36,5 @@ 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user