add a convenience routine

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@959 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-08-08 21:15:54 +00:00
parent c6b28a5094
commit b2333aa395
2 changed files with 37 additions and 0 deletions

View File

@ -1051,5 +1051,34 @@ xaccSplitGetSharePrice (Split * split)
return (split->share_price);
}
/********************************************************************\
\********************************************************************/
Account *
xaccGetAccountByName (Transaction *trans, const char * name)
{
Split *s;
Account *acc;
int i;
if (!trans) return NULL;
if (!name) return NULL;
/* walk through the splits, looking for one, any one, that has a parent account */
i = 0;
s = trans->splits[0];
while (s) {
acc = s->acc;
if (acc) break;
i++;
s = trans->splits[i];
}
if (!acc) return 0x0;
acc = xaccGetPeerAccountFromName (acc, name);
return acc;
}
/************************ END OF ************************************\
\************************* FILE *************************************/

View File

@ -126,6 +126,7 @@ char * xaccTransGetNum (Transaction *);
char * xaccTransGetDescription (Transaction *);
time_t xaccTransGetDate (Transaction *);
/* ------------- splits --------------- */
/* return the number of splits */
int xaccTransCountSplits (Transaction *trans);
@ -221,4 +222,11 @@ int xaccSplitOrder (Split **sa, Split **sb);
*/
int xaccCountTransactions (Transaction **tarray);
/*
* convenience routine that is essentially identical to
* xaccGetPeerrAccountFromName, except that it accepts the handy
* transaction as root.
*/
Account * xaccGetAccountByName (Transaction *, const char *);
#endif /* __XACC_TRANSACTION_H__ */