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 to 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, record the copied anchor split index and use that to
reference the blank split when the transaction is pasted.
  • Loading branch information
Bob-IT committed Sep 21, 2024
1 parent 521b974 commit 35cd037
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gnucash/register/ledger-core/split-register.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ typedef struct
};
CursorClass cursor_class;
GncGUID leader_guid;
gint anchor_split_index;
} ft_fs_store;

static ft_fs_store copied_item = { 0, { NULL } };
Expand Down Expand Up @@ -101,6 +102,7 @@ clear_copied_item()
copied_item.ft = NULL;
copied_item.cursor_class = CURSOR_CLASS_NONE;
copied_item.leader_guid = *guid_null();
copied_item.anchor_split_index = 0;
}

static void
Expand Down Expand Up @@ -828,6 +830,7 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
}

copied_item.leader_guid = info->default_account;
copied_item.anchor_split_index = xaccTransGetSplitIndex (trans, split);
}
}

Expand Down Expand Up @@ -1082,7 +1085,11 @@ gnc_split_register_paste_current (SplitRegister* reg)
if (trans == blank_trans)
{
/* In pasting, the blank split is deleted. Pick a new one. */
blank_split = xaccTransGetSplit (trans, 0);
gint anchor_split_index = copied_item.anchor_split_index;
if (anchor_split_index > num_splits)
anchor_split_index = 0;

blank_split = xaccTransGetSplit (trans, anchor_split_index);
info->blank_split_guid = *xaccSplitGetGUID (blank_split);
info->blank_split_edited = TRUE;
info->auto_complete = FALSE;
Expand Down

0 comments on commit 35cd037

Please sign in to comment.