On Thu, Oct 18, 2007 at 11:53:58AM -0700, Andrew Sackville-West wrote: > As was discussed on irc yesterday > (http://lists.gnucash.org/logs/2007/10/2007-10-17.html#T13:39:55), > here is a patch for a two-column income-statement. Seems kinda silly > to me, but apparently the germans really want this, so there it is ;)
I heard back from the user requesting this and apparently the germans like to look at what they spend *before* they look at what they made, so I have added another option to reverse the order of income/expense in the report. It defaults to the "standard" display of income/expense, but can be changed to expense/income. It works in either two-column or one-column mode. > > meanwhile, its also here: > http://bugzilla.gnome.org/show_bug.cgi?id=488004 and been updated there as well. A
Index: src/report/standard-reports/income-statement.scm
===================================================================
--- src/report/standard-reports/income-statement.scm (revision 16566)
+++ src/report/standard-reports/income-statement.scm (working copy)
@@ -123,6 +123,14 @@
(N_ "Closing Entries Pattern is regular expression"))
(define opthelp-closing-regexp
(N_ "Causes the Closing Entries Pattern to be treated as a regular expression"))
+(define optname-two-column
+ (N_ "Display as a two column report"))
+(define opthelp-two-column
+ (N_ "Divides the report into an income column and an expense column"))
+(define optname-standard-order
+ (N_ "Display in standard, income first, order"))
+(define opthelp-standard-order
+ (N_ "Causes the report to display in the standard order, placing income before expenses"))
;; options generator
(define (income-statement-options-generator)
@@ -132,11 +140,11 @@
(gnc:register-option options new-option))))
(add-option
- (gnc:make-string-option
+ (gnc:make-string-option
gnc:pagename-general optname-report-title
"a" opthelp-report-title (_ reportname)))
(add-option
- (gnc:make-string-option
+ (gnc:make-string-option
gnc:pagename-general optname-party-name
"b" opthelp-party-name ""))
;; this should default to company name in (gnc-get-current-book)
@@ -225,17 +233,28 @@
(gnc:make-simple-boolean-option
gnc:pagename-display optname-label-expense
"i" opthelp-label-expense #t))
+
(add-option
(gnc:make-simple-boolean-option
gnc:pagename-display optname-total-expense
"j" opthelp-total-expense #t))
+
+ (add-option
+ (gnc:make-simple-boolean-option
+ gnc:pagename-display optname-two-column
+ "k" opthelp-two-column #f))
+
+ (add-option
+ (gnc:make-simple-boolean-option
+ gnc:pagename-display optname-standard-order
+ "l" opthelp-standard-order #t))
;; closing entry match criteria
;;
;; N.B.: transactions really should have a field where we can put
;; transaction types like "Adjusting/Closing/Correcting Entries"
(add-option
- (gnc:make-string-option
+ (gnc:make-string-option
pagename-entries optname-closing-pattern
"a" opthelp-closing-pattern (N_ "Closing Entries")))
(add-option
@@ -285,9 +304,9 @@
(depth-limit (get-option gnc:pagename-accounts
optname-depth-limit))
(bottom-behavior (get-option gnc:pagename-accounts
- optname-bottom-behavior))
+ optname-bottom-behavior))
(report-commodity (get-option pagename-commodities
- optname-report-commodity))
+ optname-report-commodity))
(price-source (get-option pagename-commodities
optname-price-source))
(show-fcur? (get-option pagename-commodities
@@ -295,7 +314,7 @@
(show-rates? (get-option pagename-commodities
optname-show-rates))
(parent-balance-mode (get-option gnc:pagename-display
- optname-parent-balance-mode))
+ optname-parent-balance-mode))
(parent-total-mode
(car
(assoc-ref '((t #t) (f #f) (canonically-tabbed canonically-tabbed))
@@ -306,23 +325,27 @@
(omit-zb-bals? (get-option gnc:pagename-display
optname-omit-zb-bals))
(label-revenue? (get-option gnc:pagename-display
- optname-label-revenue))
+ optname-label-revenue))
(total-revenue? (get-option gnc:pagename-display
- optname-total-revenue))
+ optname-total-revenue))
(label-expense? (get-option gnc:pagename-display
- optname-label-expense))
+ optname-label-expense))
(total-expense? (get-option gnc:pagename-display
- optname-total-expense))
+ optname-total-expense))
(use-links? (get-option gnc:pagename-display
- optname-account-links))
+ optname-account-links))
(use-rules? (get-option gnc:pagename-display
- optname-use-rules))
+ optname-use-rules))
(closing-str (get-option pagename-entries
optname-closing-pattern))
(closing-cased (get-option pagename-entries
optname-closing-casing))
(closing-regexp (get-option pagename-entries
optname-closing-regexp))
+ (two-column? (get-option gnc:pagename-display
+ optname-two-column))
+ (standard-order? (get-option gnc:pagename-display
+ optname-standard-order))
(closing-pattern
(list (list 'str closing-str)
(list 'cased closing-cased)
@@ -331,7 +354,7 @@
)
(indent 0)
(tabbing #f)
-
+
;; decompose the account list
(split-up-accounts (gnc:decompose-accountlist accounts))
(revenue-accounts (assoc-ref split-up-accounts ACCT-TYPE-INCOME))
@@ -421,7 +444,9 @@
;; Create the account tables below where their
;; percentage time can be tracked.
- (build-table (gnc:make-html-table)) ;; gnc:html-table
+ (inc-table (gnc:make-html-table)) ;; gnc:html-table
+ (exp-table (gnc:make-html-table))
+
(table-env #f) ;; parameters for :make-
(params #f) ;; and -add-account-
(revenue-table #f) ;; gnc:html-acct-table
@@ -531,7 +556,7 @@
'show-balance))
(list 'multicommodity-mode (if show-fcur? 'table #f))
(list 'rule-mode use-rules?)
- )
+ )
)
;; Workaround to force gtkhtml into displaying wide
@@ -541,44 +566,92 @@
\
")
))
- (gnc:html-table-append-row! build-table space)
- )
-
+ (gnc:html-table-append-row! inc-table space)
+ (gnc:html-table-append-row! exp-table space))
+
+
(gnc:report-percent-done 80)
(if label-revenue?
- (add-subtotal-line build-table (_ "Revenues") #f #f))
+ (add-subtotal-line inc-table (_ "Revenues") #f #f))
(set! revenue-table
(gnc:make-html-acct-table/env/accts
table-env revenue-accounts))
(gnc:html-table-add-account-balances
- build-table revenue-table params)
+ inc-table revenue-table params)
(if total-revenue?
(add-subtotal-line
- build-table (_ "Total Revenue") #f revenue-total))
+ inc-table (_ "Total Revenue") #f revenue-total))
(gnc:report-percent-done 85)
(if label-expense?
(add-subtotal-line
- build-table (_ "Expenses") #f #f))
+ exp-table (_ "Expenses") #f #f))
(set! expense-table
(gnc:make-html-acct-table/env/accts
table-env expense-accounts))
(gnc:html-table-add-account-balances
- build-table expense-table params)
+ exp-table expense-table params)
(if total-expense?
(add-subtotal-line
- build-table (_ "Total Expenses") #f expense-total))
+ exp-table (_ "Total Expenses") #f expense-total))
(report-line
- build-table
+ (if standard-order?
+ exp-table
+ inc-table)
(string-append (_ "Net income") period-for)
(string-append (_ "Net loss") period-for)
net-income
(* 2 (- tree-depth 1)) exchange-fn #f #f
)
- (gnc:html-document-add-object! doc build-table)
+ (gnc:html-document-add-object!
+ doc
+ (let* ((build-table (gnc:make-html-table)))
+ (if two-column?
+ (gnc:html-table-append-row!
+ build-table
+ (if standard-order?
+ (list
+ (gnc:make-html-table-cell inc-table)
+ (gnc:make-html-table-cell exp-table)
+ )
+ (list
+ (gnc:make-html-table-cell exp-table)
+ (gnc:make-html-table-cell inc-table)
+ )
+ )
+ )
+ (if standard-order?
+ (begin
+ (gnc:html-table-append-row!
+ build-table
+ (list (gnc:make-html-table-cell inc-table)))
+ (gnc:html-table-append-row!
+ build-table
+ (list (gnc:make-html-table-cell exp-table)))
+ )
+ (begin
+ (gnc:html-table-append-row!
+ build-table
+ (list (gnc:make-html-table-cell exp-table)))
+ (gnc:html-table-append-row!
+ build-table
+ (list (gnc:make-html-table-cell inc-table)))
+ )
+ )
+ )
+
+ (gnc:html-table-set-style!
+ build-table "td"
+ 'attribute '("align" "left")
+ 'attribute '("valign" "top"))
+ build-table
+ )
+ )
+
+
;; add currency information if requested
(gnc:report-percent-done 90)
(if show-rates?
signature.asc
Description: Digital signature
_______________________________________________ gnucash-devel mailing list [email protected] https://lists.gnucash.org/mailman/listinfo/gnucash-devel
