mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
move credit account to split
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@376 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bf3d975da9
commit
a0e9dfb56f
@ -133,9 +133,9 @@ freeAccount( Account *acc )
|
|||||||
if (!trans) continue;
|
if (!trans) continue;
|
||||||
/* free the transaction only if its not
|
/* free the transaction only if its not
|
||||||
* a part of a double entry */
|
* a part of a double entry */
|
||||||
if (_acc == trans->credit) trans->credit = NULL;
|
if (_acc == trans->credit_split.acc) trans->credit_split.acc = NULL;
|
||||||
if (_acc == trans->debit) trans->debit = NULL;
|
if (_acc == trans->debit) trans->debit = NULL;
|
||||||
if ( (NULL == trans->debit) && (NULL == trans->credit) ) {
|
if ( (NULL == trans->debit) && (NULL == trans->credit_split.acc) ) {
|
||||||
freeTransaction( trans );
|
freeTransaction( trans );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,7 +257,8 @@ removeTransaction( Account *acc, int num )
|
|||||||
|
|
||||||
/* if this is a double-entry transaction, be sure to
|
/* if this is a double-entry transaction, be sure to
|
||||||
* unmark it. */
|
* unmark it. */
|
||||||
if (((Account *)trans->credit) == acc) trans->credit = NULL;
|
if (((Account *)trans->credit_split.acc) == acc)
|
||||||
|
trans->credit_split.acc = NULL;
|
||||||
if (((Account *)trans->debit) == acc) trans->debit = NULL;
|
if (((Account *)trans->debit) == acc) trans->debit = NULL;
|
||||||
|
|
||||||
return trans;
|
return trans;
|
||||||
@ -307,11 +308,11 @@ insertTransaction( Account *acc, Transaction *trans )
|
|||||||
* in another account, assume this is the other half.
|
* in another account, assume this is the other half.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( (acc != (Account *) trans->credit) &&
|
if ( (acc != (Account *) trans->credit_split.acc) &&
|
||||||
(acc != (Account *) trans->debit) ) {
|
(acc != (Account *) trans->debit) ) {
|
||||||
|
|
||||||
if (NULL == trans->credit) {
|
if (NULL == trans->credit_split.acc) {
|
||||||
trans->credit = (struct _account *) acc;
|
trans->credit_split.acc = (struct _account *) acc;
|
||||||
} else
|
} else
|
||||||
if (NULL == trans->debit) {
|
if (NULL == trans->debit) {
|
||||||
trans->debit = (struct _account *) acc;
|
trans->debit = (struct _account *) acc;
|
||||||
@ -323,7 +324,7 @@ insertTransaction( Account *acc, Transaction *trans )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans->debit == trans->credit) {
|
if (trans->debit == trans->credit_split.acc) {
|
||||||
printf ("Internal Error: insertTransaction(): \n");
|
printf ("Internal Error: insertTransaction(): \n");
|
||||||
printf ("debited and credit accounts cannot be the same\n");
|
printf ("debited and credit accounts cannot be the same\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -448,9 +449,9 @@ xaccGetOtherAccount( Account *acc, Transaction *trans )
|
|||||||
if (NULL == acc) return NULL;
|
if (NULL == acc) return NULL;
|
||||||
|
|
||||||
if (acc == ((Account *) trans->debit)) {
|
if (acc == ((Account *) trans->debit)) {
|
||||||
return ((Account *) trans->credit);
|
return ((Account *) trans->credit_split.acc);
|
||||||
} else
|
} else
|
||||||
if (acc == ((Account *) trans->credit)) {
|
if (acc == ((Account *) trans->credit_split.acc)) {
|
||||||
return ((Account *) trans->debit);
|
return ((Account *) trans->debit);
|
||||||
} else {
|
} else {
|
||||||
printf ("Internal Error: xaccGetOtherAccount(): inconsistent entry \n");
|
printf ("Internal Error: xaccGetOtherAccount(): inconsistent entry \n");
|
||||||
@ -477,19 +478,22 @@ double xaccGetAmount (Account *acc, Transaction *trans)
|
|||||||
double xaccGetShareAmount (Account *acc, Transaction *trans)
|
double xaccGetShareAmount (Account *acc, Transaction *trans)
|
||||||
{
|
{
|
||||||
double themount; /* amount */
|
double themount; /* amount */
|
||||||
|
struct _account *_acc = (struct _account *) acc;
|
||||||
|
|
||||||
if (NULL == trans) return 0.0;
|
if (NULL == trans) return 0.0;
|
||||||
if (NULL == acc) return 0.0;
|
if (NULL == acc) return 0.0;
|
||||||
|
|
||||||
/* for a double-entry, determine if this is a credit or a debit */
|
/* for a double-entry, determine if this is a credit or a debit */
|
||||||
if ( trans->credit == ((struct _account *) acc) ) {
|
if ( trans->credit_split.acc == _acc ) {
|
||||||
themount = trans->damount;
|
themount = trans->damount;
|
||||||
} else
|
} else
|
||||||
if ( trans->debit == ((struct _account *) acc) ) {
|
if ( trans->debit == _acc ) {
|
||||||
themount = - (trans->damount);
|
themount = - (trans->damount);
|
||||||
} else {
|
} else {
|
||||||
printf ("Internal Error: xaccGetShareAmount: missing double entry \n");
|
printf ("Internal Error: xaccGetShareAmount: missing double entry \n");
|
||||||
printf ("this error should not occur. Please report the problem. \n");
|
printf ("this error should not occur. Please report the problem. \n");
|
||||||
printf ("acc=%p deb=%p cred=%p\n", acc, trans->debit, trans->credit);
|
printf ("acc=%p deb=%p cred=%p\n",
|
||||||
|
acc, trans->debit, trans->credit_split.acc);
|
||||||
themount = 0.0; /* punt */
|
themount = 0.0; /* punt */
|
||||||
}
|
}
|
||||||
return themount;
|
return themount;
|
||||||
@ -500,11 +504,13 @@ double xaccGetShareAmount (Account *acc, Transaction *trans)
|
|||||||
|
|
||||||
void xaccSetShareAmount (Account *acc, Transaction *trans, double themount)
|
void xaccSetShareAmount (Account *acc, Transaction *trans, double themount)
|
||||||
{
|
{
|
||||||
|
struct _account *_acc = (struct _account *) acc;
|
||||||
|
|
||||||
/* for a double-entry, determine if this is a credit or a debit */
|
/* for a double-entry, determine if this is a credit or a debit */
|
||||||
if ( trans->credit == ((struct _account *) acc) ) {
|
if ( trans->credit_split.acc == _acc ) {
|
||||||
trans->damount = themount;
|
trans->damount = themount;
|
||||||
} else
|
} else
|
||||||
if ( trans->debit == ((struct _account *) acc) ) {
|
if ( trans->debit == _acc ) {
|
||||||
trans->damount = - themount;
|
trans->damount = - themount;
|
||||||
} else {
|
} else {
|
||||||
printf ("Internal Error: xaccSetShareAmount: missing double entry \n");
|
printf ("Internal Error: xaccSetShareAmount: missing double entry \n");
|
||||||
@ -530,12 +536,13 @@ void xaccSetAmount (Account *acc, Transaction *trans, double themount)
|
|||||||
double xaccGetBalance (Account *acc, Transaction *trans)
|
double xaccGetBalance (Account *acc, Transaction *trans)
|
||||||
{
|
{
|
||||||
double themount; /* amount */
|
double themount; /* amount */
|
||||||
|
struct _account *_acc = (struct _account *) acc;
|
||||||
|
|
||||||
/* for a double-entry, determine if this is a credit or a debit */
|
/* for a double-entry, determine if this is a credit or a debit */
|
||||||
if ( trans->credit == ((struct _account *) acc) ) {
|
if ( trans->credit_split.acc == _acc ) {
|
||||||
themount = trans->credit_balance;
|
themount = trans->credit_balance;
|
||||||
} else
|
} else
|
||||||
if ( trans->debit == ((struct _account *) acc) ) {
|
if ( trans->debit == _acc ) {
|
||||||
themount = trans->debit_balance;
|
themount = trans->debit_balance;
|
||||||
} else {
|
} else {
|
||||||
printf ("Internal Error: xaccGetBalance: missing double entry \n");
|
printf ("Internal Error: xaccGetBalance: missing double entry \n");
|
||||||
@ -551,12 +558,13 @@ double xaccGetBalance (Account *acc, Transaction *trans)
|
|||||||
double xaccGetClearedBalance (Account *acc, Transaction *trans)
|
double xaccGetClearedBalance (Account *acc, Transaction *trans)
|
||||||
{
|
{
|
||||||
double themount; /* amount */
|
double themount; /* amount */
|
||||||
|
struct _account *_acc = (struct _account *) acc;
|
||||||
|
|
||||||
/* for a double-entry, determine if this is a credit or a debit */
|
/* for a double-entry, determine if this is a credit or a debit */
|
||||||
if ( trans->credit == ((struct _account *) acc) ) {
|
if ( trans->credit_split.acc == _acc ) {
|
||||||
themount = trans->credit_cleared_balance;
|
themount = trans->credit_cleared_balance;
|
||||||
} else
|
} else
|
||||||
if ( trans->debit == ((struct _account *) acc) ) {
|
if ( trans->debit == _acc ) {
|
||||||
themount = trans->debit_cleared_balance;
|
themount = trans->debit_cleared_balance;
|
||||||
} else {
|
} else {
|
||||||
printf ("Internal Error: xaccGetClearedBalance: missing double entry \n");
|
printf ("Internal Error: xaccGetClearedBalance: missing double entry \n");
|
||||||
@ -572,12 +580,13 @@ double xaccGetClearedBalance (Account *acc, Transaction *trans)
|
|||||||
double xaccGetReconciledBalance (Account *acc, Transaction *trans)
|
double xaccGetReconciledBalance (Account *acc, Transaction *trans)
|
||||||
{
|
{
|
||||||
double themount; /* amount */
|
double themount; /* amount */
|
||||||
|
struct _account *_acc = (struct _account *) acc;
|
||||||
|
|
||||||
/* for a double-entry, determine if this is a credit or a debit */
|
/* for a double-entry, determine if this is a credit or a debit */
|
||||||
if ( trans->credit == ((struct _account *) acc) ) {
|
if ( trans->credit_split.acc == _acc ) {
|
||||||
themount = trans->credit_reconciled_balance;
|
themount = trans->credit_reconciled_balance;
|
||||||
} else
|
} else
|
||||||
if ( trans->debit == ((struct _account *) acc) ) {
|
if ( trans->debit == _acc ) {
|
||||||
themount = trans->debit_reconciled_balance;
|
themount = trans->debit_reconciled_balance;
|
||||||
} else {
|
} else {
|
||||||
printf ("Internal Error: xaccGetReconciledBalance: missing double entry \n");
|
printf ("Internal Error: xaccGetReconciledBalance: missing double entry \n");
|
||||||
@ -593,12 +602,13 @@ double xaccGetReconciledBalance (Account *acc, Transaction *trans)
|
|||||||
double xaccGetShareBalance (Account *acc, Transaction *trans)
|
double xaccGetShareBalance (Account *acc, Transaction *trans)
|
||||||
{
|
{
|
||||||
double themount; /* amount */
|
double themount; /* amount */
|
||||||
|
struct _account *_acc = (struct _account *) acc;
|
||||||
|
|
||||||
/* for a double-entry, determine if this is a credit or a debit */
|
/* for a double-entry, determine if this is a credit or a debit */
|
||||||
if ( trans->credit == ((struct _account *) acc) ) {
|
if ( trans->credit_split.acc == _acc ) {
|
||||||
themount = trans->credit_share_balance;
|
themount = trans->credit_share_balance;
|
||||||
} else
|
} else
|
||||||
if ( trans->debit == ((struct _account *) acc) ) {
|
if ( trans->debit == _acc ) {
|
||||||
themount = trans->debit_share_balance;
|
themount = trans->debit_share_balance;
|
||||||
} else {
|
} else {
|
||||||
printf ("Internal Error: xaccGetShareBalance: missing double entry \n");
|
printf ("Internal Error: xaccGetShareBalance: missing double entry \n");
|
||||||
@ -669,7 +679,7 @@ xaccRecomputeBalance( Account * acc )
|
|||||||
dreconciled_balance += amt * (trans->share_price);
|
dreconciled_balance += amt * (trans->share_price);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracc = (Account *) trans->credit;
|
tracc = (Account *) trans->credit_split.acc;
|
||||||
if (tracc == acc) {
|
if (tracc == acc) {
|
||||||
/* For bank accounts, the invarient subtotal is the dollar
|
/* For bank accounts, the invarient subtotal is the dollar
|
||||||
* amount. For stock accoounts, the invarient is the share amount */
|
* amount. For stock accoounts, the invarient is the share amount */
|
||||||
@ -797,7 +807,7 @@ xaccCheckDateOrderDE (Transaction *trans )
|
|||||||
|
|
||||||
if (NULL == trans) return 0;
|
if (NULL == trans) return 0;
|
||||||
|
|
||||||
acc = (Account *) (trans->credit);
|
acc = (Account *) (trans->credit_split.acc);
|
||||||
outOfOrder += xaccCheckDateOrder (acc, trans);
|
outOfOrder += xaccCheckDateOrder (acc, trans);
|
||||||
acc = (Account *) (trans->debit);
|
acc = (Account *) (trans->debit);
|
||||||
outOfOrder += xaccCheckDateOrder (acc, trans);
|
outOfOrder += xaccCheckDateOrder (acc, trans);
|
||||||
@ -882,7 +892,7 @@ xaccConsolidateTransactions (Account * acc)
|
|||||||
|
|
||||||
/* if no match, then continue on in the loop.
|
/* if no match, then continue on in the loop.
|
||||||
* we really must match everything to get a duplicate */
|
* we really must match everything to get a duplicate */
|
||||||
if (ta->credit != tb->credit) continue;
|
if (ta->credit_split.acc != tb->credit_split.acc) continue;
|
||||||
if (ta->debit != tb->debit) continue;
|
if (ta->debit != tb->debit) continue;
|
||||||
if (ta->credit_split.reconciled != tb->credit_split.reconciled) continue;
|
if (ta->credit_split.reconciled != tb->credit_split.reconciled) continue;
|
||||||
if (ta->date.year != tb->date.year) continue;
|
if (ta->date.year != tb->date.year) continue;
|
||||||
@ -898,13 +908,13 @@ xaccConsolidateTransactions (Account * acc)
|
|||||||
/* if we got to here, then there must be a duplicate. */
|
/* if we got to here, then there must be a duplicate. */
|
||||||
/* before deleting it, remove it from the other
|
/* before deleting it, remove it from the other
|
||||||
* double-entry account */
|
* double-entry account */
|
||||||
if (acc == (Account *) tb->credit) {
|
if (acc == (Account *) tb->credit_split.acc) {
|
||||||
xaccRemoveTransaction ((Account *) tb->debit, tb);
|
xaccRemoveTransaction ((Account *) tb->debit, tb);
|
||||||
}
|
}
|
||||||
if (acc == (Account *) tb->debit) {
|
if (acc == (Account *) tb->debit) {
|
||||||
xaccRemoveTransaction ((Account *) tb->credit, tb);
|
xaccRemoveTransaction ((Account *) tb->credit_split.acc, tb);
|
||||||
}
|
}
|
||||||
tb->credit = NULL;
|
tb->credit_split.acc = NULL;
|
||||||
tb->debit = NULL;
|
tb->debit = NULL;
|
||||||
|
|
||||||
/* Free the transaction, and shuffle down by one.
|
/* Free the transaction, and shuffle down by one.
|
||||||
|
@ -561,8 +561,10 @@ xaccMergeAccounts (AccountGroup *grp)
|
|||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
trans = acc_b->transaction[k];
|
trans = acc_b->transaction[k];
|
||||||
acc_b->transaction[k] = NULL;
|
acc_b->transaction[k] = NULL;
|
||||||
if (acc_b == (Account *) trans->debit) trans->debit = (struct _account *) acc_a;
|
if (acc_b == (Account *) trans->debit)
|
||||||
if (acc_b == (Account *) trans->credit) trans->credit = (struct _account *) acc_a;
|
trans->debit = (struct _account *) acc_a;
|
||||||
|
if (acc_b == (Account *) trans->credit_split.acc)
|
||||||
|
trans->credit_split.acc = (struct _account *) acc_a;
|
||||||
insertTransaction (acc_a, trans);
|
insertTransaction (acc_a, trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ readTransaction( int fd, Account *acc, int token )
|
|||||||
XACC_FLIP_INT (acc_id);
|
XACC_FLIP_INT (acc_id);
|
||||||
INFO_2 ("readTransaction(): credit %d\n", acc_id);
|
INFO_2 ("readTransaction(): credit %d\n", acc_id);
|
||||||
peer_acc = locateAccount (acc_id);
|
peer_acc = locateAccount (acc_id);
|
||||||
trans -> credit = (struct _account *) peer_acc;
|
trans -> credit_split.acc = (struct _account *) peer_acc;
|
||||||
|
|
||||||
/* insert the transaction into both the debit and
|
/* insert the transaction into both the debit and
|
||||||
* the credit accounts; first the credit ... */
|
* the credit accounts; first the credit ... */
|
||||||
@ -1032,7 +1032,7 @@ writeTransaction( int fd, Transaction *trans )
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* write the double-entry values */
|
/* write the double-entry values */
|
||||||
xfer_acc = (Account *) (trans->credit);
|
xfer_acc = (Account *) (trans->credit_split.acc);
|
||||||
acc_id = -1;
|
acc_id = -1;
|
||||||
if (xfer_acc) acc_id = xfer_acc -> id;
|
if (xfer_acc) acc_id = xfer_acc -> id;
|
||||||
INFO_2 ("writeTransaction: credit %d \n", acc_id);
|
INFO_2 ("writeTransaction: credit %d \n", acc_id);
|
||||||
|
12
src/QIFIO.c
12
src/QIFIO.c
@ -606,7 +606,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
|
|
||||||
if (!qifline) {
|
if (!qifline) {
|
||||||
xaccRemoveTransaction ((Account *) trans->debit, trans);
|
xaccRemoveTransaction ((Account *) trans->debit, trans);
|
||||||
xaccRemoveTransaction ((Account *) trans->credit, trans);
|
xaccRemoveTransaction ((Account *) trans->credit_split.acc, trans);
|
||||||
freeTransaction (trans);
|
freeTransaction (trans);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -774,7 +774,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
* transaction, and return */
|
* transaction, and return */
|
||||||
if ('!' == qifline[0]) {
|
if ('!' == qifline[0]) {
|
||||||
xaccRemoveTransaction ((Account *) trans->debit, trans);
|
xaccRemoveTransaction ((Account *) trans->debit, trans);
|
||||||
xaccRemoveTransaction ((Account *) trans->credit, trans);
|
xaccRemoveTransaction ((Account *) trans->credit_split.acc, trans);
|
||||||
freeTransaction (trans);
|
freeTransaction (trans);
|
||||||
return qifline;
|
return qifline;
|
||||||
}
|
}
|
||||||
@ -807,7 +807,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
* sub_acc; the security account is credited.
|
* sub_acc; the security account is credited.
|
||||||
* But, just in case its missing, avoid a core dump */
|
* But, just in case its missing, avoid a core dump */
|
||||||
if (sub_acc) {
|
if (sub_acc) {
|
||||||
trans->credit = (struct _account *) sub_acc;
|
trans->credit_split.acc = (struct _account *) sub_acc;
|
||||||
insertTransaction (sub_acc, trans);
|
insertTransaction (sub_acc, trans);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -819,10 +819,10 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
* account gets the dividend credit; otherwise, the
|
* account gets the dividend credit; otherwise, the
|
||||||
* main account gets it */
|
* main account gets it */
|
||||||
if (xfer_acc) {
|
if (xfer_acc) {
|
||||||
trans->credit = (struct _account *) xfer_acc;
|
trans->credit_split.acc = (struct _account *) xfer_acc;
|
||||||
insertTransaction (xfer_acc, trans);
|
insertTransaction (xfer_acc, trans);
|
||||||
} else {
|
} else {
|
||||||
trans->credit = (struct _account *) acc;
|
trans->credit_split.acc = (struct _account *) acc;
|
||||||
insertTransaction( acc, trans );
|
insertTransaction( acc, trans );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* the transaction itself appears as a credit */
|
/* the transaction itself appears as a credit */
|
||||||
trans->credit = (struct _account *) acc;
|
trans->credit_split.acc = (struct _account *) acc;
|
||||||
insertTransaction( acc, trans );
|
insertTransaction( acc, trans );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ xaccGetDisplayAmountStrings (RegWindow *regData,
|
|||||||
acc = (Account *) (trans->debit);
|
acc = (Account *) (trans->debit);
|
||||||
show_debit = xaccIsAccountInList (acc, regData->blackacc);
|
show_debit = xaccIsAccountInList (acc, regData->blackacc);
|
||||||
|
|
||||||
acc = (Account *) (trans->credit);
|
acc = (Account *) (trans->credit_split.acc);
|
||||||
show_credit = xaccIsAccountInList (acc, regData->blackacc);
|
show_credit = xaccIsAccountInList (acc, regData->blackacc);
|
||||||
|
|
||||||
/* attempt to keep all displayed quantities positive by
|
/* attempt to keep all displayed quantities positive by
|
||||||
@ -427,7 +427,7 @@ xaccGetDisplayAmountStrings (RegWindow *regData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
show_credit = 0;
|
show_credit = 0;
|
||||||
acc = (Account *) (trans->credit);
|
acc = (Account *) (trans->credit_split.acc);
|
||||||
if (acc) {
|
if (acc) {
|
||||||
if ((MUTUAL == acc->type) || (STOCK == acc->type) ) {
|
if ((MUTUAL == acc->type) || (STOCK == acc->type) ) {
|
||||||
show_credit = xaccIsAccountInList (acc, regData->blackacc);
|
show_credit = xaccIsAccountInList (acc, regData->blackacc);
|
||||||
@ -562,8 +562,8 @@ regRefresh( RegWindow *regData )
|
|||||||
trans = tarray[i];
|
trans = tarray[i];
|
||||||
if (0.0 > trans->damount) {
|
if (0.0 > trans->damount) {
|
||||||
struct _account *tmp;
|
struct _account *tmp;
|
||||||
tmp = trans->credit;
|
tmp = trans->credit_split.acc;
|
||||||
trans->credit = trans->debit;
|
trans->credit_split.acc = trans->debit;
|
||||||
trans->debit = tmp;
|
trans->debit = tmp;
|
||||||
trans->damount = - (trans->damount);
|
trans->damount = - (trans->damount);
|
||||||
}
|
}
|
||||||
@ -597,7 +597,7 @@ regRefresh( RegWindow *regData )
|
|||||||
sprintf( buf, "%s", xfer_acc->accountName );
|
sprintf( buf, "%s", xfer_acc->accountName );
|
||||||
newData[row+XFRM_CELL_R][XFRM_CELL_C] = XtNewString(buf);
|
newData[row+XFRM_CELL_R][XFRM_CELL_C] = XtNewString(buf);
|
||||||
}
|
}
|
||||||
xfer_acc = (Account *) trans -> credit;
|
xfer_acc = (Account *) trans -> credit_split.acc;
|
||||||
if (xfer_acc) {
|
if (xfer_acc) {
|
||||||
sprintf( buf, "%s", xfer_acc->accountName );
|
sprintf( buf, "%s", xfer_acc->accountName );
|
||||||
newData[row+XTO_CELL_R][XTO_CELL_C] = XtNewString(buf);
|
newData[row+XTO_CELL_R][XTO_CELL_C] = XtNewString(buf);
|
||||||
@ -703,7 +703,7 @@ regRefresh( RegWindow *regData )
|
|||||||
}
|
}
|
||||||
|
|
||||||
show_credit = 0;
|
show_credit = 0;
|
||||||
acc = (Account *) (trans->credit);
|
acc = (Account *) (trans->credit_split.acc);
|
||||||
if (acc) {
|
if (acc) {
|
||||||
if ( (MUTUAL == acc->type) || (STOCK == acc->type) ) {
|
if ( (MUTUAL == acc->type) || (STOCK == acc->type) ) {
|
||||||
show_credit = xaccIsAccountInList (acc, regData->blackacc);
|
show_credit = xaccIsAccountInList (acc, regData->blackacc);
|
||||||
@ -838,7 +838,7 @@ regRecalculateBalance( RegWindow *regData )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
credit_acc = (Account *) (trans->credit);
|
credit_acc = (Account *) (trans->credit_split.acc);
|
||||||
debit_acc = (Account *) (trans->debit);
|
debit_acc = (Account *) (trans->debit);
|
||||||
|
|
||||||
/* figure out if this transaction shows up as a debit
|
/* figure out if this transaction shows up as a debit
|
||||||
@ -1040,7 +1040,7 @@ regRecalculateBalance( RegWindow *regData )
|
|||||||
#else
|
#else
|
||||||
value = DABS(value);
|
value = DABS(value);
|
||||||
#endif
|
#endif
|
||||||
acc = (Account *) (trans->credit);
|
acc = (Account *) (trans->credit_split.acc);
|
||||||
show = xaccIsAccountInList (acc, regData->blackacc);
|
show = xaccIsAccountInList (acc, regData->blackacc);
|
||||||
/* show only if value is non-zero (it may be zero if a price
|
/* show only if value is non-zero (it may be zero if a price
|
||||||
* is recorded) */
|
* is recorded) */
|
||||||
@ -1067,7 +1067,7 @@ regRecalculateBalance( RegWindow *regData )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
acc = (Account *) (trans->credit);
|
acc = (Account *) (trans->credit_split.acc);
|
||||||
if (acc) {
|
if (acc) {
|
||||||
if ((MUTUAL == acc->type) || (STOCK == acc->type)) {
|
if ((MUTUAL == acc->type) || (STOCK == acc->type)) {
|
||||||
show += xaccIsAccountInList (acc, regData->blackacc);
|
show += xaccIsAccountInList (acc, regData->blackacc);
|
||||||
@ -1235,12 +1235,12 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
acc->parent->saved = False;
|
acc->parent->saved = False;
|
||||||
|
|
||||||
/* by default, new transactions are considered credits */
|
/* by default, new transactions are considered credits */
|
||||||
trans->credit = (struct _account *) acc;
|
trans->credit_split.acc = (struct _account *) acc;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Be sure to prompt the user to save to disk after changes are made! */
|
/* Be sure to prompt the user to save to disk after changes are made! */
|
||||||
Account *acc;
|
Account *acc;
|
||||||
acc = (Account *) trans->credit;
|
acc = (Account *) trans->credit_split.acc;
|
||||||
if (acc) acc->parent->saved = False;
|
if (acc) acc->parent->saved = False;
|
||||||
acc = (Account *) trans->debit;
|
acc = (Account *) trans->debit;
|
||||||
if (acc) acc->parent->saved = False;
|
if (acc) acc->parent->saved = False;
|
||||||
@ -1268,7 +1268,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
DEBUG("MOD_XTO_PHASE_ONE\n");
|
DEBUG("MOD_XTO_PHASE_ONE\n");
|
||||||
|
|
||||||
/* for a general ledger, from and to are easy to determine */
|
/* for a general ledger, from and to are easy to determine */
|
||||||
xfer_acct = (Account *) trans->credit;
|
xfer_acct = (Account *) trans->credit_split.acc;
|
||||||
|
|
||||||
if (xfer_acct) {
|
if (xfer_acct) {
|
||||||
/* remove the transaction from wherever it used to be */
|
/* remove the transaction from wherever it used to be */
|
||||||
@ -1320,7 +1320,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
/* if a transfer account exists, and we are not trying to transfer
|
/* if a transfer account exists, and we are not trying to transfer
|
||||||
* from ourself to ourself, then proceed, otheriwse ignore. */
|
* from ourself to ourself, then proceed, otheriwse ignore. */
|
||||||
if (xfer_acct) {
|
if (xfer_acct) {
|
||||||
if (((1 < regData->numAcc) && (xfer_acct != (Account *) (trans->credit)))
|
if (((1 < regData->numAcc) && (xfer_acct != (Account *) (trans->credit_split.acc)))
|
||||||
|| ((1 >= regData->numAcc) && (xfer_acct != regData->blackacc[0])) ) {
|
|| ((1 >= regData->numAcc) && (xfer_acct != regData->blackacc[0])) ) {
|
||||||
|
|
||||||
/* for a new transaction, the default will be that the
|
/* for a new transaction, the default will be that the
|
||||||
@ -1374,12 +1374,13 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
if (xfer_acct != ((Account *) (trans->debit))) {
|
if (xfer_acct != ((Account *) (trans->debit))) {
|
||||||
/* for a ledger, the transfer-to account is always
|
/* for a ledger, the transfer-to account is always
|
||||||
* the credited account. */
|
* the credited account. */
|
||||||
if (NULL != trans->credit) {
|
if (NULL != trans->credit_split.acc) {
|
||||||
printf ("Internal Error: regSaveTransaction(): ");
|
printf ("Internal Error: regSaveTransaction(): ");
|
||||||
printf ("the credited account is not null. \n");
|
printf ("the credited account is not null. \n");
|
||||||
printf (" was 0x%x will be 0x%x \n", trans->credit, xfer_acct);
|
printf (" was 0x%x will be 0x%x \n",
|
||||||
|
trans->credit_split.acc, xfer_acct);
|
||||||
}
|
}
|
||||||
trans->credit = (struct _account *)xfer_acct;
|
trans->credit_split.acc = (struct _account *)xfer_acct;
|
||||||
|
|
||||||
/* insert the transaction into the transfer account */
|
/* insert the transaction into the transfer account */
|
||||||
insertTransaction (xfer_acct, trans);
|
insertTransaction (xfer_acct, trans);
|
||||||
@ -1478,7 +1479,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
|
|
||||||
acc = (Account *) (trans->debit);
|
acc = (Account *) (trans->debit);
|
||||||
show += xaccIsAccountInList (acc, regData->blackacc);
|
show += xaccIsAccountInList (acc, regData->blackacc);
|
||||||
acc = (Account *) (trans->credit);
|
acc = (Account *) (trans->credit_split.acc);
|
||||||
show += xaccIsAccountInList (acc, regData->blackacc);
|
show += xaccIsAccountInList (acc, regData->blackacc);
|
||||||
|
|
||||||
themount = 0.0;
|
themount = 0.0;
|
||||||
@ -1578,7 +1579,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
|
|
||||||
/* for single-account registers, the insertion account
|
/* for single-account registers, the insertion account
|
||||||
* is always the credited account */
|
* is always the credited account */
|
||||||
trans->credit = (struct _account *) acc;
|
trans->credit_split.acc = (struct _account *) acc;
|
||||||
insertTransaction (acc, trans);
|
insertTransaction (acc, trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1591,7 +1592,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
* where to insert.
|
* where to insert.
|
||||||
*
|
*
|
||||||
* Warn the user about this. */
|
* Warn the user about this. */
|
||||||
if ((NULL == trans->credit) && (NULL == trans->debit)) {
|
if ((NULL == trans->credit_split.acc) && (NULL == trans->debit)) {
|
||||||
errorBox (toplevel, XFER_NO_ACC_MSG);
|
errorBox (toplevel, XFER_NO_ACC_MSG);
|
||||||
freeTransaction (trans);
|
freeTransaction (trans);
|
||||||
regData->changed = MOD_NONE;
|
regData->changed = MOD_NONE;
|
||||||
@ -1621,7 +1622,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
* recalculate the balances */
|
* recalculate the balances */
|
||||||
if( regData->changed & (MOD_XFRM | MOD_XTO | MOD_RECN |
|
if( regData->changed & (MOD_XFRM | MOD_XTO | MOD_RECN |
|
||||||
MOD_AMNT | MOD_PRIC | MOD_NEW)) {
|
MOD_AMNT | MOD_PRIC | MOD_NEW)) {
|
||||||
RECALC_BALANCE ((trans->credit));
|
RECALC_BALANCE ((trans->credit_split.acc));
|
||||||
RECALC_BALANCE ((trans->debit));
|
RECALC_BALANCE ((trans->debit));
|
||||||
|
|
||||||
/* if this is a ledger window, then we have to update
|
/* if this is a ledger window, then we have to update
|
||||||
@ -1644,7 +1645,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
REFRESH_REGISTER (old_xto_acct);
|
REFRESH_REGISTER (old_xto_acct);
|
||||||
}
|
}
|
||||||
|
|
||||||
REFRESH_REGISTER ((trans->credit));
|
REFRESH_REGISTER ((trans->credit_split.acc));
|
||||||
REFRESH_REGISTER ((trans->debit));
|
REFRESH_REGISTER ((trans->debit));
|
||||||
/* if this is a ledger window, then we have to update
|
/* if this is a ledger window, then we have to update
|
||||||
* it as well. If this is not a ledger window, one of
|
* it as well. If this is not a ledger window, one of
|
||||||
@ -1694,7 +1695,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
REFRESH_RECONCILE_WIN ((trans->credit));
|
REFRESH_RECONCILE_WIN ((trans->credit_split.acc));
|
||||||
REFRESH_RECONCILE_WIN ((trans->debit));
|
REFRESH_RECONCILE_WIN ((trans->debit));
|
||||||
|
|
||||||
regData->changed = MOD_NONE;
|
regData->changed = MOD_NONE;
|
||||||
@ -2678,7 +2679,7 @@ deleteCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
|
|
||||||
if( verifyBox( toplevel, buf ) )
|
if( verifyBox( toplevel, buf ) )
|
||||||
{
|
{
|
||||||
Account * cred = (Account *) (trans->credit);
|
Account * cred = (Account *) (trans->credit_split.acc);
|
||||||
Account * deb = (Account *) (trans->debit);
|
Account * deb = (Account *) (trans->debit);
|
||||||
|
|
||||||
/* remove the transaction from both accounts */
|
/* remove the transaction from both accounts */
|
||||||
|
@ -124,7 +124,6 @@ initTransaction( Transaction * trans )
|
|||||||
|
|
||||||
/* fill in some sane defaults */
|
/* fill in some sane defaults */
|
||||||
trans->debit = 0x0;
|
trans->debit = 0x0;
|
||||||
trans->credit = 0x0;
|
|
||||||
|
|
||||||
trans->num = XtNewString("");
|
trans->num = XtNewString("");
|
||||||
trans->description = XtNewString("");
|
trans->description = XtNewString("");
|
||||||
@ -171,7 +170,7 @@ freeTransaction( Transaction *trans )
|
|||||||
/* free a transaction only if it is not claimed
|
/* free a transaction only if it is not claimed
|
||||||
* by any accounts. */
|
* by any accounts. */
|
||||||
if (trans->debit) return;
|
if (trans->debit) return;
|
||||||
if (trans->credit) return;
|
if (trans->credit_split.acc) return;
|
||||||
/*
|
/*
|
||||||
hack alert -- don't do this until splits are fully
|
hack alert -- don't do this until splits are fully
|
||||||
implemented and tested.
|
implemented and tested.
|
||||||
|
@ -474,7 +474,7 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
|
|
||||||
/* make note of which accounts this was transfered from & to */
|
/* make note of which accounts this was transfered from & to */
|
||||||
trans->debit = (struct _account *) getAccount(grp,xferData->from);
|
trans->debit = (struct _account *) getAccount(grp,xferData->from);
|
||||||
trans->credit = (struct _account *) getAccount(grp,xferData->to);
|
trans->credit_split.acc = (struct _account *) getAccount(grp,xferData->to);
|
||||||
|
|
||||||
/* insert transaction into from acount */
|
/* insert transaction into from acount */
|
||||||
acc = getAccount(grp,xferData->from);
|
acc = getAccount(grp,xferData->from);
|
||||||
|
Loading…
Reference in New Issue
Block a user