"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gnucash/report/reports/standard/account-piecharts.scm" between
gnucash-5.0.tar.bz2 and gnucash-5.1.tar.bz2

About: GnuCash is personal and small-business financial-accounting software.

account-piecharts.scm  (gnucash-5.0.tar.bz2):account-piecharts.scm  (gnucash-5.1.tar.bz2)
skipping to change at line 304 skipping to change at line 304
(gnc:report-starting reportname) (gnc:report-starting reportname)
;; Get all options ;; Get all options
(let ((to-date (gnc:time64-end-day-time (let ((to-date (gnc:time64-end-day-time
(gnc:date-option-absolute-time (gnc:date-option-absolute-time
(get-option gnc:pagename-general optname-to-date)))) (get-option gnc:pagename-general optname-to-date))))
(from-date (if do-intervals? (from-date (if do-intervals?
(gnc:time64-start-day-time (gnc:time64-start-day-time
(gnc:date-option-absolute-time (gnc:date-option-absolute-time
(get-option gnc:pagename-general (get-option gnc:pagename-general
optname-from-date))) optname-from-date)))
'())) '()))
(accounts (get-option gnc:pagename-accounts optname-accounts)) (accounts (get-option gnc:pagename-accounts optname-accounts))
(account-levels (account-levels
(if depth-based? (if depth-based?
(get-option gnc:pagename-accounts optname-levels) (get-option gnc:pagename-accounts optname-levels)
'all)) 'all))
(report-currency (get-option gnc:pagename-general (report-currency (get-option gnc:pagename-general
optname-report-currency)) optname-report-currency))
(price-source (get-option gnc:pagename-general (price-source (get-option gnc:pagename-general
optname-price-source)) optname-price-source))
(report-title (get-option gnc:pagename-general (report-title (get-option gnc:pagename-general
gnc:optname-reportname)) gnc:optname-reportname))
(averaging-selection (if do-intervals? (averaging-selection (if do-intervals?
(get-option gnc:pagename-general (get-option gnc:pagename-general
optname-averaging) optname-averaging)
'None)) 'None))
(show-fullname? (get-option gnc:pagename-display optname-fullname)) (show-fullname? (get-option gnc:pagename-display optname-fullname))
(show-total? (get-option gnc:pagename-display optname-show-total)) (show-total? (get-option gnc:pagename-display optname-show-total))
(show-percent? (get-option gnc:pagename-display optname-show-percent)) (show-percent? (get-option gnc:pagename-display optname-show-percent))
(max-slices (inexact->exact (max-slices (inexact->exact
(get-option gnc:pagename-display optname-slices))) (get-option gnc:pagename-display optname-slices)))
(height (get-option gnc:pagename-display optname-plot-height)) (height (get-option gnc:pagename-display optname-plot-height))
(width (get-option gnc:pagename-display optname-plot-width)) (width (get-option gnc:pagename-display optname-plot-width))
(sort-method (get-option gnc:pagename-display optname-sort-method)) (sort-method (get-option gnc:pagename-display optname-sort-method))
(document (gnc:make-html-document)) (document (gnc:make-html-document))
(chart (gnc:make-html-chart)) (chart (gnc:make-html-chart))
(topl-accounts (gnc:filter-accountlist-type (topl-accounts (gnc:filter-accountlist-type
account-types account-types
(gnc-account-get-children-sorted (gnc-account-get-children-sorted
(gnc-get-current-root-account))))) (gnc-get-current-root-account)))))
;; Returns true if the account a was selected in the account ;; Returns true if the account a was selected in the account
;; selection option. ;; selection option.
skipping to change at line 409 skipping to change at line 409
(* (gnc:gnc-monetary-amount (* (gnc:gnc-monetary-amount
(gnc:sum-collector-commodity c report-currency exchange-fn)) (gnc:sum-collector-commodity c report-currency exchange-fn))
averaging-multiplier)) averaging-multiplier))
;; Get balance of an account as an inexact number converted to, ;; Get balance of an account as an inexact number converted to,
;; and using precision of the report's currency. ;; and using precision of the report's currency.
(define (account-balance a subaccts?) (define (account-balance a subaccts?)
(collector->amount (profit-fn a subaccts?))) (collector->amount (profit-fn a subaccts?)))
(define (count-accounts current-depth accts) (define (count-accounts current-depth accts)
(if (< current-depth tree-depth) (if (< current-depth tree-depth)
(let iter ((sum 0) (let iter ((sum 0)
(remaining accts)) (remaining accts))
(if (null? remaining) (if (null? remaining)
sum sum
(let* ((cur (car remaining)) (let* ((cur (car remaining))
(tail (cdr remaining)) (tail (cdr remaining))
(subaccts (count-accounts (1+ current-depth) (subaccts (count-accounts (1+ current-depth)
(gnc-account-get-children cur )))) (gnc-account-get-children cur ))))
(iter (+ sum (1+ subaccts)) tail)))) (iter (+ sum (1+ subaccts)) tail))))
(length (filter show-acct? accts)))) (length (filter show-acct? accts))))
;; Get base data to be plotted. ;; Get base data to be plotted.
(define work-to-do (lambda () (count-accounts 1 topl-accounts))) (define work-to-do (lambda () (count-accounts 1 topl-accounts)))
(define base-data (lambda () (define base-data (lambda ()
(get-data account-balance show-acct? work-to-do tree-depth (get-data account-balance show-acct? work-to-do tree-depth
0 1 topl-accounts))) 0 1 topl-accounts)))
(define (fix-signs combined) (define (fix-signs combined)
(map (lambda (pair) (map (lambda (pair)
(if reverse-balance? (if reverse-balance?
(cons (- (car pair)) (cdr pair)) (cons (- (car pair)) (cdr pair))
pair)) pair))
combined)) combined))
;; Now do the work here. ;; Now do the work here.
(if (not (null? accounts)) (if (not (null? accounts))
(begin (begin
(set! combined (set! combined
(sort (filter (lambda (pair) (not (>= 0.0 (car pair)))) (sort (filter (lambda (pair) (not (>= 0.0 (car pair))))
(fix-signs (cdr (base-data)))) (fix-signs (cdr (base-data))))
(sort-comparator sort-method show-fullname?))) (sort-comparator sort-method show-fullname?)))
;; if too many slices, condense them to an 'other' slice ;; if too many slices, condense them to an 'other' slice
;; and add a link to a new pie report with just those ;; and add a link to a new pie report with just those
;; accounts ;; accounts
(if (> (length combined) max-slices) (if (> (length combined) max-slices)
(let* ((start (take combined (- max-slices 1))) (let* ((start (take combined (- max-slices 1)))
(finish (drop combined (- max-slices 1))) (finish (drop combined (- max-slices 1)))
(sum (apply + (unzip1 finish)))) (sum (apply + (unzip1 finish))))
(set! combined (set! combined
skipping to change at line 561 skipping to change at line 561
(format #f " (~2,1f%)" (format #f " (~2,1f%)"
(* 100 (/ (car series) (* 100 (/ (car series)
(apply + (unzip1 combined))))) (apply + (unzip1 combined)))))
""))) "")))
combined)) combined))
(gnc:html-document-add-object! document chart)) (gnc:html-document-add-object! document chart))
(gnc:html-document-add-object! (gnc:html-document-add-object!
document document
(gnc:html-make-empty-data-warning (gnc:html-make-empty-data-warning
report-title (gnc:report-id report-obj))))) report-title (gnc:report-id report-obj)))))
(gnc:html-document-add-object! (gnc:html-document-add-object!
document document
(gnc:html-make-no-account-warning (gnc:html-make-no-account-warning
report-title (gnc:report-id report-obj)))) report-title (gnc:report-id report-obj))))
(gnc:report-finished) (gnc:report-finished)
document))) document)))
(define (build-report! (define (build-report!
name acct-types income-expense? depth-based? reverse-balance? name acct-types income-expense? depth-based? reverse-balance?
menuname menutip uuid) menuname menutip uuid)
(gnc:define-report (gnc:define-report
'version 1 'version 1
'name name 'name name
 End of changes. 11 change blocks. 
14 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)