|
|
|
|
@ -947,96 +947,6 @@ xaccMoveFarEndByName (Split *split, const char *new_acc_name)
|
|
|
|
|
/********************************************************************\
|
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
xaccConsolidateTransactions (Account * acc)
|
|
|
|
|
{
|
|
|
|
|
Split *sa, *sb;
|
|
|
|
|
Transaction *ta, *tb;
|
|
|
|
|
Timespec ts;
|
|
|
|
|
int i,j;
|
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
|
|
if (!acc) return;
|
|
|
|
|
CHECK (acc);
|
|
|
|
|
|
|
|
|
|
for (i=0; i<acc->numSplits; i++) {
|
|
|
|
|
sa = acc->splits[i];
|
|
|
|
|
ta = sa->parent;
|
|
|
|
|
for (j=i+1; j<acc->numSplits; j++) {
|
|
|
|
|
sb = acc->splits[j];
|
|
|
|
|
tb = sb->parent;
|
|
|
|
|
|
|
|
|
|
/* A single transaction can have multiple splits in the same
|
|
|
|
|
* account. For instance, a split deposit in AccountA of two
|
|
|
|
|
* checks from AccountB creates two splits in AccountB with
|
|
|
|
|
* the same parent transaction. Skip this case.
|
|
|
|
|
*/
|
|
|
|
|
if (ta == tb) continue;
|
|
|
|
|
|
|
|
|
|
/* if no match, then continue on in the loop.
|
|
|
|
|
* we really must match everything to get a duplicate */
|
|
|
|
|
retval = xaccTransMatch (&ta, &tb);
|
|
|
|
|
if (retval) continue;
|
|
|
|
|
|
|
|
|
|
/* OK, looks like the two splits are a matching pair.
|
|
|
|
|
* Blow one of them, and its entire associated transaction, away.
|
|
|
|
|
* (We blow away the transaction because not only do the splits
|
|
|
|
|
* match, but so do all of their partner-splits.)
|
|
|
|
|
*
|
|
|
|
|
* But, before we blow it away, we go through each split and
|
|
|
|
|
* update the reconciled flag and date of the split in the
|
|
|
|
|
* remaining transaction with those in the one being deleted,
|
|
|
|
|
* but only if the remaining transaction has an NREC reconciled
|
|
|
|
|
* flag. In other words, the two splits match on everything
|
|
|
|
|
* but the reconciled flags and dates, so we assume that the
|
|
|
|
|
* one which is not NREC is 'more correct'. This is true in
|
|
|
|
|
* the case of importing two QIF files with overlapping
|
|
|
|
|
* transactions. Each file will have one 'half' of the
|
|
|
|
|
* transaction, but the other half will be generated by the
|
|
|
|
|
* QIF importing routines, but with default values for the
|
|
|
|
|
* reconciled data. When we load the other file, we need to
|
|
|
|
|
* replace the generated 'half' with the real one.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
xaccTransBeginEdit (ta, 1);
|
|
|
|
|
|
|
|
|
|
for (i=xaccTransCountSplits(ta); i>0; i--) {
|
|
|
|
|
sa = xaccTransGetSplit (ta, i - 1);
|
|
|
|
|
|
|
|
|
|
/* If the remaining split is reconciled as something
|
|
|
|
|
other than NREC, just leave it alone. */
|
|
|
|
|
if (xaccSplitGetReconcile(sa) != NREC)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* We get the matching split using the ticket value
|
|
|
|
|
generated by xaccTransMatch above. */
|
|
|
|
|
sb = xaccTransGetSplit(tb, sa->ticket);
|
|
|
|
|
|
|
|
|
|
xaccSplitSetReconcile (sa, xaccSplitGetReconcile(sb));
|
|
|
|
|
xaccSplitGetDateReconciledTS (sb, &ts);
|
|
|
|
|
xaccSplitSetDateReconciledTS (sa, &ts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xaccTransCommitEdit (ta);
|
|
|
|
|
|
|
|
|
|
xaccTransBeginEdit (tb, 1);
|
|
|
|
|
xaccTransDestroy (tb);
|
|
|
|
|
xaccTransCommitEdit (tb);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* It should be safe to just "break" here, as all splits
|
|
|
|
|
* with index i or less have been checked already and couldn't
|
|
|
|
|
* have been dupes. So index i is still valid, although j is
|
|
|
|
|
* not. Note that numSplits changed ...
|
|
|
|
|
*/
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************************************************************\
|
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
xaccAccountSetType (Account *acc, int tip)
|
|
|
|
|
{
|
|
|
|
|
|