gnucash maint: Multiple changes pushed

Mike Alexander mta at code.gnucash.org
Mon Jan 28 23:36:30 EST 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/62a4e73f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5bd78754 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/df192447 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2820af71 (commit)
	from  https://github.com/Gnucash/gnucash/commit/7d0adfd0 (commit)



commit 62a4e73f7fc08b2393cc1eb619526885f32d633a
Author: Mike Alexander <mta at umich.edu>
Date:   Mon Jan 28 01:33:04 2019 -0500

    Don't use GNC-DENOM-SIGFIGS when converting prices
    to gnc-numeric values.

diff --git a/libgnucash/scm/price-quotes.scm b/libgnucash/scm/price-quotes.scm
index 603090d..732704f 100644
--- a/libgnucash/scm/price-quotes.scm
+++ b/libgnucash/scm/price-quotes.scm
@@ -403,13 +403,12 @@
               ((price) "unknown")
               (else #f)))
 
-      ;; FIXME: SIGFIGS is not what we want here...
       (if price
           (set! price
                 (double-to-gnc-numeric price
-                                           GNC-DENOM-AUTO
-                                           (logior (GNC-DENOM-SIGFIGS 9)
-                                                   GNC-RND-ROUND))))
+                                       GNC-DENOM-AUTO
+                                       (logior GNC-DENOM-REDUCE
+                                               GNC-RND-NEVER))))
 
       (if gnc-time
           (set! gnc-time (timestr->time64 gnc-time time-zone))

commit 5bd787543703c40920dd4e5ae9d8c044a7f8b10d
Author: Mike Alexander <mta at umich.edu>
Date:   Sun Jan 27 23:44:36 2019 -0500

    Revert the part of 923b01e2 which reverses currency quotes less than 1.
    Now that GnuCash uses 64 bit numbers in numerics this is not necessary.
    It can store a number as small as 1e-9 with 9 significant digits.

diff --git a/libgnucash/quotes/gnc-fq-dump b/libgnucash/quotes/gnc-fq-dump
index 44e1826..e87e55c 100755
--- a/libgnucash/quotes/gnc-fq-dump
+++ b/libgnucash/quotes/gnc-fq-dump
@@ -168,7 +168,9 @@ if ($exchange eq "currency") {
   while ($#ARGV >= 0) {
     my $to = shift;
     my $result = $q->currency($from, $to);
-    unless (defined($result) && $result >= 1) {
+    # Sometimes quotes are available in only one direction.
+    # If we didn't get the one we wanted try the reverse quote
+    unless (defined($result)) {
         my $inv_res = $q->currency($to, $from);
         if (defined($inv_res)) {
             my $tmp = $to;
diff --git a/libgnucash/quotes/gnc-fq-helper.in b/libgnucash/quotes/gnc-fq-helper.in
index fb6e4e9..1e78191 100755
--- a/libgnucash/quotes/gnc-fq-helper.in
+++ b/libgnucash/quotes/gnc-fq-helper.in
@@ -349,10 +349,8 @@ while(<>) {
 
     my $price = $quoter->currency($from_currency, $to_currency);
     my $inv_price = undef;
-    #Sometimes price quotes are available in only one direction, and if the
-    #direction we asked for results in a quote < 1 we want the other direction
-    #if it's available to get more significant digits.
-    unless (defined($price) && $price > 1) {
+    # Sometimes price quotes are available in only one direction.
+    unless (defined($price)) {
         $inv_price = $quoter->currency($to_currency, $from_currency);
         if (defined($inv_price)) {
             my $tmp = $to_currency;

commit df19244792202faa0f0d802902d3de6b472ee2f3
Author: Mike Alexander <mta at umich.edu>
Date:   Mon Jan 28 17:29:21 2019 -0500

    Fix the comments on double_to_gnc_numeric.  GNC_DENOM_AUTO is allowed.
    
    GNC_DENOM_AUTO

diff --git a/libgnucash/engine/gnc-numeric.h b/libgnucash/engine/gnc-numeric.h
index 7840736..15e6792 100644
--- a/libgnucash/engine/gnc-numeric.h
+++ b/libgnucash/engine/gnc-numeric.h
@@ -270,9 +270,7 @@ gnc_numeric gnc_numeric_zero(void)
 
 /** Convert a floating-point number to a gnc_numeric.
  *
- * Both 'denom' and 'how' are used as in arithmetic, but
- * GNC_DENOM_AUTO is not recognized; a denominator must be specified
- * either explicitly or through sigfigs.
+ * Both 'denom' and 'how' are used as in arithmetic.
  *
  * \sa \ref Arguments
  *
@@ -280,15 +278,16 @@ gnc_numeric gnc_numeric_zero(void)
  *
  * \param denom The denominator of the gnc_numeric return value. If
  * the 'how' argument contains the GNC_HOW_DENOM_SIGFIG flag, this
- * value will be ignored.
+ * value will be ignored.  If GNC_DENOM_AUTO is given an appropriate
+ * power of ten will be used for the denominator (it may be reduced
+ * by rounding if appropriate).
  *
  * \param how Describes the rounding policy and output
- * denominator. Watch out: You \e must specify a rounding policy such
+ * denominator. Watch out: You must specify a rounding policy such
  * as GNC_HOW_RND_NEVER, otherwise the fractional part of the input
  * value is silently discarded! Common values for 'how' are
  * (GNC_HOW_DENOM_REDUCE|GNC_HOW_RND_NEVER) or
- * (GNC_HOW_DENOM_FIXED|GNC_HOW_RND_NEVER). As mentioned above,
- * GNC_DENOM_AUTO is not allowed here.
+ * (GNC_HOW_DENOM_FIXED|GNC_HOW_RND_NEVER).
  *
  * \return The newly created gnc_numeric rational value.
  */

commit 2820af7166f391823e4417945984ba040b0577ff
Author: Mike Alexander <mta at umich.edu>
Date:   Sun Jan 27 21:16:56 2019 -0500

    Make test-backend-dbi-basic build and run with libdbi 8.
    
    This may not be the correct fix, but it is plausible and it
    makes the test build and run.

diff --git a/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp b/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
index 055062f..4980adb 100644
--- a/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
+++ b/libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp
@@ -275,7 +275,7 @@ destroy_database (gchar* url)
 #if HAVE_LIBDBI_R
         conn = dbi_conn_new_r (scheme, dbi_instance);
 #else
-        conn = dbi_conn_new (protocol);
+        conn = dbi_conn_new (scheme);
 #endif
     port = g_strdup_printf ("%d", portnum);
     if (conn == NULL)



Summary of changes:
 libgnucash/backend/dbi/test/test-backend-dbi-basic.cpp |  2 +-
 libgnucash/engine/gnc-numeric.h                        | 13 ++++++-------
 libgnucash/quotes/gnc-fq-dump                          |  4 +++-
 libgnucash/quotes/gnc-fq-helper.in                     |  6 ++----
 libgnucash/scm/price-quotes.scm                        |  7 +++----
 5 files changed, 15 insertions(+), 17 deletions(-)



More information about the gnucash-changes mailing list