[Gnucash-changes] -- do not add voided transsactions to lots.
Linas Vepstas
linas at cvs.gnucash.org
Sat Jul 3 14:54:49 EDT 2004
Log Message:
-----------
-- do not add voided transsactions to lots.
-- improve dagnostic prints for certain errors
Modified Files:
--------------
gnucash/src/engine:
Scrub2.c
Revision Data
-------------
Index: Scrub2.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Scrub2.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -Lsrc/engine/Scrub2.c -Lsrc/engine/Scrub2.c -u -r1.35 -r1.36
--- src/engine/Scrub2.c
+++ src/engine/Scrub2.c
@@ -77,6 +77,11 @@
/* If already in lot, then no-op */
if (split->lot) continue;
+
+ /* Skip voided transactions */
+ if (gnc_numeric_zero_p (split->amount) &&
+ xaccTransGetVoidStatus(split->parent)) continue;
+
if (xaccSplitAssign (split)) goto restart_loop;
}
xaccAccountCommitEdit (acc);
@@ -113,6 +118,10 @@
split = pcy->PolicyGetSplit (pcy, lot);
if (!split) return; /* Handle the common case */
+ /* Reject voided transactions */
+ if (gnc_numeric_zero_p(split->amount) &&
+ xaccTransGetVoidStatus(split->parent)) return;
+
xaccAccountBeginEdit (acc);
/* Loop until we've filled up the lot, (i.e. till the
@@ -121,8 +130,6 @@
{
Split *subsplit;
-PINFO ("duuuuude split=%s %s", gnc_numeric_to_string
-(split->amount),gnc_numeric_to_string (split->value));
subsplit = xaccSplitAssignToLot (split, lot);
if (subsplit == split)
{
@@ -179,7 +186,7 @@
/* This lot has mixed currencies. Can't double-balance.
* Silently punt */
PWARN ("Lot with multiple currencies:\n"
- "\ttrans=%s curr=%s\n", xaccTransGetDescription(trans),
+ "\ttrans=%s curr=%s", xaccTransGetDescription(trans),
gnc_commodity_get_fullname(trans->common_currency));
break;
}
@@ -198,10 +205,19 @@
/* Unhandled error condition. Not sure what to do here,
* Since the ComputeCapGains should have gotten it right.
* I suppose there might be small rounding errors, a penny or two,
- * the ideal thing would to figure out why there's a roudning
+ * the ideal thing would to figure out why there's a rounding
* error, and fix that.
*/
- PERR ("Closed lot fails to double-balance !!\n");
+ PERR ("Closed lot fails to double-balance !! lot value=%s",
+ gnc_numeric_to_string (value));
+ GList *node;
+ for (node=lot->splits; node; node=node->next)
+ {
+ Split *s = node->data;
+ PERR ("s=%p amt=%s val=%s", s,
+ gnc_numeric_to_string(s->amount),
+ gnc_numeric_to_string(s->value));
+ }
}
LEAVE ("lot=%s", kvp_frame_get_string (gnc_lot_get_slots (lot), "/title"));
@@ -409,6 +425,10 @@
rc = TRUE;
goto restart;
}
+ if (gnc_numeric_zero_p (split->amount))
+ {
+ PWARN ("Result of merge has zero amt!");
+ }
LEAVE (" splits merged=%d", rc);
return rc;
}
More information about the gnucash-changes
mailing list