python question

Sampsa Riikonen sampsa.lists at gmail.com
Mon Jan 9 04:24:20 EST 2012


Dear devs,

I have a few questions concerning the python bindings:

First of all, I start a new session as follows:

ses=Session("rapkotest.gnucash",ignore_lock=True)
root=ses.book.get_root_account()

Then ..

1)  how do I iterate through all the transactions for a given period in 
the book?

Now I am only able to access the transaction through..

test=root.get_children()
test=Account(instance=test[0])
trans=test.GetSplitList()[0]

etc.

So I first have to go to the account, then to the split and then to the 
transaction.

I would like to go the other way around, i.e. go to the list of 
transactions (in time order) directly.


2) how do I get the total balance of a set of subaccounts?

The following method gives me the balance of an account:

test.GetBalance().to_double()

However, if "test" is an account which consists of various subaccounts, how
can I get the cumulative total saldo of the subaccounts?  i.e. if "test" 
has subaccounts "a","b","c"
then I would like to have "a+b+c" with a single method.. is there such a 
method?

Kind Regards,

Sampsa



More information about the gnucash-devel mailing list