GnuCash
Contact   Instructions
Bug 797355 - General Journal report seems to be off balance
Summary: General Journal report seems to be off balance
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Reports (show other bugs)
Version: 3.6
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: reports
QA Contact: reports
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-18 13:57 EDT by Avi Markovitz
Modified: 2019-08-26 06:45 EDT (History)
4 users (show)

See Also:


Attachments
unbalanced register report (238.45 KB, image/png)
2019-08-18 13:57 EDT, Avi Markovitz
no flags Details
General Journal Report (322.56 KB, image/png)
2019-08-20 09:45 EDT, Avi Markovitz
no flags Details
Example book showing some journal report oddities. (71.34 KB, text/plain)
2019-08-20 13:39 EDT, John Ralls
no flags Details
CSV of the Journal Report. (1.34 KB, text/plain)
2019-08-20 13:45 EDT, John Ralls
no flags Details
trimmed journal (26.43 KB, image/png)
2019-08-21 02:22 EDT, Christopher Lam
no flags Details
screenshot showing change of value = $0 (8.50 KB, text/html)
2019-08-22 18:47 EDT, Christopher Lam
no flags Details

Description Avi Markovitz 2019-08-18 13:57:09 EDT
Created attachment 373363 [details]
unbalanced register report

I would expect total credit and debit in the register report to be equal and the difference should be zero. 

As can be seen in the attachment it is not the case (on my system)
Comment 1 John Ralls 2019-08-18 14:34:27 EDT
Why would you expect that unless the register that the report is based on happens to have a zero balance?
Comment 2 Avi Markovitz 2019-08-19 03:24:47 EDT
This register report (reprotrs->assets and liabilities->general journal), do not let you select any variables (accounts or dates) so it must pull all transactions from all accounts for all dates (or accounting period?). If this is the case, then the total debit and total credit of the journal should be equal (not zero), should be no difference between debit and credit totals.
Comment 3 John Ralls 2019-08-19 11:17:05 EDT
No, it's called a Register Report and is in the menu as Account Report for a reason: It pulls in the visible (i.e. not filtered by View>Filter By...) transactions in the register that has focus at the time that you run the report. You'll notice that it's not in the menu when the Accounts page has focus.

The primary use-case is to be able to create a custom report of sorts by running a Find query and then running the Account Report on the results register.

If you want a configurable dump of all of the transactions in the book use the Transaction Report.
Comment 4 Avi Markovitz 2019-08-20 09:45:29 EDT
Created attachment 373365 [details]
General Journal Report

Great! But that's not the report I was talking about. Please see the attached screenshot and the navigation to the report in question under the report menu. 
(The report on the menu is called 'General Journal' although the report header says 'Register."

I created this bug report not before I copied the entire report to a spreadsheet just to make sure that there actually is a total calculation issue. Unfortunately, there is one.
Comment 5 John Ralls 2019-08-20 13:36:11 EDT
Sorry, I misunderstood your comment 2. I've changed the bug title to point to the right report.

The results are the same when one runs the Account report on the register created by Tools>General Journal and changes the date in View>Filter By... to "All".

It does look like the report's debit total doesn't include everything: In fact with a simple book having only a few income and expense transactions there is no debit column at all.
Comment 6 John Ralls 2019-08-20 13:39:39 EDT
Created attachment 373366 [details]
Example book showing some journal report oddities.
Comment 7 John Ralls 2019-08-20 13:45:11 EDT
Created attachment 373367 [details]
CSV of the Journal Report.

I've created a sample book and made a spreadsheet of the General Journal Report (by hand, because the report won't copy-and-paste in an intelligible way).
The book includes some expenses, some income, a mutual fund purchase, dividend reinvestment, and sale.

Notice that the General Journal report doesn't even provide a total for the debits, and that the credits sum differs from the spreadsheet's by $250, the amount of the Income:Capital Gain  split.
Comment 8 Christopher Lam 2019-08-20 22:22:21 EDT
A single transaction book would be nice to debug this :)

If the General Journal delegates to the Register report we'll need to ensure the Register report isn't adversely affected.
Comment 9 John Ralls 2019-08-20 22:32:49 EDT
I'd say that it's more like the Register report has the same problem whatever it is.

Since the symptom is that not all debits are included in the total ISTM a single txn book isn't likely to exemplify the problem; rather what's needed is a book that contains one of every possible transaction type so that one can see what's common among the debit splits that are included in the total and those that aren't.
Comment 10 Christopher Lam 2019-08-21 02:22:25 EDT
Created attachment 373368 [details]
trimmed journal

I've trimmed the book by deleting all regular transactions.

So I understand the General Journal should show the following?

Total Debits  $125500
Total Debits 1011.231 PIODX
Total Credits                 $125500
Total Credits                1011.231 PIODX
Comment 11 Avi Markovitz 2019-08-21 09:38:28 EDT
Correct, that's what I'd expect
Comment 12 Christopher Lam 2019-08-21 11:20:58 EDT
Try the following hack. Basically remove the equality predicate. I don't think there's any negative effects. Need to test: all options in General Journal, and the Register report obtained from Register->Report->Account Report.

