mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Christian Stimming's report patch.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3636 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bd70db82b7
commit
5c51a5f2ca
@ -42,13 +42,15 @@
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; gnc:html-build-acct-table
|
||||
;; builds and returns a tree-(hierarchy-)shaped table as a html-table object
|
||||
;; builds and returns a tree-(hierarchy-)shaped table as a html-table
|
||||
;; object
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ok, i will write more doc, later
|
||||
(define (gnc:html-build-acct-table
|
||||
start-date end-date
|
||||
tree-depth show-subaccts? accounts
|
||||
show-total? do-subtot?
|
||||
show-total? get-total-fn
|
||||
total-name do-subtot?
|
||||
show-other-curr? report-commodity exchange-fn)
|
||||
(let ((table (gnc:make-html-table))
|
||||
(topl-accounts (gnc:group-get-account-list
|
||||
@ -229,22 +231,17 @@
|
||||
|
||||
;; Show the total sum.
|
||||
(if show-total?
|
||||
(let ((total-collector (make-commodity-collector)))
|
||||
(for-each (lambda (acct)
|
||||
(total-collector
|
||||
(if (gnc:account-reverse-balance? acct)
|
||||
'minusmerge
|
||||
'merge)
|
||||
(my-get-balance acct) #f))
|
||||
(filter show-acct? topl-accounts))
|
||||
(let ((total-collector
|
||||
(get-total-fn (filter show-acct? topl-accounts)
|
||||
my-get-balance)))
|
||||
(if show-other-curr?
|
||||
(begin
|
||||
;; Show other currencies. Then show the report's
|
||||
;; Show other currencies. Therefore show the report's
|
||||
;; currency in the first line.
|
||||
(gnc:html-table-append-row!
|
||||
table
|
||||
(append (list (gnc:make-html-table-cell/size
|
||||
1 tree-depth (_ "Total")))
|
||||
1 tree-depth total-name))
|
||||
(gnc:html-make-empty-cells
|
||||
(+ 1 (* 2 (- tree-depth 1))))
|
||||
(list (gnc:commodity-value->string
|
||||
@ -272,12 +269,12 @@
|
||||
(exchange-fn (list curr val)
|
||||
report-commodity)))))))
|
||||
#f))
|
||||
;; Show no other currencies. Then just calculate one
|
||||
;; total via sum-collector-commodity and show it.
|
||||
;; Show no other currencies. Therefore just calculate
|
||||
;; one total via sum-collector-commodity and show it.
|
||||
(gnc:html-table-append-row!
|
||||
table
|
||||
(append (list (gnc:make-html-table-cell/size
|
||||
1 tree-depth (_ "Total")))
|
||||
1 tree-depth total-name))
|
||||
(gnc:html-make-empty-cells (- tree-depth 1))
|
||||
(list (gnc:sum-collector-commodity
|
||||
total-collector report-commodity
|
||||
|
@ -421,15 +421,44 @@
|
||||
(gnc:account-get-balance-at-date account date #f))
|
||||
group)))
|
||||
|
||||
;; Adds all accounts' balances, where the balances are determined with
|
||||
;; the get-balance-fn. Intended for usage with a profit and loss
|
||||
;; report, hence a) only the income/expense accounts are regarded, and
|
||||
;; b) the result is sign reversed. Returns a commodity-collector.
|
||||
(define (gnc:accounts-get-comm-total-profit accounts
|
||||
get-balance-fn)
|
||||
(let ((collector (make-commodity-collector)))
|
||||
(for-each
|
||||
(lambda (acct)
|
||||
(collector 'minusmerge (get-balance-fn acct) #f))
|
||||
(filter gnc:account-is-inc-exp?
|
||||
accounts))
|
||||
collector))
|
||||
|
||||
;; Adds all accounts' balances, where the balances are determined with
|
||||
;; the get-balance-fn. Intended for usage with a balance sheet, hence
|
||||
;; a) the income/expense accounts are ignored, and b) no signs are
|
||||
;; reversed at all. Returns a commodity-collector.
|
||||
(define (gnc:accounts-get-comm-total-assets accounts
|
||||
get-balance-fn)
|
||||
(let ((collector (make-commodity-collector)))
|
||||
(for-each
|
||||
(lambda (acct)
|
||||
(collector 'merge (get-balance-fn acct) #f))
|
||||
(filter (lambda (a) (not (gnc:account-is-inc-exp? a)))
|
||||
accounts))
|
||||
collector))
|
||||
|
||||
;; returns a commodity-collector
|
||||
(define (gnc:group-get-comm-balance-at-date group date)
|
||||
(let ((this-collector (make-commodity-collector)))
|
||||
(for-each (lambda (x) (this-collector 'merge x #f))
|
||||
(gnc:group-map-accounts
|
||||
(lambda (account)
|
||||
(gnc:account-get-comm-balance-at-date
|
||||
account date #f))
|
||||
group))
|
||||
(for-each
|
||||
(lambda (x) (this-collector 'merge x #f))
|
||||
(gnc:group-map-accounts
|
||||
(lambda (account)
|
||||
(gnc:account-get-comm-balance-at-date
|
||||
account date #f))
|
||||
group))
|
||||
this-collector))
|
||||
|
||||
;; get the change in balance from the 'from' date to the 'to' date.
|
||||
|
@ -121,7 +121,8 @@
|
||||
(table (gnc:html-build-acct-table
|
||||
#f date-tp
|
||||
tree-depth show-subaccts? accounts
|
||||
#t do-subtotals?
|
||||
#t gnc:accounts-get-comm-total-assets
|
||||
(_ "Net Assets") do-subtotals?
|
||||
show-fcur? report-currency exchange-fn)))
|
||||
|
||||
;; set some column headers
|
||||
|
@ -114,7 +114,11 @@
|
||||
(doc (gnc:make-html-document))
|
||||
(txt (gnc:make-html-text)))
|
||||
|
||||
(gnc:html-document-set-title! doc "Profit And Loss")
|
||||
(gnc:html-document-set-title!
|
||||
doc (string-append (_ "Profit and Loss") " "
|
||||
(gnc:timepair-to-datestring from-date-tp)
|
||||
" " (_ "to") " "
|
||||
(gnc:timepair-to-datestring to-date-tp)))
|
||||
(if (not (null? accounts))
|
||||
;; if no max. tree depth is given we have to find the
|
||||
;; maximum existing depth
|
||||
@ -129,7 +133,8 @@
|
||||
(table (gnc:html-build-acct-table
|
||||
from-date-tp to-date-tp
|
||||
tree-depth show-subaccts? accounts
|
||||
#t do-subtotals?
|
||||
#t gnc:accounts-get-comm-total-profit
|
||||
(_ "Profit") do-subtotals?
|
||||
show-fcur? report-currency exchange-fn)))
|
||||
|
||||
;; set some column headers
|
||||
|
Loading…
Reference in New Issue
Block a user