mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
c6b28a5094
commit
b2333aa395
@ -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 *************************************/
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user