Skip to content

Commit

Permalink
Bug 798568 - Transaction Copy/Paste problem
Browse files Browse the repository at this point in the history
When transactions are copied and pasted too the blank transaction on a
register in basic view the wrong split values are displayed. This is
due to the blank split being used for the wrong side of the transaction.

To fix this, if there is a pending transaction find the pending split
and use this to anchor the pasted transaction.
  • Loading branch information
Bob-IT committed Sep 15, 2024
1 parent 69dac5c commit fdb9fc2
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions gnucash/register/ledger-core/split-register-load.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@ add_completions_from_pre_filter_slist (TableLayout* layout, GList *pre_filter_sl
}
}

static Split *
get_default_anchor_split (Transaction* pending_trans, Transaction* blank_trans,
Split* pending_anchor_split, Split* blank_split)
{
// check if possible transaction paste to blank trans
if ((pending_trans == blank_trans) && pending_anchor_split)
return pending_anchor_split;
else
return blank_split;
}

void
gnc_split_register_load (SplitRegister* reg, GList* slist,
GList* pre_filter_slist, Account* default_account)
Expand All @@ -406,6 +417,7 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
Split* blank_split;
Split* find_split;
Split* split;
Split* pending_anchor_split = NULL;
Table* table;
GList* node;
gnc_commodity *account_comm = NULL;
Expand Down Expand Up @@ -595,9 +607,13 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
{
Split* pending_split = (Split*)node->data;
if (!xaccTransStillHasSplit (pending_trans, pending_split)) continue;

if (g_list_find (slist, pending_split) != NULL)
{
pending_anchor_split = pending_split;
continue;

}

if (g_list_find_custom (slist, pending_trans,
_find_split_with_parent_txn) != NULL)
continue;
Expand Down Expand Up @@ -635,8 +651,11 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
// used in the setting the rows insensitive
table->model->blank_trans_row = vcell_loc.virt_row;

gnc_split_register_add_transaction (reg,
blank_trans, blank_split,
// check if possible transaction paste to blank trans
Split* default_split = get_default_anchor_split (pending_trans, blank_trans,
pending_anchor_split, blank_split);

gnc_split_register_add_transaction (reg, blank_trans, default_split,
lead_cursor, split_cursor,
multi_line, start_primary_color,
info->blank_split_edited,
Expand Down Expand Up @@ -759,8 +778,11 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
// used in the setting the rows insensitive
table->model->blank_trans_row = vcell_loc.virt_row;

gnc_split_register_add_transaction (reg,
blank_trans, blank_split,
// check if possible transaction paste to blank trans
Split* default_split = get_default_anchor_split (pending_trans, blank_trans,
pending_anchor_split, blank_split);

gnc_split_register_add_transaction (reg, blank_trans, default_split,
lead_cursor, split_cursor,
multi_line, start_primary_color,
info->blank_split_edited,
Expand Down Expand Up @@ -855,7 +877,11 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
// used in the setting the rows insensitive
table->model->blank_trans_row = vcell_loc.virt_row;

gnc_split_register_add_transaction (reg, blank_trans, blank_split,
// check if possible transaction paste to blank trans
Split* default_split = get_default_anchor_split (pending_trans, blank_trans,
pending_anchor_split, blank_split);

gnc_split_register_add_transaction (reg, blank_trans, default_split,
lead_cursor, split_cursor,
multi_line, start_primary_color,
info->blank_split_edited,
Expand Down

0 comments on commit fdb9fc2

Please sign in to comment.