mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:38:25 -06:00
Bug 798983 - Empty Orphan account appears after entering transactions in 5.3
Caused by trying to set the account on the blank split. The blank split was present because the method used to clear the split list for the receiving transaction in gnc_float_txn_to_txn_swap_accounts only removed splits that belong to the transaction, and the blank split doesn't. Adds new function xaccTransClearSplits to do a more thorough job. Also improve the documentation for xaccSplitDestroy to better explain when a transaction will be destroyed if it empties the split list. # Please enter the commit message for your changes. Lines starting
This commit is contained in:
parent
76ac345edb
commit
89360252fb
@ -400,9 +400,8 @@ void gnc_float_txn_to_txn_swap_accounts (const FloatingTxn *ft, Transaction *txn
|
||||
xaccTransSetDatePostedSecs (txn, ft->m_date_posted);
|
||||
|
||||
/* strip off the old splits */
|
||||
while (xaccTransCountSplits (txn))
|
||||
xaccSplitDestroy (xaccTransGetSplit (txn, 0));
|
||||
|
||||
xaccTransClearSplits(txn);
|
||||
|
||||
/* and put on the new ones! Please note they go in the *same*
|
||||
order as in the original transaction. This is important. */
|
||||
for (iter = ft->m_splits; iter; iter = iter->next)
|
||||
|
@ -108,9 +108,10 @@ void xaccSplitReinit(Split * split);
|
||||
* leaving the accounting structure out-of-balance or otherwise
|
||||
* inconsistent.
|
||||
*
|
||||
* If the deletion of the split leaves the transaction with no splits,
|
||||
* then the transaction will be marked for deletion. (It will not be
|
||||
* deleted until the xaccTransCommitEdit() routine is called.)
|
||||
* It begins and commits an edit on the transaction, so if after the
|
||||
* split is removed the transaction has no more splits and if is not
|
||||
* open it too will be destroyed, as it will if the outer edits are
|
||||
* committed without adding transactions.
|
||||
*
|
||||
* @return TRUE upon successful deletion of the split. FALSE when
|
||||
* the parenting Transaction is a read-only one.
|
||||
|
@ -2232,6 +2232,15 @@ xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
void
|
||||
xaccTransClearSplits(Transaction* trans)
|
||||
{
|
||||
xaccTransBeginEdit(trans);
|
||||
FOR_EACH_SPLIT(trans, xaccSplitDestroy(s));
|
||||
g_list_free (trans->splits);
|
||||
trans->splits = NULL;
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
|
||||
Split *
|
||||
xaccTransGetSplit (const Transaction *trans, int i)
|
||||
|
@ -359,6 +359,17 @@ void xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
|
||||
/** Returns whether this transaction is a "closing transaction" */
|
||||
gboolean xaccTransGetIsClosingTxn (const Transaction *trans);
|
||||
|
||||
/** Remove all splits from the transaction
|
||||
*
|
||||
* Clears the split list of the transaction. All splits that the
|
||||
* transaction still owns will be destroyed, and others will be
|
||||
* unlinked.
|
||||
*
|
||||
* Opens and commits an edit on the transaction, so this will destroy
|
||||
* the transaction if it isn't already open, as will committing the
|
||||
* outer edits if new splits are not added before hand.
|
||||
*/
|
||||
void xaccTransClearSplits(Transaction* trans);
|
||||
|
||||
/** Add a split to the transaction
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user