Update eguile based balance sheet report to work with current GnuCash.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19017 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Mike Alexander 2010-04-11 19:12:29 +00:00
parent f4f35770cb
commit d757673b87
4 changed files with 88 additions and 12 deletions

View File

@ -20,7 +20,9 @@ AM_CPPFLAGS = \
gncscmmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/report/
gncscmmod_DATA = \
standard-reports.scm
standard-reports.scm \
balsheet-eg.css \
balsheet-eg.eguile.scm
gncscmreportmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/report/standard-reports
gncscmreportmod_DATA = \
@ -46,7 +48,8 @@ gncscmreportmod_DATA = \
trial-balance.scm \
general-journal.scm \
general-ledger.scm \
transaction.scm
transaction.scm \
balsheet-eg.scm
if GNUCASH_SEPARATE_BUILDDIR
#For executing test cases

View File

@ -0,0 +1,59 @@
/* Stylesheet for balsheet-eg.scm -- eguile-based Gnucash Balance Sheet report */
/* Note that body and table font family and size will be overridden */
/* by separate report options. */
body {
margin: 2em;
}
table.outer {
border-spacing: 0em;
}
table.outer tr {
vertical-align: top;
}
table.accounts tr {
vertical-align: bottom;
}
table.accounts td {
}
td {
padding: 0em 0.5em;
}
td.empty {
}
td.indent {
width: 1em;
}
td.accname {
text-align: left;
vertical-align: top;
}
td.accnametotal {
text-align: left;
vertical-align: top;
font-weight: bold;
}
td.balance {
text-align: right;
vertical-align: bottom;
}
td.balancetotal {
text-align: right;
vertical-align: bottom;
font-weight: bold;
}
td.overruled {
border-top: solid thin black;
}
td.ruledtotal {
border-top: solid thin black;
border-bottom: double medium black;
font-weight: bold;
vertical-align: bottom;
}
/* Negative amounts (in addition to separate 'sign' and 'braces' options */
.negative { color: red; }
/* Foreign currency amounts */
.foreign { font-size: smaller; font-style: italic; }

View File

