Report Programming: How to get-account-by-name?

Derek Atkins warlord at MIT.EDU
Mon Feb 11 13:34:11 EST 2013


Hi,

Carsten Rinke <carsten.rinke at gmx.de> writes:

> Hi,
>
> I am trying to write an own report that analysis the splits in
> selected accounts.
>
> I am interested to see the account types of the "other side" of the splits.
>
> I see that I can get the account name of the "other side" of the split
> with a call of
>
> (xaccSplitGetCorrAccountName split)

Note that this API will only work properly on a basic, 2-Split
transaction.  If you have a "split transaction", aka multi-split
transaction, which has >2 splits than this API will always return NULL,
because there isn't only "one other" split.  If you are absolutely sure
you only want to handle basic, two-split transactions, you could just
use xaccSplitGetOtherSplit.

> But I don't see how to get to the corresponding account type from there.
> Probably "get-account-by-name" is what I need.
> Even looking into ways to write this myself got me stuck, as I don't
> even see how to get a list of all available accounts.

Your better option would be to go through the Split's Parent
(Transaction) and from there you can get to the other Split itself (or
multiple other splits) and, from there, the account information.

> Anyone who has found out how to do this?
> Great if you could point me to an example.
>
> Thx,
> Carsten

> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-user mailing list