mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
more work to implement splits
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@387 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
129367be70
commit
934ed5efa3
@ -404,7 +404,7 @@ xaccCheckDateOrder (Account * acc, Split *split )
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* xaccCheckDateOrderDE *
|
||||
* xaccCheckTransDateOrder *
|
||||
* check this transaction to see if the date is in correct order *
|
||||
* If it is not, reorder the transactions ... *
|
||||
* This routine perfroms the check for both of the double-entry *
|
||||
@ -415,17 +415,26 @@ xaccCheckDateOrder (Account * acc, Split *split )
|
||||
\********************************************************************/
|
||||
|
||||
int
|
||||
xaccCheckDateOrderDE (Transaction *trans )
|
||||
xaccCheckTransDateOrder (Transaction *trans )
|
||||
{
|
||||
Account * acc;
|
||||
int outOfOrder = 0;
|
||||
Split *s;
|
||||
int i = 0;
|
||||
|
||||
if (NULL == trans) return 0;
|
||||
|
||||
acc = (Account *) (trans->credit_split.acc);
|
||||
outOfOrder += xaccCheckDateOrder (acc, trans);
|
||||
acc = (Account *) (trans->debit);
|
||||
outOfOrder += xaccCheckDateOrder (acc, trans);
|
||||
outOfOrder += xaccCheckDateOrder (acc, &(trans->credit_split));
|
||||
|
||||
i=0;
|
||||
s = trans->debit_splits[0];
|
||||
while (s) {
|
||||
acc = (Account *) (s->acc);
|
||||
outOfOrder += xaccCheckDateOrder (acc, s);
|
||||
i++;
|
||||
s = trans->debit_splits[i];
|
||||
}
|
||||
|
||||
if (outOfOrder) return 1;
|
||||
return 0;
|
||||
@ -495,43 +504,26 @@ xaccZeroRunningBalances( Account **list )
|
||||
void
|
||||
xaccConsolidateTransactions (Account * acc)
|
||||
{
|
||||
Transaction *ta, *tb;
|
||||
Split *sa, *sb;
|
||||
int i,j,k;
|
||||
|
||||
if (!acc) return;
|
||||
|
||||
for (i=0; i<acc->numTrans; i++) {
|
||||
ta = acc->transaction[i];
|
||||
for (j=i+1; j<acc->numTrans; j++) {
|
||||
tb = acc->transaction[j];
|
||||
for (i=0; i<acc->numSplits; i++) {
|
||||
sa = acc->splits[i];
|
||||
for (j=i+1; j<acc->numSplits; j++) {
|
||||
sb = acc->splits[j];
|
||||
|
||||
/* if no match, then continue on in the loop.
|
||||
* we really must match everything to get a duplicate */
|
||||
if (ta->credit_split.acc != tb->credit_split.acc) continue;
|
||||
if (ta->debit != tb->debit) 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;
|
||||
if (strcmp (ta->num, tb->num)) continue;
|
||||
if (strcmp (ta->description, tb->description)) continue;
|
||||
if (strcmp (ta->credit_split.memo, tb->credit_split.memo)) continue;
|
||||
if (strcmp (ta->action, tb->action)) continue;
|
||||
if (0 == DEQ(ta->credit_split.damount, tb->credit_split.damount)) continue;
|
||||
if (0 == DEQ(ta->credit_split.share_price, tb->credit_split.share_price)) continue;
|
||||
|
||||
/* if we got to here, then there must be a duplicate. */
|
||||
/* before deleting it, remove it from the other
|
||||
* double-entry account */
|
||||
if (acc == (Account *) tb->credit_split.acc) {
|
||||
xaccRemoveTransaction ((Account *) tb->debit, tb);
|
||||
}
|
||||
if (acc == (Account *) tb->debit) {
|
||||
xaccRemoveTransaction ((Account *) tb->credit_split.acc, tb);
|
||||
}
|
||||
tb->credit_split.acc = NULL;
|
||||
tb->debit = NULL;
|
||||
if (sa->parent != sb->parent) continue;
|
||||
if (sa->reconciled != sb->reconciled) continue;
|
||||
if (0 == DEQ(sa->damount, sb->damount)) continue;
|
||||
if (0 == DEQ(sa->share_price, sb->share_price)) continue;
|
||||
if (strcmp (sa->memo, sb->memo)) continue;
|
||||
|
||||
#ifdef STIL_BROKEN
|
||||
/* hack alert -- still broken from splits */
|
||||
/* Free the transaction, and shuffle down by one.
|
||||
* Need to shuffle in order to preserve date ordering. */
|
||||
freeTransaction (tb);
|
||||
@ -541,6 +533,7 @@ xaccConsolidateTransactions (Account * acc)
|
||||
}
|
||||
acc->transaction[acc->numTrans -1] = NULL;
|
||||
acc->numTrans --;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ adjBOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
* the desired balance. */
|
||||
dcurrAmount = xaccGetBalance (&(trans->credit_split));
|
||||
|
||||
xaccSetAmount (split, dcurrAmount - themount);
|
||||
xaccSetAmount (&(trans->credit_split), dcurrAmount - themount);
|
||||
|
||||
/* Refresh the account register window */
|
||||
regRefresh(acc->regData);
|
||||
|
18
src/Data.c
18
src/Data.c
@ -557,19 +557,17 @@ xaccMergeAccounts (AccountGroup *grp)
|
||||
xaccMergeAccounts (ga);
|
||||
|
||||
/* consolidate transactions */
|
||||
for (k=0; k<acc_b->numTrans; k++) {
|
||||
Transaction *trans;
|
||||
trans = acc_b->transaction[k];
|
||||
acc_b->transaction[k] = NULL;
|
||||
if (acc_b == (Account *) trans->debit)
|
||||
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);
|
||||
for (k=0; k<acc_b->numSplits; k++) {
|
||||
Split *split;
|
||||
split = acc_b->splits[k];
|
||||
acc_b->splits[k] = NULL;
|
||||
if (acc_b == (Account *) split->acc)
|
||||
split->acc = (struct _account *) acc_a;
|
||||
xaccInsertSplit (acc_a, split);
|
||||
}
|
||||
|
||||
/* free the account structure itself */
|
||||
acc_b->numTrans = 0;
|
||||
acc_b->numSplits = 0;
|
||||
freeAccount (acc_b);
|
||||
grp->account[j] = grp->account[grp->numAcc -1];
|
||||
grp->account[grp->numAcc -1] = NULL;
|
||||
|
16
src/FileIO.c
16
src/FileIO.c
@ -621,10 +621,6 @@ readTransaction( int fd, Account *acc, int token )
|
||||
split->share_price = damount;
|
||||
}
|
||||
|
||||
/* temp hack till splits fully implemented */
|
||||
trans->damount = split->damount;
|
||||
trans->share_price = split->share_price;
|
||||
|
||||
INFO_2 ("readTransaction(): amount %f \n", trans->damount);
|
||||
|
||||
/* Read the account numbers for double-entry */
|
||||
@ -769,19 +765,19 @@ xaccResetWriteFlags (AccountGroup *grp)
|
||||
for( i=0; i<numAcc; i++ ) {
|
||||
int n=0;
|
||||
Account *acc;
|
||||
Transaction * trans;
|
||||
Split *s;
|
||||
acc = getAccount (grp,i) ;
|
||||
|
||||
/* recursively do sub-accounts */
|
||||
xaccResetWriteFlags (acc->children);
|
||||
|
||||
/* zip over all accounts */
|
||||
trans = getTransaction (acc, 0);
|
||||
n++;
|
||||
while (trans) {
|
||||
trans->credit_split.write_flag = 0;
|
||||
trans = getTransaction (acc, n);
|
||||
s = acc->splits[0];
|
||||
n=0;
|
||||
while (s) {
|
||||
s -> write_flag = 0;
|
||||
n++;
|
||||
s = acc->splits[n];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user