changes to handle reconciliation in stock accounts

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@294 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1997-12-06 00:17:27 +00:00
parent 238561ab85
commit 4f53829815

View File

@ -46,13 +46,14 @@
typedef struct _RecnWindow typedef struct _RecnWindow
{ {
Account *acc; /* The account that we are reconciling */ Account *acc; /* The account that we are reconciling */
double ddiff; /* The amount ($$$) to reconcile */ double ddiff; /* The amount to reconcile */
Widget dialog; /* The reconcile window dialog */ Widget dialog; /* The reconcile window dialog */
Widget difference; /* Text field, amount left to reconcile */ Widget difference; /* Text field, amount left to reconcile */
Widget totDebit; /* Text field, total debit reconciled */ Widget totDebit; /* Text field, total debit reconciled */
Widget totCredit; /* Text field, total credit reconciled */ Widget totCredit; /* Text field, total credit reconciled */
Widget debit; /* Debit matrix show unreconciled debit */ Widget debit; /* Debit matrix show unreconciled debit */
Widget credit; /* Credit matrix, shows credits... */ Widget credit; /* Credit matrix, shows credits... */
char * symbol; /* Currency symbol or 's' for shares */
} RecnWindow; } RecnWindow;
/** PROTOTYPES ******************************************************/ /** PROTOTYPES ******************************************************/
@ -115,7 +116,8 @@ recnRefresh( RecnWindow *recnData )
if( trans->reconciled != YREC ) if( trans->reconciled != YREC )
{ {
double themount = xaccGetAmount (acc, trans); double themount;
sprintf( buf, "%c", trans->reconciled ); sprintf( buf, "%c", trans->reconciled );
rows[0] = XtNewString(buf); rows[0] = XtNewString(buf);
rows[1] = trans->num; rows[1] = trans->num;
@ -125,6 +127,14 @@ recnRefresh( RecnWindow *recnData )
(trans->date.year%100) ); (trans->date.year%100) );
rows[2] = XtNewString(buf); rows[2] = XtNewString(buf);
rows[3] = trans->description; rows[3] = trans->description;
/* for stock accounts, show share quantity,
* not currency amount */
if ((STOCK == acc->type) || (MUTUAL == acc->type)) {
themount = xaccGetShareAmount (acc, trans);
} else {
themount = xaccGetAmount (acc, trans);
}
sprintf( buf, "%.2f", DABS(themount) ); sprintf( buf, "%.2f", DABS(themount) );
rows[4] = XtNewString(buf); rows[4] = XtNewString(buf);
@ -165,30 +175,45 @@ recnRecalculateBalance( RecnWindow *recnData )
double ddebit = 0.0; double ddebit = 0.0;
double dcredit = 0.0; double dcredit = 0.0;
double ddiff = 0.0; double ddiff = 0.0;
short shrs = 0;
if ((STOCK == acc->type) || (MUTUAL == acc->type)) shrs = 1;
/* Calculate the total debit: */ /* Calculate the total debit: */
ddebit = 0.0;
XtVaGetValues( recnData->debit, XmNrows, &nrows, NULL ); XtVaGetValues( recnData->debit, XmNrows, &nrows, NULL );
for( i=0; i<nrows; i++ ) for( i=0; i<nrows; i++ )
{ {
double tmp;
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 ); trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->debit, i );
if (shrs) {
ddebit += xaccGetShareAmount (acc, trans);
} else {
ddebit += xaccGetAmount (acc, trans); ddebit += xaccGetAmount (acc, trans);
} }
} }
}
/* Calculate the total credit: */ /* Calculate the total credit: */
dcredit = 0.0;
XtVaGetValues( recnData->credit, XmNrows, &nrows, NULL ); XtVaGetValues( recnData->credit, XmNrows, &nrows, NULL );
for( i=0; i<nrows; i++ ) for( i=0; i<nrows; i++ )
{ {
double tmp;
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 ); trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->credit, i );
if (shrs) {
dcredit += xaccGetShareAmount (acc, trans);
} else {
dcredit += xaccGetAmount (acc, trans); dcredit += xaccGetAmount (acc, trans);
} }
} }
}
/* Update the difference field, and the total fields */ /* Update the difference field, and the total fields */
sprintf( buf, " $ %.2f", DABS(ddebit) ); sprintf( buf, " $ %.2f", DABS(ddebit) );