gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Sun Sep 29 06:29:59 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/5aa59e0c (commit)
via https://github.com/Gnucash/gnucash/commit/607fd6ff (commit)
via https://github.com/Gnucash/gnucash/commit/1acbc0c1 (commit)
via https://github.com/Gnucash/gnucash/commit/90d83e07 (commit)
via https://github.com/Gnucash/gnucash/commit/dad5961b (commit)
via https://github.com/Gnucash/gnucash/commit/80296a3c (commit)
from https://github.com/Gnucash/gnucash/commit/aae1143e (commit)
commit 5aa59e0ce15be21d0331c65f94fed8c5a6baf748
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Sep 29 17:22:34 2019 +0800
[reports] eradicate gtkhtml hacks
string of was used to widen cell to a minimum of 60px. use
min-width style attribute instead.
diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index 138ddef2b..771c5a81c 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -478,13 +478,13 @@
(define (get-total-balance-fn account)
(gnc:account-get-comm-balance-at-date account reportdate #f))
- ;; Workaround to force gtkhtml into displaying wide
- ;; enough columns.
- (let ((space (make-list tree-depth " \
- ")))
- (gnc:html-table-append-row! left-table space)
- (unless report-form?
- (gnc:html-table-append-row! right-table space)))
+ (let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
+ (gnc:html-table-cell-set-style!
+ wide "text-cell" 'attribute '("style" "min-width:60px"))
+ (let ((space (make-list tree-depth wide)))
+ (gnc:html-table-append-row! left-table space)
+ (unless report-form?
+ (gnc:html-table-append-row! right-table space))))
(gnc:report-percent-done 80)
(when label-assets?
diff --git a/gnucash/report/standard-reports/budget-balance-sheet.scm b/gnucash/report/standard-reports/budget-balance-sheet.scm
index 18afbe328..276e7903f 100644
--- a/gnucash/report/standard-reports/budget-balance-sheet.scm
+++ b/gnucash/report/standard-reports/budget-balance-sheet.scm
@@ -675,17 +675,13 @@
)
)
- ;; Workaround to force gtkhtml into displaying wide
- ;; enough columns.
- (let ((space
- (make-list tree-depth " \
- \
- ")
- ))
- (gnc:html-table-append-row! left-table space)
- (if (not report-form?)
- (gnc:html-table-append-row! right-table space))
- )
+ (let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
+ (gnc:html-table-cell-set-style!
+ wide "text-cell" 'attribute '("style" "min-width:60px"))
+ (let ((space (make-list tree-depth wide)))
+ (gnc:html-table-append-row! left-table space)
+ (unless report-form?
+ (gnc:html-table-append-row! right-table space))))
(gnc:report-percent-done 80)
(if label-assets? (add-subtotal-line left-table (_ "Assets") #f #f))
diff --git a/gnucash/report/standard-reports/budget-income-statement.scm b/gnucash/report/standard-reports/budget-income-statement.scm
index 98cc16a07..e73b42fad 100644
--- a/gnucash/report/standard-reports/budget-income-statement.scm
+++ b/gnucash/report/standard-reports/budget-income-statement.scm
@@ -618,16 +618,11 @@
)
)
- ;; Workaround to force gtkhtml into displaying wide
- ;; enough columns.
- (let ((space
- (make-list tree-depth " \
- \
- ")
- ))
- (gnc:html-table-append-row! inc-table space)
- (gnc:html-table-append-row! exp-table space))
-
+ (let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
+ (gnc:html-table-cell-set-style!
+ wide "text-cell" 'attribute '("style" "min-width:60px"))
+ (gnc:html-table-append-row! inc-table (make-list tree-depth wide))
+ (gnc:html-table-append-row! exp-table (make-list tree-depth wide)))
(gnc:report-percent-done 80)
(if label-revenue?
diff --git a/gnucash/report/standard-reports/equity-statement.scm b/gnucash/report/standard-reports/equity-statement.scm
index 0b627ddd9..aedc140f1 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -562,14 +562,10 @@
(gnc:report-percent-done 30)
- ;; Workaround to force gtkhtml into displaying wide
- ;; enough columns.
- (gnc:html-table-append-row!
- build-table
- (make-list 2 " \
- \
- ")
- )
+ (let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
+ (gnc:html-table-cell-set-style!
+ wide "text-cell" 'attribute '("style" "min-width:60px"))
+ (gnc:html-table-append-row! build-table (make-list 2 wide)))
(gnc:report-percent-done 80)
diff --git a/gnucash/report/standard-reports/income-statement.scm b/gnucash/report/standard-reports/income-statement.scm
index 254a5b41a..c3d1ea5d1 100644
--- a/gnucash/report/standard-reports/income-statement.scm
+++ b/gnucash/report/standard-reports/income-statement.scm
@@ -571,18 +571,13 @@
)
)
- ;; Workaround to force gtkhtml into displaying wide
- ;; enough columns.
- (let ((space
- (make-list tree-depth " \
- \
- ")
- ))
- (gnc:html-table-append-row! inc-table space)
- (gnc:html-table-append-row! exp-table space)
- (gnc:html-table-append-row! tra-table space))
+ (let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
+ (gnc:html-table-cell-set-style!
+ wide "text-cell" 'attribute '("style" "min-width:60px"))
+ (gnc:html-table-append-row! inc-table (make-list tree-depth wide))
+ (gnc:html-table-append-row! exp-table (make-list tree-depth wide))
+ (gnc:html-table-append-row! tra-table (make-list tree-depth wide)))
-
(gnc:report-percent-done 80)
(if label-revenue?
(add-subtotal-line inc-table (_ "Revenues") #f #f))
diff --git a/gnucash/report/standard-reports/trial-balance.scm b/gnucash/report/standard-reports/trial-balance.scm
index e9cfeeac1..c5db01864 100644
--- a/gnucash/report/standard-reports/trial-balance.scm
+++ b/gnucash/report/standard-reports/trial-balance.scm
@@ -559,15 +559,14 @@
(let* ((env (gnc:html-acct-table-get-row-env acct-table 0)))
(set! account-cols (get-val env 'account-cols)))
- ;; Workaround to force gtkhtml into displaying wide
- ;; enough columns.
- (let ((space
- (make-list
- (+ account-cols
- (if (eq? report-variant 'work-sheet) 10 2))
- " ")))
- (gnc:html-table-append-row! build-table space)
- (set! header-rows (+ header-rows 1)))
+ (let ((wide (gnc:make-html-table-cell/markup "text-cell" #f))
+ (ncols (+ account-cols (if (eq? report-variant 'work-sheet) 10 2))))
+ (gnc:html-table-cell-set-style!
+ wide "text-cell" 'attribute '("style" "min-width:60px"))
+ (let ((space (make-list ncols wide)))
+ (gnc:html-table-append-row! build-table space)
+ (set! header-rows (1+ header-rows))))
+
;; add the double-column headers if required
(if (eq? report-variant 'work-sheet)
(let* ((headings
commit 607fd6ff9b07ee0584c78a325fffc051cf648f89
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Sep 29 18:28:37 2019 +0800
[equity-statement] compact unrealized gain calculator
diff --git a/gnucash/report/standard-reports/equity-statement.scm b/gnucash/report/standard-reports/equity-statement.scm
index 5b97d2bce..0b627ddd9 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -406,29 +406,11 @@
;; that though....
;;
(define (unrealized-gains-at-date book-balance exchange-fn date)
- (let* ((unrealized-gain-collector (gnc:make-commodity-collector))
- (weighted-fn
- (gnc:case-exchange-fn 'weighted-average
- report-commodity date))
-
- (value
- (gnc:gnc-monetary-amount
- (gnc:sum-collector-commodity book-balance
- report-commodity
- exchange-fn)))
-
- (cost
- (gnc:gnc-monetary-amount
- (gnc:sum-collector-commodity book-balance
- report-commodity
- weighted-fn)))
-
- (unrealized-gain (gnc-numeric-sub-fixed value cost)))
-
- (unrealized-gain-collector 'add report-commodity unrealized-gain)
- unrealized-gain-collector
- )
- )
+ (define weighted-fn
+ (gnc:case-exchange-fn 'weighted-average report-commodity date))
+ (gnc:collector-
+ (gnc:sum-collector-commodity book-balance report-commodity exchange-fn)
+ (gnc:sum-collector-commodity book-balance report-commodity weighted-fn)))
;; If you ask me, any outstanding(TM) retained earnings and
;; unrealized gains should be added directly into equity,
@@ -553,7 +535,8 @@
(net-investment 'minusmerge neg-pre-closing-equity #f);; > 0
(net-investment 'merge neg-start-equity-balance #f) ;; net increase
- (set! withdrawals (account-get-total-flow 'in equity-accounts start-date end-date))
+ (set! withdrawals
+ (account-get-total-flow 'in equity-accounts start-date end-date))
(set! investments (gnc:make-commodity-collector))
(investments 'merge net-investment #f)
commit 1acbc0c1ecf1ccaaafc27a26daafb8eeccb7363d
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Sep 29 17:08:38 2019 +0800
[balance-sheet] further compact, untabify
diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index 48ceafa42..138ddef2b 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -83,7 +83,6 @@
(define optname-report-form (N_ "Single column Balance Sheet"))
(define opthelp-report-form
(N_ "Print liability/equity section in the same column under the assets section as opposed to a second column right of the assets section."))
-;; FIXME this needs an indent option
(define optname-accounts (N_ "Accounts"))
(define opthelp-accounts
@@ -285,145 +284,99 @@
(define (balance-sheet-renderer report-obj)
(define (get-option pagename optname)
(gnc:option-value
- (gnc:lookup-option
+ (gnc:lookup-option
(gnc:report-options report-obj) pagename optname)))
-
+
(gnc:report-starting reportname)
-
+
;; get all option's values
(let* (
- (report-title (get-option gnc:pagename-general optname-report-title))
- (company-name (get-option gnc:pagename-general optname-party-name))
- (reportdate (gnc:time64-end-day-time
+ (report-title (get-option gnc:pagename-general optname-report-title))
+ (company-name (get-option gnc:pagename-general optname-party-name))
+ (reportdate (gnc:time64-end-day-time
(gnc:date-option-absolute-time
- (get-option gnc:pagename-general
- optname-date))))
- (date-secs reportdate)
- (report-form? (get-option gnc:pagename-general
- optname-report-form))
- (standard-order? (get-option gnc:pagename-general
- optname-standard-order))
- (compute-unrealized-gains? (not (qof-book-use-trading-accounts
- (gnc-get-current-book))))
- (accounts (get-option gnc:pagename-accounts
- optname-accounts))
- (depth-limit (get-option gnc:pagename-accounts
- optname-depth-limit))
- (bottom-behavior (get-option gnc:pagename-accounts
- optname-bottom-behavior))
- (report-commodity (get-option pagename-commodities
- optname-report-commodity))
- (price-source (get-option pagename-commodities
- optname-price-source))
- (show-fcur? (get-option pagename-commodities
- optname-show-foreign))
- (show-rates? (get-option pagename-commodities
- optname-show-rates))
+ (get-option gnc:pagename-general optname-date))))
+ (report-form? (get-option gnc:pagename-general optname-report-form))
+ (standard-order? (get-option gnc:pagename-general optname-standard-order))
+ (use-trading-accts? (qof-book-use-trading-accounts (gnc-get-current-book)))
+ (accounts (get-option gnc:pagename-accounts optname-accounts))
+ (depth-limit (get-option gnc:pagename-accounts optname-depth-limit))
+ (bottom-behavior (get-option gnc:pagename-accounts optname-bottom-behavior))
+ (report-commodity (get-option pagename-commodities optname-report-commodity))
+ (price-source (get-option pagename-commodities optname-price-source))
+ (show-fcur? (get-option pagename-commodities optname-show-foreign))
+ (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
- (assq-ref '((t . #t) (f . #f) (canonically-tabbed . canonically-tabbed))
- (get-option gnc:pagename-display
- optname-parent-total-mode)))
- (show-zb-accts? (get-option gnc:pagename-display
- optname-show-zb-accts))
- (omit-zb-bals? (get-option gnc:pagename-display
- optname-omit-zb-bals))
- (label-assets? (get-option gnc:pagename-display
- optname-label-assets))
- (total-assets? (get-option gnc:pagename-display
- optname-total-assets))
- (label-liabilities? (get-option gnc:pagename-display
- optname-label-liabilities))
- (total-liabilities? (get-option gnc:pagename-display
- optname-total-liabilities))
- (label-equity? (get-option gnc:pagename-display
- optname-label-equity))
- (total-equity? (get-option gnc:pagename-display
- optname-total-equity))
- (use-links? (get-option gnc:pagename-display
- optname-account-links))
- (use-rules? (get-option gnc:pagename-display
- optname-use-rules))
- (indent 0)
- (tabbing #f)
-
+ (assq-ref '((t . #t) (f . #f) (canonically-tabbed . canonically-tabbed))
+ (get-option gnc:pagename-display optname-parent-total-mode)))
+ (show-zb-accts? (get-option gnc:pagename-display optname-show-zb-accts))
+ (omit-zb-bals? (get-option gnc:pagename-display optname-omit-zb-bals))
+ (label-assets? (get-option gnc:pagename-display optname-label-assets))
+ (total-assets? (get-option gnc:pagename-display optname-total-assets))
+ (label-liabilities?
+ (get-option gnc:pagename-display optname-label-liabilities))
+ (total-liabilities?
+ (get-option gnc:pagename-display optname-total-liabilities))
+ (label-equity? (get-option gnc:pagename-display optname-label-equity))
+ (total-equity? (get-option gnc:pagename-display optname-total-equity))
+ (use-links? (get-option gnc:pagename-display optname-account-links))
+ (use-rules? (get-option gnc:pagename-display optname-use-rules))
+
;; decompose the account list
(split-up-accounts (gnc:decompose-accountlist accounts))
- (asset-accounts
- (assoc-ref split-up-accounts ACCT-TYPE-ASSET))
- (liability-accounts
- (assoc-ref split-up-accounts ACCT-TYPE-LIABILITY))
+ (asset-accounts (assoc-ref split-up-accounts ACCT-TYPE-ASSET))
+ (liability-accounts (assoc-ref split-up-accounts ACCT-TYPE-LIABILITY))
(income-expense-accounts
(append (assoc-ref split-up-accounts ACCT-TYPE-INCOME)
(assoc-ref split-up-accounts ACCT-TYPE-EXPENSE)))
- (equity-accounts
- (assoc-ref split-up-accounts ACCT-TYPE-EQUITY))
- (trading-accounts
- (assoc-ref split-up-accounts ACCT-TYPE-TRADING))
-
+ (equity-accounts (assoc-ref split-up-accounts ACCT-TYPE-EQUITY))
+ (trading-accounts (assoc-ref split-up-accounts ACCT-TYPE-TRADING))
+
(doc (gnc:make-html-document))
- ;; this can occasionally put extra (blank) columns in our
- ;; table (when there is one account at the maximum depth and
- ;; it has at least one of its ancestors deselected), but this
- ;; is the only simple way to ensure that all three tables
- ;; (asset, liability, equity) have the same width.
- (tree-depth (if (equal? depth-limit 'all)
- (gnc:get-current-account-tree-depth)
- depth-limit))
+ ;; this can occasionally put extra (blank) columns in our
+ ;; table (when there is one account at the maximum depth and
+ ;; it has at least one of its ancestors deselected), but this
+ ;; is the only simple way to ensure that all three tables
+ ;; (asset, liability, equity) have the same width.
+ (tree-depth (if (eq? depth-limit 'all)
+ (gnc:get-current-account-tree-depth)
+ depth-limit))
;; exchange rates calculation parameters
(exchange-fn
(gnc:case-exchange-fn price-source report-commodity reportdate)))
-
+
;; Wrapper to call gnc:html-table-add-labeled-amount-line!
;; with the proper arguments.
(define (add-subtotal-line table pos-label neg-label signed-balance)
- (define allow-same-column-totals #t)
- (let* ((neg? (and signed-balance
- neg-label
- (gnc-numeric-negative-p
- (gnc:gnc-monetary-amount
- (gnc:sum-collector-commodity
- signed-balance report-commodity exchange-fn)))))
- (label (if neg? (or neg-label pos-label) pos-label))
- (balance (if neg?
- (let ((bal (gnc:make-commodity-collector)))
- (bal 'minusmerge signed-balance #f)
- bal)
- signed-balance))
- )
- (gnc:html-table-add-labeled-amount-line!
- table
- (+ indent (* tree-depth 2)
- (if (equal? tabbing 'canonically-tabbed) 1 0))
- "primary-subheading"
- (and (not allow-same-column-totals) balance use-rules?)
- label indent 1 "total-label-cell"
- (gnc:sum-collector-commodity balance report-commodity exchange-fn)
- (+ indent (* tree-depth 2) (- 0 1)
- (if (equal? tabbing 'canonically-tabbed) 1 0))
- 1 "total-number-cell")
- )
- )
+ (let* ((neg? (and signed-balance neg-label
+ (negative?
+ (gnc:gnc-monetary-amount
+ (gnc:sum-collector-commodity
+ signed-balance report-commodity exchange-fn)))))
+ (label (if neg? (or neg-label pos-label) pos-label))
+ (balance (if neg?
+ (gnc:collector- signed-balance)
+ signed-balance)))
+ (gnc:html-table-add-labeled-amount-line!
+ table (* tree-depth 2) "primary-subheading" #f label 0 1 "total-label-cell"
+ (gnc:sum-collector-commodity balance report-commodity exchange-fn)
+ (1- (* tree-depth 2)) 1 "total-number-cell")))
;; Wrapper around gnc:html-table-append-ruler! since we call it so
;; often.
(define (add-rule table)
- (gnc:html-table-append-ruler!
- table
- (+ (* 2 tree-depth)
- (if (equal? tabbing 'canonically-tabbed) 1 0))))
-
- ;; Return a commodity collector containing the sum of the balance of all of
- ;; the accounts on acct-list as of the time given in date-secs
- (define (account-list-balance acct-list date-secs)
- (let ((balance-collector (gnc:make-commodity-collector)))
- (for-each
- (lambda (x)
- (balance-collector 'add (xaccAccountGetCommodity x)
- (xaccAccountGetBalanceAsOfDate x date-secs)))
- acct-list)
- balance-collector))
+ (gnc:html-table-append-ruler! table (* 2 tree-depth)))
+
+ ;; Return a commodity collector containing the sum of the balance of all of
+ ;; the accounts on acct-list as of the time given in reportdate
+ (define (account-list-balance acct-list reportdate)
+ (define (acc->balance acc)
+ (gnc:make-gnc-monetary
+ (xaccAccountGetCommodity acc)
+ (xaccAccountGetBalanceAsOfDate acc reportdate)))
+ (apply gnc:monetaries-add (map acc->balance acct-list)))
;; Format the liabilities section of the report
(define (add-liability-block
@@ -431,56 +384,55 @@
total-liabilities? liability-balance)
(let* ((liability-table
(gnc:make-html-acct-table/env/accts table-env liability-accounts)))
- (when label-liabilities?
- (add-subtotal-line parent-table (_ "Liabilities") #f #f))
- (gnc:html-table-add-account-balances parent-table liability-table params)
- (when total-liabilities?
- (add-subtotal-line
+ (when label-liabilities?
+ (add-subtotal-line parent-table (_ "Liabilities") #f #f))
+ (gnc:html-table-add-account-balances parent-table liability-table params)
+ (when total-liabilities?
+ (add-subtotal-line
parent-table (_ "Total Liabilities") #f liability-balance))
- (add-rule parent-table)))
+ (add-rule parent-table)))
(define (get-total-value-fn account)
(gnc:account-get-comm-value-at-date account reportdate #f))
- ;;(gnc:warn "account names" liability-account-names)
- (gnc:html-document-set-title!
+ (gnc:html-document-set-title!
doc (string-append company-name " " report-title " "
(qof-print-date reportdate)))
-
+
(if (null? accounts)
-
+
;; error condition: no accounts specified
- ;; is this *really* necessary??
- ;; i'd be fine with an all-zero balance sheet
- ;; that would, technically, be correct....
- (gnc:html-document-add-object!
+ ;; is this *really* necessary??
+ ;; i'd be fine with an all-zero balance sheet
+ ;; that would, technically, be correct....
+ (gnc:html-document-add-object!
doc (gnc:html-make-no-account-warning reportname (gnc:report-id report-obj)))
;; Get all the balances for each of the account types.
(let* ((asset-balance
- (account-list-balance asset-accounts date-secs))
+ (account-list-balance asset-accounts reportdate))
(liability-balance
- (gnc:collector- (account-list-balance liability-accounts date-secs)))
+ (gnc:collector- (account-list-balance liability-accounts reportdate)))
(equity-balance
- (gnc:collector- (account-list-balance equity-accounts date-secs)))
+ (gnc:collector- (account-list-balance equity-accounts reportdate)))
(retained-earnings
(gnc:collector-
- (account-list-balance income-expense-accounts date-secs)))
+ (account-list-balance income-expense-accounts reportdate)))
(trading-balance
- (gnc:collector- (account-list-balance trading-accounts date-secs)))
+ (gnc:collector- (account-list-balance trading-accounts reportdate)))
(unrealized-gain-collector
- (if compute-unrealized-gains?
+ (if use-trading-accts?
+ (gnc:collector+)
(gnc:collector- asset-balance
liability-balance
(gnc:accounts-get-comm-total-assets
(append asset-accounts liability-accounts)
- get-total-value-fn))
- (gnc:collector+)))
+ get-total-value-fn))))
(total-equity-balance
(gnc:collector+ equity-balance retained-earnings
@@ -527,95 +479,92 @@
(gnc:account-get-comm-balance-at-date account reportdate #f))
;; Workaround to force gtkhtml into displaying wide
- ;; enough columns.
- (let ((space (make-list tree-depth " \
+ ;; enough columns.
+ (let ((space (make-list tree-depth " \
")))
- (gnc:html-table-append-row! left-table space)
- (unless report-form?
- (gnc:html-table-append-row! right-table space)))
- (gnc:report-percent-done 80)
+ (gnc:html-table-append-row! left-table space)
+ (unless report-form?
+ (gnc:html-table-append-row! right-table space)))
+ (gnc:report-percent-done 80)
(when label-assets?
(add-subtotal-line left-table (_ "Assets") #f #f))
- (gnc:html-table-add-account-balances left-table asset-table params)
+ (gnc:html-table-add-account-balances left-table asset-table params)
(when total-assets?
- (add-subtotal-line left-table (_ "Total Assets") #f asset-balance))
-
- (when report-form?
+ (add-subtotal-line left-table (_ "Total Assets") #f asset-balance))
+
+ (when report-form?
(add-rule left-table)
- (add-rule left-table))
+ (add-rule left-table))
(gnc:report-percent-done 85)
(when standard-order?
- (add-liability-block label-liabilities? right-table table-env
- liability-accounts params
+ (add-liability-block label-liabilities? right-table table-env
+ liability-accounts params
total-liabilities? liability-balance))
-
- (gnc:report-percent-done 88)
- (when label-equity?
- (add-subtotal-line right-table (_ "Equity") #f #f))
+ (gnc:report-percent-done 88)
+
+ (when label-equity?
+ (add-subtotal-line right-table (_ "Equity") #f #f))
(gnc:html-table-add-account-balances right-table equity-table params)
;; we omit retained earnings & unrealized gains
- ;; from the balance report, if zero, since they
- ;; are not present on normal balance sheets
- (unless (gnc-commodity-collector-allzero? retained-earnings)
- (add-subtotal-line right-table
- (_ "Retained Earnings")
- (_ "Retained Losses")
- retained-earnings))
+ ;; from the balance report, if zero, since they
+ ;; are not present on normal balance sheets
+ (unless (gnc-commodity-collector-allzero? retained-earnings)
+ (add-subtotal-line right-table
+ (_ "Retained Earnings")
+ (_ "Retained Losses")
+ retained-earnings))
(unless (gnc-commodity-collector-allzero? trading-balance)
- (add-subtotal-line right-table
- (_ "Trading Gains")
- (_ "Trading Losses")
- trading-balance))
+ (add-subtotal-line right-table
+ (_ "Trading Gains")
+ (_ "Trading Losses")
+ trading-balance))
(unless (gnc-commodity-collector-allzero? unrealized-gain-collector)
- (add-subtotal-line right-table
- (_ "Unrealized Gains")
- (_ "Unrealized Losses")
- unrealized-gain-collector))
- (when total-equity?
- (add-subtotal-line
- right-table (_ "Total Equity") #f total-equity-balance))
+ (add-subtotal-line right-table
+ (_ "Unrealized Gains")
+ (_ "Unrealized Losses")
+ unrealized-gain-collector))
+ (when total-equity?
+ (add-subtotal-line
+ right-table (_ "Total Equity") #f total-equity-balance))
(add-rule right-table)
(unless standard-order?
- (add-liability-block label-liabilities? right-table table-env
- liability-accounts params
+ (add-liability-block label-liabilities? right-table table-env
+ liability-accounts params
total-liabilities? liability-balance))
(add-subtotal-line
right-table (gnc:html-string-sanitize (_ "Total Liabilities & Equity"))
- #f liability-plus-equity)
-
- (gnc:html-document-add-object!
- doc (if report-form?
- left-table
- (let* ((build-table (gnc:make-html-table)))
- (gnc:html-table-append-row!
- build-table
- (list
- (gnc:make-html-table-cell left-table)
- (gnc:make-html-table-cell right-table)))
- (gnc:html-table-set-style!
- build-table "td"
- 'attribute '("align" "left")
- 'attribute '("valign" "top"))
- build-table)))
-
+ #f liability-plus-equity)
+
+ (gnc:html-document-add-object!
+ doc (if report-form?
+ left-table
+ (let ((build-table (gnc:make-html-table)))
+ (gnc:html-table-append-row!
+ build-table (list left-table right-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)
+ (gnc:report-percent-done 90)
(when show-rates?
(gnc:html-document-add-object!
doc (gnc:html-make-exchangerates report-commodity exchange-fn accounts)))
(gnc:report-percent-done 100)))
-
+
(gnc:report-finished)
-
+
doc))
-(gnc:define-report
+(gnc:define-report
'version 1
'name reportname
'report-guid "c4173ac99b2b448289bf4d11c731af13"
@@ -624,4 +573,3 @@
'renderer balance-sheet-renderer)
;; END
-
commit 90d83e076c41557552b367cbf0fe10755a20f4dd
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Sep 29 16:56:06 2019 +0800
[balance-sheet] compact functions
diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index 88fb403f8..48ceafa42 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -426,22 +426,18 @@
balance-collector))
;; Format the liabilities section of the report
- (define (liability-block label-liabilities? parent-table table-env liability-accounts params
- total-liabilities? liability-balance)
- (let* ((liability-table #f)) ;; gnc:html-acct-table
- (if label-liabilities?
- (add-subtotal-line
- parent-table (_ "Liabilities") #f #f))
- (set! liability-table
- (gnc:make-html-acct-table/env/accts
- table-env liability-accounts))
- (gnc:html-table-add-account-balances
- parent-table liability-table params)
- (if total-liabilities?
- (add-subtotal-line
- parent-table (_ "Total Liabilities") #f liability-balance))
-
- (add-rule parent-table)))
+ (define (add-liability-block
+ label-liabilities? parent-table table-env liability-accounts params
+ total-liabilities? liability-balance)
+ (let* ((liability-table
+ (gnc:make-html-acct-table/env/accts table-env liability-accounts)))
+ (when label-liabilities?
+ (add-subtotal-line parent-table (_ "Liabilities") #f #f))
+ (gnc:html-table-add-account-balances parent-table liability-table params)
+ (when total-liabilities?
+ (add-subtotal-line
+ parent-table (_ "Total Liabilities") #f liability-balance))
+ (add-rule parent-table)))
(define (get-total-value-fn account)
(gnc:account-get-comm-value-at-date account reportdate #f))
@@ -449,8 +445,7 @@
;;(gnc:warn "account names" liability-account-names)
(gnc:html-document-set-title!
doc (string-append company-name " " report-title " "
- (qof-print-date reportdate))
- )
+ (qof-print-date reportdate)))
(if (null? accounts)
@@ -459,10 +454,8 @@
;; i'd be fine with an all-zero balance sheet
;; that would, technically, be correct....
(gnc:html-document-add-object!
- doc
- (gnc:html-make-no-account-warning
- reportname (gnc:report-id report-obj)))
-
+ doc (gnc:html-make-no-account-warning reportname (gnc:report-id report-obj)))
+
;; Get all the balances for each of the account types.
(let* ((asset-balance
(account-list-balance asset-accounts date-secs))
@@ -530,114 +523,93 @@
(equity-table
(gnc:make-html-acct-table/env/accts table-env equity-accounts)))
- (get-total-balance-fn
- (lambda (account)
- (gnc:account-get-comm-balance-at-date
- account reportdate #f))))
+ (define (get-total-balance-fn account)
+ (gnc:account-get-comm-balance-at-date account reportdate #f))
;; Workaround to force gtkhtml into displaying wide
;; enough columns.
- (let ((space
- (make-list tree-depth " \
- \
- ")
- ))
+ (let ((space (make-list tree-depth " \
+ ")))
(gnc:html-table-append-row! left-table space)
- (if (not report-form?)
- (gnc:html-table-append-row! right-table space))
- )
-
+ (unless report-form?
+ (gnc:html-table-append-row! right-table space)))
(gnc:report-percent-done 80)
- (if label-assets? (add-subtotal-line left-table (_ "Assets") #f #f))
- (gnc:html-table-add-account-balances
- left-table asset-table params)
- (if total-assets? (add-subtotal-line
- left-table (_ "Total Assets") #f asset-balance))
+ (when label-assets?
+ (add-subtotal-line left-table (_ "Assets") #f #f))
+ (gnc:html-table-add-account-balances left-table asset-table params)
+ (when total-assets?
+ (add-subtotal-line left-table (_ "Total Assets") #f asset-balance))
(when report-form?
(add-rule left-table)
(add-rule left-table))
-
(gnc:report-percent-done 85)
- (if standard-order?
- (liability-block label-liabilities? right-table table-env
- liability-accounts params
- total-liabilities? liability-balance))
+
+ (when standard-order?
+ (add-liability-block label-liabilities? right-table table-env
+ liability-accounts params
+ total-liabilities? liability-balance))
(gnc:report-percent-done 88)
- (if label-equity?
- (add-subtotal-line
- right-table (_ "Equity") #f #f))
- (gnc:html-table-add-account-balances
- right-table equity-table params)
- ;; we omit retianed earnings & unrealized gains
+ (when label-equity?
+ (add-subtotal-line right-table (_ "Equity") #f #f))
+ (gnc:html-table-add-account-balances right-table equity-table params)
+ ;; we omit retained earnings & unrealized gains
;; from the balance report, if zero, since they
;; are not present on normal balance sheets
- (and (not (gnc-commodity-collector-allzero?
- retained-earnings))
- (add-subtotal-line right-table
- (_ "Retained Earnings")
- (_ "Retained Losses")
- retained-earnings))
- (and (not (gnc-commodity-collector-allzero?
- trading-balance))
- (add-subtotal-line right-table
- (_ "Trading Gains")
- (_ "Trading Losses")
- trading-balance))
- (and (not (gnc-commodity-collector-allzero?
- unrealized-gain-collector))
- (add-subtotal-line right-table
- (_ "Unrealized Gains")
- (_ "Unrealized Losses")
- unrealized-gain-collector))
- (if total-equity?
- (add-subtotal-line
- right-table (_ "Total Equity") #f total-equity-balance))
-
- (add-rule right-table)
-
- (if (not standard-order?)
- (liability-block label-liabilities? right-table table-env
- liability-accounts params
- total-liabilities? liability-balance))
+ (unless (gnc-commodity-collector-allzero? retained-earnings)
+ (add-subtotal-line right-table
+ (_ "Retained Earnings")
+ (_ "Retained Losses")
+ retained-earnings))
+ (unless (gnc-commodity-collector-allzero? trading-balance)
+ (add-subtotal-line right-table
+ (_ "Trading Gains")
+ (_ "Trading Losses")
+ trading-balance))
+ (unless (gnc-commodity-collector-allzero? unrealized-gain-collector)
+ (add-subtotal-line right-table
+ (_ "Unrealized Gains")
+ (_ "Unrealized Losses")
+ unrealized-gain-collector))
+ (when total-equity?
+ (add-subtotal-line
+ right-table (_ "Total Equity") #f total-equity-balance))
+
+ (add-rule right-table)
+
+ (unless standard-order?
+ (add-liability-block label-liabilities? right-table table-env
+ liability-accounts params
+ total-liabilities? liability-balance))
(add-subtotal-line
- right-table (gnc:html-string-sanitize
- (_ "Total Liabilities & Equity"))
+ right-table (gnc:html-string-sanitize (_ "Total Liabilities & Equity"))
#f liability-plus-equity)
(gnc:html-document-add-object!
- doc
- (if report-form?
- left-table
- (let* ((build-table (gnc:make-html-table))
- )
- (gnc:html-table-append-row!
- build-table
- (list
- (gnc:make-html-table-cell left-table)
- (gnc:make-html-table-cell right-table)
- )
- )
- (gnc:html-table-set-style!
- build-table "td"
- 'attribute '("align" "left")
- 'attribute '("valign" "top"))
- build-table
- )
- )
- )
+ doc (if report-form?
+ left-table
+ (let* ((build-table (gnc:make-html-table)))
+ (gnc:html-table-append-row!
+ build-table
+ (list
+ (gnc:make-html-table-cell left-table)
+ (gnc:make-html-table-cell right-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?
- (gnc:html-document-add-object!
- doc ;;(gnc:html-markup-p)
- (gnc:html-make-exchangerates
- report-commodity exchange-fn accounts)))
- (gnc:report-percent-done 100)))
+ (when show-rates?
+ (gnc:html-document-add-object!
+ doc (gnc:html-make-exchangerates report-commodity exchange-fn accounts)))
+
+ (gnc:report-percent-done 100)))
(gnc:report-finished)
commit dad5961b51a9f37276ad1fafd97db0f16e88221f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Sep 29 16:47:44 2019 +0800
[balance-sheet] define vars in formals rather than set!
diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index a4541a589..88fb403f8 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -442,7 +442,10 @@
parent-table (_ "Total Liabilities") #f liability-balance))
(add-rule parent-table)))
-
+
+ (define (get-total-value-fn account)
+ (gnc:account-get-comm-value-at-date account reportdate #f))
+
;;(gnc:warn "account names" liability-account-names)
(gnc:html-document-set-title!
doc (string-append company-name " " report-title " "
@@ -461,14 +464,37 @@
reportname (gnc:report-id report-obj)))
;; Get all the balances for each of the account types.
- (let* ((asset-balance #f)
- (liability-balance #f)
- (equity-balance #f)
- (retained-earnings #f)
- (trading-balance #f)
- (unrealized-gain-collector #f)
- (total-equity-balance #f)
- (liability-plus-equity #f)
+ (let* ((asset-balance
+ (account-list-balance asset-accounts date-secs))
+
+ (liability-balance
+ (gnc:collector- (account-list-balance liability-accounts date-secs)))
+
+ (equity-balance
+ (gnc:collector- (account-list-balance equity-accounts date-secs)))
+
+ (retained-earnings
+ (gnc:collector-
+ (account-list-balance income-expense-accounts date-secs)))
+
+ (trading-balance
+ (gnc:collector- (account-list-balance trading-accounts date-secs)))
+
+ (unrealized-gain-collector
+ (if compute-unrealized-gains?
+ (gnc:collector- asset-balance
+ liability-balance
+ (gnc:accounts-get-comm-total-assets
+ (append asset-accounts liability-accounts)
+ get-total-value-fn))
+ (gnc:collector+)))
+
+ (total-equity-balance
+ (gnc:collector+ equity-balance retained-earnings
+ unrealized-gain-collector trading-balance))
+
+ (liability-plus-equity
+ (gnc:collector+ liability-balance total-equity-balance))
;; Create the account tables below where their
;; percentage time can be tracked.
@@ -476,112 +502,40 @@
(right-table (if report-form?
left-table
(gnc:make-html-table)))
- (table-env #f) ;; parameters for :make-
- (params #f) ;; and -add-account-
- (asset-table #f) ;; gnc:html-acct-table
- (equity-table #f) ;; gnc:html-acct-table
+
+ (table-env
+ (list
+ (list 'start-date #f)
+ (list 'end-date reportdate)
+ (list 'display-tree-depth tree-depth)
+ (list 'depth-limit-behavior (if bottom-behavior 'flatten 'summarize))
+ (list 'report-commodity report-commodity)
+ (list 'exchange-fn exchange-fn)
+ (list 'parent-account-subtotal-mode parent-total-mode)
+ (list 'zero-balance-mode
+ (if show-zb-accts? 'show-leaf-acct 'omit-leaf-acct))
+ (list 'account-label-mode (if use-links? 'anchor 'name))))
+
+ (params
+ (list
+ (list 'parent-account-balance-mode parent-balance-mode)
+ (list 'zero-balance-display-mode
+ (if omit-zb-bals? 'omit-balance 'show-balance))
+ (list 'multicommodity-mode (and show-fcur? 'table))
+ (list 'rule-mode use-rules?)))
+
+ (asset-table
+ (gnc:make-html-acct-table/env/accts table-env asset-accounts))
+
+ (equity-table
+ (gnc:make-html-acct-table/env/accts table-env equity-accounts)))
+
(get-total-balance-fn
(lambda (account)
(gnc:account-get-comm-balance-at-date
- account reportdate #f)))
- (get-total-value-fn
- (lambda (account)
- (gnc:account-get-comm-value-at-date account reportdate #f))))
-
- ;; If you ask me, any outstanding(TM) retained earnings and
- ;; unrealized gains should be added directly into equity,
- ;; since the balance sheet does not have a period over which
- ;; to report earnings.... See discussion on bugzilla.
- (gnc:report-percent-done 4)
-
- ;; sum assets
- (set! asset-balance (account-list-balance asset-accounts date-secs))
- (gnc:report-percent-done 6)
-
- ;; sum liabilities
- (set! liability-balance
- (gnc:collector- (account-list-balance liability-accounts date-secs)))
- (gnc:report-percent-done 8)
-
- ;; sum equities
- (set! equity-balance
- (gnc:collector- (account-list-balance equity-accounts date-secs)))
- (gnc:report-percent-done 12)
-
- ;; sum any retained earnings
- (set! retained-earnings
- (gnc:collector- (account-list-balance income-expense-accounts date-secs)))
- (set! trading-balance
- (gnc:collector- (account-list-balance trading-accounts date-secs)))
- (gnc:report-percent-done 14)
-
- ;; sum any unrealized gains
- ;;
- ;; Hm... unrealized gains.... This is when you purchase
- ;; something and its value increases/decreases (prior to
- ;; your selling it) and you have to reflect that on your
- ;; balance sheet.
- ;;
- ;; Don't calculate unrealized gains if we were asked not to. If we are using
- ;; commodity trading accounts they will automatically accumulate the gains.
- (set! unrealized-gain-collector
- (if compute-unrealized-gains?
- (gnc:collector- asset-balance
- liability-balance
- (gnc:accounts-get-comm-total-assets
- (append asset-accounts liability-accounts)
- get-total-value-fn))
- (gnc:collector+)))
-
- ;; calculate equity and liability+equity totals
- (set! total-equity-balance
- (gnc:collector+ equity-balance retained-earnings
- unrealized-gain-collector trading-balance))
- (set! liability-plus-equity
- (gnc:collector+ liability-balance total-equity-balance))
- (gnc:report-percent-done 30)
-
- ;;; Arbitrarily declare that the building of these tables
- ;;; takes 50% of the total amount of time spent building
- ;;; this report. (from 30%-80%)
-
- (set! table-env
- (list
- (list 'start-date #f)
- (list 'end-date reportdate)
- (list 'display-tree-depth tree-depth)
- (list 'depth-limit-behavior (if bottom-behavior
- 'flatten
- 'summarize))
- (list 'report-commodity report-commodity)
- (list 'exchange-fn exchange-fn)
- (list 'parent-account-subtotal-mode parent-total-mode)
- (list 'zero-balance-mode (if show-zb-accts?
- 'show-leaf-acct
- 'omit-leaf-acct))
- (list 'account-label-mode (if use-links?
- 'anchor
- 'name))
- )
- )
- (set! params
- (list
- (list 'parent-account-balance-mode parent-balance-mode)
- (list 'zero-balance-display-mode (if omit-zb-bals?
- 'omit-balance
- 'show-balance))
- (list 'multicommodity-mode (if show-fcur? 'table #f))
- (list 'rule-mode use-rules?)
- )
- )
-
- ;(gnc:html-table-set-style!
- ; left-table "table" 'attribute '("rules" "rows"))
- ;(gnc:html-table-set-style!
- ; right-table "table" 'attribute '("rules" "rows"))
- ;; could also '("border" "1") or '("rules" "all")
-
- ;; Workaround to force gtkhtml into displaying wide
+ account reportdate #f))))
+
+ ;; Workaround to force gtkhtml into displaying wide
;; enough columns.
(let ((space
(make-list tree-depth " \
@@ -595,20 +549,17 @@
(gnc:report-percent-done 80)
(if label-assets? (add-subtotal-line left-table (_ "Assets") #f #f))
- (set! asset-table
- (gnc:make-html-acct-table/env/accts
- table-env asset-accounts))
+
(gnc:html-table-add-account-balances
left-table asset-table params)
(if total-assets? (add-subtotal-line
left-table (_ "Total Assets") #f asset-balance))
- (if report-form?
- (add-rule left-table))
- (if report-form?
- (add-rule left-table))
-
- (gnc:report-percent-done 85)
+ (when report-form?
+ (add-rule left-table)
+ (add-rule left-table))
+
+ (gnc:report-percent-done 85)
(if standard-order?
(liability-block label-liabilities? right-table table-env
liability-accounts params
@@ -618,9 +569,6 @@
(if label-equity?
(add-subtotal-line
right-table (_ "Equity") #f #f))
- (set! equity-table
- (gnc:make-html-acct-table/env/accts
- table-env equity-accounts))
(gnc:html-table-add-account-balances
right-table equity-table params)
;; we omit retianed earnings & unrealized gains
commit 80296a3c8a733c82106c1dac598c25507faad109
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Sep 29 16:41:07 2019 +0800
[balance-sheet] use collector arithmetic
diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index cdebc8771..a4541a589 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -462,120 +462,84 @@
;; Get all the balances for each of the account types.
(let* ((asset-balance #f)
- (neg-liability-balance #f) ;; credit balances are < 0
(liability-balance #f)
- (neg-equity-balance #f)
(equity-balance #f)
- (neg-retained-earnings #f) ;; credit, income - expenses, < 0
- (retained-earnings #f)
- (neg-trading-balance #f)
- (trading-balance #f)
+ (retained-earnings #f)
+ (trading-balance #f)
(unrealized-gain-collector #f)
(total-equity-balance #f)
(liability-plus-equity #f)
-
+
;; Create the account tables below where their
;; percentage time can be tracked.
- (left-table (gnc:make-html-table)) ;; gnc:html-table
- (right-table (if report-form? left-table
- (gnc:make-html-table)))
- (table-env #f) ;; parameters for :make-
- (params #f) ;; and -add-account-
+ (left-table (gnc:make-html-table)) ;; gnc:html-table
+ (right-table (if report-form?
+ left-table
+ (gnc:make-html-table)))
+ (table-env #f) ;; parameters for :make-
+ (params #f) ;; and -add-account-
(asset-table #f) ;; gnc:html-acct-table
(equity-table #f) ;; gnc:html-acct-table
- (get-total-balance-fn
- (lambda (account)
- (gnc:account-get-comm-balance-at-date
- account reportdate #f)))
+ (get-total-balance-fn
+ (lambda (account)
+ (gnc:account-get-comm-balance-at-date
+ account reportdate #f)))
(get-total-value-fn
(lambda (account)
- (gnc:account-get-comm-value-at-date account reportdate #f)))
- )
-
- ;; If you ask me, any outstanding(TM) retained earnings and
- ;; unrealized gains should be added directly into equity,
- ;; since the balance sheet does not have a period over which
- ;; to report earnings.... See discussion on bugzilla.
- (gnc:report-percent-done 4)
- ;; sum assets
- (set! asset-balance (account-list-balance asset-accounts date-secs))
- (gnc:report-percent-done 6)
- ;; sum liabilities
- (set! neg-liability-balance (account-list-balance liability-accounts date-secs))
- (set! liability-balance
- (gnc:make-commodity-collector))
- (liability-balance 'minusmerge
- neg-liability-balance
- #f)
- (gnc:report-percent-done 8)
- ;; sum equities
- (set! neg-equity-balance (account-list-balance equity-accounts date-secs))
- (set! equity-balance (gnc:make-commodity-collector))
- (equity-balance 'minusmerge
- neg-equity-balance
- #f)
- (gnc:report-percent-done 12)
- ;; sum any retained earnings
- (set! neg-retained-earnings (account-list-balance income-expense-accounts date-secs))
- (set! retained-earnings (gnc:make-commodity-collector))
- (retained-earnings 'minusmerge
- neg-retained-earnings
- #f)
- (set! neg-trading-balance (account-list-balance trading-accounts date-secs))
- (set! trading-balance (gnc:make-commodity-collector))
- (trading-balance 'minusmerge
- neg-trading-balance
- #f)
- (gnc:report-percent-done 14)
- ;; sum any unrealized gains
- ;;
- ;; Hm... unrealized gains.... This is when you purchase
- ;; something and its value increases/decreases (prior to
- ;; your selling it) and you have to reflect that on your
- ;; balance sheet.
- ;;
+ (gnc:account-get-comm-value-at-date account reportdate #f))))
+
+ ;; If you ask me, any outstanding(TM) retained earnings and
+ ;; unrealized gains should be added directly into equity,
+ ;; since the balance sheet does not have a period over which
+ ;; to report earnings.... See discussion on bugzilla.
+ (gnc:report-percent-done 4)
+
+ ;; sum assets
+ (set! asset-balance (account-list-balance asset-accounts date-secs))
+ (gnc:report-percent-done 6)
+
+ ;; sum liabilities
+ (set! liability-balance
+ (gnc:collector- (account-list-balance liability-accounts date-secs)))
+ (gnc:report-percent-done 8)
+
+ ;; sum equities
+ (set! equity-balance
+ (gnc:collector- (account-list-balance equity-accounts date-secs)))
+ (gnc:report-percent-done 12)
+
+ ;; sum any retained earnings
+ (set! retained-earnings
+ (gnc:collector- (account-list-balance income-expense-accounts date-secs)))
+ (set! trading-balance
+ (gnc:collector- (account-list-balance trading-accounts date-secs)))
+ (gnc:report-percent-done 14)
+
+ ;; sum any unrealized gains
+ ;;
+ ;; Hm... unrealized gains.... This is when you purchase
+ ;; something and its value increases/decreases (prior to
+ ;; your selling it) and you have to reflect that on your
+ ;; balance sheet.
+ ;;
;; Don't calculate unrealized gains if we were asked not to. If we are using
;; commodity trading accounts they will automatically accumulate the gains.
- (set! unrealized-gain-collector (gnc:make-commodity-collector))
- (if compute-unrealized-gains?
- (let ((asset-basis (gnc:accounts-get-comm-total-assets
- asset-accounts
- get-total-value-fn))
- (neg-liability-basis (gnc:accounts-get-comm-total-assets
- liability-accounts
- get-total-value-fn)))
- ;; Calculate unrealized gains from assets.
- (unrealized-gain-collector 'merge asset-balance #f)
- (unrealized-gain-collector 'minusmerge asset-basis #f)
- ;; Combine with unrealized gains from liabilities
- (unrealized-gain-collector 'merge neg-liability-balance #f)
- (unrealized-gain-collector 'minusmerge neg-liability-basis #f)))
+ (set! unrealized-gain-collector
+ (if compute-unrealized-gains?
+ (gnc:collector- asset-balance
+ liability-balance
+ (gnc:accounts-get-comm-total-assets
+ (append asset-accounts liability-accounts)
+ get-total-value-fn))
+ (gnc:collector+)))
;; calculate equity and liability+equity totals
- (set! total-equity-balance (gnc:make-commodity-collector))
- (total-equity-balance 'merge
- equity-balance
- #f)
- (total-equity-balance 'merge
- retained-earnings
- #f)
- (total-equity-balance 'merge
- unrealized-gain-collector
- #f)
- (total-equity-balance 'merge
- trading-balance
- #f)
- (gnc:report-percent-done 18)
- (set! liability-plus-equity (gnc:make-commodity-collector))
- (liability-plus-equity 'merge
- liability-balance
- #f)
- (liability-plus-equity 'merge
- total-equity-balance
- #f)
-
- (gnc:report-percent-done 20)
- (gnc:report-percent-done 30)
+ (set! total-equity-balance
+ (gnc:collector+ equity-balance retained-earnings
+ unrealized-gain-collector trading-balance))
+ (set! liability-plus-equity
+ (gnc:collector+ liability-balance total-equity-balance))
+ (gnc:report-percent-done 30)
;;; Arbitrarily declare that the building of these tables
;;; takes 50% of the total amount of time spent building
Summary of changes:
gnucash/report/standard-reports/balance-sheet.scm | 656 ++++++++-------------
.../standard-reports/budget-balance-sheet.scm | 18 +-
.../standard-reports/budget-income-statement.scm | 15 +-
.../report/standard-reports/equity-statement.scm | 43 +-
.../report/standard-reports/income-statement.scm | 17 +-
gnucash/report/standard-reports/trial-balance.scm | 17 +-
6 files changed, 281 insertions(+), 485 deletions(-)
More information about the gnucash-changes
mailing list