mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make it possible to include trading accounts in the Income Statement and Profit and Loss reports.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20124 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8be9b0a9ad
commit
2f4e33a86f
@ -93,6 +93,12 @@
|
||||
(define optname-total-revenue (N_ "Include revenue total"))
|
||||
(define opthelp-total-revenue
|
||||
(N_ "Whether or not to include a line indicating total revenue"))
|
||||
(define optname-label-trading (N_ "Label the trading accounts section"))
|
||||
(define opthelp-label-trading
|
||||
(N_ "Whether or not to include a label for the trading accounts section"))
|
||||
(define optname-total-trading (N_ "Include trading accounts total"))
|
||||
(define opthelp-total-trading
|
||||
(N_ "Whether or not to include a line indicating total trading accounts balance"))
|
||||
(define optname-label-expense (N_ "Label the expense section"))
|
||||
(define opthelp-label-expense
|
||||
(N_ "Whether or not to include a label for the expense section"))
|
||||
@ -227,6 +233,15 @@
|
||||
gnc:pagename-display optname-total-revenue
|
||||
"h" opthelp-total-revenue #t))
|
||||
|
||||
(add-option
|
||||
(gnc:make-simple-boolean-option
|
||||
gnc:pagename-display optname-label-trading
|
||||
"h1" opthelp-label-trading #t))
|
||||
(add-option
|
||||
(gnc:make-simple-boolean-option
|
||||
gnc:pagename-display optname-total-trading
|
||||
"h2" opthelp-total-trading #t))
|
||||
|
||||
(add-option
|
||||
(gnc:make-simple-boolean-option
|
||||
gnc:pagename-display optname-label-expense
|
||||
@ -325,6 +340,10 @@
|
||||
optname-label-revenue))
|
||||
(total-revenue? (get-option gnc:pagename-display
|
||||
optname-total-revenue))
|
||||
(label-trading? (get-option gnc:pagename-display
|
||||
optname-label-trading))
|
||||
(total-trading? (get-option gnc:pagename-display
|
||||
optname-total-trading))
|
||||
(label-expense? (get-option gnc:pagename-display
|
||||
optname-label-expense))
|
||||
(total-expense? (get-option gnc:pagename-display
|
||||
@ -355,10 +374,8 @@
|
||||
;; decompose the account list
|
||||
(split-up-accounts (gnc:decompose-accountlist accounts))
|
||||
(revenue-accounts (assoc-ref split-up-accounts ACCT-TYPE-INCOME))
|
||||
(trading-accounts (assoc-ref split-up-accounts ACCT-TYPE-TRADING))
|
||||
(expense-accounts (assoc-ref split-up-accounts ACCT-TYPE-EXPENSE))
|
||||
(income-expense-accounts
|
||||
(append (assoc-ref split-up-accounts ACCT-TYPE-INCOME)
|
||||
(assoc-ref split-up-accounts ACCT-TYPE-EXPENSE)))
|
||||
|
||||
(doc (gnc:make-html-document))
|
||||
;; this can occasionally put extra (blank) columns in our
|
||||
@ -437,17 +454,20 @@
|
||||
(neg-revenue-total #f)
|
||||
(revenue-total #f)
|
||||
(expense-total #f)
|
||||
(trading-total #f)
|
||||
(net-income #f)
|
||||
|
||||
;; Create the account tables below where their
|
||||
;; percentage time can be tracked.
|
||||
(inc-table (gnc:make-html-table)) ;; gnc:html-table
|
||||
(exp-table (gnc:make-html-table))
|
||||
(tra-table (gnc:make-html-table))
|
||||
|
||||
(table-env #f) ;; parameters for :make-
|
||||
(params #f) ;; and -add-account-
|
||||
(revenue-table #f) ;; gnc:html-acct-table
|
||||
(expense-table #f) ;; gnc:html-acct-table
|
||||
(trading-table #f)
|
||||
|
||||
(terse-period? #t)
|
||||
(period-for (if terse-period?
|
||||
@ -517,9 +537,14 @@
|
||||
(neg-revenue-total 'minusmerge revenue-closing #f)
|
||||
(set! revenue-total (gnc:make-commodity-collector))
|
||||
(revenue-total 'minusmerge neg-revenue-total #f)
|
||||
(set! trading-total
|
||||
(gnc:accountlist-get-comm-balance-interval
|
||||
trading-accounts
|
||||
start-date-tp end-date-tp))
|
||||
;; calculate net income
|
||||
(set! net-income (gnc:make-commodity-collector))
|
||||
(net-income 'merge revenue-total #f)
|
||||
(net-income 'merge trading-total #f)
|
||||
(net-income 'minusmerge expense-total #f)
|
||||
|
||||
(set! table-env
|
||||
@ -564,7 +589,8 @@
|
||||
")
|
||||
))
|
||||
(gnc:html-table-append-row! inc-table space)
|
||||
(gnc:html-table-append-row! exp-table space))
|
||||
(gnc:html-table-append-row! exp-table space)
|
||||
(gnc:html-table-append-row! tra-table space))
|
||||
|
||||
|
||||
(gnc:report-percent-done 80)
|
||||
@ -592,6 +618,17 @@
|
||||
(add-subtotal-line
|
||||
exp-table (_ "Total Expenses") #f expense-total))
|
||||
|
||||
(if label-trading?
|
||||
(add-subtotal-line tra-table (_ "Trading") #f #f))
|
||||
(set! trading-table
|
||||
(gnc:make-html-acct-table/env/accts
|
||||
table-env trading-accounts))
|
||||
(gnc:html-table-add-account-balances
|
||||
tra-table trading-table params)
|
||||
(if total-trading?
|
||||
(add-subtotal-line
|
||||
tra-table (_ "Total Trading") #f trading-total))
|
||||
|
||||
(report-line
|
||||
(if standard-order?
|
||||
exp-table
|
||||
@ -611,11 +648,15 @@
|
||||
(if standard-order?
|
||||
(list
|
||||
(gnc:make-html-table-cell inc-table)
|
||||
(if (not (null? trading-accounts))
|
||||
(gnc:make-html-table-cell tra-table))
|
||||
(gnc:make-html-table-cell exp-table)
|
||||
)
|
||||
(list
|
||||
(gnc:make-html-table-cell exp-table)
|
||||
(gnc:make-html-table-cell inc-table)
|
||||
(if (not (null? trading-accounts))
|
||||
(gnc:make-html-table-cell tra-table))
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -624,6 +665,10 @@
|
||||
(gnc:html-table-append-row!
|
||||
build-table
|
||||
(list (gnc:make-html-table-cell inc-table)))
|
||||
(if (not (null? trading-accounts))
|
||||
(gnc:html-table-append-row!
|
||||
build-table
|
||||
(list (gnc:make-html-table-cell tra-table))))
|
||||
(gnc:html-table-append-row!
|
||||
build-table
|
||||
(list (gnc:make-html-table-cell exp-table)))
|
||||
@ -635,6 +680,10 @@
|
||||
(gnc:html-table-append-row!
|
||||
build-table
|
||||
(list (gnc:make-html-table-cell inc-table)))
|
||||
(if (not (null? trading-accounts))
|
||||
(gnc:html-table-append-row!
|
||||
build-table
|
||||
(list (gnc:make-html-table-cell tra-table))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user