prevent transfers from/to same account

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@242 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1997-12-02 08:05:08 +00:00
parent e605c00283
commit 3b37a3cc38
2 changed files with 13 additions and 2 deletions

View File

@ -300,6 +300,12 @@ insertTransaction( Account *acc, Transaction *trans )
}
}
if (trans->debit == trans->credit) {
printf ("Internal Error: insertTransaction(): \n");
printf ("debited and credit accounts cannot be the same\n");
return -1;
}
/* mark the data file as needing to be saved: */
if( acc->parent != NULL ) acc->parent->saved = False;

View File

@ -1173,8 +1173,13 @@ regSaveTransaction( RegWindow *regData, int position )
/* get the new account from the name */
xfer_acct = xaccGetAccountFromName (topgroup, name);
if (xfer_acct) {
/* if a transfer account exists, and we are not trying to transfer
* from ourself to ourself, then proceed, otheriwse ignore. */
/* hack alert -- should put up a popup warning if user tries
* to transfer from & to the same account -- the two must differ! */
if (xfer_acct && ( ((1 < regData->numAcc) && (xfer_acct != (Account *) (trans->credit)))
|| ((1 >= regData->numAcc) && (xfer_acct != regData->blackacc[0])) )) {
/* for a new transaction, the default will be that the
* transfer occurs from the debited account */
if( regData->changed & MOD_NEW) {