From 1e10ba84e2abc9402861eb8d340988a58e88ea18 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sat, 5 Sep 1998 07:36:28 +0000 Subject: [PATCH] add a utility routine git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1096 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Transaction.c | 14 ++++++++++++++ src/engine/Transaction.h | 12 +++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index c6bd0a7ca1..a1187b3699 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -1142,5 +1142,19 @@ xaccGetOtherSplit (Split *split) return NULL; /* never reached, in theory */ } +/********************************************************************\ +\********************************************************************/ + +int +xaccIsPeerSplit (Split *sa, Split *sb) +{ + Transaction *ta, *tb; + if (!sa || !sb) return 0; + ta = sa->parent; + tb = sb->parent; + if (ta == tb) return 1; + return 0; +} + /************************ END OF ************************************\ \************************* FILE *************************************/ diff --git a/src/engine/Transaction.h b/src/engine/Transaction.h index 75c9c93128..1c5c3444e0 100644 --- a/src/engine/Transaction.h +++ b/src/engine/Transaction.h @@ -210,7 +210,7 @@ double xaccSplitGetClearedBalance (Split *); double xaccSplitGetReconciledBalance (Split *); double xaccSplitGetShareBalance (Split *); -/* return teh parent transaction of the split */ +/* return the parent transaction of the split */ Transaction * xaccSplitGetParent (Split *); /* return the memo, action strings */ @@ -257,9 +257,15 @@ Account * xaccGetAccountByName (Transaction *, const char *); /* * The GetOtherSplit() is a convenience routine that returns - * the other of a pair of splits. If there are more than two - * splits, it returns NULL. + * the other of a pair of splits. If there are more than two + * splits, it returns NULL. */ Split * xaccGetOtherSplit (Split *); +/* The IsPeerSplit() is a convenience routine that returns + * a non-zero value if the two splits share a common + * parent transaction, else it returns zero. + */ +int xaccIsPeerSplit (Split *, Split *); + #endif /* __XACC_TRANSACTION_H__ */