[Gnucash-changes] add debugging print statements

Linas Vepstas linas at cvs.gnucash.org
Sun May 30 01:10:27 EDT 2004


Log Message:
-----------
add debugging print statements

Modified Files:
--------------
    gnucash/src/engine:
        cap-gains.c

Revision Data
-------------
Index: cap-gains.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/cap-gains.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lsrc/engine/cap-gains.c -Lsrc/engine/cap-gains.c -u -r1.21 -r1.22
--- src/engine/cap-gains.c
+++ src/engine/cap-gains.c
@@ -612,7 +612,7 @@
    pcy = lot->account->policy;
    currency = split->parent->common_currency;
 
-   ENTER ("split=%p gains=%p status=0x%x lot=%s", split, 
+   ENTER ("(split=%p gains=%p status=0x%x lot=%s)", split, 
        split->gains_split, split->gains,
        kvp_frame_get_string (gnc_lot_get_slots (lot), "/title"));
 
@@ -638,11 +638,13 @@
          xaccTransCommitEdit (trans);
       }
 #endif
+      PINFO ("Lot opening split, returning.");
       return;
    }
 
    if (GAINS_STATUS_GAINS & split->gains)
    {
+      PINFO ("split is a gains recording split, switch over");
       /* If this is the split that records the gains, then work with 
        * the split that generates the gains. 
        */
@@ -688,7 +690,11 @@
     * nothing to do. Just return. */
    if ((FALSE == (split->gains & GAINS_STATUS_A_VDIRTY))  &&
        (split->gains_split) &&
-       (FALSE == (split->gains_split->gains & GAINS_STATUS_A_VDIRTY))) return;
+       (FALSE == (split->gains_split->gains & GAINS_STATUS_A_VDIRTY))) 
+   {
+      PINFO ("split not dirty, returning");
+      return;
+   }
 
    /* Yow! If amount is zero, there's nothing to do! Amount-zero splits 
     * may exist if users attempted to manually record gains. */
@@ -709,6 +715,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!");
       return;
    }
 
@@ -720,7 +727,7 @@
    if (0 > gnc_numeric_compare (gnc_numeric_abs(opening_amount),
                                 gnc_numeric_abs(split->amount)))
    {
-      PERR ("Malformed Lot! (too thin!)\n");
+      PERR ("Malformed Lot! (too thin!)");
       return;
    }
    if ( (gnc_numeric_negative_p(opening_amount) ||
@@ -728,7 +735,7 @@
         (gnc_numeric_positive_p(opening_amount) ||
          gnc_numeric_negative_p(split->amount)))
    {
-      PERR ("Malformed Lot! (too fat!)\n");
+      PERR ("Malformed Lot! (too fat!)");
       return;
    }
 
@@ -743,7 +750,6 @@
                    GNC_DENOM_AUTO, GNC_RND_NEVER);
    value = gnc_numeric_div (value, opening_amount, 
                    gnc_numeric_denom(opening_value), GNC_DENOM_EXACT);
-   
    value = gnc_numeric_sub (value, split->value,
                            GNC_DENOM_AUTO, GNC_DENOM_LCD);
    PINFO ("Open amt=%s val=%s;  split amt=%s val=%s; gains=%s\n",
@@ -752,6 +758,11 @@
           gnc_numeric_to_string (split->amount),
           gnc_numeric_to_string (split->value),
           gnc_numeric_to_string (value));
+   if (gnc_numeric_check (value))
+   {
+      PERR ("Numeric overflow during gains calculation");
+      return;
+   }
 
    /* Are the cap gains zero?  If not, add a balancing transaction.
     * As per design doc lots.txt: the transaction has two splits, 
@@ -855,7 +866,7 @@
 
       xaccTransCommitEdit (trans);
    }
-   LEAVE ("lot=%s", kvp_frame_get_string (gnc_lot_get_slots (lot), "/title"));
+   LEAVE ("(lot=%s)", kvp_frame_get_string (gnc_lot_get_slots (lot), "/title"));
 }
 
 /* ============================================================== */


More information about the gnucash-changes mailing list