mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
almost done implementing splits
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@392 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
a8c79c7d4c
commit
124d1e5d74
@ -680,7 +680,7 @@ createCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
xaccTransSetDescription (trans, OPEN_BALN_STR);
|
xaccTransSetDescription (trans, OPEN_BALN_STR);
|
||||||
|
|
||||||
/* add the new transaction to the account */
|
/* add the new transaction to the account */
|
||||||
insertTransaction( acc, trans );
|
xaccInsertSplit (acc, &(trans->credit_split) );
|
||||||
|
|
||||||
/* once the account is set up, add it to account group
|
/* once the account is set up, add it to account group
|
||||||
* If the user indicated a parent acccount, make it a
|
* If the user indicated a parent acccount, make it a
|
||||||
|
@ -243,6 +243,35 @@ xaccInsertSplit ( Account *acc, Split *split )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************\
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
xaccRemoveSplit ( Account *acc, Split *split )
|
||||||
|
{
|
||||||
|
int i,j;
|
||||||
|
|
||||||
|
if (!acc) return;
|
||||||
|
if (!split) return;
|
||||||
|
|
||||||
|
/* mark the data file as needing to be saved: */
|
||||||
|
if( acc->parent != NULL ) acc->parent->saved = False;
|
||||||
|
|
||||||
|
for( i=0,j=0; j<acc->numSplits; i++,j++ ) {
|
||||||
|
acc->splits[i] = acc->splits[j];
|
||||||
|
if (split == acc->splits[i]) i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
split->acc = NULL;
|
||||||
|
|
||||||
|
acc->numSplits --;
|
||||||
|
|
||||||
|
/* make sure the array is NULL terminated */
|
||||||
|
acc->splits[acc->numSplits] = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* xaccRecomputeBalance *
|
* xaccRecomputeBalance *
|
||||||
* recomputes the partial balances and the current balance for *
|
* recomputes the partial balances and the current balance for *
|
||||||
@ -396,8 +425,8 @@ xaccCheckDateOrder (Account * acc, Split *split )
|
|||||||
|
|
||||||
/* take care of re-ordering, if necessary */
|
/* take care of re-ordering, if necessary */
|
||||||
if( outOfOrder ) {
|
if( outOfOrder ) {
|
||||||
removeTransaction( acc, position );
|
xaccRemoveSplit( acc, split );
|
||||||
insertTransaction( acc, split );
|
xaccInsertSplit( acc, split );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -672,7 +672,7 @@ readTransaction( int fd, Account *acc, int token )
|
|||||||
if (peer_acc) {
|
if (peer_acc) {
|
||||||
Split *split;
|
Split *split;
|
||||||
split = xaccMallocSplit ();
|
split = xaccMallocSplit ();
|
||||||
xaccAppendSplit (trans, split);
|
xaccTransAppendSplit (trans, split);
|
||||||
split -> acc = (struct _account *) peer_acc;
|
split -> acc = (struct _account *) peer_acc;
|
||||||
xaccInsertSplit (peer_acc, split);
|
xaccInsertSplit (peer_acc, split);
|
||||||
split->damount = -num_shares;
|
split->damount = -num_shares;
|
||||||
@ -718,7 +718,7 @@ readTransaction( int fd, Account *acc, int token )
|
|||||||
for (i=0; i<numSplits; i++) {
|
for (i=0; i<numSplits; i++) {
|
||||||
split = readSplit (fd, token);
|
split = readSplit (fd, token);
|
||||||
split->parent = trans;
|
split->parent = trans;
|
||||||
xaccAppendSplit( trans, split);
|
xaccTransAppendSplit( trans, split);
|
||||||
xaccInsertSplit( ((Account *) (split->acc)), split);
|
xaccInsertSplit( ((Account *) (split->acc)), split);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -696,7 +696,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
split -> parent = trans; /* parent transaction */
|
split -> parent = trans; /* parent transaction */
|
||||||
split -> acc = (struct _account *) xaccGetXferQIFAccount (acc, qifline);
|
split -> acc = (struct _account *) xaccGetXferQIFAccount (acc, qifline);
|
||||||
|
|
||||||
xaccAppendSplit (trans, split);
|
xaccTransAppendSplit (trans, split);
|
||||||
|
|
||||||
/* hack alert -- we should insert this split into
|
/* hack alert -- we should insert this split into
|
||||||
* the split account, and remove the L field */
|
* the split account, and remove the L field */
|
||||||
@ -788,7 +788,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
if (share_xfer) {
|
if (share_xfer) {
|
||||||
if (!split) {
|
if (!split) {
|
||||||
split = xaccMallocSplit ();
|
split = xaccMallocSplit ();
|
||||||
xaccAppendSplit (trans, split);
|
xaccTransAppendSplit (trans, split);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the transaction into the main brokerage
|
/* Insert the transaction into the main brokerage
|
||||||
@ -832,7 +832,7 @@ char * xaccReadQIFTransaction (int fd, Account *acc)
|
|||||||
if (xfer_acc) {
|
if (xfer_acc) {
|
||||||
if (!split) {
|
if (!split) {
|
||||||
split = xaccMallocSplit ();
|
split = xaccMallocSplit ();
|
||||||
xaccAppendSplit (trans, split);
|
xaccTransAppendSplit (trans, split);
|
||||||
}
|
}
|
||||||
split->acc = (struct _account *) xfer_acc;
|
split->acc = (struct _account *) xfer_acc;
|
||||||
xaccInsertSplit (xfer_acc, split);
|
xaccInsertSplit (xfer_acc, split);
|
||||||
|
@ -92,7 +92,7 @@ recnRefresh( RecnWindow *recnData )
|
|||||||
{
|
{
|
||||||
int i,nrows;
|
int i,nrows;
|
||||||
char buf[BUFSIZE];
|
char buf[BUFSIZE];
|
||||||
Transaction *trans;
|
Split *split;
|
||||||
Account *acc = recnData->acc;
|
Account *acc = recnData->acc;
|
||||||
|
|
||||||
/* NOTE: an improvement of the current design would be to use the
|
/* NOTE: an improvement of the current design would be to use the
|
||||||
@ -110,15 +110,17 @@ recnRefresh( RecnWindow *recnData )
|
|||||||
|
|
||||||
/* Add the non-reconciled transactions */
|
/* Add the non-reconciled transactions */
|
||||||
i=0;
|
i=0;
|
||||||
while( (trans=getTransaction(acc,i++)) != NULL )
|
split = acc->splits[i];
|
||||||
|
while( split)
|
||||||
{
|
{
|
||||||
String rows[5];
|
String rows[5];
|
||||||
|
Transaction *trans = split->parent;
|
||||||
|
|
||||||
if( YREC != trans->credit_split.reconciled )
|
if( YREC != split->reconciled )
|
||||||
{
|
{
|
||||||
double themount;
|
double themount;
|
||||||
|
|
||||||
sprintf( buf, "%c", trans->credit_split.reconciled );
|
sprintf( buf, "%c", split->reconciled );
|
||||||
rows[0] = XtNewString(buf);
|
rows[0] = XtNewString(buf);
|
||||||
rows[1] = trans->num;
|
rows[1] = trans->num;
|
||||||
sprintf( buf, "%2d/%2d/%02d",
|
sprintf( buf, "%2d/%2d/%02d",
|
||||||
@ -131,9 +133,9 @@ recnRefresh( RecnWindow *recnData )
|
|||||||
/* for stock accounts, show share quantity,
|
/* for stock accounts, show share quantity,
|
||||||
* not currency amount */
|
* not currency amount */
|
||||||
if ((STOCK == acc->type) || (MUTUAL == acc->type)) {
|
if ((STOCK == acc->type) || (MUTUAL == acc->type)) {
|
||||||
themount = xaccGetShareAmount (acc, trans);
|
themount = split->damount;
|
||||||
} else {
|
} else {
|
||||||
themount = xaccGetAmount (acc, trans);
|
themount = split->damount * split->share_price;
|
||||||
}
|
}
|
||||||
sprintf( buf, "%.2f", DABS(themount) );
|
sprintf( buf, "%.2f", DABS(themount) );
|
||||||
rows[4] = XtNewString(buf);
|
rows[4] = XtNewString(buf);
|
||||||
@ -142,13 +144,13 @@ recnRefresh( RecnWindow *recnData )
|
|||||||
{
|
{
|
||||||
XtVaGetValues( recnData->debit, XmNrows, &nrows, NULL );
|
XtVaGetValues( recnData->debit, XmNrows, &nrows, NULL );
|
||||||
XbaeMatrixAddRows( recnData->debit, nrows, rows, NULL, NULL, 1 );
|
XbaeMatrixAddRows( recnData->debit, nrows, rows, NULL, NULL, 1 );
|
||||||
XbaeMatrixSetRowUserData( recnData->debit, nrows, (XtPointer)trans );
|
XbaeMatrixSetRowUserData( recnData->debit, nrows, (XtPointer)split );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
XtVaGetValues( recnData->credit, XmNrows, &nrows, NULL );
|
XtVaGetValues( recnData->credit, XmNrows, &nrows, NULL );
|
||||||
XbaeMatrixAddRows( recnData->credit, nrows, rows, NULL, NULL, 1 );
|
XbaeMatrixAddRows( recnData->credit, nrows, rows, NULL, NULL, 1 );
|
||||||
XbaeMatrixSetRowUserData( recnData->credit,nrows, (XtPointer)trans );
|
XbaeMatrixSetRowUserData( recnData->credit,nrows, (XtPointer)split );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,7 +170,7 @@ recnRefresh( RecnWindow *recnData )
|
|||||||
void
|
void
|
||||||
recnRecalculateBalance( RecnWindow *recnData )
|
recnRecalculateBalance( RecnWindow *recnData )
|
||||||
{
|
{
|
||||||
Transaction *trans;
|
Split * split;
|
||||||
Account *acc = recnData ->acc;
|
Account *acc = recnData ->acc;
|
||||||
char *amt;
|
char *amt;
|
||||||
int i,nrows;
|
int i,nrows;
|
||||||
@ -188,11 +190,11 @@ recnRecalculateBalance( RecnWindow *recnData )
|
|||||||
String recn = XbaeMatrixGetCell( recnData->debit, i, 0 );
|
String recn = XbaeMatrixGetCell( recnData->debit, i, 0 );
|
||||||
if( recn[0] == YREC )
|
if( recn[0] == YREC )
|
||||||
{
|
{
|
||||||
trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->debit, i );
|
split = (Split *)XbaeMatrixGetRowUserData( recnData->debit, i );
|
||||||
if (shrs) {
|
if (shrs) {
|
||||||
ddebit += xaccGetShareAmount (acc, trans);
|
ddebit += split->damount;
|
||||||
} else {
|
} else {
|
||||||
ddebit += xaccGetAmount (acc, trans);
|
ddebit += split->damount * split->share_price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,11 +208,11 @@ recnRecalculateBalance( RecnWindow *recnData )
|
|||||||
String recn = XbaeMatrixGetCell( recnData->credit, i, 0 );
|
String recn = XbaeMatrixGetCell( recnData->credit, i, 0 );
|
||||||
if( recn[0] == YREC )
|
if( recn[0] == YREC )
|
||||||
{
|
{
|
||||||
trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->credit, i );
|
split = (Split *)XbaeMatrixGetRowUserData( recnData->credit, i );
|
||||||
if (shrs) {
|
if (shrs) {
|
||||||
dcredit += xaccGetShareAmount (acc, trans);
|
dcredit += split->damount;
|
||||||
} else {
|
} else {
|
||||||
dcredit += xaccGetAmount (acc, trans);
|
dcredit += split->damount * split->share_price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -799,7 +801,7 @@ void
|
|||||||
recnOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
recnOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||||
{
|
{
|
||||||
int nrows,i;
|
int nrows,i;
|
||||||
Transaction *trans;
|
Split *split;
|
||||||
RecnWindow *recnData = (RecnWindow *)cd;
|
RecnWindow *recnData = (RecnWindow *)cd;
|
||||||
AccountGroup *grp = topgroup; /* hack alert -- should pass as arg .. */
|
AccountGroup *grp = topgroup; /* hack alert -- should pass as arg .. */
|
||||||
|
|
||||||
@ -810,8 +812,8 @@ recnOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
String recn = XbaeMatrixGetCell( recnData->debit, i, 0 );
|
String recn = XbaeMatrixGetCell( recnData->debit, i, 0 );
|
||||||
if( recn[0] == YREC )
|
if( recn[0] == YREC )
|
||||||
{
|
{
|
||||||
trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->debit, i );
|
split = (Split *)XbaeMatrixGetRowUserData( recnData->debit, i );
|
||||||
xaccTransSetReconcile (trans, YREC);
|
split->reconciled = YREC;
|
||||||
/* mark the datafile as needing to be saved: */
|
/* mark the datafile as needing to be saved: */
|
||||||
grp->saved = False;
|
grp->saved = False;
|
||||||
}
|
}
|
||||||
@ -824,8 +826,8 @@ recnOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
String recn = XbaeMatrixGetCell( recnData->credit, i, 0 );
|
String recn = XbaeMatrixGetCell( recnData->credit, i, 0 );
|
||||||
if( recn[0] == YREC )
|
if( recn[0] == YREC )
|
||||||
{
|
{
|
||||||
trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->credit, i );
|
split = (Split *)XbaeMatrixGetRowUserData( recnData->credit, i );
|
||||||
xaccTransSetReconcile (trans, YREC);
|
split->reconciled = YREC;
|
||||||
/* mark the datafile as needing to be saved: */
|
/* mark the datafile as needing to be saved: */
|
||||||
grp->saved = False;
|
grp->saved = False;
|
||||||
}
|
}
|
||||||
@ -867,10 +869,10 @@ recnCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
|
|
||||||
if( YREC == val[0] )
|
if( YREC == val[0] )
|
||||||
{
|
{
|
||||||
Transaction *trans =
|
Split *split =
|
||||||
(Transaction *)XbaeMatrixGetRowUserData( mw, cbs->row );
|
(Split *)XbaeMatrixGetRowUserData( mw, cbs->row );
|
||||||
|
|
||||||
sprintf( buf, "%c", trans->credit_split.reconciled );
|
sprintf( buf, "%c", split->reconciled );
|
||||||
XbaeMatrixSetCell( mw, cbs->row, cbs->column, buf );
|
XbaeMatrixSetCell( mw, cbs->row, cbs->column, buf );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
* Huntington Beach, CA 92648-4632 *
|
* Huntington Beach, CA 92648-4632 *
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
|
#ifdef NOT_TODAY
|
||||||
|
|
||||||
#include <Xm/Xm.h>
|
#include <Xm/Xm.h>
|
||||||
#include <Xm/DialogS.h>
|
#include <Xm/DialogS.h>
|
||||||
#include <Xm/Form.h>
|
#include <Xm/Form.h>
|
||||||
@ -368,7 +370,12 @@ xaccGetDisplayAmountStrings (RegWindow *regData,
|
|||||||
Account * acc;
|
Account * acc;
|
||||||
int show_debit, show_credit;
|
int show_debit, show_credit;
|
||||||
|
|
||||||
acc = (Account *) (trans->debit);
|
/* hack alert -- should examine all splits ... */
|
||||||
|
if (trans->debit_splits[0]) {
|
||||||
|
acc = (Account *) ((trans->debit_splits[0]) -> acc);
|
||||||
|
} else {
|
||||||
|
acc = NULL;
|
||||||
|
}
|
||||||
show_debit = xaccIsAccountInList (acc, regData->blackacc);
|
show_debit = xaccIsAccountInList (acc, regData->blackacc);
|
||||||
|
|
||||||
acc = (Account *) (trans->credit_split.acc);
|
acc = (Account *) (trans->credit_split.acc);
|
||||||
@ -419,7 +426,13 @@ xaccGetDisplayAmountStrings (RegWindow *regData,
|
|||||||
* the account type is stock or mutual, since other types
|
* the account type is stock or mutual, since other types
|
||||||
* do not have shares. */
|
* do not have shares. */
|
||||||
show_debit = 0;
|
show_debit = 0;
|
||||||
acc = (Account *) (trans->debit);
|
|
||||||
|
/* hack alert -- should examine all splits ... */
|
||||||
|
if (trans->debit_splits[0]) {
|
||||||
|
acc = (Account *) ((trans->debit_splits[0]) -> acc);
|
||||||
|
} else {
|
||||||
|
acc = NULL;
|
||||||
|
}
|
||||||
if (acc) {
|
if (acc) {
|
||||||
if ((MUTUAL == acc->type) || (STOCK == acc->type) ) {
|
if ((MUTUAL == acc->type) || (STOCK == acc->type) ) {
|
||||||
show_debit = xaccIsAccountInList (acc, regData->blackacc);
|
show_debit = xaccIsAccountInList (acc, regData->blackacc);
|
||||||
@ -494,10 +507,10 @@ regRefresh( RegWindow *regData )
|
|||||||
{
|
{
|
||||||
if( regData != NULL )
|
if( regData != NULL )
|
||||||
{
|
{
|
||||||
Transaction *trans;
|
Split *split;
|
||||||
Transaction **tarray;
|
Split **sarray;
|
||||||
int old_num_rows, new_num_rows, delta_rows;
|
int old_num_rows, new_num_rows, delta_rows;
|
||||||
int i,j, ntrans, ncols;
|
int i,j, nsplits, ncols;
|
||||||
char buf[BUFSIZE];
|
char buf[BUFSIZE];
|
||||||
String **data = NULL;
|
String **data = NULL;
|
||||||
String **newData;
|
String **newData;
|
||||||
@ -513,17 +526,17 @@ regRefresh( RegWindow *regData )
|
|||||||
|
|
||||||
/* first, build a sorted array of transactions */
|
/* first, build a sorted array of transactions */
|
||||||
if (1 == regData->numAcc) {
|
if (1 == regData->numAcc) {
|
||||||
tarray = regData->blackacc[0]->transaction;
|
sarray = regData->blackacc[0]->splits;
|
||||||
ntrans = regData->blackacc[0]->numTrans;
|
nsplits = regData->blackacc[0]->numSplits;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
tarray = accListGetSortedTrans (regData->blackacc);
|
sarray = accListGetSortedSplits (regData->blackacc);
|
||||||
ntrans = xaccCountTransactions (tarray);
|
nsplits = xaccCountSplits (sarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate one extra transaction row. That extra row
|
/* Allocate one extra transaction row. That extra row
|
||||||
* is used to allow the user to add new transactions */
|
* is used to allow the user to add new transactions */
|
||||||
new_num_rows = NUM_ROWS_PER_TRANS*(ntrans+1) + NUM_HEADER_ROWS;
|
new_num_rows = NUM_ROWS_PER_TRANS*(nsplits+1) + NUM_HEADER_ROWS;
|
||||||
|
|
||||||
XtVaGetValues( regData->reg, XmNrows, &old_num_rows, NULL );
|
XtVaGetValues( regData->reg, XmNrows, &old_num_rows, NULL );
|
||||||
XtVaGetValues( regData->reg, XmNcells, &data, NULL );
|
XtVaGetValues( regData->reg, XmNcells, &data, NULL );
|
||||||
@ -557,10 +570,12 @@ regRefresh( RegWindow *regData )
|
|||||||
NULL, NULL, NULL, delta_rows );
|
NULL, NULL, NULL, delta_rows );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BROKEN_BECAUSE_OF_SPLITS
|
||||||
|
/* hack alert -- discard or fix this ... */
|
||||||
/* try to keep all amounts positive */
|
/* try to keep all amounts positive */
|
||||||
for (i=0; i<ntrans; i++) {
|
for (i=0; i<nsplits; i++) {
|
||||||
trans = tarray[i];
|
split = sarray[i];
|
||||||
if (0.0 > trans->damount) {
|
if (0.0 > split->damount) {
|
||||||
struct _account *tmp;
|
struct _account *tmp;
|
||||||
tmp = trans->credit_split.acc;
|
tmp = trans->credit_split.acc;
|
||||||
trans->credit_split.acc = trans->debit;
|
trans->credit_split.acc = trans->debit;
|
||||||
@ -568,15 +583,18 @@ regRefresh( RegWindow *regData )
|
|||||||
trans->damount = - (trans->damount);
|
trans->damount = - (trans->damount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* and fill in the data for the matrix: */
|
/* and fill in the data for the matrix: */
|
||||||
for (i=0; i<ntrans; i++) {
|
for (i=0; i<nsplits; i++) {
|
||||||
|
Transaction *trans;
|
||||||
int row;
|
int row;
|
||||||
|
|
||||||
trans = tarray[i];
|
split = sarray[i];
|
||||||
|
trans = split->parent;
|
||||||
row = NUM_ROWS_PER_TRANS*i + NUM_HEADER_ROWS;
|
row = NUM_ROWS_PER_TRANS*i + NUM_HEADER_ROWS;
|
||||||
|
|
||||||
XbaeMatrixSetRowUserData ( regData->reg, row, (XPointer) trans);
|
XbaeMatrixSetRowUserData ( regData->reg, row, (XPointer) split);
|
||||||
|
|
||||||
sprintf( buf, "%2d/%2d", trans->date.month, trans->date.day );
|
sprintf( buf, "%2d/%2d", trans->date.month, trans->date.day );
|
||||||
newData[row+DATE_CELL_R][DATE_CELL_C] = XtNewString(buf);
|
newData[row+DATE_CELL_R][DATE_CELL_C] = XtNewString(buf);
|
||||||
@ -592,10 +610,16 @@ regRefresh( RegWindow *regData )
|
|||||||
(INC_LEDGER == regData->type) ||
|
(INC_LEDGER == regData->type) ||
|
||||||
(PORTFOLIO == regData->type) ) {
|
(PORTFOLIO == regData->type) ) {
|
||||||
Account *xfer_acc;
|
Account *xfer_acc;
|
||||||
xfer_acc = (Account *) trans -> debit;
|
Split *deb;
|
||||||
if (xfer_acc) {
|
|
||||||
sprintf( buf, "%s", xfer_acc->accountName );
|
/* hack alert -- handle all splits ... */
|
||||||
newData[row+XFRM_CELL_R][XFRM_CELL_C] = XtNewString(buf);
|
deb = trans -> debit_splits[0];
|
||||||
|
if (deb) {
|
||||||
|
xfer_acc = (Account *) (deb->acc);
|
||||||
|
if (xfer_acc) {
|
||||||
|
sprintf( buf, "%s", xfer_acc->accountName );
|
||||||
|
newData[row+XFRM_CELL_R][XFRM_CELL_C] = XtNewString(buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xfer_acc = (Account *) trans -> credit_split.acc;
|
xfer_acc = (Account *) trans -> credit_split.acc;
|
||||||
if (xfer_acc) {
|
if (xfer_acc) {
|
||||||
@ -610,7 +634,9 @@ regRefresh( RegWindow *regData )
|
|||||||
Account *main_acc, *xfer_acc;
|
Account *main_acc, *xfer_acc;
|
||||||
|
|
||||||
main_acc = regData->blackacc[0];
|
main_acc = regData->blackacc[0];
|
||||||
xfer_acc = xaccGetOtherAccount (main_acc, trans);
|
|
||||||
|
/* hack alert -- should display all splits ... */
|
||||||
|
xfer_acc = (Account *) (split->parent->credit_split.acc);
|
||||||
if (xfer_acc) {
|
if (xfer_acc) {
|
||||||
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);
|
||||||
@ -619,13 +645,13 @@ regRefresh( RegWindow *regData )
|
|||||||
|
|
||||||
sprintf( buf, "%s", trans->description );
|
sprintf( buf, "%s", trans->description );
|
||||||
newData[row+DESC_CELL_R][DESC_CELL_C] = XtNewString(buf);
|
newData[row+DESC_CELL_R][DESC_CELL_C] = XtNewString(buf);
|
||||||
sprintf( buf, "%s", trans->credit_split.memo );
|
sprintf( buf, "%s", split->memo );
|
||||||
newData[row+MEMO_CELL_R][MEMO_CELL_C] = XtNewString(buf);
|
newData[row+MEMO_CELL_R][MEMO_CELL_C] = XtNewString(buf);
|
||||||
|
|
||||||
sprintf( buf, "%c", trans->credit_split.reconciled );
|
sprintf( buf, "%c", split->reconciled );
|
||||||
newData[row+RECN_CELL_R][RECN_CELL_C] = XtNewString(buf);
|
newData[row+RECN_CELL_R][RECN_CELL_C] = XtNewString(buf);
|
||||||
|
|
||||||
sprintf( buf, "%s", trans->action );
|
sprintf( buf, "%s", split->action );
|
||||||
newData[row+ACTN_CELL_R][ACTN_CELL_C] = XtNewString(buf);
|
newData[row+ACTN_CELL_R][ACTN_CELL_C] = XtNewString(buf);
|
||||||
|
|
||||||
/* ----------------------------------- */
|
/* ----------------------------------- */
|
||||||
@ -653,11 +679,11 @@ regRefresh( RegWindow *regData )
|
|||||||
|
|
||||||
case INC_LEDGER:
|
case INC_LEDGER:
|
||||||
case GEN_LEDGER:
|
case GEN_LEDGER:
|
||||||
themount = trans->damount * trans->share_price;
|
themount = split->damount * split->share_price;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PORTFOLIO:
|
case PORTFOLIO:
|
||||||
themount = trans->damount;
|
themount = split->damount;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -683,7 +709,7 @@ regRefresh( RegWindow *regData )
|
|||||||
break;
|
break;
|
||||||
case STOCK:
|
case STOCK:
|
||||||
case MUTUAL:
|
case MUTUAL:
|
||||||
sprintf( buf, "%.2f ", trans->share_price );
|
sprintf( buf, "%.2f ", split->share_price );
|
||||||
newData[row+PRCC_CELL_R][PRCC_CELL_C] = XtNewString(buf);
|
newData[row+PRCC_CELL_R][PRCC_CELL_C] = XtNewString(buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3377,4 +3403,5 @@ dateCellFormat( Widget mw, XbaeMatrixModifyVerifyCallbackStruct *mvcbs, int do_y
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/************************** END OF FILE *************************/
|
/************************** END OF FILE *************************/
|
||||||
|
@ -54,7 +54,6 @@ xaccInitSplit( Split * split )
|
|||||||
split->damount = 0.0;
|
split->damount = 0.0;
|
||||||
split->share_price = 1.0;
|
split->share_price = 1.0;
|
||||||
|
|
||||||
split->write_flag = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
@ -79,9 +78,10 @@ xaccFreeSplit( Split *split )
|
|||||||
* by any accounts. */
|
* by any accounts. */
|
||||||
if (split->acc) return;
|
if (split->acc) return;
|
||||||
|
|
||||||
xaccRemoveSplit (split);
|
xaccTransRemoveSplit (split->parent, split);
|
||||||
|
|
||||||
XtFree(split->memo);
|
XtFree(split->memo);
|
||||||
|
XtFree(split->action);
|
||||||
|
|
||||||
/* just in case someone looks up freed memory ... */
|
/* just in case someone looks up freed memory ... */
|
||||||
split->memo = 0x0;
|
split->memo = 0x0;
|
||||||
@ -90,7 +90,6 @@ xaccFreeSplit( Split *split )
|
|||||||
split->share_price = 1.0;
|
split->share_price = 1.0;
|
||||||
split->parent = NULL;
|
split->parent = NULL;
|
||||||
|
|
||||||
split->write_flag = 0;
|
|
||||||
_free(split);
|
_free(split);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +170,7 @@ initTransaction( Transaction * trans )
|
|||||||
trans->debit_splits[0] = NULL;
|
trans->debit_splits[0] = NULL;
|
||||||
|
|
||||||
xaccInitSplit ( &(trans->credit_split));
|
xaccInitSplit ( &(trans->credit_split));
|
||||||
trans->credit_split->parent = trans;
|
trans->credit_split.parent = trans;
|
||||||
|
|
||||||
trans->date.year = 1900;
|
trans->date.year = 1900;
|
||||||
trans->date.month = 1;
|
trans->date.month = 1;
|
||||||
@ -194,17 +193,22 @@ mallocTransaction( void )
|
|||||||
void
|
void
|
||||||
freeTransaction( Transaction *trans )
|
freeTransaction( Transaction *trans )
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
Split *s;
|
||||||
|
|
||||||
if (!trans) return;
|
if (!trans) return;
|
||||||
|
|
||||||
/* 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->credit_split.acc) return;
|
if (trans->credit_split.acc) return;
|
||||||
/*
|
|
||||||
hack alert -- don't do this until splits are fully
|
i = 0;
|
||||||
implemented and tested.
|
s = trans->debit_splits[i];
|
||||||
if (NULL != trans->debit_splits[0]) return;
|
while (s) {
|
||||||
*/
|
if (s->acc) return;
|
||||||
|
i++;
|
||||||
|
s = trans->debit_splits[i];
|
||||||
|
}
|
||||||
|
|
||||||
_free (trans->debit_splits);
|
_free (trans->debit_splits);
|
||||||
XtFree(trans->num);
|
XtFree(trans->num);
|
||||||
@ -256,7 +260,7 @@ xaccTransRecomputeAmount (Transaction *trans)
|
|||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
void
|
void
|
||||||
xaccAppendSplit (Transaction *trans, Split *split)
|
xaccTransAppendSplit (Transaction *trans, Split *split)
|
||||||
{
|
{
|
||||||
int i, num;
|
int i, num;
|
||||||
Split **oldarray;
|
Split **oldarray;
|
||||||
@ -286,17 +290,14 @@ xaccAppendSplit (Transaction *trans, Split *split)
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccRemoveSplit (Split *split)
|
xaccTransRemoveSplit (Transaction *trans, Split *split)
|
||||||
{
|
{
|
||||||
int i=0, n=0;
|
int i=0, n=0;
|
||||||
Split *s;
|
Split *s;
|
||||||
Transaction *trans;
|
|
||||||
|
|
||||||
if (!split) return;
|
if (!split) return;
|
||||||
trans = (Transaction *) split->parent;
|
|
||||||
split->parent = NULL;
|
|
||||||
|
|
||||||
if (!trans) return;
|
if (!trans) return;
|
||||||
|
split->parent = NULL;
|
||||||
|
|
||||||
s = trans->debit_splits[0];
|
s = trans->debit_splits[0];
|
||||||
while (s) {
|
while (s) {
|
||||||
@ -310,8 +311,6 @@ xaccRemoveSplit (Split *split)
|
|||||||
|
|
||||||
/* bring dollar amounts into synchrony */
|
/* bring dollar amounts into synchrony */
|
||||||
xaccTransRecomputeAmount (trans);
|
xaccTransRecomputeAmount (trans);
|
||||||
|
|
||||||
/* hack alert -- we should also remove it from the account */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
@ -345,7 +344,8 @@ xaccSplitOrder (Split **sa, Split **sb)
|
|||||||
if ( !(*sa) && (*sb) ) return +1;
|
if ( !(*sa) && (*sb) ) return +1;
|
||||||
if ( !(*sa) && !(*sb) ) return 0;
|
if ( !(*sa) && !(*sb) ) return 0;
|
||||||
|
|
||||||
retval = xaccTransOrder (sa->parent, sb->parent);
|
retval = xaccTransOrder ( ((Transaction **) &((*sa)->parent)),
|
||||||
|
((Transaction **) &((*sb)->parent)));
|
||||||
if (0 != retval) return retval;
|
if (0 != retval) return retval;
|
||||||
|
|
||||||
/* otherwise, sort on memo strings */
|
/* otherwise, sort on memo strings */
|
||||||
|
@ -442,6 +442,7 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
{
|
{
|
||||||
XferWindow *xferData = (XferWindow *)cd;
|
XferWindow *xferData = (XferWindow *)cd;
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
|
Split *split;
|
||||||
Account *acc;
|
Account *acc;
|
||||||
String str;
|
String str;
|
||||||
float val=0.0;
|
float val=0.0;
|
||||||
@ -456,7 +457,9 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
grp->saved = False;
|
grp->saved = False;
|
||||||
|
|
||||||
/* a double-entry transfer -- just one record, two accounts */
|
/* a double-entry transfer -- just one record, two accounts */
|
||||||
trans = mallocTransaction();
|
trans = mallocTransaction();
|
||||||
|
split = xaccMallocSplit();
|
||||||
|
xaccTransAppendSplit (trans, split);
|
||||||
|
|
||||||
/* Create the transaction */
|
/* Create the transaction */
|
||||||
str = XmTextGetString(xferData->date);
|
str = XmTextGetString(xferData->date);
|
||||||
@ -465,20 +468,18 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
&(trans->date.day), &(trans->date.year) );
|
&(trans->date.day), &(trans->date.year) );
|
||||||
str = XmTextGetString(xferData->amount);
|
str = XmTextGetString(xferData->amount);
|
||||||
sscanf( str, "%f", &val ); /* sscanf must take float not double arg */
|
sscanf( str, "%f", &val ); /* sscanf must take float not double arg */
|
||||||
trans->damount = val;
|
split->damount = -val;
|
||||||
trans->num = XtNewString("");
|
|
||||||
|
|
||||||
xaccTransSetMemo (trans, XmTextGetString(xferData->memo));
|
xaccTransSetMemo (trans, XmTextGetString(xferData->memo));
|
||||||
xaccTransSetDescription (trans, XmTextGetString(xferData->desc));
|
xaccTransSetDescription (trans, XmTextGetString(xferData->desc));
|
||||||
xaccTransSetReconcile (trans, NREC);
|
xaccTransSetReconcile (trans, NREC);
|
||||||
|
|
||||||
/* 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);
|
split->acc = (struct _account *) getAccount(grp,xferData->from);
|
||||||
trans->credit_split.acc = (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);
|
xaccInsertSplit (((Account *) (split->acc)), split);
|
||||||
insertTransaction( acc, trans );
|
|
||||||
|
|
||||||
/* Refresh the "from" account register window */
|
/* Refresh the "from" account register window */
|
||||||
regRefresh(acc->regData);
|
regRefresh(acc->regData);
|
||||||
@ -486,8 +487,7 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
recnRefresh(acc->recnData);
|
recnRefresh(acc->recnData);
|
||||||
|
|
||||||
/* insert transaction into to acount */
|
/* insert transaction into to acount */
|
||||||
acc = getAccount(grp,xferData->to);
|
xaccInsertSplit (((Account *) (trans->credit_split.acc)), &(trans->credit_split));
|
||||||
insertTransaction( acc, trans );
|
|
||||||
|
|
||||||
/* Refresh the "to" account register window */
|
/* Refresh the "to" account register window */
|
||||||
regRefresh(acc->regData);
|
regRefresh(acc->regData);
|
||||||
|
Loading…
Reference in New Issue
Block a user