mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
move reconciled field to split
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@375 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -659,12 +659,12 @@ xaccRecomputeBalance( Account * acc )
|
||||
share_balance += amt;
|
||||
dbalance += amt * (trans->share_price);
|
||||
|
||||
if( NREC != trans->reconciled ) {
|
||||
if( NREC != trans->credit_split.reconciled ) {
|
||||
share_cleared_balance += amt;
|
||||
dcleared_balance += amt * (trans->share_price);
|
||||
}
|
||||
|
||||
if( YREC == trans->reconciled ) {
|
||||
if( YREC == trans->credit_split.reconciled ) {
|
||||
share_reconciled_balance += amt;
|
||||
dreconciled_balance += amt * (trans->share_price);
|
||||
}
|
||||
@@ -884,7 +884,7 @@ xaccConsolidateTransactions (Account * acc)
|
||||
* we really must match everything to get a duplicate */
|
||||
if (ta->credit != tb->credit) continue;
|
||||
if (ta->debit != tb->debit) continue;
|
||||
if (ta->reconciled != tb->reconciled) continue;
|
||||
if (ta->credit_split.reconciled != tb->credit_split.reconciled) continue;
|
||||
if (ta->date.year != tb->date.year) continue;
|
||||
if (ta->date.month != tb->date.month) continue;
|
||||
if (ta->date.day != tb->date.day) continue;
|
||||
|
||||
@@ -307,7 +307,7 @@ adjBOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
/* fill out the rest of the fields */
|
||||
XtFree (trans->description);
|
||||
trans->description = XtNewString(ADJ_BALN_STR);
|
||||
trans->reconciled = NREC;
|
||||
xaccTransSetReconcile (trans, NREC);
|
||||
|
||||
pos = insertTransaction( acc, trans );
|
||||
|
||||
|
||||
25
src/FileIO.c
25
src/FileIO.c
@@ -485,6 +485,8 @@ readTransaction( int fd, Account *acc, int token )
|
||||
int dummy_category;
|
||||
Transaction *trans = 0x0;
|
||||
Split *split;
|
||||
char *tmp;
|
||||
char recn;
|
||||
|
||||
/* create a transaction structure with at least one split */
|
||||
trans = mallocTransaction();
|
||||
@@ -519,13 +521,15 @@ readTransaction( int fd, Account *acc, int token )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
trans->credit_split.memo = readString( fd, token );
|
||||
if( trans->credit_split.memo == NULL )
|
||||
tmp = readString( fd, token );
|
||||
if( NULL == tmp )
|
||||
{
|
||||
PERR ("Premature end of Transaction at memo");
|
||||
freeTransaction(trans);
|
||||
return NULL;
|
||||
}
|
||||
xaccTransSetMemo (trans, tmp);
|
||||
XtFree (tmp);
|
||||
|
||||
/* action first introduced in version 3 of the file format */
|
||||
if (3 <= token) {
|
||||
@@ -547,13 +551,14 @@ readTransaction( int fd, Account *acc, int token )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = read( fd, &(trans->reconciled), sizeof(char) );
|
||||
err = read( fd, &recn, sizeof(char) );
|
||||
if( err != sizeof(char) )
|
||||
{
|
||||
PERR ("Premature end of Transaction at reconciled");
|
||||
freeTransaction(trans);
|
||||
return NULL;
|
||||
}
|
||||
xaccTransSetReconcile (trans, recn);
|
||||
|
||||
if( 1 >= token ) {
|
||||
/* Note: this is for version 0 of file format only.
|
||||
@@ -561,15 +566,19 @@ readTransaction( int fd, Account *acc, int token )
|
||||
* aren't reconciled until you get your bank statement, and
|
||||
* use the reconcile window to mark the transaction reconciled
|
||||
*/
|
||||
if( trans->reconciled == YREC ) trans->reconciled = CREC;
|
||||
if( YREC == trans->credit_split.reconciled == YREC ) {
|
||||
xaccTransSetReconcile (trans, CREC);
|
||||
}
|
||||
}
|
||||
|
||||
/* make sure the value of trans->reconciled is valid...
|
||||
* I have to do this mainly for if I change what NREC and
|
||||
* YREC are defined to be... this way it might loose all
|
||||
* the reconciled data, but at least the field is valid */
|
||||
if( (trans->reconciled != YREC) && (trans->reconciled != CREC) )
|
||||
trans->reconciled = NREC;
|
||||
if( (YREC != trans->credit_split.reconciled) &&
|
||||
(CREC != trans->credit_split.reconciled) ) {
|
||||
xaccTransSetReconcile (trans, NREC);
|
||||
}
|
||||
|
||||
/* Version 1 files stored the amount as an integer,
|
||||
* with the amount recorded as pennies.
|
||||
@@ -689,7 +698,7 @@ readString( int fd, int token )
|
||||
if( err != size )
|
||||
{
|
||||
printf( "Error: readString: size = %d err = %d str = %s\n", size, err, str );
|
||||
_free(str);
|
||||
XtFree(str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1005,7 +1014,7 @@ writeTransaction( int fd, Transaction *trans )
|
||||
if( err != sizeof(int) )
|
||||
return -1;
|
||||
|
||||
err = write( fd, &(trans->reconciled), sizeof(char) );
|
||||
err = write( fd, &(trans->credit_split.reconciled), sizeof(char) );
|
||||
if( err != sizeof(char) )
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -114,11 +114,11 @@ recnRefresh( RecnWindow *recnData )
|
||||
{
|
||||
String rows[5];
|
||||
|
||||
if( trans->reconciled != YREC )
|
||||
if( YREC != trans->credit_split.reconciled )
|
||||
{
|
||||
double themount;
|
||||
|
||||
sprintf( buf, "%c", trans->reconciled );
|
||||
sprintf( buf, "%c", trans->credit_split.reconciled );
|
||||
rows[0] = XtNewString(buf);
|
||||
rows[1] = trans->num;
|
||||
sprintf( buf, "%2d/%2d/%02d",
|
||||
@@ -811,7 +811,7 @@ recnOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
if( recn[0] == YREC )
|
||||
{
|
||||
trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->debit, i );
|
||||
trans->reconciled = YREC;
|
||||
xaccTransSetReconcile (trans, YREC);
|
||||
/* mark the datafile as needing to be saved: */
|
||||
grp->saved = False;
|
||||
}
|
||||
@@ -825,7 +825,7 @@ recnOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
if( recn[0] == YREC )
|
||||
{
|
||||
trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->credit, i );
|
||||
trans->reconciled = YREC;
|
||||
xaccTransSetReconcile (trans, YREC);
|
||||
/* mark the datafile as needing to be saved: */
|
||||
grp->saved = False;
|
||||
}
|
||||
@@ -860,17 +860,17 @@ recnCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
XbaeMatrixSelectRow( mw, cbs->row );
|
||||
|
||||
/* If we are in the "reconciled" cell, toggle value */
|
||||
if( cbs->column == 0 )
|
||||
if( 0 == cbs->column )
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
String val = XbaeMatrixGetCell( mw, cbs->row, cbs->column );
|
||||
|
||||
if( val[0] == YREC )
|
||||
if( YREC == val[0] )
|
||||
{
|
||||
Transaction *trans =
|
||||
(Transaction *)XbaeMatrixGetRowUserData( mw, cbs->row );
|
||||
|
||||
sprintf( buf, "%c", trans->reconciled );
|
||||
sprintf( buf, "%c", trans->credit_split.reconciled );
|
||||
XbaeMatrixSetCell( mw, cbs->row, cbs->column, buf );
|
||||
}
|
||||
else
|
||||
|
||||
@@ -622,7 +622,7 @@ regRefresh( RegWindow *regData )
|
||||
sprintf( buf, "%s", trans->credit_split.memo );
|
||||
newData[row+MEMO_CELL_R][MEMO_CELL_C] = XtNewString(buf);
|
||||
|
||||
sprintf( buf, "%c", trans->reconciled );
|
||||
sprintf( buf, "%c", trans->credit_split.reconciled );
|
||||
newData[row+RECN_CELL_R][RECN_CELL_C] = XtNewString(buf);
|
||||
|
||||
sprintf( buf, "%s", trans->action );
|
||||
@@ -870,7 +870,7 @@ regRecalculateBalance( RegWindow *regData )
|
||||
dbalance += tmp;
|
||||
credit_acc -> running_balance = tmp;
|
||||
|
||||
if( NREC != trans->reconciled ) {
|
||||
if( NREC != trans->credit_split.reconciled ) {
|
||||
tmp = xaccGetClearedBalance (credit_acc, trans);
|
||||
dclearedBalance -= credit_acc -> running_cleared_balance;
|
||||
dclearedBalance += tmp;
|
||||
@@ -884,7 +884,7 @@ regRecalculateBalance( RegWindow *regData )
|
||||
dbalance += tmp;
|
||||
debit_acc -> running_balance = tmp;
|
||||
|
||||
if( NREC != trans->reconciled ) {
|
||||
if( NREC != trans->credit_split.reconciled ) {
|
||||
tmp = xaccGetClearedBalance (debit_acc, trans);
|
||||
dclearedBalance -= debit_acc -> running_cleared_balance;
|
||||
dclearedBalance += tmp;
|
||||
@@ -1402,9 +1402,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
{
|
||||
DEBUG("MOD_DESC\n");
|
||||
/* ... the description... */
|
||||
XtFree( trans->description );
|
||||
trans->description =
|
||||
XtNewString(
|
||||
xaccTransSetDescription (trans,
|
||||
XbaeMatrixGetCell(regData->reg,row+DESC_CELL_R,DESC_CELL_C) );
|
||||
}
|
||||
|
||||
@@ -1431,8 +1429,8 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
{
|
||||
DEBUG("MOD_RECN\n");
|
||||
/* ...the reconciled flag (char)... */
|
||||
trans->reconciled =
|
||||
(XbaeMatrixGetCell(regData->reg,row+RECN_CELL_R,RECN_CELL_C))[0];
|
||||
xaccTransSetReconcile (trans,
|
||||
(XbaeMatrixGetCell(regData->reg,row+RECN_CELL_R,RECN_CELL_C))[0]);
|
||||
}
|
||||
|
||||
if( regData->changed & MOD_AMNT )
|
||||
@@ -2850,7 +2848,7 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
trans = (Transaction *) XbaeMatrixGetRowUserData (regData->reg, currow);
|
||||
|
||||
/* If trans==NULL, then this must be a new transaction */
|
||||
if( (trans != NULL) && (trans->reconciled == YREC) )
|
||||
if( (trans != NULL) && (YREC == trans->credit_split.reconciled) )
|
||||
{
|
||||
char msg[BUFSIZE];
|
||||
sprintf( msg, RECN_TRANS_WARN );
|
||||
|
||||
@@ -135,7 +135,6 @@ initTransaction( Transaction * trans )
|
||||
|
||||
xaccInitSplit ( &(trans->credit_split));
|
||||
|
||||
trans->reconciled = NREC;
|
||||
trans->damount = 0.0;
|
||||
trans->share_price = 1.0;
|
||||
|
||||
@@ -188,7 +187,6 @@ implemented and tested.
|
||||
trans->num = 0x0;
|
||||
trans->description = 0x0;
|
||||
trans->action = 0x0;
|
||||
trans->reconciled = NREC;
|
||||
trans->damount = 0.0;
|
||||
trans->share_price = 1.0;
|
||||
|
||||
@@ -380,14 +378,27 @@ xaccCountTransactions (Transaction **tarray)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccTransSetDescription (Transaction *trans, char *desc)
|
||||
{
|
||||
if (trans->description) XtFree (trans->description);
|
||||
trans->description = XtNewString (desc);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xaccTransSetMemo (Transaction *trans, char *memo)
|
||||
{
|
||||
|
||||
if (trans->credit_split.memo) XtFree (trans->credit_split.memo);
|
||||
trans->credit_split.memo = XtNewString (memo);
|
||||
}
|
||||
|
||||
void
|
||||
xaccTransSetReconcile (Transaction *trans, char recn)
|
||||
{
|
||||
trans->credit_split.reconciled = recn;
|
||||
}
|
||||
|
||||
/************************ END OF ************************************\
|
||||
\************************* FILE *************************************/
|
||||
|
||||
|
||||
@@ -469,8 +469,8 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
trans->num = XtNewString("");
|
||||
|
||||
xaccTransSetMemo (trans, XmTextGetString(xferData->memo));
|
||||
trans->description = XmTextGetString(xferData->desc);
|
||||
trans->reconciled = NREC;
|
||||
xaccTransSetDescription (trans, XmTextGetString(xferData->desc));
|
||||
xaccTransSetReconcile (trans, NREC);
|
||||
|
||||
/* make note of which accounts this was transfered from & to */
|
||||
trans->debit = (struct _account *) getAccount(grp,xferData->from);
|
||||
|
||||
Reference in New Issue
Block a user