mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Sort the splits in a transaction when the transaction is committed,
not each time the view of the transaction is refreshed in the register. #92156 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7476 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
a0ec45ad40
commit
d1ff3b469e
10
ChangeLog
10
ChangeLog
@ -6,6 +6,16 @@
|
|||||||
|
|
||||||
2002-11-12 David Hampton <hampton@employees.org>
|
2002-11-12 David Hampton <hampton@employees.org>
|
||||||
|
|
||||||
|
* src/register/ledger-core/split-register-load.c
|
||||||
|
(gnc_split_register_add_transaction): Don't sort transaction
|
||||||
|
splits here. This function gets called every time you switch
|
||||||
|
splits, and so can reorder them just when you least expect
|
||||||
|
it. #92156
|
||||||
|
|
||||||
|
* src/engine/Transaction.c (xaccTransCommitEdit): Sort transaction
|
||||||
|
splits when the user has finished making changes to the
|
||||||
|
transaction. #92156
|
||||||
|
|
||||||
* src/register/ledger-core/split-register-control.c
|
* src/register/ledger-core/split-register-control.c
|
||||||
(gnc_split_register_traverse): Move the checking for non-existent
|
(gnc_split_register_traverse): Move the checking for non-existent
|
||||||
and placeholder accounts to a separate function, and call that new
|
and placeholder accounts to a separate function, and call that new
|
||||||
|
@ -1637,6 +1637,34 @@ xaccTransCommitEdit (Transaction *trans)
|
|||||||
/* ------------------------------------------------- */
|
/* ------------------------------------------------- */
|
||||||
/* OK, at this point, we are done making sure that
|
/* OK, at this point, we are done making sure that
|
||||||
* we've got a validly constructed transaction.
|
* we've got a validly constructed transaction.
|
||||||
|
*
|
||||||
|
* Next, sort the splits
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
GList *node, *new_list = NULL;
|
||||||
|
|
||||||
|
/* first debits */
|
||||||
|
for (node = trans->splits; node; node = node->next) {
|
||||||
|
split = node->data;
|
||||||
|
if (gnc_numeric_negative_p (xaccSplitGetValue (split)))
|
||||||
|
continue;
|
||||||
|
new_list = g_list_append(new_list, split);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* then credits */
|
||||||
|
for (node = trans->splits; node; node = node->next) {
|
||||||
|
split = node->data;
|
||||||
|
if (!gnc_numeric_negative_p (xaccSplitGetValue (split)))
|
||||||
|
continue;
|
||||||
|
new_list = g_list_append(new_list, split);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* install newly sorted list */
|
||||||
|
g_list_free(trans->splits);
|
||||||
|
trans->splits = new_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
* Next, we send it off to the back-end, to see if the
|
* Next, we send it off to the back-end, to see if the
|
||||||
* back-end will accept it.
|
* back-end will accept it.
|
||||||
*/
|
*/
|
||||||
|
@ -83,7 +83,6 @@ gnc_split_register_add_transaction (SplitRegister *reg,
|
|||||||
CellBlock *split_cursor,
|
CellBlock *split_cursor,
|
||||||
gboolean visible_splits,
|
gboolean visible_splits,
|
||||||
gboolean start_primary_color,
|
gboolean start_primary_color,
|
||||||
gboolean sort_splits,
|
|
||||||
gboolean add_blank,
|
gboolean add_blank,
|
||||||
Transaction *find_trans,
|
Transaction *find_trans,
|
||||||
Split *find_split,
|
Split *find_split,
|
||||||
@ -100,43 +99,6 @@ gnc_split_register_add_transaction (SplitRegister *reg,
|
|||||||
TRUE, start_primary_color, *vcell_loc);
|
TRUE, start_primary_color, *vcell_loc);
|
||||||
vcell_loc->virt_row++;
|
vcell_loc->virt_row++;
|
||||||
|
|
||||||
if (sort_splits)
|
|
||||||
{
|
|
||||||
/* first debits */
|
|
||||||
for (node = xaccTransGetSplitList (trans); node; node = node->next)
|
|
||||||
{
|
|
||||||
Split *secondary = node->data;
|
|
||||||
|
|
||||||
if (gnc_numeric_negative_p (xaccSplitGetValue (secondary)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (secondary == find_split && find_class == CURSOR_CLASS_SPLIT)
|
|
||||||
*new_split_row = vcell_loc->virt_row;
|
|
||||||
|
|
||||||
gnc_table_set_vcell (reg->table, split_cursor,
|
|
||||||
xaccSplitGetGUID (secondary),
|
|
||||||
visible_splits, TRUE, *vcell_loc);
|
|
||||||
vcell_loc->virt_row++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* then credits */
|
|
||||||
for (node = xaccTransGetSplitList (trans); node; node = node->next)
|
|
||||||
{
|
|
||||||
Split *secondary = node->data;
|
|
||||||
|
|
||||||
if (!gnc_numeric_negative_p (xaccSplitGetValue (secondary)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (secondary == find_split && find_class == CURSOR_CLASS_SPLIT)
|
|
||||||
*new_split_row = vcell_loc->virt_row;
|
|
||||||
|
|
||||||
gnc_table_set_vcell (reg->table, split_cursor,
|
|
||||||
xaccSplitGetGUID (secondary),
|
|
||||||
visible_splits, TRUE, *vcell_loc);
|
|
||||||
vcell_loc->virt_row++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
for (node = xaccTransGetSplitList (trans); node; node = node->next)
|
for (node = xaccTransGetSplitList (trans); node; node = node->next)
|
||||||
{
|
{
|
||||||
@ -409,7 +371,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
|||||||
gnc_split_register_add_transaction (reg, trans, split,
|
gnc_split_register_add_transaction (reg, trans, split,
|
||||||
lead_cursor, split_cursor,
|
lead_cursor, split_cursor,
|
||||||
multi_line, start_primary_color,
|
multi_line, start_primary_color,
|
||||||
TRUE, TRUE,
|
TRUE,
|
||||||
find_trans, find_split, find_class,
|
find_trans, find_split, find_class,
|
||||||
&new_split_row, &vcell_loc);
|
&new_split_row, &vcell_loc);
|
||||||
|
|
||||||
@ -446,7 +408,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
|
|||||||
|
|
||||||
gnc_split_register_add_transaction (reg, trans, split,
|
gnc_split_register_add_transaction (reg, trans, split,
|
||||||
lead_cursor, split_cursor,
|
lead_cursor, split_cursor,
|
||||||
multi_line, start_primary_color, FALSE,
|
multi_line, start_primary_color,
|
||||||
info->blank_split_edited, find_trans,
|
info->blank_split_edited, find_trans,
|
||||||
find_split, find_class, &new_split_row,
|
find_split, find_class, &new_split_row,
|
||||||
&vcell_loc);
|
&vcell_loc);
|
||||||
|
Loading…
Reference in New Issue
Block a user