[Gnucash-changes] improved diagnostic messages
Linas Vepstas
linas at cvs.gnucash.org
Sun Jul 4 00:26:02 EDT 2004
Log Message:
-----------
improved diagnostic messages
Modified Files:
--------------
gnucash/src/engine:
cap-gains.c
Scrub2.c
Scrub3.c
Revision Data
-------------
Index: Scrub2.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Scrub2.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -Lsrc/engine/Scrub2.c -Lsrc/engine/Scrub2.c -u -r1.36 -r1.37
--- src/engine/Scrub2.c
+++ src/engine/Scrub2.c
@@ -100,7 +100,6 @@
void
xaccLotFill (GNCLot *lot)
{
- gnc_numeric lot_baln;
Account *acc;
Split *split;
GNCPolicy *pcy;
@@ -109,11 +108,10 @@
acc = lot->account;
pcy = acc->policy;
- ENTER ("acc=%s", acc->accountName);
+ ENTER ("(lot=%s, acc=%s)", gnc_lot_get_title(lot), acc->accountName);
/* If balance already zero, we have nothing to do. */
- lot_baln = gnc_lot_get_balance (lot);
- if (gnc_numeric_zero_p (lot_baln)) return;
+ if (gnc_lot_is_closed (lot)) return;
split = pcy->PolicyGetSplit (pcy, lot);
if (!split) return; /* Handle the common case */
@@ -134,18 +132,21 @@
if (subsplit == split)
{
PERR ("Accounting Policy gave us a split that "
- "doesn't fit into this lot");
+ "doesn't fit into this lot\n"
+ "lot baln=%s, isclosed=%d, aplit amt=%s",
+ gnc_numeric_to_string (gnc_lot_get_balance(lot)),
+ gnc_lot_is_closed (lot),
+ gnc_numeric_to_string (split->amount));
break;
}
- lot_baln = gnc_lot_get_balance (lot);
- if (gnc_numeric_zero_p (lot_baln)) break;
+ if (gnc_lot_is_closed (lot)) break;
split = pcy->PolicyGetSplit (pcy, lot);
if (!split) break;
}
xaccAccountCommitEdit (acc);
- LEAVE ("acc=%s", acc->accountName);
+ LEAVE ("(lot=%s, acc=%s)", gnc_lot_get_title(lot), acc->accountName);
}
/* ============================================================== */
Index: Scrub3.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Scrub3.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lsrc/engine/Scrub3.c -Lsrc/engine/Scrub3.c -u -r1.12 -r1.13
--- src/engine/Scrub3.c
+++ src/engine/Scrub3.c
@@ -152,7 +152,7 @@
}
xaccAccountCommitEdit(acc);
- LEAVE (" deleted=%d", splits_deleted);
+ LEAVE ("(lot=%s, deleted=%d)", gnc_lot_get_title(lot), splits_deleted);
return splits_deleted;
}
Index: cap-gains.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/cap-gains.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -Lsrc/engine/cap-gains.c -Lsrc/engine/cap-gains.c -u -r1.26 -r1.27
--- src/engine/cap-gains.c
+++ src/engine/cap-gains.c
@@ -399,7 +399,7 @@
acc = split->acc;
xaccAccountBeginEdit (acc);
gnc_lot_add_split (lot, split);
- PINFO ("simple added split to lot, new lot baln=%s (%s)",
+ PINFO ("added split to empty lot, new lot baln=%s (%s)",
gnc_numeric_to_string (gnc_lot_get_balance(lot)),
gnc_lot_get_title (lot));
xaccAccountCommitEdit (acc);
@@ -407,15 +407,29 @@
}
/* If the sign of the split is the same as the sign of the lot,
- * we won't add it, because that would make the lot bigger, not
- * smaller. Our only function here is to make lot balances smaller.
+ * add the split, but complain about it ... none of the currently
+ * implemented accounting policies should be giving us splits
+ * that make lots larger. One a lot is open, the FIFO/LIFO
+ * policies should be working only to make the lot smaller.
+ * We can remove teh warning emssage come the day we have
+ * fancier policies.
*/
baln_is_positive = gnc_numeric_positive_p (baln);
amt_is_positive = gnc_numeric_positive_p (split->amount);
if ((baln_is_positive && amt_is_positive) ||
((!baln_is_positive) && (!amt_is_positive)))
{
- return split;
+ PWARN ("accounting policy gave us split that enlarges the lot!\n"
+ "old lot baln=%s split amt=%s lot=%s",
+ gnc_numeric_to_string (gnc_lot_get_balance(lot)),
+ gnc_numeric_to_string (split->amount),
+ gnc_lot_get_title (lot));
+
+ acc = split->acc;
+ xaccAccountBeginEdit (acc);
+ gnc_lot_add_split (lot, split);
+ xaccAccountCommitEdit (acc);
+ return NULL;
}
/* If adding the split would make the lot balance change sign,
@@ -680,7 +694,7 @@
xaccTransCommitEdit (trans);
}
#endif
- PINFO ("Lot opening split, returning.");
+ LEAVE ("Lot opening split, returning.");
return;
}
@@ -734,7 +748,7 @@
(split->gains_split) &&
(FALSE == (split->gains_split->gains & GAINS_STATUS_A_VDIRTY)))
{
- PINFO ("split not dirty, returning");
+ LEAVE ("split not dirty, returning");
return;
}
@@ -757,7 +771,7 @@
* I don't know how to compute cap gains for that. This is not
* an error. Just punt, silently.
*/
- PINFO ("Can't compute gains, mismatched commodities!");
+ LEAVE ("Can't compute gains, mismatched commodities!");
return;
}
@@ -769,9 +783,18 @@
if (0 > gnc_numeric_compare (gnc_numeric_abs(opening_amount),
gnc_numeric_abs(split->amount)))
{
- PERR ("Malformed Lot! (too thin!) opening amt=%s split amt=%s ",
+ GList *n;
+ for (n=lot->splits; n; n=n->next)
+ {
+ Split *s = n->data;
+ PINFO ("split amt=%s", gnc_numeric_to_string(s->amount));
+ }
+ PERR ("Malformed Lot \"%s\"! (too thin!) "
+ "opening amt=%s split amt=%s baln=%s",
+ gnc_lot_get_title (lot),
gnc_numeric_to_string (opening_amount),
- gnc_numeric_to_string (split->amount));
+ gnc_numeric_to_string (split->amount),
+ gnc_numeric_to_string (gnc_lot_get_balance(lot)));
return;
}
if ( (gnc_numeric_negative_p(opening_amount) ||
@@ -779,9 +802,18 @@
(gnc_numeric_positive_p(opening_amount) ||
gnc_numeric_negative_p(split->amount)))
{
- PERR ("Malformed Lot! (too fat!) opening amt=%s split amt=%s ",
+ GList *n;
+ for (n=lot->splits; n; n=n->next)
+ {
+ Split *s = n->data;
+ PINFO ("split amt=%s", gnc_numeric_to_string(s->amount));
+ }
+ PERR ("Malformed Lot \"%s\"! (too fat!) "
+ "opening amt=%s split amt=%s baln=%s",
+ gnc_lot_get_title (lot),
gnc_numeric_to_string (opening_amount),
- gnc_numeric_to_string (split->amount));
+ gnc_numeric_to_string (split->amount),
+ gnc_numeric_to_string (gnc_lot_get_balance(lot)));
return;
}
More information about the gnucash-changes
mailing list