From d12ee9a4fc50265bfa2aeb6561bff1006f2f134f Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 1 Jul 2018 15:38:15 +0800 Subject: [PATCH 1/4] [commodity-utilities] prevent crash if end-date is #f crash happens when (I think) no valid splits found. --- gnucash/report/report-system/commodity-utilities.scm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm index 1328f1b310..a6b8bbdc90 100644 --- a/gnucash/report/report-system/commodity-utilities.scm +++ b/gnucash/report/report-system/commodity-utilities.scm @@ -48,8 +48,9 @@ (xaccQueryAddAccountMatch query currency-accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND) - (xaccQueryAddDateMatchTT - query #f end-date #t end-date QOF-QUERY-AND) + (if end-date + (xaccQueryAddDateMatchTT + query #f end-date #t end-date QOF-QUERY-AND)) ;; Get the query result, i.e. all splits in currency ;; accounts. From 5c8af37901bba6e8c8d7a0f0c97f840a25edba75 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 2 Jul 2018 08:58:05 +0800 Subject: [PATCH 2/4] [tests] modify load-path to find the parent directory Find the parent directory programmatically. --- gnucash/report/business-reports/test/test-invoice.scm | 4 +++- gnucash/report/standard-reports/test/test-transaction.scm | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gnucash/report/business-reports/test/test-invoice.scm b/gnucash/report/business-reports/test/test-invoice.scm index 3db7c4a864..52159d6c47 100644 --- a/gnucash/report/business-reports/test/test-invoice.scm +++ b/gnucash/report/business-reports/test/test-invoice.scm @@ -26,7 +26,9 @@ (run-test-proper))) (define (coverage-test tester) - (add-to-load-path "/home/chris/sources/gnucash/gnucash/report/business-reports") + (let* ((currfile (dirname (current-filename))) + (path (string-take currfile (string-rindex currfile #\/)))) + (add-to-load-path path)) (call-with-values (lambda() (with-code-coverage tester)) diff --git a/gnucash/report/standard-reports/test/test-transaction.scm b/gnucash/report/standard-reports/test/test-transaction.scm index 56f6ffc453..08be14d4e6 100644 --- a/gnucash/report/standard-reports/test/test-transaction.scm +++ b/gnucash/report/standard-reports/test/test-transaction.scm @@ -50,11 +50,12 @@ (run-test-proper))) (define (coverage-test) - (define %test-vm (make-vm)) - (add-to-load-path "/home/chris/sources/gnucash/gnucash/report/standard-reports") + (let* ((currfile (dirname (current-filename))) + (path (string-take currfile (string-rindex currfile #\/)))) + (add-to-load-path path)) (call-with-values (lambda() - (with-code-coverage %test-vm run-test-proper)) + (with-code-coverage run-test-proper)) (lambda (data result) (let ((port (open-output-file "/tmp/lcov.info"))) (coverage-data->lcov data port) From 0594beb08112c8fff19d198b505e85ed64bea8e5 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 5 Jul 2018 15:43:08 +0800 Subject: [PATCH 3/4] Bug 779888 - Find Transaction by Value will not always find a split when commodities change This commit changes the "Shares" find-text to "Amount". Thus, a transfer from USD for 100USD -> 80GBP will be found if "Amount=80" or "Amount=100" are chosen. A search for "Value=80" will not find it. Perhaps the "Value" search option should be removed? --- gnucash/gnome/dialog-find-transactions2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnucash/gnome/dialog-find-transactions2.c b/gnucash/gnome/dialog-find-transactions2.c index 93514bd637..15b02da60d 100644 --- a/gnucash/gnome/dialog-find-transactions2.c +++ b/gnucash/gnome/dialog-find-transactions2.c @@ -121,7 +121,7 @@ gnc_ui_find_transactions_dialog_create2 (GNCLedgerDisplay2 * orig_ledg) type, SPLIT_RECONCILE, NULL); params = gnc_search_param_prepend (params, N_("Share Price"), NULL, type, SPLIT_SHARE_PRICE, NULL); - params = gnc_search_param_prepend (params, N_("Shares"), NULL, + params = gnc_search_param_prepend (params, N_("Amount"), NULL, type, SPLIT_AMOUNT, NULL); params = gnc_search_param_prepend (params, N_("Value"), NULL, type, SPLIT_VALUE, NULL); From 582265d0c6b3a499ca50a761633be02ad742c5cd Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 5 Jul 2018 19:37:41 +0800 Subject: [PATCH 4/4] [job-report] Prevent Crash if there is no AR account I think this crash is triggered because the 'account' variable defaults to the first available AR account. If there's no AR account it becomes null, and querying null's default book leads to segfault. I guess I can fix segfault too by fixing gnc_account_get_book. --- gnucash/report/business-reports/job-report.scm | 2 +- libgnucash/engine/Account.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gnucash/report/business-reports/job-report.scm b/gnucash/report/business-reports/job-report.scm index 40b2bbfd51..e58f5a33d8 100644 --- a/gnucash/report/business-reports/job-report.scm +++ b/gnucash/report/business-reports/job-report.scm @@ -541,7 +541,7 @@ (end-date (gnc:time64-end-day-time (gnc:date-option-absolute-time (opt-val gnc:pagename-general (N_ "To"))))) - (book (gnc-account-get-book account)) + (book (gnc-get-current-book)) (date-format (gnc:options-fancy-date book)) (type (opt-val "__reg" "owner-type")) (type-str "") diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index a1144562a6..7920660cd3 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -1015,6 +1015,7 @@ xaccInitAccount (Account * acc, QofBook *book) QofBook * gnc_account_get_book(const Account *account) { + if (!account) return NULL; return qof_instance_get_book(QOF_INSTANCE(account)); }