gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Mon Aug 26 06:42:47 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/18aff5d1 (commit)
via https://github.com/Gnucash/gnucash/commit/0d35e7c6 (commit)
via https://github.com/Gnucash/gnucash/commit/6b0bfa07 (commit)
via https://github.com/Gnucash/gnucash/commit/d7813206 (commit)
from https://github.com/Gnucash/gnucash/commit/cc222515 (commit)
commit 18aff5d1c1743e42450d8cd2a6bfc65c7020d71c
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Aug 21 23:31:11 2019 +0800
Bug 797355 - General Journal report seems to be off balance
Previously, for general-journal, each split was being analyzed, and
only the source split was counted for totals. This change will means
the source split *and* its peers were accounted for.
diff --git a/gnucash/report/standard-reports/register.scm b/gnucash/report/standard-reports/register.scm
index 766952b8f..ec0d6bdb2 100644
--- a/gnucash/report/standard-reports/register.scm
+++ b/gnucash/report/standard-reports/register.scm
@@ -610,20 +610,15 @@
;; ----------------------------------------------
;; update totals, but don't add them to the table
;; ----------------------------------------------
- (if multi-rows?
- (for-each
- (lambda (split)
- (if (equal? (xaccSplitGetAccount current)
- (xaccSplitGetAccount split))
- (accumulate-totals split
- total-collector total-value
- debit-collector debit-value
- credit-collector credit-value)))
- (xaccTransGetSplitList (xaccSplitGetParent current)))
- (accumulate-totals current
- total-collector total-value
- debit-collector debit-value
- credit-collector credit-value))
+ (for-each
+ (lambda (split)
+ (accumulate-totals split
+ total-collector total-value
+ debit-collector debit-value
+ credit-collector credit-value))
+ (if multi-rows?
+ (xaccTransGetSplitList (xaccSplitGetParent current))
+ (list current)))
;; ----------------------------------
;; add the splits to the table
;; ----------------------------------
diff --git a/gnucash/report/standard-reports/test/test-register.scm b/gnucash/report/standard-reports/test/test-register.scm
index 05ed5db82..1daba08e3 100644
--- a/gnucash/report/standard-reports/test/test-register.scm
+++ b/gnucash/report/standard-reports/test/test-register.scm
@@ -64,6 +64,10 @@
(account-alist (create-test-data))
(bank (cdr (assoc "Bank" account-alist))))
+ (gnc-commodity-set-user-symbol
+ (xaccAccountGetCommodity (assoc-ref account-alist "GBP Bank"))
+ "#")
+
(let ((query (qof-query-create-for-splits)))
(qof-query-set-book query (gnc-get-current-book))
(xaccQueryAddAccountMatch query (list bank)
@@ -75,61 +79,93 @@
231
(length (sxml->table-row-col sxml 1 #f #f)))
- (test-equal "total debit = 2587"
+ (test-equal "total debit = $2587"
'("Total Debits" "$2,587.00")
(sxml->table-row-col sxml 1 -3 #f))
- (test-equal "total credits = 401"
+ (test-equal "total credits = $401"
'("Total Credits" "$401.00")
(sxml->table-row-col sxml 1 -1 #f)))
(set-option options "__reg" "journal" #t)
(let ((sxml (options->sxml options "journal")))
- (test-equal "table has 333 cells"
- 333
+ (test-equal "table has 337 cells"
+ 337
(length (sxml->table-row-col sxml 1 #f #f)))
- (test-equal "total debit = 2587"
- '("Total Debits" "$2,587.00")
- (sxml->table-row-col sxml 1 -3 #f))
+ (test-equal "total debit = #6"
+ '("Total Debits" "#6.00")
+ (sxml->table-row-col sxml 1 135 #f))
- (test-equal "total credits = 401"
- '("Total Credits" "$401.00")
- (sxml->table-row-col sxml 1 -1 #f)))
+ (test-equal "total debit = $2979"
+ '("Total Debits" "$2,979.00")
+ (sxml->table-row-col sxml 1 136 #f))
+
+ (test-equal "total credits = #10"
+ '("Total Credits" "#10.00")
+ (sxml->table-row-col sxml 1 138 #f))
+
+ (test-equal "total credits = 2974"
+ '("Total Credits" "$2,974.00")
+ (sxml->table-row-col sxml 1 139 #f)))
(set-option options "__reg" "ledger-type" #t)
(let ((sxml (options->sxml options "ledger-type")))
- (test-equal "table has 335 cells"
- 335
+ (test-equal "table has 341 cells"
+ 341
(length (sxml->table-row-col sxml 1 #f #f)))
- (test-equal "total debit = 2587"
- '("Total Debits" "$2,587.00")
- (sxml->table-row-col sxml 1 -5 #f))
+ (test-equal "total debit = #6"
+ '("Total Debits" "#6.00")
+ (sxml->table-row-col sxml 1 135 #f))
- (test-equal "total credits = 401"
- '("Total Credits" "$401.00")
- (sxml->table-row-col sxml 1 -3 #f))
+ (test-equal "total debit = $2979"
+ '("Total Debits" "$2,979.00")
+ (sxml->table-row-col sxml 1 136 #f))
- (test-equal "net change = 401"
- '("Net Change" "$2,186.00")
- (sxml->table-row-col sxml 1 -1 #f)))
+ (test-equal "total credits = #10"
+ '("Total Credits" "#10.00")
+ (sxml->table-row-col sxml 1 138 #f))
+
+ (test-equal "total credits = $2974"
+ '("Total Credits" "$2,974.00")
+ (sxml->table-row-col sxml 1 139 #f))
+
+ (test-equal "net change = #4"
+ '("Net Change" "#4.00")
+ (sxml->table-row-col sxml 1 141 #f))
+
+ (test-equal "net change = $5"
+ '("Net Change" "$5.00")
+ (sxml->table-row-col sxml 1 142 #f)))
(set-option options "__reg" "double" #t)
(let ((sxml (options->sxml options "double")))
- (test-equal "table has 339 cells"
- 339
+ (test-equal "table has 345 cells"
+ 345
(length (sxml->table-row-col sxml 1 #f #f)))
- (test-equal "total debit = 2587"
- '("Total Debits" "$2,587.00")
- (sxml->table-row-col sxml 1 -5 #f))
+ (test-equal "total debit = #6"
+ '("Total Debits" "#6.00")
+ (sxml->table-row-col sxml 1 179 #f))
- (test-equal "total credits = 401"
- '("Total Credits" "$401.00")
- (sxml->table-row-col sxml 1 -3 #f))
+ (test-equal "total debit = $2979"
+ '("Total Debits" "$2,979.00")
+ (sxml->table-row-col sxml 1 180 #f))
- (test-equal "net change = 401"
- '("Net Change" "$2,186.00")
- (sxml->table-row-col sxml 1 -1 #f)))
+ (test-equal "total credits = #10"
+ '("Total Credits" "#10.00")
+ (sxml->table-row-col sxml 1 182 #f))
+
+ (test-equal "total credits = $2974"
+ '("Total Credits" "$2,974.00")
+ (sxml->table-row-col sxml 1 183 #f))
+
+ (test-equal "net change = #4"
+ '("Net Change" "#4.00")
+ (sxml->table-row-col sxml 1 185 #f))
+
+ (test-equal "net change = $5"
+ '("Net Change" "$5.00")
+ (sxml->table-row-col sxml 1 186 #f)))
))
commit 0d35e7c63d60fc53092a18f00a097554ba4c1ce5
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 24 22:57:02 2019 +0800
[register] remove unused functions
diff --git a/gnucash/report/standard-reports/register.scm b/gnucash/report/standard-reports/register.scm
index 56d2e22a0..766952b8f 100644
--- a/gnucash/report/standard-reports/register.scm
+++ b/gnucash/report/standard-reports/register.scm
@@ -163,17 +163,6 @@
(addto! heading-list (_ "Balance")))
(reverse heading-list)))
-(define (gnc:split-get-balance-display split-info? split)
- (let* ((account (xaccSplitGetAccount split))
- (balance
- (if split-info?
- (xaccSplitGetBalance split)
- (xaccTransGetAccountBalance
- (xaccSplitGetParent split) account))))
- (if (and (not (null? account)) (gnc-reverse-balance account))
- (- balance)
- balance)))
-
(define (add-split-row table split column-vector row-style transaction-info?
split-info? action-for-num? ledger-type? double? memo?
description? total-collector)
@@ -360,10 +349,6 @@
(reverse row-contents))))))
split-value))
-(define (lookup-sort-key sort-option)
- (vector-ref (cdr (assq sort-option comp-funcs-assoc-list)) 0))
-(define (lookup-subtotal-pred sort-option)
- (vector-ref (cdr (assq sort-option comp-funcs-assoc-list)) 1))
(define (options-generator)
commit 6b0bfa075ca5c964e4b2df775b228271b2ecf378
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 24 22:53:31 2019 +0800
[register] fix Transfer acc for single-account splits
single account splits shouldn't show "-- Split Transaction --" in
transfer account. show "None".
diff --git a/gnucash/report/standard-reports/register.scm b/gnucash/report/standard-reports/register.scm
index e5673d092..56d2e22a0 100644
--- a/gnucash/report/standard-reports/register.scm
+++ b/gnucash/report/standard-reports/register.scm
@@ -228,16 +228,15 @@
(addto! row-contents
(gnc:make-html-table-cell/markup
"text-cell"
- (if split-info?
- (if transaction-info?
- (let ((other-split
- (xaccSplitGetOtherSplit split)))
- (if (not (null? other-split))
- (gnc-account-get-full-name
- (xaccSplitGetAccount other-split))
- (_ "-- Split Transaction --")))
- (gnc-account-get-full-name account))
- " "))))
+ (cond
+ ((not split-info?) #f)
+ ((not transaction-info?) (gnc-account-get-full-name account))
+ (else (case (xaccTransCountSplits (xaccSplitGetParent split))
+ ((2) (gnc-account-get-full-name
+ (xaccSplitGetAccount
+ (xaccSplitGetOtherSplit split))))
+ ((1) (_ "None"))
+ (else (_ "-- Split Transaction --"))))))))
(if (shares-col column-vector)
(addto! row-contents
(gnc:make-html-table-cell/markup
commit d7813206ce982364c1ba9bff02aa7bef868375d4
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Aug 24 22:38:29 2019 +0800
[register] compact functions, inline single-use function
diff --git a/gnucash/report/standard-reports/register.scm b/gnucash/report/standard-reports/register.scm
index 58f93da3a..e5673d092 100644
--- a/gnucash/report/standard-reports/register.scm
+++ b/gnucash/report/standard-reports/register.scm
@@ -516,27 +516,23 @@
(gnc:monetary-neg monetary)
monetary)))
- (if (or single-col credit-col debit-col)
- (begin
- (gnc:html-table-append-row!
- table
- (list
- (gnc:make-html-table-cell/size
- 1 (num-columns-required used-columns)
- (gnc:make-html-text (gnc:html-markup-hr)))))
-
- (for-each (lambda (currency)
- (gnc:html-table-append-row/markup!
- table
- subtotal-style
- (append (cons (gnc:make-html-table-cell/markup
- "total-label-cell" label)
- '())
- (list (gnc:make-html-table-cell/size/markup
- 1 (colspan currency)
- "total-number-cell"
- (display-subtotal currency))))))
- currency-totals)))))
+ (when (or single-col credit-col debit-col)
+ (gnc:html-table-append-row!
+ table
+ (list
+ (gnc:make-html-table-cell/size
+ 1 (num-columns-required used-columns)
+ (gnc:make-html-text (gnc:html-markup-hr)))))
+
+ (for-each
+ (lambda (monetary)
+ (gnc:html-table-append-row/markup!
+ table subtotal-style
+ (list (gnc:make-html-table-cell/markup "total-label-cell" label)
+ (gnc:make-html-table-cell/size/markup
+ 1 (colspan monetary) "total-number-cell"
+ (display-subtotal monetary)))))
+ currency-totals))))
(define (accumulate-totals split total-amount total-value
debit-amount debit-value
@@ -556,17 +552,6 @@
(total-amount 'add split-currency split-amount)
(total-value 'add trans-currency split-value)))
- (define (add-other-split-rows split table used-columns row-style
- action-for-num? ledger-type? total-collector)
- (let loop ((splits (xaccTransGetSplitList (xaccSplitGetParent split))))
- (when (pair? splits)
- (add-split-row table (car splits) used-columns row-style #f #t
- action-for-num? ledger-type? #f
- (opt-val "Display" "Memo")
- (opt-val "Display" "Description")
- total-collector)
- (loop (cdr splits)))))
-
(define (splits-leader splits)
(let ((accounts (map xaccSplitGetAccount splits)))
(and (pair? accounts)
@@ -664,10 +649,15 @@
double? (opt-val "Display" "Memo")
(opt-val "Display" "Description")
total-collector)
- (if multi-rows?
- (add-other-split-rows current table used-columns
- "alternate-row" action-for-num?
- ledger-type? total-collector))
+ (when multi-rows?
+ (for-each
+ (lambda (split)
+ (add-split-row table split used-columns "alternate-row"
+ #f #t action-for-num? ledger-type? #f
+ (opt-val "Display" "Memo")
+ (opt-val "Display" "Description") total-collector))
+ (xaccTransGetSplitList (xaccSplitGetParent current))))
+
(loop (cdr splits)
(not odd-row?))))))
table))
Summary of changes:
gnucash/report/standard-reports/register.scm | 119 ++++++++-------------
.../report/standard-reports/test/test-register.scm | 100 +++++++++++------
2 files changed, 112 insertions(+), 107 deletions(-)
More information about the gnucash-changes
mailing list