mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user