add datte reconciled to file format

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1283 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/xacc-12-patch
Linas Vepstas 28 years ago
parent 539af447a7
commit f89fbf4fa4

@ -54,8 +54,8 @@
* numGroups (Group)^numGroups *
* Transaction ::== num date_entered date_posted description *
* numSplits (Split)^numSplits *
* Split ::== memo action reconciled *
* amount share_price account *
* Split ::== memo action reconciled date_recned *
* amount share_price account *
* token ::== int [the version of file format == VERSION] *
* numTrans ::== int *
* numAccounts ::== int *
@ -72,6 +72,7 @@
* num ::== String *
* date_entered::== Date *
* date_posted ::== Date *
* date_recned ::== Date *
* description ::== String *
* memo ::== String *
* action ::== String *
@ -989,6 +990,25 @@ readSplit ( int fd, int token )
}
xaccSplitSetReconcile (split, recn);
/* version 8 and newwer files store date-reconciled */
if (8 <= token) {
struct timespec ts;
int rc;
rc = readTSDate( fd, &ts, token );
if( -1 == rc )
{
PERR ("Premature end of Split at date");
xaccSplitDestroy (split);
return NULL;
}
xaccSplitSetDateReconciledTS (split, &ts);
} else {
time_t now;
now = time (0);
xaccSplitSetDateReconciledSecs (split, now);
}
/* first, read number of shares ... */
err = read( fd, &num_shares, sizeof(double) );
if( sizeof(double) != err )
@ -1513,6 +1533,7 @@ writeSplit ( int fd, Split *split )
{
int err=0;
int acc_id;
struct timespec ts;
double damount;
Account *xfer_acc;
char recn;
@ -1531,6 +1552,10 @@ writeSplit ( int fd, Split *split )
err = write( fd, &recn, sizeof(char) );
if( err != sizeof(char) )
return -1;
xaccSplitGetDateReconciledTS (split, &ts);
err = writeTSDate( fd, &ts);
if( -1 == err ) return err;
damount = xaccSplitGetShareAmount (split);
INFO_2 ("writeSplit: amount=%f \n", damount);

@ -1377,6 +1377,7 @@ xaccTransSetDateSecs (Transaction *trans, time_t secs)
CHECK_OPEN (trans);
trans->date_posted.tv_sec = secs;
trans->date_posted.tv_nsec = 0;
/* Because the date has changed, we need to make sure that each of the
* splits is properly ordered in each of thier accounts. We could do that
@ -1395,6 +1396,7 @@ xaccTransSetDateEnteredSecs (Transaction *trans, time_t secs)
CHECK_OPEN (trans);
trans->date_entered.tv_sec = secs;
trans->date_entered.tv_nsec = 0;
}
void
@ -1439,10 +1441,14 @@ xaccTransSetDate (Transaction *trans, int day, int mon, int year)
void
xaccTransSetDateToday (Transaction *trans)
{
time_t secs;
struct timeval tv;
secs = time (0);
xaccTransSetDateSecs (trans, secs);
if (!trans) return;
CHECK_OPEN (trans);
gettimeofday (&tv, NULL);
trans->date_posted.tv_sec = tv.tv_sec;
trans->date_posted.tv_nsec = 1000 * tv.tv_usec;
}
@ -1609,6 +1615,32 @@ xaccSplitSetReconcile (Split *split, char recn)
xaccAccountRecomputeBalance (split->acc);
}
void
xaccSplitSetDateReconciledSecs (Split *split, time_t secs)
{
if (!split) return;
MARK_SPLIT (split);
split->date_reconciled.tv_sec = secs;
split->date_reconciled.tv_nsec = 0;
}
void
xaccSplitSetDateReconciledTS (Split *split, struct timespec *ts)
{
if (!split) return;
MARK_SPLIT (split);
split->date_reconciled = *ts;
}
void
xaccSplitGetDateReconciledTS (Split * split, Timespec *ts)
{
if (!split || !ts) return;
*ts = (split->date_reconciled);
}
/********************************************************************\
\********************************************************************/

@ -212,6 +212,10 @@ void xaccSplitSetAction (Split *, const char *);
* are "no", "cleared" and "reconciled"
*/
void xaccSplitSetReconcile (Split *, char);
void xaccSplitSetDateReconciledSecs (Split *, time_t);
void xaccSplitSetDateReconciledTS (Split *, struct timespec *);
void xaccSplitGetDateReconciledTS (Split *, struct timespec *);
/*
* The following four functions set the prices and amounts.

Loading…
Cancel
Save