After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 95844 - QIF Import -denom set for integer misinterpreted by numeric_convert
QIF Import -denom set for integer misinterpreted by numeric_convert
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Import - Other
git-master
Other Linux
: Normal normal
: ---
Assigned To: Chris Lyttle
Chris Lyttle
Depends on:
Blocks:
 
 
Reported: 2002-10-15 17:15 UTC by Larry Evans
Modified: 2018-06-29 20:19 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Larry Evans 2002-10-15 17:15:36 UTC
In the Q field of QIF file, when a positive entry contains no 
decimal point, the double_to_gnc_numeric function in gnc-numeric.c
returns both a negative numerator and negative denominator.
However, the gnc_numeric_convert interprets a negative denominator
as signifying multiply instead of divide.  This results in
incorrect values.  For example,

  Q6,666

results in :out.num=-66660 :out.denom=-10 on output from
double_to_gnc_numeric.  However, when these values are
passed to gnc_numeric_convert, with how=7, the output is:

:out.num=66660000000 
:out.denom=100000 

which give a value of 666600 instead of 6666 as required.
Comment 1 Larry Evans 2002-10-16 13:28:23 UTC
The problem is caused by:
  (gnc:double-to-gnc-numeric
    (+ 0.0 read-val) GNC-DENOM-AUTO
    (logior (GNC-DENOM-SIGFIGS (- (string-length filtered-string) 1))
            GNC-RND-ROUND))
in the body of:
  (define (qif-parse:parse-number/format value-string format)
the 1 is supposed to subtract for the decimal point; however,
this doesn't account for this being absent in the case of an
integer, e.g. 6,666.  I tested a change to solve this problem;
however, I got another error while reading dates:

Gtk-CRITICAL **: file gtkcombo.c: line 849
(gtk_combo_set_popdown_strings): assertion `strings != NULL' failed.
Comment 2 Larry Evans 2002-10-17 03:35:59 UTC
The aforementioned error in file gtkcombo.c: line 849 is 
probably caused by the call at druid-qif-import.c:496. The
format list is null.  Judging from display's during the parse,
all dates were parsed successfully; so, it must be something
besides that.  This is supported by the comments shortly
before line 496.
Comment 3 Larry Evans 2002-10-17 14:51:51 UTC
The ultimate cause of the gtkcombo.c: line 849 error was not changing
the comma radix case like the decimal radix case was changed in
qif-parse:parse-number/format.  After this change was made,
the error disappeared. The relevant code is:

  (case format 
    ((decimal)
     (let* ((filtered-string
             (string-remove-char 
              (string-remove-char value-string #\,)
              #\$)
            );;end filtered-string
            (read-val
             (with-input-from-string filtered-string
               (lambda () (read)))
            );;end read-val
            (has-radix
             ( if (regexp-exec (make-regexp "^.*[.].*$") filtered-string)
               1
               0
             )
            );;end has-radix
           );;end let*
       (if (number? read-val)
           (begin
            (gnc:double-to-gnc-numeric
              (+ 0.0 read-val) GNC-DENOM-AUTO
              (logior (GNC-DENOM-SIGFIGS (- (string-length
filtered-string) has-radix))
                      GNC-RND-ROUND))
           );;end begin for then part of if
           (gnc:numeric-zero);;end else part of if
       );;end if
     );;end let*
    );;end decimal case
Comment 4 Derek Atkins 2002-10-19 18:06:16 UTC
A (different) patch for this problem has been committed to CVS.
Comment 5 Derek Atkins 2002-10-19 23:16:00 UTC
from Larry:

I just tested it and it worked fine.

So I'm closing this as fixed.

Thanks!
Comment 6 John Ralls 2018-06-29 20:19:26 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=95844. Please update any external references or bookmarks.