modified   gnucash/report/standard-reports/register.scm
@@ -644,8 +644,7 @@
           (if multi-rows?
               (for-each
                (lambda (split)
-                 (if (equal? (xaccSplitGetAccount current)
-                             (xaccSplitGetAccount split))
+                 (if #t
                      (accumulate-totals split
                                         total-collector total-value
                                         debit-collector debit-value
Comment 13 Christopher Lam 2019-08-21 11:23:44 EDT
Also need to test the above reports in a book *with* currency conversions
Comment 14 Christopher Lam 2019-08-22 01:40:55 EDT
P.S. while testing the above change please thoroughly test the "Value change" line  -- I suspect it'll now always show "$0.00". If this is the case, then perhaps we need to reconsider whether to remove this line, or the fix is incorrect?
Comment 15 John Ralls 2019-08-22 12:36:43 EDT
That's something of a special case of a single-commodity General Journal report. A register report of a single account will nearly always have a non-zero value change, and a multi-commodity General Journal often will as well: Consider that you hold 100 shares of XYZ bought for 1000 AUD: The report will show changes in value of +100 XYZ and -1000 AUD. Failing to record realized gains and losses will also produce a difference in debits and credits and so a change in value.
Comment 16 Avi Markovitz 2019-08-22 13:50:04 EDT
Sorry, but I can't make it run, after modifying register.scm, GnuCash crashes with the following error msg:

"avi@avi-PC-Mint19:~$ gnucash
;;; note: source file /home/avi/opt/share/gnucash/scm/html-document.scm
;;;       newer than compiled /home/avi/opt/lib/gnucash/scm/ccache/2.0/html-document.go
;;; found fresh local cache at /home/avi/.cache/guile/ccache/2.0-LE-8-2.0/home/avi/opt/share/gnucash/scm/html-document.scm.go
;;; note: source file /home/avi/opt/share/gnucash/scm/html-fonts.scm
;;;       newer than compiled /home/avi/opt/lib/gnucash/scm/ccache/2.0/html-fonts.go
;;; found fresh local cache at /home/avi/.cache/guile/ccache/2.0-LE-8-2.0/home/avi/opt/share/gnucash/scm/html-fonts.scm.go
Backtrace:
In ice-9/eval-string.scm:
  44: 19 [read-and-eval #<input: string 564540024340> #:lang ...]
  37: 18 [lp (use-modules (gnucash report standard-reports))]
In ice-9/eval.scm:
 505: 17 [#<procedure 56453f224520 at ice-9/eval.scm:499:4 (exp)> (use-modules #)]
In ice-9/psyntax.scm:
1106: 16 [expand-top-sequence ((use-modules #)) () ((top)) ...]
 989: 15 [scan ((use-modules (gnucash report standard-reports))) () ...]
 279: 14 [scan ((# #) #(syntax-object *unspecified* # #)) () (()) ...]
In ice-9/boot-9.scm:
3589: 13 [process-use-modules (((gnucash report standard-reports)))]
 705: 12 [map #<procedure 56453f2d5540 at ice-9/boot-9.scm:3589:25 (mif-args)> ((#))]
3590: 11 [#<procedure 56453f2d5540 at ice-9/boot-9.scm:3589:25 (mif-args)> (#)]
2867: 10 [resolve-interface (gnucash report standard-reports) #:select ...]
2792: 9 [#<procedure 56453f2cbde0 at ice-9/boot-9.scm:2780:4 (name #:optional autoload version #:key ensure)> # ...]
3068: 8 [try-module-autoload (gnucash report standard-reports) #f]
2404: 7 [save-module-excursion #<procedure 56453fb11630 at ice-9/boot-9.scm:3069:17 ()>]
3088: 6 [#<procedure 56453fb11630 at ice-9/boot-9.scm:3069:17 ()>]
In unknown file:
   ?: 5 [primitive-load-path "gnucash/report/standard-reports" ...]
In standard-reports.scm:
 119: 4 [#<procedure 5645402d4080 ()>]
In ice-9/boot-9.scm:
 778: 3 [for-each #<procedure 56453fd7e880 at standard-reports.scm:120:1 (x)> #]
In standard-reports.scm:
 123: 2 [#<procedure 56453fd7e880 at standard-reports.scm:120:1 (x)> #{register \x28;copy\x29;}#]
In ice-9/boot-9.scm:
2870: 1 [resolve-interface (gnucash report standard-reports ...) #:select ...]
In unknown file:
   ?: 0 [scm-error misc-error #f ...]

ERROR: In procedure scm-error:
ERROR: no code for module (gnucash report standard-reports #{register \x28;copy\x29;}#)"
Comment 17 Christopher Lam 2019-08-22 18:47:29 EDT
Created attachment 373371 [details]
screenshot showing change of value = $0

@jralls I mean the Value columns which are only present when Display/Value is switched on. It queries xaccSplitGetValue which always balances. See screenshot.

@avi you've renamed to register-copy.csm -- won't work. Edit register.scm directly.
Comment 18 Christopher Lam 2019-08-22 18:49:40 EDT
addendum @Jralls always balances for "General Journal" report. For Register->Report->Account Report it won't.
Comment 19 John Ralls 2019-08-22 19:27:57 EDT
OIC.

FWIW it works the same with trading accounts enabled. I guess it would be a surprise if it didn't.
Comment 20 Avi Markovitz 2019-08-26 05:21:45 EDT
This looks good to me...
Comment 21 Christopher Lam 2019-08-26 06:45:36 EDT
Fixed in maint, using a slightly different (neater) approach but equivalent logic. Thank you for reporting; the GJ report was annoying me for a while now.

Note You need to log in before you can comment on or make changes to this bug.