Bug 797233 - Balance Sheet, Chart of Accounts, and other reports...

crash when involving foreign currency stocks.

Scheme's inexact->exact function just converts the floating-point
representation of a number into an exact rational (documented in the
API Reference, Simple Generic Data Types, Numerical data types, Exact
and Inexact Numbers), which isn't what we want.

We want the number converted to exact directly from the string and to do
that we have gnc-fq-helper preface it with #e.
This commit is contained in:
John Ralls 2019-05-14 13:34:07 -07:00
parent 217418bb8c
commit fc567208f3
2 changed files with 2 additions and 8 deletions

View File

@ -186,7 +186,7 @@ sub schemify_num {
if(!$numstr) { return "failed-conversion"; }
if($numstr =~ /^\s*(\d+(\.\d+)?([eE][+-]?\d+)?)$/o) {
return $1;
return "#e" . $1;
} else {
return "failed-conversion";
}

View File

@ -404,13 +404,7 @@
(else #f)))
(if price
;; The second argument to inexact->exact is chosen to give reasonable values
;; for prices between .12345e-9 and 12345678.87654
;; inexact->exact is probably not necessary but it can't hurt and is cheap.
(set! price
(gnc-scm-to-numeric
(rationalize (inexact->exact price) 1/1000000000000000))))
(set! price (gnc-scm-to-numeric price)))
(if gnc-time
(set! gnc-time (timestr->time64 gnc-time time-zone))
(set! gnc-time (gnc:get-today)))