@ -166,10 +166,12 @@
(let* ((accrec-as (process-acc-list asset-accounts #f))
(accrec-li (process-acc-list liability-accounts #t))
(accrec-eq (process-acc-list equity-accounts #t))
(accrec-tr (process-acc-list trading-accounts #t))
(maxdepth 0)
(rshift-as 0)
(rshift-li 0)
(rshift-eq 0)
(rshift-tr 0)
(balancing-cc (gnc:make-commodity-collector))
(balancing-accrec (newaccrec-clean)))
(accrec-set-namelink! accrec-as (_ "Assets Accounts"))
@ -187,6 +189,9 @@
(accrec-set-namelink! accrec-eq (_ "Equity Accounts"))
(accrec-set-placeholder?! accrec-eq #t)
(balancing-cc 'minusmerge (accrec-subtotal-cc accrec-eq) #f)
(accrec-set-namelink! accrec-tr (_ "Trading Accounts"))
(accrec-set-placeholder?! accrec-tr #t)
(balancing-cc 'minusmerge (accrec-subtotal-cc accrec-tr) #f)
;; Create a balancing entry
(if (not (gnc-commodity-collector-allzero? balancing-cc))
(begin
@ -207,12 +212,16 @@
(if (and (one-depth-1 accrec-eq)
(> (accrec-treedepth accrec-eq) 1))
(set! rshift-eq 1))
(if (and (one-depth-1 accrec-tr)
(> (accrec-treedepth accrec-tr) 1))
(set! rshift-tr 1))
(if debugging?
(begin
(display "<p>Assets: ") (display accrec-as)
(display "<p>Liabilities: ") (display accrec-li)
(display "<p>Equities: ") (display accrec-eq)))
(display "<p>Equities: ") (display accrec-eq)
(display "<p>Trading: ") (display accrec-tr)))
?>
<table border="0" class="outer"><tr valign="top"><td valign="top"> <!-- outer table to control columns -->
@ -221,7 +230,8 @@
(set! maxdepth (max (accrec-treedepth accrec-as)
(accrec-treedepth accrec-li)
(accrec-treedepth accrec-eq)))
(accrec-treedepth accrec-eq)
(accrec-treedepth accrec-tr)))
; Display assets section
(display-accounts-table-r (list accrec-as) #f maxdepth rshift-as (one-depth-1 accrec-as))
@ -229,14 +239,14 @@
; Split table across columns if required
(case opt-columns
('autocols
((autocols)
?>
</table>
<!-- <table border="0" align="left"><tr><td>&nbsp;</td></tr></table> -->
&nbsp;&nbsp;<table border="0" align="left">
<?scm
)
('twocols
((twocols)
?>
</table></td><td valign="top"><table border="0">
<?scm
@ -245,11 +255,13 @@
; Display liabilities and equity sections
(display-accounts-table-r (list accrec-li) #t maxdepth rshift-li (one-depth-1 accrec-li))
(hrule (* maxdepth 2))
(display-accounts-table-r (list accrec-tr) #t maxdepth rshift-tr (one-depth-1 accrec-tr))
(hrule (* maxdepth 2))
(display-accounts-table-r (list accrec-eq) #t maxdepth rshift-eq (one-depth-1 accrec-eq))
(hrule (* maxdepth 2))
(display-acc-row
maxdepth 0 0
(_ "Total Equity and Liabilities")
(_ "Total Equity, Trading, and Liabilities")
(format-comm-coll-total (accrec-subtotal-cc accrec-as)) ; yes, show the assets total
#t #f)

View File

@ -31,7 +31,7 @@
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(define-module (gnucash report balsheet-eg))
(define-module (gnucash report standard-reports balsheet-eg))
(use-modules (gnucash main))
(use-modules (gnucash gnc-module))
(use-modules (gnucash business-utils))
@ -117,7 +117,7 @@
(define (gnc:company-info key) ; this should be in business-utils.scm soon
;; Access company info from key-value pairs for current book
(kvp-frame-get-slot-path-gslist
(gnc-book-get-slots (gnc-get-current-book))
(qof-book-get-slots (gnc-get-current-book))
(append gnc:*kvp-option-path* (list gnc:*business-label* key))))
(define (add-to-cc cc com num neg?)
@ -445,7 +445,7 @@
ACCT-TYPE-ASSET ACCT-TYPE-LIABILITY
ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL ACCT-TYPE-CURRENCY
ACCT-TYPE-PAYABLE ACCT-TYPE-RECEIVABLE
ACCT-TYPE-EQUITY )
ACCT-TYPE-EQUITY ACCT-TYPE-TRADING )
;ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)
(gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
;; decompose the account list
@ -456,6 +456,8 @@
(assoc-ref split-up-accounts ACCT-TYPE-LIABILITY))
(equity-accounts
(assoc-ref split-up-accounts ACCT-TYPE-EQUITY))
(trading-accounts
(assoc-ref split-up-accounts ACCT-TYPE-TRADING))
;; exchange rates calculation parameters
@ -469,7 +471,7 @@
(coyname (or (gnc:company-info gnc:*company-name*) ""))
(css? (and (defined? 'gnc-html-engine-supports-css) (gnc-html-engine-supports-css)))
(css? (gnc-html-engine-supports-css))
(html #f))
@ -717,7 +719,7 @@
'report-guid "2e3751edeb7544e8a20fd19e9d08bb65"
'menu-name (N_ "Balance Sheet using eguile-gnc")
'menu-tip (N_ "Display a balance sheet (using eguile template)")
'menu-path (list gnc:menuname-business-reports)
'menu-path (list gnc:menuname-asset-liability)
'options-generator balsheet-options-generator
'renderer balsheet-renderer)