From 9b4173362233d25e512583a7ebabe19bcab19171 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Wed, 9 Dec 2020 23:14:25 +0800 Subject: [PATCH] [balsheet-pnl] show most recent period first by default --- .../report/reports/standard/balsheet-pnl.scm | 17 ++++++++++++++++- .../reports/standard/test/test-balsheet-pnl.scm | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gnucash/report/reports/standard/balsheet-pnl.scm b/gnucash/report/reports/standard/balsheet-pnl.scm index 7b357e2185..a3e1ce75ac 100644 --- a/gnucash/report/reports/standard/balsheet-pnl.scm +++ b/gnucash/report/reports/standard/balsheet-pnl.scm @@ -62,6 +62,9 @@ https://bugs.gnucash.org/"))) (define optname-period (N_ "Period duration")) (define opthelp-period (N_ "Duration between time periods")) +(define optname-reverse-chrono (N_ "Period order is most recent first")) +(define opthelp-reverse-chrono (N_ "Period order is most recent first")) + (define optname-dual-columns (N_ "Enable dual columns")) (define opthelp-dual-columns (N_ "Selecting this option will enable double-column \ reporting.")) @@ -202,6 +205,8 @@ also show overall period profit & loss.")) options gnc:pagename-general optname-dual-columns (not x)) + (gnc-option-db-set-option-selectable-by-name + options gnc:pagename-general optname-reverse-chrono x) (case report-type ((balsheet) (gnc-option-db-set-option-selectable-by-name @@ -229,6 +234,11 @@ also show overall period profit & loss.")) gnc:pagename-general optname-dual-columns "c4" opthelp-dual-columns #t)) + (add-option + (gnc:make-simple-boolean-option + gnc:pagename-general optname-reverse-chrono + "c5" opthelp-reverse-chrono #t)) + (add-option (gnc:make-multichoice-option gnc:pagename-general optname-options-summary @@ -350,6 +360,7 @@ also show overall period profit & loss.")) (define* (add-multicolumn-acct-table table title accountlist maxindent get-cell-monetary-fn cols-data #:key + (reverse-cols? #f) (omit-zb-bals? #f) (show-zb-accts? #t) (disable-account-indent? #f) @@ -427,7 +438,7 @@ also show overall period profit & loss.")) (list account-cell) (gnc:html-make-empty-cells (if amount-indenting? (1- amount-indent) 0)) - rest + (if reverse-cols? (reverse rest) rest) (gnc:html-make-empty-cells (if amount-indenting? (- maxindent amount-indent) 0))))) (if row-markup @@ -749,6 +760,8 @@ also show overall period profit & loss.")) ((eq? report-type 'pnl) (list startdate enddate)) (else (list enddate)))) + (reverse-chrono? (get-option gnc:pagename-general optname-reverse-chrono)) + (report-dates-vec (list->vector report-dates)) (num-report-dates (vector-length report-dates-vec)) @@ -1057,6 +1070,7 @@ also show overall period profit & loss.")) table title accounts maxindent get-cell-monetary-fn (iota num-report-dates) + #:reverse-cols? reverse-chrono? #:omit-zb-bals? omit-zb-bals? #:show-zb-accts? show-zb-accts? #:disable-account-indent? disable-account-indent? @@ -1231,6 +1245,7 @@ also show overall period profit & loss.")) (> num-report-dates 2)) '(overall-period) '())) + #:reverse-cols? reverse-chrono? #:omit-zb-bals? omit-zb-bals? #:show-zb-accts? show-zb-accts? #:disable-account-indent? disable-account-indent? diff --git a/gnucash/report/reports/standard/test/test-balsheet-pnl.scm b/gnucash/report/reports/standard/test/test-balsheet-pnl.scm index 2d0d899795..68c10d834c 100644 --- a/gnucash/report/reports/standard/test/test-balsheet-pnl.scm +++ b/gnucash/report/reports/standard/test/test-balsheet-pnl.scm @@ -475,6 +475,7 @@ (define (multicol-balsheet-tests) (define (default-testing-options) (let ((options (gnc:make-report-options multicol-balsheet-uuid))) + (set-option! options "General" "Period order is most recent first" #f) (set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 1 1 1970))) (set-option! options "General" "End Date" @@ -557,6 +558,7 @@ (define (multicol-pnl-tests) (define (default-testing-options) (let ((options (gnc:make-report-options multicol-pnl-uuid))) + (set-option! options "General" "Period order is most recent first" #f) (set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 1 1 1980))) (set-option! options "General" "End Date"