r18320 - gnucash/trunk/src/register/ledger-core - Bug #585784: Fix wrong fractional precision in stock/mutual fund registers Bug 585784 - Wrong fractional precision displayed in stock/mutual fund registers

Christian Stimming cstim at code.gnucash.org
Fri Sep 18 15:50:49 EDT 2009


Author: cstim
Date: 2009-09-18 15:50:48 -0400 (Fri, 18 Sep 2009)
New Revision: 18320
Trac: http://svn.gnucash.org/trac/changeset/18320

Modified:
   gnucash/trunk/src/register/ledger-core/split-register-model.c
Log:
Bug #585784: Fix wrong fractional precision in stock/mutual fund registers Bug 585784 -  Wrong fractional precision displayed in stock/mutual fund registers

The original patch attempted to fix bug #529494 by replacing the
gnc_split_value_print_info function with gnc_split_register_print_info, which
instead of using the print info of the transaction's commodity, used the print
info of the commodity of the register's account.  However, this was not the
correct behavior in all cases either.  This patch eliminates the
gnc_split_register_print_info and instead puts the logic for selecting the
appropriate print info into the functions which previously called it.

* In gnc_split_register_get_balance_entry, the print info of the account of
the split is used (xaccSplitGetAccount); if the split doesn't have an account,
the print info of the register's default account
(gnc_split_register_get_default_account) is used

* In gnc_split_register_get_debcred_entry, if there is no split, the account
info of the register's default account (gnc_split_register_get_default_account)
is used.  Otherwise, if the register is a Stock/Mutual Fund register or an
(obsolete) Currency register, the print info of the transaction's currency is
used (xaccTransGetCurrency).  Finally in all other cases, the print info of the
register's default account (gnc_split_register_get_default_account) is used.

* In gnc_template_register_get_debcred_entry, there is no account to reference,
so the default print info (gnc_default_print_info) is used.

Patch by Daniel Harding.

Modified: gnucash/trunk/src/register/ledger-core/split-register-model.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model.c	2009-09-18 19:40:57 UTC (rev 18319)
+++ gnucash/trunk/src/register/ledger-core/split-register-model.c	2009-09-18 19:50:48 UTC (rev 18320)
@@ -1061,12 +1061,6 @@
   return g_strdup (help);
 }
 
-static GNCPrintAmountInfo gnc_split_register_print_info (SplitRegister *reg)
-{
-  return gnc_account_print_info (gnc_split_register_get_default_account (reg),
-      FALSE);
-}
-
 static const char *
 gnc_split_register_get_balance_entry (VirtualLocation virt_loc,
                                       gboolean translate,
@@ -1078,6 +1072,7 @@
   gnc_numeric balance;
   gboolean is_trans;
   Split *split;
+  Account *account;
 
   split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
 
@@ -1093,18 +1088,14 @@
   else
     balance = xaccSplitGetBalance (split);
 
-  {
-    Account *account;
+  account = xaccSplitGetAccount (split);
+  if (!account)
+    account = gnc_split_register_get_default_account (reg);
 
-    account = xaccSplitGetAccount (split);
-    if (!account)
-      account = gnc_split_register_get_default_account (reg);
+  if (gnc_reverse_balance (account))
+    balance = gnc_numeric_neg (balance);
 
-    if (gnc_reverse_balance (account))
-      balance = gnc_numeric_neg (balance);
-  }
-
-  return xaccPrintAmount (balance, gnc_split_register_print_info (reg));
+  return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
 }
 
 static const char *
@@ -1458,11 +1449,12 @@
 				       GNC_RND_ROUND);
     }
 
-    return xaccPrintAmount (imbalance, gnc_split_register_print_info (reg));
+    return xaccPrintAmount (imbalance, gnc_account_print_info (acc, FALSE));
   }
 
   {
     gnc_numeric amount;
+    GNCPrintAmountInfo print_info;
 
     /* If this account is not a stock/mutual/currency account, and
      * currency != the account commodity, then use the SplitAmount
@@ -1472,6 +1464,7 @@
     case STOCK_REGISTER:
     case CURRENCY_REGISTER:
       amount = xaccSplitGetValue (split);
+      print_info = gnc_commodity_print_info (currency, FALSE);
       break;
 
     default:
@@ -1487,6 +1480,7 @@
 	  amount = xaccSplitConvertAmount(split, account);
 	else
 	  amount = xaccSplitGetValue (split);
+	print_info = gnc_account_print_info (account, FALSE);
       }
     }
 
@@ -1501,7 +1495,7 @@
 
     amount = gnc_numeric_abs (amount);
 
-    return xaccPrintAmount (amount, gnc_split_register_print_info (reg));
+    return xaccPrintAmount (amount, print_info);
   }
 }
 
@@ -1867,7 +1861,7 @@
     amount = gnc_numeric_abs (amount);
 
     /* FIXME: This should be fixed to be correct for the "fake" account. */
-    return xaccPrintAmount (amount, gnc_split_register_print_info (reg));
+    return xaccPrintAmount (amount, gnc_default_print_info (FALSE));
   }
 
   return NULL;



More information about the gnucash-changes mailing list