gnucash master: Bug 797770 - Reconciliation report does not consider credit transactions

Christopher Lam clam at code.gnucash.org
Wed May 27 07:28:52 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/64198574 (commit)
	from  https://github.com/Gnucash/gnucash/commit/12680ebb (commit)



commit 641985746226d16f63d56169af96effdd231715f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon May 25 20:21:14 2020 +0800

    Bug 797770 - Reconciliation report does not consider credit transactions
    
    A few preparatory changes...
    
    * calculated-cells augmented to allow 7 fields instead of 6. 7th field
    defines whether cell is mergeable for subtotal-table. note only the
    first element in calculated-cells is currently considered for the
    subtotal-table accumulator.
    
    * backward compatible upgrade to trep-engine's add-subtotal-row --
    handles both 6-field and 7-field calculated-cells. 7th field, if
    missing, is assumed to be #f.
    
    * transaction report: unlock subtotal-table when amount='double in
    addition to 'single.
    
    And finally the bug fix itself:
    
    * reconcile-report: fix subtotal-table accumulator to consider both Dr
    and Cr

diff --git a/gnucash/report/reports/standard/reconcile-report.scm b/gnucash/report/reports/standard/reconcile-report.scm
index 822ecef1e..1d975bd07 100644
--- a/gnucash/report/reports/standard/reconcile-report.scm
+++ b/gnucash/report/reports/standard/reconcile-report.scm
@@ -85,10 +85,10 @@ to the Reconciliation Date.")
     ;; similar to default-calculated-cells but disable dual-subtotals.
     (list (vector (_ "Funds In")
                   debit-amount #f #t #f
-                  (const ""))
+                  (const "") #t)
           (vector (_ "Funds Out")
                   credit-amount #f #t #f
-                  (const "")))))
+                  (const "") #f))))
 
 (define (reconcile-report-renderer rpt)
   (gnc:trep-renderer
diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index c317941b4..5d4e30dac 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -905,7 +905,7 @@ be excluded from periodic reporting.")
 
       (gnc-option-db-set-option-selectable-by-name
        options gnc:pagename-display optname-grid
-       (eq? amount-value 'single))
+       (not (eq? amount-value 'none)))
 
       (gnc-option-db-set-option-selectable-by-name
        options gnc:pagename-display "Enable links"
@@ -947,7 +947,7 @@ be excluded from periodic reporting.")
       (list (N_ "Shares")                       "k"  (_ "Display the number of shares?") #f)
       (list (N_ "Price")                        "l"  (_ "Display the shares price?") #f)
       ;; note the "Amount" multichoice option in between here
-      (list optname-grid                        "m5" (_ "Display a subtotal summary table. This requires Display/Amount being 'single") #f)
+      (list optname-grid                        "m5" (_ "Display a subtotal summary table.") #f)
       (list (N_ "Running Balance")              "n"  (_ "Display a running balance?") #f)
       (list (N_ "Totals")                       "o"  (_ "Display the totals?") #t)))
 
@@ -1319,43 +1319,44 @@ be excluded from periodic reporting.")
          ;;         friendly-heading-fn (friendly-heading-fn account) to retrieve
          ;;                             friendly name for account debit/credit
          ;;                             or 'bal-bf for balance-brought-forward
+         ;;         start-dual-column?  #t: merge with next cell for subtotal table.
 
          (if (column-uses? 'amount-single)
              (list (vector (header-commodity (_ "Amount"))
                            converted-amount #t #t #f
-                           (lambda (a) "")))
+                           (lambda (a) "") #f))
              '())
 
          (if (column-uses? 'amount-double)
              (list (vector (header-commodity (_ "Debit"))
                            converted-debit-amount #f #t #t
-                           friendly-debit)
+                           friendly-debit #t)
                    (vector (header-commodity (_ "Credit"))
                            converted-credit-amount #f #t #f
-                           friendly-credit))
+                           friendly-credit #f))
              '())
 
          (if (and (column-uses? 'amount-original-currency)
                   (column-uses? 'amount-single))
              (list (vector (_ "Amount")
                            original-amount #t #t #f
-                           (lambda (a) "")))
+                           (lambda (a) "") #f))
              '())
 
          (if (and (column-uses? 'amount-original-currency)
                   (column-uses? 'amount-double))
              (list (vector (_ "Debit")
                            original-debit-amount #f #t #t
-                           friendly-debit)
+                           friendly-debit #t)
                    (vector (_ "Credit")
                            original-credit-amount #f #t #f
-                           friendly-credit))
+                           friendly-credit #f))
              '())
 
          (if (column-uses? 'running-balance)
              (list (vector (_ "Running Balance")
                            running-balance #t #f #f
-                           'bal-bf))
+                           'bal-bf #f))
              '()))))
 
     (define calculated-cells
@@ -1447,6 +1448,15 @@ be excluded from periodic reporting.")
                          (fn (xaccSplitGetAccount split))))))))
              calculated-cells))))))
 
+    ;; check first calculated-cell vector's 7th cell. originally these
+    ;; had only 6 cells. backward-compatible upgrade. useful for the
+    ;; next function, add-subtotal-row.
+    (define first-column-merge?
+      (let ((first-cell (and (pair? calculated-cells) (car calculated-cells))))
+        (and first-cell
+             (<= 7 (vector-length first-cell))
+             (vector-ref first-cell 6))))
+
     (define (add-subtotal-row subtotal-string subtotal-collectors
                               subtotal-style level row col)
       (let* ((left-indent (case level
@@ -1525,12 +1535,16 @@ be excluded from periodic reporting.")
                                  "total-number-cell" mon)
                                 result))))))))
 
-        ;; take the first column of each commodity, add onto the subtotal grid
+        (define (get-commodity-grid-amount commodity)
+          (define zero (gnc:make-gnc-monetary commodity 0))
+          (gnc:monetary+
+           (or (retrieve-commodity (car columns) commodity) zero)
+           (gnc:monetary-neg
+            (or (and first-column-merge? (retrieve-commodity (cadr columns) commodity))
+                zero))))
+
         (set! grid
-          (grid-add grid row col
-                    (map (lambda (commodity)
-                           (retrieve-commodity (car columns) commodity))
-                         list-of-commodities)))
+          (grid-add grid row col (map get-commodity-grid-amount list-of-commodities)))
 
         ;; each commodity subtotal gets a separate line in the html-table
         ;; each line comprises: indenting, first-column, data-columns
@@ -2023,8 +2037,8 @@ be excluded from periodic reporting.")
                                    (keylist-get-info date-subtotal-list
                                                      primary-date-subtotal 'renderer-fn)
                                    (opt-val pagename-sorting optname-prime-subtotal))
-                               (eq? (opt-val gnc:pagename-display (N_ "Amount"))
-                                    'single)))
+                               (memq (opt-val gnc:pagename-display (N_ "Amount"))
+                                     '(single double))))
          (infobox-display (opt-val gnc:pagename-general optname-infobox-display))
          (query (qof-query-create-for-splits)))
 



Summary of changes:
 .../report/reports/standard/reconcile-report.scm   |  4 +-
 gnucash/report/trep-engine.scm                     | 46 ++++++++++++++--------
 2 files changed, 32 insertions(+), 18 deletions(-)



More information about the gnucash-changes mailing list