Use utf8 collation routines when sorting splits in a register. Also,

only sort on the date of transactions (not date and time) since
gnucash doesn't allow times to be input.  Fixes #127809.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13497 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton
2006-03-05 21:14:19 +00:00
parent 7f4c6402e0
commit 399f475f2c
3 changed files with 36 additions and 13 deletions

View File

@@ -1,3 +1,11 @@
2006-03-05 David Hampton <hampton@employees.org>
* src/engine/Transaction.c:
* src/engine/Split.c: Use utf8 collation routines when sorting
splits in a register. Also, only sort on the date of
transactions (not date and time) since gnucash doesn't allow times
to be input. Fixes #127809.
2006-03-05 Joshua Sled <jsled@asynchronous.org>
* packaging/gnucash-1.9.x.ebuild: Add checks for libgsf and

View File

@@ -1108,14 +1108,18 @@ xaccSplitDateOrder (const Split *sa, const Split *sb)
if (retval) return retval;
/* otherwise, sort on memo strings */
da = sa->memo;
db = sb->memo;
SAFE_STRCMP (da, db);
da = sa->memo ? sa->memo : "";
db = sb->memo ? sb->memo : "";
retval = g_utf8_collate (da, db);
if (retval)
return retval;
/* otherwise, sort on action strings */
da = sa->action;
db = sb->action;
SAFE_STRCMP (da, db);
da = sa->action ? sa->action : "";
db = sb->action ? sb->action : "";
retval = g_utf8_collate (da, db);
if (retval != 0)
return retval;
/* the reconciled flag ... */
if (sa->reconciled < sb->reconciled) return -1;
@@ -1242,7 +1246,7 @@ xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb)
ab = sb->acc;
full_a = xaccAccountGetFullName(aa);
full_b = xaccAccountGetFullName(ab);
retval = safe_strcmp(full_a, full_b);
retval = g_utf8_collate(full_a, full_b);
g_free(full_a);
g_free(full_b);
return retval;

View File

@@ -1203,18 +1203,25 @@ xaccTransGetVersion (const Transaction *trans)
return trans ? trans->version : 0;
}
#define SECS_PER_DAY 86400
int
xaccTransOrder (const Transaction *ta, const Transaction *tb)
{
char *da, *db;
int na, nb;
int na, nb, retval;
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);
/* Only sort on the date, since time info isn't displayed */
na = ta->date_posted.tv_sec / SECS_PER_DAY;
nb = tb->date_posted.tv_sec / SECS_PER_DAY;
if (na < nb)
return -1;
if (na > nb)
return 1;
/* otherwise, sort on number string */
na = atoi(ta->num);
@@ -1222,13 +1229,17 @@ xaccTransOrder (const Transaction *ta, const Transaction *tb)
if (na < nb) return -1;
if (na > nb) return +1;
#ifdef ANYONE_CARES_ABOUT_SORT_ON_DATE_ENTERED
/* if dates differ, return */
DATE_CMP(ta,tb,date_entered);
#endif
/* otherwise, sort on description string */
da = ta->description;
db = tb->description;
SAFE_STRCMP (da, db);
da = ta->description ? ta->description : "";
db = tb->description ? tb->description : "";
retval = g_utf8_collate (da, db);
if (retval)
return retval;
/* else, sort on guid - keeps sort stable. */
return guid_compare(&(ta->inst.entity.guid), &(tb->inst.entity.guid));