How to remove all txns from an Account?

Charles Day cedayiv at gmail.com
Tue Apr 15 12:33:18 EDT 2008


What is the proper way to destroy all transactions that involve a particular
account?

I tried using xaccAccountTreeForEachTransaction(), but that uses
xaccAccountStagedTransactionTraversal() which has a limitation in that it
assumes that no splits are being removed from the account. Is this
limitation intentional?

So for example, the following code doesn't work and actually can cause
crashes:

/* Remove all the transactions in this account and its descendants. */
xaccAccountTreeForEachTransaction(acc, remove_transaction_cb, NULL);

---where remove_transaction_cb is defined as the following---

static gint
remove_transaction_cb(Transaction * trans, void * data)
{
  /* Destroy the transaction. */
  xaccTransDestroy(trans);

  return 0;
}

Cheers,
Charles


More information about the gnucash-devel mailing list