Created attachment 373917 [details] cashflow exception Hi there, When I open Reports -> Income & expense -> Cash flow, following exception was throw ... In cash-flow-calc.scm: 61:36 3 (_ #<swig-pointer Split * 5583dabb4ee0>) In standard/cash-flow.scm: 229:13 2 (to-report-currency _ _ 1369501200) In commodity-utilities.scm: 702:12 1 (gnc:exchange-by-pricedb-nearest _ #<swig-pointer gnc_commodity * 5583d8d984b0> _) In unknown file: 0 (gnc-pricedb-convert-balance-nearest-price-t64 #<swig-pointer struct gnc_price_db_s * 5583d8d61860> 50 #<swig-pointer gnc_commodity * 5583d8d973c0> #<swig-pointer gnc_commodity * 5583d8d984b0> 1369544400) Throw to key `numerical-overflow' with args `("/" "Numerical overflow" #f #f)'. If I create new file, that not happend I don't know how to debug this bug (I don't familiar with Lisp) Full log is in attachment I use "gnucash 4.2-1" (archlinux) Build ID: 4.2+(2020-09-26)
If you modify commodity-utilities.scm as follows, the https://wiki.gnucash.org/wiki/Tracefile will give valuable information. (Hint: add the gnc:pk line) modified gnucash/report/commodity-utilities.scm @@ -693,6 +693,7 @@ ;; <gnc-monetary>. (define (gnc:exchange-by-pricedb-nearest foreign domestic date) + (gnc:pk foreign domestic date) (and (record? foreign) (gnc:gnc-monetary? foreign) date
After insert above line I found the transaction that cause error It is a 50 USD transaction, with exchange rate to VND I try change the value to 51USD, cashflow work fine Then I change back to orginal value, and it is ok now Or if I save it as XML, it will be ok too (I use is sqlite backend) I don't know what cause the problem, maybe because old gnucash version (year 2013)
Created attachment 373918 [details] file cause bug I send the minimum file that cause error
What options have you set for the cash flow report? The defaults seem to work fine on your attached file with the report currency either USD or VND.
I bet the original file has no VNDUSD price.
I just open default report, no option If I create new user, problem is solved for that user So the problem is in my machine But I don't know what wrong Because I try to recreate /home/<user>, or create new user with same UID, problem is still exists
See your price database; VND/USD has no price on 27/05/13. Not sure how you managed that. Could this be the cause?
Correct see the 2nd line of prices table:- USD/VND price is -1/0 SELECT * from "prices" LIMIT 8 9c7170a9f5a905e19e9692af80e53c26,44be3c71668990c68cf1cef43e2f6043,2a7c80f27f31d0e579f677494c9db001,20130522170000,user:xfer-dialog,,21360,1 9652742c363f649b7a41d3ed7106c361,44be3c71668990c68cf1cef43e2f6043,2a7c80f27f31d0e579f677494c9db001,20130526170000,user:xfer-dialog,,-1,0 4f280c73d0bd115150f1424cbf666619,44be3c71668990c68cf1cef43e2f6043,2a7c80f27f31d0e579f677494c9db001,20140430170000,user:xfer-dialog,,21000,1 01672a3cff500ef0dd07bd466f73230b,44be3c71668990c68cf1cef43e2f6043,2a7c80f27f31d0e579f677494c9db001,20140430170000,user:xfer-dialog,,440000,21 5fe6c490b7d4f91ce462fb9853d8e7b8,60aacdafa49dda93acc92dd0e0daa338,2a7c80f27f31d0e579f677494c9db001,20160216170000,user:price,transaction,160500000,10000 218b09ad6fb33aa195e38eb28887f8b8,60aacdafa49dda93acc92dd0e0daa338,2a7c80f27f31d0e579f677494c9db001,20160220170000,user:price-editor,,160500000,10000 8180466a7999f2ba568291bbd6ec52c2,44be3c71668990c68cf1cef43e2f6043,2a7c80f27f31d0e579f677494c9db001,20170426170000,user:xfer-dialog,transaction,227666667,10000 0c4e3895f32e57be0e7b7c671df90af1,44be3c71668990c68cf1cef43e2f6043,2a7c80f27f31d0e579f677494c9db001,20170503170000,user:price,,227666667,10000
To reproduce bug: startdate - april-2013 enddate - june-2013 currency - VND Here's a fix which returns price=0 when price at date is invalid. I think this is safe. @@ -2592,6 +2592,9 @@ gnc_pricedb_get_nearest_price (GNCPriceDB *pdb, if (gnc_numeric_zero_p (price)) price = indirect_price_conversion (pdb, orig_currency, new_currency, t); + if (gnc_numeric_check (price)) + return gnc_numeric_zero (); + return gnc_numeric_reduce (price); }
Better fix -- gnc_pricedb_get_nearest_price may still return invalid gnc_numeric; convert_amount_at_date return gnc_numeric_zero if price is invalid. modified libgnucash/engine/gnc-pricedb.c @@ -2616,6 +2616,10 @@ static gnc_numeric convert_amount_at_date (GNCPriceDB *pdb, price = gnc_pricedb_get_nearest_price (pdb, orig_currency, new_currency, t); + /* some prices are invalid. return zero instead. see 798015 */ + if (gnc_numeric_check (price)) + return gnc_numeric_zero (); + return gnc_numeric_mul (amount, price, gnc_commodity_get_fraction (new_currency), GNC_HOW_DENOM_EXACT | GNC_HOW_RND_ROUND);
fixed in maint. Please build from latest, or latest flatpak from tomorrow onwards https://code.gnucash.org/builds/flatpak/maint/