mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge Vincent Dawans' branch 'bug798879' into stable #1617
This commit is contained in:
commit
d214b2f05d
@ -226,6 +226,7 @@ with *EUGOODS* in the account description."))
|
||||
(GncOptionDBPtr-make-internal options gnc:pagename-display "Amount")
|
||||
(GncOptionDBPtr-make-internal options gnc:pagename-display "Sign Reverses")
|
||||
(GncOptionDBPtr-make-internal options gnc:pagename-display "Running Balance")
|
||||
(GncOptionDBPtr-make-internal options gnc:pagename-display "Running Totals")
|
||||
;; No multilines allowed
|
||||
(GncOptionDBPtr-make-internal options gnc:pagename-display "Detail Level")
|
||||
(GncOptionDBPtr-make-internal options pagename-sorting "Show Informal Debit/Credit Headers")
|
||||
|
@ -299,7 +299,16 @@
|
||||
(test-equal "month total present, and is $190 in original-currency"
|
||||
'("$190.00")
|
||||
(get-row-col sxml 6 -1))
|
||||
))
|
||||
)
|
||||
|
||||
;; dual columns with all running totals
|
||||
(set-option! options "Display" "Running Totals" 'all)
|
||||
(let ((sxml (options->sxml options "test column headers with original currency and running totals")))
|
||||
(test-equal "default headers with all running totals, indented, includes common-currency"
|
||||
'("Date" "Num" "Description" "Memo/Notes" "Account" "Amount (USD)"
|
||||
"Running Secondary Subtotal (USD)" "Running Primary Subtotal (USD)" "Running Grand Total (USD)"
|
||||
"Amount" "Running Secondary Subtotal" "Running Primary Subtotal" "Running Grand Total")
|
||||
(get-row-col sxml 0 #f))))
|
||||
|
||||
(test-end "general options")
|
||||
|
||||
@ -478,7 +487,7 @@
|
||||
(set-option! options "Display" name #f))
|
||||
(list "Date" "Reconciled Date" "Num" "Description" "Memo" "Notes"
|
||||
"Account Name" "Other Account Name" "Shares" "Price" "Account Balance"
|
||||
"Totals"))
|
||||
"Grand Total"))
|
||||
(let ((sxml (options->sxml options "all columns off")))
|
||||
(test-assert "all display columns off, except amount and subtotals are enabled, there should be 2 columns"
|
||||
(= (length ((sxpath '(// (table 1) // (tr 1) // th)) sxml))
|
||||
@ -536,11 +545,12 @@
|
||||
(set-option! options "Display" name #t))
|
||||
(list "Date" "Reconciled Date" "Num" "Description" "Memo" "Notes"
|
||||
"Account Name" "Other Account Name" "Shares" "Price" "Account Balance"
|
||||
"Totals" "Use Full Other Account Name" "Use Full Account Name"))
|
||||
"Grand Total" "Use Full Other Account Name" "Use Full Account Name"))
|
||||
(set-option! options "Display" "Running Totals" 'grand)
|
||||
(let* ((sxml (options->sxml options "all columns on")))
|
||||
(test-equal "all display columns on, displays correct columns"
|
||||
(list "Date" "Reconciled Date" "Num" "Description" "Memo/Notes" "Account"
|
||||
"Transfer from/to" "Shares" "Price" "Amount" "Account Balance")
|
||||
"Transfer from/to" "Shares" "Price" "Amount" "Account Balance" "Running Grand Total")
|
||||
(get-row-col sxml 0 #f))
|
||||
(test-assert "reconciled dates must be 01/03/70 or whitespace"
|
||||
(and-map
|
||||
@ -561,7 +571,7 @@
|
||||
(set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 13 02 1971)))
|
||||
(set-option! options "General" "End Date" (cons 'absolute (gnc-dmy2time64 15 02 1971)))
|
||||
(set-option! options "Display" "Detail Level" 'multi-line)
|
||||
(set-option! options "Display" "Totals" #f)
|
||||
(set-option! options "Display" "Grand Total" #f)
|
||||
(set-option! options "Sorting" "Primary Subtotal" #f)
|
||||
(set-option! options "Sorting" "Primary Subtotal for Date Key" 'none)
|
||||
(set-option! options "Sorting" "Secondary Subtotal" #f)
|
||||
@ -700,6 +710,20 @@
|
||||
(test-equal "running balance, showing Balance b/f"
|
||||
(list "Bank: Balance b/f" "-$99.00")
|
||||
(get-row-col sxml 1 #f)))
|
||||
|
||||
;; test running grand total
|
||||
(set! options (default-testing-options))
|
||||
(set-option! options "Display" "Running Totals" 'grand)
|
||||
(set-option! options "Sorting" "Primary Subtotal" #f)
|
||||
(let* ((sxml (options->sxml options "running grand total"))
|
||||
(cs (char-set-adjoin! (char-set-copy char-set:digit) #\-)))
|
||||
(test-equal "Last running grand total equals grand total"
|
||||
(get-row-col sxml -3 -1)
|
||||
(get-row-col sxml -1 -2))
|
||||
(test-equal "Row 9 running grand total matches row 8 running grand total + row 9 amount"
|
||||
(+ (string->number (string-filter cs (car (get-row-col sxml 8 -1))))
|
||||
(string->number (string-filter cs (car (get-row-col sxml 9 -2)))))
|
||||
(string->number (string-filter cs (car (get-row-col sxml 9 -1))))))
|
||||
)
|
||||
|
||||
(test-end "display options")
|
||||
@ -711,7 +735,7 @@
|
||||
(set-option! options "General" "End Date" (cons 'absolute (gnc-dmy2time64 31 12 1970)))
|
||||
;;(set-option! options "Accounts" "Accounts" (gnc-account-get-descendants (gnc-account-get-root bank)))
|
||||
(set-option! options "Accounts" "Accounts" (list bank))
|
||||
(set-option! options "Display" "Totals" #f)
|
||||
(set-option! options "Display" "Grand Total" #f)
|
||||
(set-option! options "Display" "Other Account Name" #t)
|
||||
(set-option! options "Filter" "Void Transactions" 'both)
|
||||
(set-option! options "Sorting" "Primary Subtotal" #f)
|
||||
@ -773,7 +797,7 @@
|
||||
(set-option! options "Sorting" "Primary Subtotal" #t)
|
||||
(set-option! options "Sorting" "Secondary Key" 'date)
|
||||
(set-option! options "Sorting" "Secondary Subtotal for Date Key" 'monthly)
|
||||
(set-option! options "Display" "Totals" #t)
|
||||
(set-option! options "Display" "Grand Total" #t)
|
||||
(set-option! options "Sorting" "Secondary Subtotal for Date Key" 'quarterly)
|
||||
(set-option! options "Sorting" "Show subtotals only (hide transactional data)" #t)
|
||||
(let* ((sxml (options->sxml options "sorting=account-name, date-quarterly, subtotals only")))
|
||||
@ -783,7 +807,7 @@
|
||||
|
||||
(set! options (default-testing-options))
|
||||
(set-option! options "Accounts" "Accounts" (gnc-account-get-descendants (gnc-account-get-root bank)))
|
||||
(set-option! options "Display" "Totals" #t)
|
||||
(set-option! options "Display" "Grand Total" #t)
|
||||
(set-option! options "Display" "Amount" 'double)
|
||||
(set-option! options "Currency" "Show original currency amount" #t)
|
||||
(set-option! options "General" "Table for Exporting" #f)
|
||||
@ -803,7 +827,7 @@
|
||||
(get-row-col sxml 91 #f)))
|
||||
|
||||
(set-option! options "Accounts" "Accounts" (list bank))
|
||||
(set-option! options "Display" "Totals" #f)
|
||||
(set-option! options "Display" "Grand Total" #f)
|
||||
(set-option! options "Sorting" "Show subtotals only (hide transactional data)" #t)
|
||||
(let* ((sxml (options->sxml options "sorting=date quarterly")))
|
||||
(test-equal "quarterly subtotals are correct"
|
||||
@ -840,7 +864,80 @@
|
||||
(get-row-col sxml #f 4))
|
||||
(test-equal "weekly subtotals are correct (2)"
|
||||
'("$15.00" "$8.00" "$100.00")
|
||||
(get-row-col sxml #f 5))))
|
||||
(get-row-col sxml #f 5)))
|
||||
|
||||
;; test running subtotals
|
||||
(set! options (default-testing-options))
|
||||
(set-option! options "Display" "Grand Total" #f)
|
||||
(set-option! options "Display" "Running Totals" 'sub)
|
||||
(set-option! options "Sorting" "Primary Key" 'account-name)
|
||||
(set-option! options "Sorting" "Primary Subtotal" #t)
|
||||
(set-option! options "Sorting" "Secondary Key" 'date)
|
||||
(set-option! options "Sorting" "Secondary Subtotal for Date Key" 'monthly)
|
||||
(let* ((sxml (options->sxml options "running subtotals"))
|
||||
(cs (char-set-adjoin! (char-set-copy char-set:digit) #\-)))
|
||||
(test-equal "Running subtotal columns are present"
|
||||
(list "Date" "Num" "Description" "Memo/Notes" "Account" "Amount"
|
||||
"Running Secondary Subtotal" "Running Primary Subtotal")
|
||||
(get-row-col sxml 0 #f))
|
||||
(test-equal "Last running primary subtotal equals primary subtotal"
|
||||
(get-row-col sxml -3 -1)
|
||||
(get-row-col sxml -1 -3))
|
||||
(test-equal "Row 10 running primary subtotal matches row 9 running primary subtotal + row 10 amount"
|
||||
(+ (string->number (string-filter cs (car (get-row-col sxml 9 -1))))
|
||||
(string->number (string-filter cs (car (get-row-col sxml 10 -3)))))
|
||||
(string->number (string-filter cs (car (get-row-col sxml 10 -1)))))
|
||||
(test-equal "In first secondary group, last running secondary subtotal equals secondary subtotal"
|
||||
(get-row-col sxml 5 -2)
|
||||
(get-row-col sxml 6 -3))
|
||||
(test-equal "Row 10 running secondary subtotal matches row 9 running secondary subtotal + row 10 amount"
|
||||
(+ (string->number (string-filter cs (car (get-row-col sxml 9 -2))))
|
||||
(string->number (string-filter cs (car (get-row-col sxml 10 -3)))))
|
||||
(string->number (string-filter cs (car (get-row-col sxml 10 -2))))))
|
||||
;; test all running totals shown
|
||||
(set-option! options "Display" "Running Totals" 'all)
|
||||
(let* ((sxml (options->sxml options "all running totals"))
|
||||
(cs (char-set-adjoin! (char-set-copy char-set:digit) #\-)))
|
||||
(test-equal "All running total columns are present"
|
||||
(list "Date" "Num" "Description" "Memo/Notes" "Account" "Amount"
|
||||
"Running Secondary Subtotal" "Running Primary Subtotal" "Running Grand Total")
|
||||
(get-row-col sxml 0 #f)))
|
||||
;; test no running totals shown
|
||||
(set-option! options "Display" "Running Totals" 'none)
|
||||
(let* ((sxml (options->sxml options "no running totals"))
|
||||
(cs (char-set-adjoin! (char-set-copy char-set:digit) #\-)))
|
||||
(test-equal "No running total columns are present"
|
||||
(list "Date" "Num" "Description" "Memo/Notes" "Account" "Amount")
|
||||
(get-row-col sxml 0 #f)))
|
||||
|
||||
;; test that only columns with subtotals are displayed when
|
||||
;; "Show subtotals only (hide transactional data)" is selected
|
||||
(set! options (default-testing-options))
|
||||
(for-each
|
||||
(lambda (name)
|
||||
(set-option! options "Display" name #t))
|
||||
(list "Date" "Reconciled Date" "Num" "Description" "Memo" "Notes"
|
||||
"Account Name" "Other Account Name" "Shares" "Price" "Account Balance"
|
||||
"Grand Total" "Use Full Other Account Name" "Use Full Account Name"))
|
||||
(set-option! options "Display" "Running Totals" 'all)
|
||||
(set-option! options "Sorting" "Primary Key" 'account-name)
|
||||
(set-option! options "Sorting" "Primary Subtotal" #t)
|
||||
(set-option! options "Sorting" "Secondary Key" 'date)
|
||||
(set-option! options "Sorting" "Secondary Subtotal for Date Key" 'monthly)
|
||||
(set-option! options "Sorting" "Show subtotals only (hide transactional data)" #t)
|
||||
(set-option! options "Currency" "Common Currency" #t)
|
||||
(set-option! options "Currency" "Show original currency amount" #t)
|
||||
(let* ((sxml (options->sxml options "show subtotals only, single column")))
|
||||
(test-equal "all display columns on with single amount; show subtotals only, so only amount columns are shown"
|
||||
(list "Amount (USD)" "Amount")
|
||||
(get-row-col sxml 0 #f)))
|
||||
|
||||
(set-option! options "Display" "Amount" 'double)
|
||||
(let* ((sxml (options->sxml options "show subtotals only, dual column")))
|
||||
(test-equal "all display columns on with dual amount; show subtotals only, so only debit/credit columns are shown"
|
||||
(list "Debit (USD)" "Credit (USD)" "Debit" "Credit")
|
||||
(get-row-col sxml 0 #f)))
|
||||
)
|
||||
|
||||
(test-end "sorting options")
|
||||
|
||||
|
@ -74,6 +74,12 @@
|
||||
;;Display
|
||||
(define optname-detail-level (N_ "Detail Level"))
|
||||
(define optname-grid (N_ "Subtotal Table"))
|
||||
(define optname-grand-total (N_ "Grand Total"))
|
||||
;; Translators: a running total is a total that is continually adjusted on every line.
|
||||
;; To be consistent, also consider how the term "Running Balance" is translated.
|
||||
;; "Running Totals" is the plural form as it refers to the running total and running subtotals.
|
||||
;; To be consistent, also consider how the singular form "Running Total" is translated.
|
||||
(define optname-running-totals (N_ "Running Totals"))
|
||||
|
||||
;;Sorting
|
||||
(define pagename-sorting (N_ "Sorting"))
|
||||
@ -921,7 +927,7 @@ be excluded from periodic reporting.")
|
||||
;; note the "Amount" multichoice option in between here
|
||||
(list optname-grid "m5" (G_ "Display a subtotal summary table.") #f)
|
||||
(list (N_ "Account Balance") "n" (G_ "Display the balance of the underlying account on each line?") #f)
|
||||
(list (N_ "Totals") "o" (G_ "Display the totals?") #t)))
|
||||
(list optname-grand-total "o" (G_ "Display a grand total section at the bottom?") #t)))
|
||||
|
||||
(when BOOK-SPLIT-ACTION
|
||||
(gnc-register-simple-boolean-option options
|
||||
@ -983,7 +989,16 @@ be excluded from periodic reporting.")
|
||||
gnc:pagename-display (N_ "Sign Reverses")
|
||||
"m1" (G_ "Reverse amount display for certain account types.")
|
||||
"global"
|
||||
(keylist->vectorlist sign-reverse-list)))
|
||||
(keylist->vectorlist sign-reverse-list))
|
||||
|
||||
(gnc-register-multichoice-option options
|
||||
gnc:pagename-display optname-running-totals
|
||||
"o2" (G_ "Display running totals as per report sort order?")
|
||||
"none"
|
||||
(list (vector 'none (G_ "None"))
|
||||
(vector 'all (G_ "Grand Total and Subtotals"))
|
||||
(vector 'grand (G_ "Grand Total Only"))
|
||||
(vector 'sub (G_ "Subtotals Only")))))
|
||||
|
||||
;; this hidden option will toggle whether the default
|
||||
;; qof-query is run, or a different query which ensures
|
||||
@ -1058,6 +1073,17 @@ be excluded from periodic reporting.")
|
||||
(or (primary-get-info 'renderer-fn)
|
||||
(secondary-get-info 'renderer-fn))))
|
||||
(cons 'running-balance (opt-val gnc:pagename-display "Account Balance"))
|
||||
(cons 'running-grand-total
|
||||
(or (eq? (opt-val gnc:pagename-display optname-running-totals) 'grand)
|
||||
(eq? (opt-val gnc:pagename-display optname-running-totals) 'all)))
|
||||
(cons 'running-prime
|
||||
(and (primary-get-info 'renderer-fn)
|
||||
(or (eq? (opt-val gnc:pagename-display optname-running-totals) 'sub)
|
||||
(eq? (opt-val gnc:pagename-display optname-running-totals) 'all))))
|
||||
(cons 'running-sec
|
||||
(and (secondary-get-info 'renderer-fn)
|
||||
(or (eq? (opt-val gnc:pagename-display optname-running-totals) 'sub)
|
||||
(eq? (opt-val gnc:pagename-display optname-running-totals) 'all))))
|
||||
(cons 'account-full-name
|
||||
(opt-val gnc:pagename-display (N_ "Use Full Account Name")))
|
||||
(cons 'memo (opt-val gnc:pagename-display (N_ "Memo")))
|
||||
@ -1143,6 +1169,18 @@ be excluded from periodic reporting.")
|
||||
(gnc:accounts-get-commodities c_account_1 #f) enddate #f #f)
|
||||
gnc:exchange-by-pricedb-nearest))
|
||||
|
||||
;; Returns #t if a calculated-cell definition has the subtotal flag
|
||||
(define (cell-with-subtotals? cell)
|
||||
(assq-ref cell 'subtotal?))
|
||||
|
||||
;; Collectors for running total and subtotals
|
||||
(define converted-running-total-collector (gnc:make-commodity-collector))
|
||||
(define original-running-total-collector (gnc:make-commodity-collector))
|
||||
(define converted-running-prime-collector (gnc:make-commodity-collector))
|
||||
(define original-running-prime-collector (gnc:make-commodity-collector))
|
||||
(define converted-running-sec-collector (gnc:make-commodity-collector))
|
||||
(define original-running-sec-collector (gnc:make-commodity-collector))
|
||||
|
||||
(define left-columns
|
||||
(let* ((add-if (lambda (pred? . items) (if pred? items '())))
|
||||
(left-cols-list
|
||||
@ -1284,7 +1322,7 @@ be excluded from periodic reporting.")
|
||||
|
||||
(if (or (column-uses? 'subtotals-only)
|
||||
(and (null? left-cols-list)
|
||||
(or (opt-val gnc:pagename-display "Totals")
|
||||
(or (opt-val gnc:pagename-display optname-grand-total)
|
||||
(primary-get-info 'renderer-fn)
|
||||
(secondary-get-info 'renderer-fn))))
|
||||
`(((heading . "") (renderer-fn . ,(const #f))))
|
||||
@ -1347,7 +1385,46 @@ be excluded from periodic reporting.")
|
||||
(gnc:monetary-neg (original-amount s tr?)))))
|
||||
(original-account-balance (lambda (s tr?)
|
||||
(gnc:make-gnc-monetary
|
||||
(split-currency s) (xaccSplitGetBalance s)))))
|
||||
(split-currency s) (xaccSplitGetBalance s))))
|
||||
;; Helper function to add the splits to the running total collectors.
|
||||
;; Third argument is the function that returns converted or original amount.
|
||||
;; Returns current monetary from specified running total collector.
|
||||
(add-split-to-collector (lambda (s tr? coll amt-fn)
|
||||
(coll 'add
|
||||
(gnc:gnc-monetary-commodity (amt-fn s tr?))
|
||||
(gnc:gnc-monetary-amount (amt-fn s tr?)))
|
||||
(coll 'getmonetary
|
||||
(gnc:gnc-monetary-commodity (amt-fn s tr?)) #f)))
|
||||
(converted-running-total (lambda (s tr?)
|
||||
(and tr?
|
||||
(add-split-to-collector s tr?
|
||||
converted-running-total-collector
|
||||
converted-amount))))
|
||||
(converted-running-prime (lambda (s tr?)
|
||||
(and tr?
|
||||
(add-split-to-collector s tr?
|
||||
converted-running-prime-collector
|
||||
converted-amount))))
|
||||
(converted-running-sec (lambda (s tr?)
|
||||
(and tr?
|
||||
(add-split-to-collector s tr?
|
||||
converted-running-sec-collector
|
||||
converted-amount))))
|
||||
(original-running-total (lambda (s tr?)
|
||||
(and tr?
|
||||
(add-split-to-collector s tr?
|
||||
original-running-total-collector
|
||||
original-amount))))
|
||||
(original-running-prime (lambda (s tr?)
|
||||
(and tr?
|
||||
(add-split-to-collector s tr?
|
||||
original-running-prime-collector
|
||||
original-amount))))
|
||||
(original-running-sec (lambda (s tr?)
|
||||
(and tr?
|
||||
(add-split-to-collector s tr?
|
||||
original-running-sec-collector
|
||||
original-amount)))))
|
||||
(append
|
||||
;; each column will be a list of pairs whose car is a metadata header,
|
||||
;; and whose cdr is the procedure, string or bool to obtain the metadata
|
||||
@ -1411,6 +1488,63 @@ be excluded from periodic reporting.")
|
||||
(cons 'merge-dual-column? #f))))
|
||||
'())
|
||||
|
||||
(if (column-uses? 'running-sec)
|
||||
(list (list (cons 'heading (header-commodity
|
||||
;; Translators: this is the running total for the secondary subtotal.
|
||||
;; For translation to be consistent, make sure it follows the same
|
||||
;; pattern as for these other strings: “Running Totals”,
|
||||
;; "Secondary Subtotal” and "Running Primary Subtotal"
|
||||
(G_ "Running Secondary Subtotal")))
|
||||
(cons 'calc-fn converted-running-sec)
|
||||
(cons 'reverse-column? #f)
|
||||
(cons 'subtotal? #f)
|
||||
(cons 'start-dual-column? #f)
|
||||
(cons 'friendly-heading-fn (const ""))
|
||||
(cons 'merge-dual-column? #f)))
|
||||
'())
|
||||
|
||||
(if (column-uses? 'running-prime)
|
||||
(list (list (cons 'heading (header-commodity
|
||||
(if (secondary-get-info 'renderer-fn)
|
||||
;; Translators: this is the running total for the primary subtotal.
|
||||
;; For translation to be consistent, make sure it follows the same
|
||||
;; pattern as for these other strings: “Running Totals” and
|
||||
;; “Primary Subtotal”
|
||||
(G_ "Running Primary Subtotal")
|
||||
;; Translators: "Running Subtotal" is a shorter version of
|
||||
;; "Running Primary Subtotal" used when a running primary subtotal
|
||||
;; is displayed without a secondary subtotal.
|
||||
(G_ "Running Subtotal"))))
|
||||
(cons 'calc-fn converted-running-prime)
|
||||
(cons 'reverse-column? #f)
|
||||
(cons 'subtotal? #f)
|
||||
(cons 'start-dual-column? #f)
|
||||
(cons 'friendly-heading-fn (const ""))
|
||||
(cons 'merge-dual-column? #f)))
|
||||
'())
|
||||
|
||||
(if (column-uses? 'running-grand-total)
|
||||
(list (list (cons 'heading (header-commodity
|
||||
(if (or (primary-get-info 'renderer-fn)
|
||||
(secondary-get-info 'renderer-fn))
|
||||
;; Translators: this is the running total for the grand total.
|
||||
;; For translation to be consistent, make sure it follows the same
|
||||
;; pattern as for these other strings: “Running Totals” and
|
||||
;; "Grand Total”
|
||||
(G_ "Running Grand Total")
|
||||
;; Translators: "Running Total" is a shorter version of
|
||||
;; "Running Grand Total" used when the running grand total is
|
||||
;; displayed without subtotals. To be consistent, also consider
|
||||
;; how the plural form "Running Totals" is translated.
|
||||
(G_ "Running Total"))))
|
||||
(cons 'calc-fn converted-running-total)
|
||||
(cons 'reverse-column? #f)
|
||||
(cons 'subtotal? #f)
|
||||
(cons 'start-dual-column? #f)
|
||||
(cons 'friendly-heading-fn (const ""))
|
||||
(cons 'merge-dual-column? #f)))
|
||||
'())
|
||||
|
||||
(if (and (column-uses? 'amount-original-currency)
|
||||
(column-uses? 'amount-single))
|
||||
(list (list (cons 'heading (G_ "Amount"))
|
||||
@ -1457,20 +1591,65 @@ be excluded from periodic reporting.")
|
||||
(cons 'start-dual-column? #f)
|
||||
(cons 'friendly-heading-fn #f)
|
||||
(cons 'merge-dual-column? #f))))
|
||||
'())
|
||||
|
||||
(if (and (column-uses? 'amount-original-currency)
|
||||
(column-uses? 'running-sec))
|
||||
(list (list (cons 'heading (G_ "Running Secondary Subtotal"))
|
||||
(cons 'calc-fn original-running-sec)
|
||||
(cons 'reverse-column? #f)
|
||||
(cons 'subtotal? #f)
|
||||
(cons 'start-dual-column? #f)
|
||||
(cons 'friendly-heading-fn (const ""))
|
||||
(cons 'merge-dual-column? #f)))
|
||||
'())
|
||||
|
||||
(if (and (column-uses? 'amount-original-currency)
|
||||
(column-uses? 'running-prime))
|
||||
(list (list (cons 'heading
|
||||
(if (secondary-get-info 'renderer-fn)
|
||||
(G_ "Running Primary Subtotal")
|
||||
(G_ "Running Subtotal")))
|
||||
(cons 'calc-fn original-running-prime)
|
||||
(cons 'reverse-column? #f)
|
||||
(cons 'subtotal? #f)
|
||||
(cons 'start-dual-column? #f)
|
||||
(cons 'friendly-heading-fn (const ""))
|
||||
(cons 'merge-dual-column? #f)))
|
||||
'())
|
||||
|
||||
(if (and (column-uses? 'amount-original-currency)
|
||||
(column-uses? 'running-grand-total))
|
||||
(list (list (cons 'heading
|
||||
(if (or (primary-get-info 'renderer-fn)
|
||||
(secondary-get-info 'renderer-fn))
|
||||
(G_ "Running Grand Total")
|
||||
(G_ "Running Total")))
|
||||
(cons 'calc-fn original-running-total)
|
||||
(cons 'reverse-column? #f)
|
||||
(cons 'subtotal? #f)
|
||||
(cons 'start-dual-column? #f)
|
||||
(cons 'friendly-heading-fn (const ""))
|
||||
(cons 'merge-dual-column? #f)))
|
||||
'()))))
|
||||
|
||||
(define calculated-cells
|
||||
;; this part will check whether custom-calculated-cells were specified. this
|
||||
;; describes a custom function which consumes an options list, and generates
|
||||
;; an association list similar to default-calculated-cells as above.
|
||||
(if custom-calculated-cells
|
||||
(let ((cc (custom-calculated-cells options)))
|
||||
(cond
|
||||
((not (pair? cc)) (gnc:error "welp" cc) default-calculated-cells)
|
||||
((vector? (car cc)) (upgrade-vector-to-assoclist cc))
|
||||
((any invalid-cell? cc) (gnc:error "welp" cc) default-calculated-cells)
|
||||
(else cc)))
|
||||
default-calculated-cells))
|
||||
(let ((cc (if custom-calculated-cells
|
||||
(let ((ccc (custom-calculated-cells options)))
|
||||
(cond
|
||||
((not (pair? ccc)) (gnc:error "welp" ccc)
|
||||
default-calculated-cells)
|
||||
((vector? (car ccc)) (upgrade-vector-to-assoclist ccc))
|
||||
((any invalid-cell? ccc) (gnc:error "welp" ccc)
|
||||
default-calculated-cells)
|
||||
(else ccc)))
|
||||
default-calculated-cells)))
|
||||
;; Only keep cells with subtotals when "Show subtotals only" is selected
|
||||
;; otherwise leave all calculated-cells as is.
|
||||
(if (column-uses? 'subtotals-only) (filter cell-with-subtotals? cc) cc)))
|
||||
|
||||
(define headings-left-columns
|
||||
(map (cut assq-ref <> 'heading) left-columns))
|
||||
@ -1770,7 +1949,13 @@ be excluded from periodic reporting.")
|
||||
(and cell-content
|
||||
(gnc:make-html-table-cell/markup
|
||||
"number-cell"
|
||||
(if opt-use-links?
|
||||
;; If link option is enabled, to avoid cluttering, we show links
|
||||
;; only on number cells that are set to show a subtotal,
|
||||
;; unless no columns are set to show a subtotal, in which case links
|
||||
;; are shown on all number cells.
|
||||
(if (and opt-use-links? (or (cell-with-subtotals? cell)
|
||||
(not (any cell-with-subtotals?
|
||||
cell-calculators))))
|
||||
(gnc:html-split-anchor split cell-content)
|
||||
cell-content)))))
|
||||
cell-calculators))))
|
||||
@ -1821,7 +2006,7 @@ be excluded from periodic reporting.")
|
||||
|
||||
(if (null? splits)
|
||||
|
||||
(when (opt-val gnc:pagename-display "Totals")
|
||||
(when (opt-val gnc:pagename-display optname-grand-total)
|
||||
(gnc:html-table-append-row/markup!
|
||||
table def:grand-total-style
|
||||
(list
|
||||
@ -1902,7 +2087,11 @@ be excluded from periodic reporting.")
|
||||
(when secondary-subtotal-comparator
|
||||
(add-subheading (render-summary next 'secondary #t)
|
||||
def:secondary-subtotal-style next
|
||||
'secondary))))
|
||||
'secondary))
|
||||
(converted-running-prime-collector 'reset #f #f)
|
||||
(original-running-prime-collector 'reset #f #f)
|
||||
(converted-running-sec-collector 'reset #f #f)
|
||||
(original-running-sec-collector 'reset #f #f)))
|
||||
|
||||
(else
|
||||
(when (and secondary-subtotal-comparator
|
||||
@ -1926,7 +2115,9 @@ be excluded from periodic reporting.")
|
||||
secondary-subtotal-collectors)
|
||||
(when next
|
||||
(add-subheading (render-summary next 'secondary #t)
|
||||
def:secondary-subtotal-style next 'secondary)))))
|
||||
def:secondary-subtotal-style next 'secondary)
|
||||
(converted-running-sec-collector 'reset #f #f)
|
||||
(original-running-sec-collector 'reset #f #f)))))
|
||||
|
||||
(loop rest (not odd-row?) (1+ work-done)))))
|
||||
|
||||
|
@ -117,6 +117,7 @@ const OptionAliases Aliases::c_option_aliases
|
||||
{"Specify date to filter by...", {nullptr, "Specify date to filter by…"}},
|
||||
// trep-engine:
|
||||
{"Running Balance", {nullptr, "Account Balance"}},
|
||||
{"Totals", {nullptr, "Grand Total"}},
|
||||
};
|
||||
|
||||
static bool
|
||||
|
Loading…
Reference in New Issue
Block a user