mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 731589 - Add account level selection on accounts option tab
This commit is contained in:
parent
8de928241f
commit
f750cab8b2
@ -46,6 +46,10 @@
|
|||||||
(define optname-running-sum (N_ "Running Sum"))
|
(define optname-running-sum (N_ "Running Sum"))
|
||||||
(define optname-chart-type (N_ "Chart Type"))
|
(define optname-chart-type (N_ "Chart Type"))
|
||||||
|
|
||||||
|
(define optname-depth-limit (N_ "Levels of Subaccounts"))
|
||||||
|
(define opthelp-depth-limit
|
||||||
|
(N_ "Maximum number of levels in the account tree displayed."))
|
||||||
|
|
||||||
;(define (options-generator inc-exp?)
|
;(define (options-generator inc-exp?)
|
||||||
(define (options-generator)
|
(define (options-generator)
|
||||||
(let* (
|
(let* (
|
||||||
@ -106,6 +110,10 @@
|
|||||||
(gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
|
(gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
|
||||||
#f #t))
|
#f #t))
|
||||||
|
|
||||||
|
(gnc:options-add-account-levels!
|
||||||
|
options gnc:pagename-accounts optname-depth-limit
|
||||||
|
"b" opthelp-depth-limit 6)
|
||||||
|
|
||||||
;; Set default page
|
;; Set default page
|
||||||
(gnc:options-set-default-section options gnc:pagename-general)
|
(gnc:options-set-default-section options gnc:pagename-general)
|
||||||
|
|
||||||
@ -170,11 +178,11 @@
|
|||||||
(if running-sum
|
(if running-sum
|
||||||
(set! bgt-sum (+ bgt-sum
|
(set! bgt-sum (+ bgt-sum
|
||||||
(gnc-numeric-to-double
|
(gnc-numeric-to-double
|
||||||
(gnc-budget-get-account-period-value budget acct period))))
|
(gnc:get-account-period-rolledup-budget-value budget acct period))))
|
||||||
|
|
||||||
(set! bgt-sum
|
(set! bgt-sum
|
||||||
(gnc-numeric-to-double
|
(gnc-numeric-to-double
|
||||||
(gnc-budget-get-account-period-value budget acct period)))
|
(gnc:get-account-period-rolledup-budget-value budget acct period)))
|
||||||
)
|
)
|
||||||
(set! bgt-vals (append bgt-vals (list bgt-sum)))
|
(set! bgt-vals (append bgt-vals (list bgt-sum)))
|
||||||
|
|
||||||
@ -249,12 +257,31 @@
|
|||||||
(gnc:option-value
|
(gnc:option-value
|
||||||
(gnc:lookup-option (gnc:report-options report-obj) section name)))
|
(gnc:lookup-option (gnc:report-options report-obj) section name)))
|
||||||
|
|
||||||
|
;; This is a helper function to find out the level of the account
|
||||||
|
;; with in the account tree
|
||||||
|
(define (get-account-level account level)
|
||||||
|
(let (
|
||||||
|
(parent (gnc-account-get-parent account))
|
||||||
|
)
|
||||||
|
(cond
|
||||||
|
(
|
||||||
|
(null? parent) ;; exit
|
||||||
|
level
|
||||||
|
)
|
||||||
|
(else
|
||||||
|
(get-account-level parent (+ level 1))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
(let* (
|
(let* (
|
||||||
(budget (get-option gnc:pagename-general optname-budget))
|
(budget (get-option gnc:pagename-general optname-budget))
|
||||||
(budget-valid? (and budget (not (null? budget))))
|
(budget-valid? (and budget (not (null? budget))))
|
||||||
(running-sum (get-option gnc:pagename-general optname-running-sum))
|
(running-sum (get-option gnc:pagename-general optname-running-sum))
|
||||||
(chart-type (get-option gnc:pagename-general optname-chart-type))
|
(chart-type (get-option gnc:pagename-general optname-chart-type))
|
||||||
(accounts (get-option gnc:pagename-accounts optname-accounts))
|
(accounts (get-option gnc:pagename-accounts optname-accounts))
|
||||||
|
(depth-limit (get-option gnc:pagename-accounts optname-depth-limit))
|
||||||
(report-title (get-option gnc:pagename-general
|
(report-title (get-option gnc:pagename-general
|
||||||
gnc:optname-reportname))
|
gnc:optname-reportname))
|
||||||
(document (gnc:make-html-document))
|
(document (gnc:make-html-document))
|
||||||
@ -276,8 +303,20 @@
|
|||||||
(else
|
(else
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (acct)
|
(lambda (acct)
|
||||||
(if (null? (gnc-account-get-descendants acct))
|
(if (or
|
||||||
(gnc:html-document-add-object! document
|
(and (equal? depth-limit 'all)
|
||||||
|
(null? (gnc-account-get-descendants acct))
|
||||||
|
)
|
||||||
|
(and (not (equal? depth-limit 'all))
|
||||||
|
(<= (get-account-level acct 0) depth-limit)
|
||||||
|
(null? (gnc-account-get-descendants acct))
|
||||||
|
)
|
||||||
|
(and (not (equal? depth-limit 'all))
|
||||||
|
(= (get-account-level acct 0) depth-limit)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(gnc:html-document-add-object!
|
||||||
|
document
|
||||||
(gnc:chart-create-budget-actual budget acct running-sum chart-type)
|
(gnc:chart-create-budget-actual budget acct running-sum chart-type)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user