The function name xaccSplitDateOrder is misleading, so rename it to

xaccSplitOrder.  Add a new xaccSplitOrderDateOnly function.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15838 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2007-04-06 02:31:28 +00:00
parent 897633f01b
commit df0cfeddc2
5 changed files with 35 additions and 10 deletions

View File

@ -804,7 +804,7 @@ xaccAccountSortSplits (Account *acc, gboolean force)
{ {
if (!acc || !acc->sort_dirty || (!force && acc->inst.editlevel > 0)) return; if (!acc || !acc->sort_dirty || (!force && acc->inst.editlevel > 0)) return;
acc->splits = g_list_sort(acc->splits, (GCompareFunc)xaccSplitDateOrder); acc->splits = g_list_sort(acc->splits, (GCompareFunc)xaccSplitOrder);
acc->sort_dirty = FALSE; acc->sort_dirty = FALSE;
acc->balance_dirty = TRUE; acc->balance_dirty = TRUE;
} }

View File

@ -525,7 +525,7 @@ xaccSplitCommitEdit(Split *s)
if (!g_list_find(acc->splits, s)) { if (!g_list_find(acc->splits, s)) {
if (acc->inst.editlevel == 0) { if (acc->inst.editlevel == 0) {
acc->splits = g_list_insert_sorted( acc->splits = g_list_insert_sorted(
acc->splits, s, (GCompareFunc)xaccSplitDateOrder); acc->splits, s, (GCompareFunc)xaccSplitOrder);
} else { } else {
acc->splits = g_list_prepend(acc->splits, s); acc->splits = g_list_prepend(acc->splits, s);
acc->sort_dirty = TRUE; acc->sort_dirty = TRUE;
@ -1126,8 +1126,8 @@ xaccSplitDestroy (Split *split)
/********************************************************************\ /********************************************************************\
\********************************************************************/ \********************************************************************/
int gint
xaccSplitDateOrder (const Split *sa, const Split *sb) xaccSplitOrder (const Split *sa, const Split *sb)
{ {
int retval; int retval;
int comp; int comp;
@ -1178,6 +1178,30 @@ xaccSplitDateOrder (const Split *sa, const Split *sb)
return 0; return 0;
} }
gint
xaccSplitOrderDateOnly (const Split *sa, const Split *sb)
{
Transaction *ta, *tb;
if (sa == sb) return 0;
/* nothing is always less than something */
if (!sa && sb) return -1;
if (sa && !sb) return +1;
ta = sa->parent;
tb = sb->parent;
if ( ta && !tb ) return -1;
if ( !ta && tb ) return +1;
if ( !ta && !tb ) return 0;
/* if dates differ, return */
DATE_CMP(ta,tb,date_posted);
/* If the dates are the same, do not change the order */
return -1;
}
static gboolean static gboolean
get_corr_account_split(const Split *sa, const Split **retval) get_corr_account_split(const Split *sa, const Split **retval)
{ {
@ -1843,7 +1867,7 @@ gboolean xaccSplitRegister (void)
{ NULL }, { NULL },
}; };
qof_class_register (GNC_ID_SPLIT, (QofSortFunc)xaccSplitDateOrder, params); qof_class_register (GNC_ID_SPLIT, (QofSortFunc)xaccSplitOrder, params);
qof_class_register (SPLIT_ACCT_FULLNAME, qof_class_register (SPLIT_ACCT_FULLNAME,
(QofSortFunc)xaccSplitCompareAccountFullNames, NULL); (QofSortFunc)xaccSplitCompareAccountFullNames, NULL);
qof_class_register (SPLIT_CORR_ACCT_NAME, qof_class_register (SPLIT_CORR_ACCT_NAME,

View File

@ -348,7 +348,7 @@ const char *xaccSplitGetType(const Split *s);
void xaccSplitMakeStockSplit(Split *s); void xaccSplitMakeStockSplit(Split *s);
/** /**
* The xaccSplitDateOrder(sa,sb) method is useful for sorting. * The xaccSplitOrder(sa,sb) method is useful for sorting.
* if sa and sb have different transactions, return their xaccTransOrder * if sa and sb have different transactions, return their xaccTransOrder
* return a negative value if split sa has a smaller currency-value than sb, * return a negative value if split sa has a smaller currency-value than sb,
* return a positive value if split sa has a larger currency-value than sb, * return a positive value if split sa has a larger currency-value than sb,
@ -359,7 +359,8 @@ void xaccSplitMakeStockSplit(Split *s);
* Then it compares the reconciled flags, then the reconciled dates, * Then it compares the reconciled flags, then the reconciled dates,
* Finally, it returns zero if all of the above match. * Finally, it returns zero if all of the above match.
*/ */
int xaccSplitDateOrder (const Split *sa, const Split *sb); gint xaccSplitOrder (const Split *sa, const Split *sb);
gint xaccSplitOrderDateOnly (const Split *sa, const Split *sb);
/* /*

View File

@ -777,7 +777,7 @@ xaccTransGetAccountBalance (const Transaction *trans,
/* This test needs to correspond to the comparison function used when /* This test needs to correspond to the comparison function used when
sorting the splits for computing the running balance. */ sorting the splits for computing the running balance. */
if (xaccSplitDateOrder (last_split, split) < 0) if (xaccSplitOrder (last_split, split) < 0)
last_split = split; last_split = split;
} }

View File

@ -375,7 +375,7 @@ gnc_lot_get_earliest_split (GNCLot *lot)
{ {
if (! lot->splits) if (! lot->splits)
return NULL; return NULL;
lot->splits = g_list_sort (lot->splits, (GCompareFunc) xaccSplitDateOrder); lot->splits = g_list_sort (lot->splits, (GCompareFunc) xaccSplitOrderDateOnly);
return lot->splits->data; return lot->splits->data;
} }
@ -386,7 +386,7 @@ gnc_lot_get_latest_split (GNCLot *lot)
if (! lot->splits) if (! lot->splits)
return NULL; return NULL;
lot->splits = g_list_sort (lot->splits, (GCompareFunc) xaccSplitDateOrder); lot->splits = g_list_sort (lot->splits, (GCompareFunc) xaccSplitOrderDateOnly);
for (node = lot->splits; node->next; node = node->next) for (node = lot->splits; node->next; node = node->next)
; ;