mplement ability to delete a transaction

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@486 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-02-02 02:13:18 +00:00
parent 8348efbfad
commit 87e4ad928f

View File

@ -828,35 +828,63 @@ static void
deleteCB( Widget mw, XtPointer cd, XtPointer cb ) deleteCB( Widget mw, XtPointer cd, XtPointer cb )
{ {
RegWindow *regData = (RegWindow *)cd; RegWindow *regData = (RegWindow *)cd;
Split * split;
Transaction *trans; Transaction *trans;
int currow;
#ifdef JUNK
if( NULL != trans)
{
char buf[BUFSIZE]; char buf[BUFSIZE];
int num_splits;
/* get the current split based on cursor position */
split = xaccGetCurrentSplit (regData->ledger);
if (NULL == split ) return;
/* ask for user confirmation before performing
* permanent daamge */
trans = (Transaction *) split->parent;
sprintf (buf, TRANS_DEL_MSG, trans->description); sprintf (buf, TRANS_DEL_MSG, trans->description);
if (!verifyBox (toplevel, buf)) return;
if( verifyBox( toplevel, buf ) ) /* if this split is the credit split, or if it
{ * is the only debit split for this transaction,
Account * cred = (Account *) (trans->credit_split.acc); * then delete the entire transaction; otherwise,
Account * deb = (Account *) (trans->debit); * delete only the split, and readjust the
* transaction totals.
*/
num_splits = xaccCountSplits (trans->debit_splits);
if ((split == &(trans->credit_split)) || (1 >= num_splits)) {
Account *acc;
int i = 0;
/* remove the transaction from both accounts */ /* loop over all of the debit splits, killing each of them */
REMOVE_TRANS (cred, trans); split = trans->debit_splits[i];
REMOVE_TRANS (deb, trans); while (split) {
acc = (Account *) (split->acc);
xaccRemoveSplit (acc, split);
xaccFreeSplit (split);
RECALC_BALANCE (deb); i++;
RECALC_BALANCE (cred); split = trans->debit_splits[i];
REFRESH_REGISTER (deb);
REFRESH_REGISTER (cred);
/* Delete the transaction */
freeTransaction (trans);
} }
/* kill the credit split */
acc = (Account *) (trans->credit_split.acc);
xaccRemoveSplit (acc, &(trans->credit_split));
xaccFreeTransaction (trans);
} else {
Account *credit_acc, *debit_acc;
debit_acc = (Account *) (split->acc);
credit_acc = (Account *) (trans->credit_split.acc);
xaccTransRemoveSplit (trans, split);
xaccTransRecomputeAmount (trans);
xaccRemoveSplit (debit_acc, split);
split->acc = NULL;
xaccFreeSplit (split);
accRefresh (debit_acc);
accRefresh (credit_acc);
} }
#endif
} }
/********************************************************************\ /********************************************************************\