gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Mon Sep 30 04:54:55 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/2684e51d (commit)
via https://github.com/Gnucash/gnucash/commit/72dc9bd3 (commit)
via https://github.com/Gnucash/gnucash/commit/545454e3 (commit)
via https://github.com/Gnucash/gnucash/commit/18c79a8a (commit)
via https://github.com/Gnucash/gnucash/commit/b481e2ea (commit)
via https://github.com/Gnucash/gnucash/commit/e579f6af (commit)
via https://github.com/Gnucash/gnucash/commit/c21d173c (commit)
via https://github.com/Gnucash/gnucash/commit/99b5d79a (commit)
via https://github.com/Gnucash/gnucash/commit/fd6b102f (commit)
via https://github.com/Gnucash/gnucash/commit/1da86a5f (commit)
via https://github.com/Gnucash/gnucash/commit/187d3833 (commit)
from https://github.com/Gnucash/gnucash/commit/82e9b14d (commit)
commit 2684e51dbf12d3cf3a9aa4d3c7c9f22f5278e9d2
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 16:34:28 2019 +0800
[reports][API] gnc:make-html-table-cell/min-width
A better version of 5aa59e0ce - new API call to create a table-cell
with min-width style attribute. Can be used by balsheet-pnl as
well.
diff --git a/gnucash/report/report-system/html-table.scm b/gnucash/report/report-system/html-table.scm
index 7d6d5c762..ceedb8ece 100644
--- a/gnucash/report/report-system/html-table.scm
+++ b/gnucash/report/report-system/html-table.scm
@@ -73,6 +73,12 @@
(gnc:make-html-table-cell-internal rowspan colspan markup
objects (gnc:make-html-style-table)))
+(define (gnc:make-html-table-cell/min-width px)
+ (let ((cell (gnc:make-html-table-cell)))
+ (gnc:html-table-cell-set-style!
+ cell "td" 'attribute (list "style" (format #f "min-width:~apx" px)))
+ cell))
+
(define (gnc:make-html-table-header-cell . objects)
(gnc:make-html-table-cell-internal 1 1 "th" objects
(gnc:make-html-style-table)))
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index ceee70e11..16726290d 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -563,6 +563,7 @@
(export gnc:make-html-table-header-cell)
(export gnc:make-html-table-header-cell/markup)
(export gnc:make-html-table-header-cell/size)
+(export gnc:make-html-table-cell/min-width)
(export gnc:html-table-cell?)
(export gnc:html-table-cell-rowspan)
(export gnc:html-table-cell-set-rowspan!)
diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index b7699f2bf..912524740 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -473,13 +473,10 @@
(equity-table
(gnc:make-html-acct-table/env/accts table-env equity-accounts)))
- (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))))
+ (let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
+ (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/balsheet-pnl.scm b/gnucash/report/standard-reports/balsheet-pnl.scm
index bca8f5ad4..8d06801b1 100644
--- a/gnucash/report/standard-reports/balsheet-pnl.scm
+++ b/gnucash/report/standard-reports/balsheet-pnl.scm
@@ -419,11 +419,7 @@ also show overall period profit & loss."))
(loop (cons (thunk) result) (1- n)))))
(define (make-narrow-cell)
- (let ((narrow (gnc:make-html-table-cell/markup "text-cell" #f)))
- (gnc:html-table-cell-set-style!
- narrow "text-cell"
- 'attribute '("style" "width:1px"))
- narrow))
+ (gnc:make-html-table-cell/min-width 1))
(define (add-indented-row indent label label-markup amount-indent rest)
(when (or (not depth-limit) (<= indent depth-limit))
diff --git a/gnucash/report/standard-reports/budget-balance-sheet.scm b/gnucash/report/standard-reports/budget-balance-sheet.scm
index b5edc5e1f..1d1cb6029 100644
--- a/gnucash/report/standard-reports/budget-balance-sheet.scm
+++ b/gnucash/report/standard-reports/budget-balance-sheet.scm
@@ -653,16 +653,13 @@
(list 'rule-mode use-rules?)
)
)
-
- (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)
+
+ (let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
+ (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))
(set! asset-table
(gnc:make-html-acct-table/env/accts
diff --git a/gnucash/report/standard-reports/budget-income-statement.scm b/gnucash/report/standard-reports/budget-income-statement.scm
index 635fb57ea..d26085212 100644
--- a/gnucash/report/standard-reports/budget-income-statement.scm
+++ b/gnucash/report/standard-reports/budget-income-statement.scm
@@ -582,11 +582,9 @@
)
)
- (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)))
+ (let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
+ (gnc:html-table-append-row! inc-table space)
+ (gnc:html-table-append-row! exp-table space))
(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 51387b545..85ad4cc85 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -440,10 +440,8 @@
(gnc:report-percent-done 30)
- (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:html-table-append-row!
+ build-table (make-list 2 (gnc:make-html-table-cell/min-width 60)))
(gnc:report-percent-done 80)
diff --git a/gnucash/report/standard-reports/income-statement.scm b/gnucash/report/standard-reports/income-statement.scm
index 035b57b5c..d5477685d 100644
--- a/gnucash/report/standard-reports/income-statement.scm
+++ b/gnucash/report/standard-reports/income-statement.scm
@@ -548,12 +548,10 @@
)
)
- (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)))
+ (let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
+ (gnc:html-table-append-row! inc-table space)
+ (gnc:html-table-append-row! exp-table space)
+ (gnc:html-table-append-row! tra-table space))
(gnc:report-percent-done 80)
(if label-revenue?
diff --git a/gnucash/report/standard-reports/trial-balance.scm b/gnucash/report/standard-reports/trial-balance.scm
index 3ca1dd62e..48f879179 100644
--- a/gnucash/report/standard-reports/trial-balance.scm
+++ b/gnucash/report/standard-reports/trial-balance.scm
@@ -557,13 +557,10 @@
(let* ((env (gnc:html-acct-table-get-row-env acct-table 0)))
(set! account-cols (get-val env 'account-cols)))
- (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))))
+ (let* ((ncols (+ account-cols (if (eq? report-variant 'work-sheet) 10 2)))
+ (space (make-list ncols (gnc:make-html-table-cell/min-width 60))))
+ (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)
commit 72dc9bd301a762ccf22c67296842dd868c2b37ad
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 15:22:23 2019 +0800
[budget-income-statement] remove dead code
indent & tabbing are constants, refactor them out
diff --git a/gnucash/report/standard-reports/budget-income-statement.scm b/gnucash/report/standard-reports/budget-income-statement.scm
index e73b42fad..635fb57ea 100644
--- a/gnucash/report/standard-reports/budget-income-statement.scm
+++ b/gnucash/report/standard-reports/budget-income-statement.scm
@@ -71,8 +71,6 @@
(define opthelp-budget-period-end
(N_ "Select a budget period that ends the reporting range."))
-;; FIXME this could use an indent option
-
(define optname-accounts (N_ "Accounts"))
(define opthelp-accounts
(N_ "Report on these accounts, if display depth allows."))
@@ -384,8 +382,6 @@
optname-two-column))
(standard-order? (get-option gnc:pagename-display
optname-standard-order))
- (indent 0)
- (tabbing #f)
;; decompose the account list
(split-up-accounts (gnc:decompose-accountlist accounts))
@@ -406,41 +402,23 @@
(gnc:case-exchange-fn price-source report-commodity date-t64))
)
- ;; 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
+ (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))
- )
+ (balance (if neg? (gnc:collector- signed-balance) 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"
+ table (* tree-depth 2) "primary-subheading" #f label 0 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")
- )
- )
+ (1- (* tree-depth 2)) 1 "total-number-cell")))
;; wrapper around gnc:html-table-append-ruler!
(define (add-rule table)
(gnc:html-table-append-ruler!
- table
- (+ (* 2 tree-depth)
- (if (equal? tabbing 'canonically-tabbed) 1 0))))
+ table (* 2 tree-depth)))
(cond
((null? accounts)
@@ -507,34 +485,20 @@
;; a helper to add a line to our report
(define (report-line
- table pos-label neg-label amount col
- exchange-fn rule? row-style)
- (let* ((neg? (and amount
- neg-label
- (gnc-numeric-negative-p
+ table pos-label neg-label amount col exchange-fn rule? row-style)
+ (let* ((neg? (and amount neg-label
+ (negative?
(gnc:gnc-monetary-amount
(gnc:sum-collector-commodity
amount report-commodity exchange-fn)))))
(label (if neg? (or neg-label pos-label) pos-label))
- (pos-bal (if neg?
- (gnc:collector- amount)
- amount))
+ (abs-amt (if neg? (gnc:collector- amount) amount))
(bal (gnc:sum-collector-commodity
- pos-bal report-commodity exchange-fn))
- (balance
- (cond
- ((gnc:uniform-commodity? pos-bal report-commodity) bal)
- (show-fcur? (gnc-commodity-table pos-bal report-commodity
- exchange-fn))
- (else bal)))
- (column (or col 0))
- )
+ abs-amt report-commodity exchange-fn)))
(gnc:html-table-add-labeled-amount-line!
table (* 2 tree-depth) row-style rule?
label 0 1 "text-cell"
- bal (+ col 1) 1 "number-cell")
- )
- )
+ bal (1+ col) 1 "number-cell")))
(gnc:report-percent-done 5)
commit 545454e347687a4de5931557766f5596140a76f6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 15:21:32 2019 +0800
[income-statement] remove dead code
indent and tabbing are constant, refactor them out
diff --git a/gnucash/report/standard-reports/income-statement.scm b/gnucash/report/standard-reports/income-statement.scm
index c3d1ea5d1..035b57b5c 100644
--- a/gnucash/report/standard-reports/income-statement.scm
+++ b/gnucash/report/standard-reports/income-statement.scm
@@ -58,7 +58,6 @@
(define optname-start-date (N_ "Start Date"))
(define optname-end-date (N_ "End Date"))
-;; FIXME this could use an indent option
(define optname-accounts (N_ "Accounts"))
(define opthelp-accounts
@@ -363,12 +362,8 @@
(list (list 'str closing-str)
(list 'cased closing-cased)
(list 'regexp closing-regexp)
- (list 'closing #t)
- )
- )
- (indent 0)
- (tabbing #f)
-
+ (list 'closing #t)))
+
;; decompose the account list
(split-up-accounts (gnc:decompose-accountlist accounts))
(revenue-accounts (assoc-ref split-up-accounts ACCT-TYPE-INCOME))
@@ -392,7 +387,6 @@
;; 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
@@ -400,32 +394,15 @@
(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))
- )
+ (balance (if neg? (gnc:collector- signed-balance) 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"
+ table (* tree-depth 2) "primary-subheading" #f label 0 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")
- )
- )
+ (1- (* tree-depth 2)) 1 "total-number-cell")))
;; wrapper around gnc:html-table-append-ruler!
(define (add-rule table)
- (gnc:html-table-append-ruler!
- table
- (+ (* 2 tree-depth)
- (if (equal? tabbing 'canonically-tabbed) 1 0))))
+ (gnc:html-table-append-ruler! table (* 2 tree-depth)))
(gnc:html-document-set-title!
doc (format #f
commit 18c79a8a6a777aef531e5a277af205462a23d683
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 15:21:14 2019 +0800
[trial-balance] remove dead code
diff --git a/gnucash/report/standard-reports/trial-balance.scm b/gnucash/report/standard-reports/trial-balance.scm
index c5db01864..3ca1dd62e 100644
--- a/gnucash/report/standard-reports/trial-balance.scm
+++ b/gnucash/report/standard-reports/trial-balance.scm
@@ -72,7 +72,6 @@
(define optname-end-date (N_ "Date of Report"))
(define optname-report-variant (N_ "Report variation"))
(define opthelp-report-variant (N_ "Kind of trial balance to generate."))
-;; FIXME this needs an indent option
(define optname-accounts (N_ "Accounts"))
(define opthelp-accounts
@@ -361,7 +360,6 @@
(show-rates? (get-option pagename-commodities optname-show-rates))
(show-zb-accts? #t)
(use-links? (get-option gnc:pagename-display optname-account-links))
- (indent 0)
;; decompose the account list
(split-up-accounts (gnc:decompose-accountlist accounts))
commit b481e2ea7b0e27e6b14b712dca9381e6b34e5305
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 15:20:55 2019 +0800
[budget-balance-sheet] remove dead code
indent and tabbing are constant, refactor them out
diff --git a/gnucash/report/standard-reports/budget-balance-sheet.scm b/gnucash/report/standard-reports/budget-balance-sheet.scm
index 276e7903f..b5edc5e1f 100644
--- a/gnucash/report/standard-reports/budget-balance-sheet.scm
+++ b/gnucash/report/standard-reports/budget-balance-sheet.scm
@@ -48,7 +48,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
@@ -333,8 +332,6 @@
optname-account-links))
(use-rules? (get-option gnc:pagename-display
optname-use-rules))
- (indent 0)
- (tabbing #f)
;; decompose the account list
(split-up-accounts (gnc:decompose-accountlist accounts))
@@ -359,42 +356,24 @@
(gnc:case-exchange-fn price-source report-commodity date-t64))
)
- ;; 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
+ (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))
- )
+ (balance (if neg? (gnc:collector- signed-balance) 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"
+ table (* tree-depth 2) "primary-subheading" #f label 0 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")
- )
- )
-
+ (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))))
+ table (* 2 tree-depth)))
(cond
((null? accounts)
commit e579f6af56813e9ea71efa80197f382ab986dad6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 15:19:30 2019 +0800
[balance-sheet] remove dead code
diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index 771c5a81c..b7699f2bf 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -356,9 +356,7 @@
(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)))
+ (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)
@@ -475,9 +473,6 @@
(equity-table
(gnc:make-html-acct-table/env/accts table-env equity-accounts)))
- (define (get-total-balance-fn account)
- (gnc:account-get-comm-balance-at-date account reportdate #f))
-
(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"))
commit c21d173c0679ee45c3b48bf711c275581a4b2f89
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 15:21:50 2019 +0800
[equity-statement] remove dead code
* 'balance' in add-report-line was defined but never used
* capital/drawing accounts are not defined. remove.
diff --git a/gnucash/report/standard-reports/equity-statement.scm b/gnucash/report/standard-reports/equity-statement.scm
index c233af468..51387b545 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -265,20 +265,13 @@
(equity-accounts
(assoc-ref split-up-accounts ACCT-TYPE-EQUITY))
- ;; N.B.: equity-accounts will also contain drawing accounts
- ;; these must still be split-out and itemized separately
- (capital-accounts #f)
- (drawing-accounts #f)
-
(closing-pattern
(list (list 'str closing-str)
(list 'cased closing-cased)
(list 'regexp closing-regexp)
(list 'positive #f)
- (list 'closing #t)
- )
- )
-
+ (list 'closing #t)))
+
(doc (gnc:make-html-document))
;; exchange rates calculation parameters
(start-exchange-fn
@@ -364,14 +357,7 @@
(gnc:accounts-get-comm-total-assets
equity-accounts get-end-balance-fn))
- ;; these variables wont be used until gnucash gets
- ;; conta account types
- (start-capital-balance #f)
- (end-capital-balance #f)
- (start-drawing-balance #f)
- (end-drawing-balance #f)
-
- (start-book-balance
+ (start-book-balance
(gnc:collector+ start-asset-balance
neg-start-liability-balance
neg-start-equity-balance
@@ -440,31 +426,17 @@
(define (add-report-line
table pos-label neg-label amount col
exchange-fn rule? row-style)
- (let* ((neg? (and amount
- neg-label
- (gnc-numeric-negative-p
+ (let* ((neg? (and amount neg-label
+ (negative?
(gnc:gnc-monetary-amount
(gnc:sum-collector-commodity
amount report-commodity exchange-fn)))))
(label (if neg? (or neg-label pos-label) pos-label))
- (pos-bal (if neg?
- (gnc:collector- amount)
- amount))
- (bal (gnc:sum-collector-commodity
- pos-bal report-commodity exchange-fn))
- (balance
- (cond
- ((gnc:uniform-commodity? pos-bal report-commodity) bal)
- (show-fcur? (gnc-commodity-table
- pos-bal report-commodity exchange-fn))
- (else bal)))
- (column (or col 0)))
+ (pos-bal (if neg? (gnc:collector- amount) amount)))
(gnc:html-table-add-labeled-amount-line!
- table 3 row-style rule?
- label 0 1 "text-cell"
- bal (+ col 1) 1 "number-cell")
- )
- )
+ table 3 row-style rule? label 0 1 "text-cell"
+ (gnc:sum-collector-commodity pos-bal report-commodity exchange-fn)
+ (1+ col) 1 "number-cell")))
(gnc:report-percent-done 30)
commit 99b5d79a448626ec3cc26842016fbce3ce97398a
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 15:30:20 2019 +0800
[equity-statement] compact and rename to add-report-line
diff --git a/gnucash/report/standard-reports/equity-statement.scm b/gnucash/report/standard-reports/equity-statement.scm
index a148c11b1..c233af468 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -437,8 +437,8 @@
(period-for (string-append " " (_ "for Period"))))
;; a helper to add a line to our report
- (define (report-line
- table pos-label neg-label amount col
+ (define (add-report-line
+ table pos-label neg-label amount col
exchange-fn rule? row-style)
(let* ((neg? (and amount
neg-label
@@ -468,67 +468,56 @@
(gnc:report-percent-done 30)
- (let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
+ (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)
-
- (report-line
- build-table
- (string-append (_ "Capital") ", "
- (qof-print-date start-date-printable))
- #f start-total-equity
- 1 start-exchange-fn #f "primary-subheading"
- )
- (report-line
- build-table
- (string-append (_ "Net income") period-for)
- (string-append (_ "Net loss") period-for)
- net-income
- 0 end-exchange-fn #f #f
- )
- (report-line
- build-table
- (string-append (_ "Investments") period-for)
- #f
- investments
- 0 end-exchange-fn #f #f
- )
- (report-line
- build-table
- (string-append (_ "Withdrawals") period-for)
- #f
- withdrawals
- 0 end-exchange-fn #f #f
- )
- (or (gnc-commodity-collector-allzero? net-unrealized-gains)
- (report-line
- build-table
- (_ "Unrealized Gains")
- (_ "Unrealized Losses")
- net-unrealized-gains
- 0 end-exchange-fn #f #f
- )
- )
- (report-line
- build-table
- (_ "Increase in capital")
- (_ "Decrease in capital")
- capital-increase
- 1 end-exchange-fn use-rules? #f
- )
- (report-line
- build-table
- (string-append (_ "Capital") ", "
- (qof-print-date end-date))
- #f
- end-total-equity
- 1 end-exchange-fn #f "primary-subheading"
- )
-
- (gnc:html-document-add-object! doc build-table)
+
+ (gnc:report-percent-done 80)
+
+ (add-report-line
+ build-table
+ (string-append (_ "Capital") ", " (qof-print-date start-date-printable))
+ #f start-total-equity 1 start-exchange-fn #f "primary-subheading")
+
+ (add-report-line
+ build-table
+ (string-append (_ "Net income") period-for)
+ (string-append (_ "Net loss") period-for)
+ net-income 0 end-exchange-fn #f #f)
+
+ (add-report-line
+ build-table
+ (string-append (_ "Investments") period-for) #f
+ investments 0 end-exchange-fn #f #f)
+
+ (add-report-line
+ build-table
+ (string-append (_ "Withdrawals") period-for)
+ #f withdrawals 0 end-exchange-fn #f #f)
+
+ (unless (gnc-commodity-collector-allzero? net-unrealized-gains)
+ (add-report-line
+ build-table
+ (_ "Unrealized Gains")
+ (_ "Unrealized Losses")
+ net-unrealized-gains
+ 0 end-exchange-fn #f #f))
+
+ (add-report-line
+ build-table
+ (_ "Increase in capital")
+ (_ "Decrease in capital")
+ capital-increase
+ 1 end-exchange-fn use-rules? #f)
+
+ (add-report-line
+ build-table
+ (string-append (_ "Capital") ", " (qof-print-date end-date)) #f
+ end-total-equity
+ 1 end-exchange-fn #f "primary-subheading")
+
+ (gnc:html-document-add-object! doc build-table)
;; add currency information if requested
(gnc:report-percent-done 90)
commit fd6b102f8e3c719ef675e08559aa3ebb23c122d6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 13:46:06 2019 +0800
[equity-statement] compact functions
diff --git a/gnucash/report/standard-reports/equity-statement.scm b/gnucash/report/standard-reports/equity-statement.scm
index 8698d44ec..a148c11b1 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -532,31 +532,25 @@
;; add currency information if requested
(gnc:report-percent-done 90)
- (and show-rates?
- (let* ((curr-tbl (gnc:make-html-table))
- (headers (list
- (qof-print-date start-date-printable)
- (qof-print-date end-date)
- )
- )
- (then (gnc:html-make-exchangerates
- report-commodity start-exchange-fn accounts))
- (now (gnc:html-make-exchangerates
- report-commodity end-exchange-fn accounts))
- )
-
- (gnc:html-table-set-col-headers! curr-tbl headers)
- (gnc:html-table-set-style!
- curr-tbl "table" 'attribute '("border" "1"))
- (gnc:html-table-set-style!
- then "table" 'attribute '("border" "0"))
- (gnc:html-table-set-style!
- now "table" 'attribute '("border" "0"))
- (gnc:html-table-append-ruler! build-table 3)
- (gnc:html-table-append-row! curr-tbl (list then now))
- (gnc:html-document-add-object! doc curr-tbl)
- )
- )
+ (when show-rates?
+ (let* ((curr-tbl (gnc:make-html-table))
+ (headers (list
+ (qof-print-date start-date-printable)
+ (qof-print-date end-date)))
+ (then (gnc:html-make-exchangerates
+ report-commodity start-exchange-fn accounts))
+ (now (gnc:html-make-exchangerates
+ report-commodity end-exchange-fn accounts)))
+ (gnc:html-table-set-col-headers! curr-tbl headers)
+ (gnc:html-table-set-style!
+ curr-tbl "table" 'attribute '("border" "1"))
+ (gnc:html-table-set-style!
+ then "table" 'attribute '("border" "0"))
+ (gnc:html-table-set-style!
+ now "table" 'attribute '("border" "0"))
+ (gnc:html-table-append-ruler! build-table 3)
+ (gnc:html-table-append-row! curr-tbl (list then now))
+ (gnc:html-document-add-object! doc curr-tbl)))
(gnc:report-percent-done 100)))
commit 1da86a5fe4266699f79e1ab60d27e5b342beb3a7
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Sep 30 13:50:12 2019 +0800
[equity-statement] define vars in formals instead of set!
diff --git a/gnucash/report/standard-reports/equity-statement.scm b/gnucash/report/standard-reports/equity-statement.scm
index 8287e014d..8698d44ec 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -269,10 +269,7 @@
;; these must still be split-out and itemized separately
(capital-accounts #f)
(drawing-accounts #f)
- (investments #f)
- (withdrawals #f)
- (net-investment #f)
- (income-expense-closing #f)
+
(closing-pattern
(list (list 'str closing-str)
(list 'cased closing-cased)
@@ -291,7 +288,21 @@
(gnc:case-exchange-fn
price-source report-commodity end-date))
)
-
+
+ (define (unrealized-gains-at-date book-balance exchange-fn date)
+ (define weighted-fn
+ (gnc:case-exchange-fn 'weighted-average report-commodity date))
+ (gnc:monetaries-add
+ (gnc:sum-collector-commodity book-balance report-commodity exchange-fn)
+ (gnc:monetary-neg
+ (gnc:sum-collector-commodity book-balance report-commodity weighted-fn))))
+
+ (define (get-start-balance-fn account)
+ (gnc:account-get-comm-balance-at-date account start-date #f))
+
+ (define (get-end-balance-fn account)
+ (gnc:account-get-comm-balance-at-date account end-date #f))
+
(gnc:html-document-set-title!
doc (format #f
(string-append "~a ~a "
@@ -311,54 +322,120 @@
reportname (gnc:report-id report-obj)))
;; Get all the balances for each account group.
- (let* ((book-balance #f) ;; assets - liabilities - equity, norm 0
- (start-asset-balance #f)
- (end-asset-balance #f)
- (neg-start-liability-balance #f) ;; credit balances are < 0
- (neg-end-liability-balance #f)
- (neg-pre-start-retained-earnings #f)
- (neg-pre-end-retained-earnings #f)
- (neg-net-income #f)
- (net-income #f)
-
- (neg-start-equity-balance #f)
- (neg-end-equity-balance #f)
-
+ (let* ((start-asset-balance
+ (gnc:accounts-get-comm-total-assets
+ asset-accounts get-start-balance-fn))
+
+ (end-asset-balance
+ (gnc:accounts-get-comm-total-assets
+ asset-accounts get-end-balance-fn))
+
+ (neg-start-liability-balance
+ (gnc:accounts-get-comm-total-assets
+ liability-accounts get-start-balance-fn))
+
+ (neg-end-liability-balance
+ (gnc:accounts-get-comm-total-assets
+ liability-accounts get-end-balance-fn))
+
+ (neg-pre-start-retained-earnings
+ (gnc:accountlist-get-comm-balance-at-date-with-closing
+ income-expense-accounts start-date))
+
+ (neg-pre-end-retained-earnings
+ (gnc:accountlist-get-comm-balance-at-date-with-closing
+ income-expense-accounts end-date))
+
+ (income-expense-closing
+ (gnc:account-get-trans-type-balance-interval-with-closing
+ income-expense-accounts closing-pattern start-date end-date))
+
+ (net-income
+ (gnc:collector-
+ income-expense-closing
+ (gnc:accountlist-get-comm-balance-interval-with-closing
+ income-expense-accounts start-date end-date)))
+
+ (neg-start-equity-balance
+ (gnc:accounts-get-comm-total-assets
+ equity-accounts get-start-balance-fn))
+
+ (neg-end-equity-balance
+ (gnc:accounts-get-comm-total-assets
+ equity-accounts get-end-balance-fn))
+
;; these variables wont be used until gnucash gets
;; conta account types
(start-capital-balance #f)
(end-capital-balance #f)
(start-drawing-balance #f)
(end-drawing-balance #f)
-
- (start-book-balance #f)
- (end-book-balance #f)
-
- (start-unrealized-gains #f)
- (end-unrealized-gains #f)
- (net-unrealized-gains #f)
-
- (equity-closing #f)
- (neg-pre-closing-equity #f)
-
- (capital-increase #f)
-
- (start-total-equity #f)
- (end-total-equity #f)
-
+
+ (start-book-balance
+ (gnc:collector+ start-asset-balance
+ neg-start-liability-balance
+ neg-start-equity-balance
+ neg-pre-start-retained-earnings))
+
+ (end-book-balance
+ (gnc:collector+ end-asset-balance
+ neg-end-liability-balance
+ neg-end-equity-balance
+ neg-pre-end-retained-earnings))
+
+ (start-unrealized-gains
+ (unrealized-gains-at-date start-book-balance
+ start-exchange-fn
+ start-date))
+
+ (net-unrealized-gains
+ (unrealized-gains-at-date end-book-balance
+ end-exchange-fn
+ end-date))
+
+ (equity-closing
+ (gnc:account-get-trans-type-balance-interval-with-closing
+ equity-accounts closing-pattern start-date end-date))
+
+ (neg-pre-closing-equity
+ (gnc:collector- neg-end-equity-balance
+ equity-closing))
+
+ (net-investment
+ (gnc:collector- neg-start-equity-balance
+ neg-pre-closing-equity))
+
+ ;; calculate investments & draws...
+ ;; do a transaction query and classify the splits by dr/cr.
+ ;; assume that positive shares on an equity account are debits
+ ;; withdrawals = investments - (investments - withdrawals)
+ ;; investments = withdrawals + (investments - withdrawals)
+ (withdrawals
+ (account-get-total-flow 'in equity-accounts start-date end-date))
+
+ (investments
+ (gnc:collector+ net-investment withdrawals))
+
+ (capital-increase
+ (gnc:collector+ net-income
+ investments
+ net-unrealized-gains
+ (gnc:collector- withdrawals)))
+
+ (start-total-equity
+ (gnc:collector- start-unrealized-gains
+ neg-start-equity-balance
+ neg-pre-start-retained-earnings))
+
+ (end-total-equity
+ (gnc:collector+ start-total-equity
+ capital-increase))
+
;; Create the account table below where its
;; percentage time can be tracked.
(build-table (gnc:make-html-table)) ;; gnc:html-table
- (get-start-balance-fn
- (lambda (account)
- (gnc:account-get-comm-balance-at-date
- account start-date #f)))
- (get-end-balance-fn
- (lambda (account)
- (gnc:account-get-comm-balance-at-date
- account end-date #f)))
(period-for (string-append " " (_ "for Period"))))
-
+
;; a helper to add a line to our report
(define (report-line
table pos-label neg-label amount col
@@ -388,177 +465,9 @@
bal (+ col 1) 1 "number-cell")
)
)
-
- ;; 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.
- ;;
- ;; I *think* a decrease in the value of a liability or
- ;; equity constitutes an unrealized loss. I'm unsure about
- ;; that though....
- ;;
- (define (unrealized-gains-at-date book-balance exchange-fn date)
- (define weighted-fn
- (gnc:case-exchange-fn 'weighted-average report-commodity date))
- (gnc:monetaries-add (gnc:sum-collector-commodity
- book-balance report-commodity exchange-fn)
- (gnc:monetary-neg
- (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,
- ;; both at the start and end dates of the reporting period.
- (gnc:report-percent-done 4)
-
- ;; start and end asset balances
- (set! start-asset-balance
- (gnc:accounts-get-comm-total-assets
- asset-accounts get-start-balance-fn)) ; OK
- (set! end-asset-balance
- (gnc:accounts-get-comm-total-assets
- asset-accounts get-end-balance-fn)) ; OK
-
- ;; start and end liability balances
- (set! neg-start-liability-balance
- (gnc:accounts-get-comm-total-assets
- liability-accounts get-start-balance-fn)) ; OK
- (set! neg-end-liability-balance
- (gnc:accounts-get-comm-total-assets
- liability-accounts get-end-balance-fn)) ; OK
-
- ;; start and end retained earnings (income - expenses)
- (set! neg-pre-start-retained-earnings
- (gnc:accountlist-get-comm-balance-at-date-with-closing
- income-expense-accounts start-date)) ; OK
- (set! neg-pre-end-retained-earnings
- (gnc:accountlist-get-comm-balance-at-date-with-closing
- income-expense-accounts end-date)) ; OK
- ;; neg-pre-end-retained-earnings is not used to calculate
- ;; profit but is used to calculate unrealized gains
-
- ;; calculate net income
- ;; first, ask out how much profit/loss was closed
- (set! income-expense-closing
- (gnc:account-get-trans-type-balance-interval-with-closing
- income-expense-accounts closing-pattern
- start-date end-date)
- )
- ;; find retained earnings for the period
- (set! neg-net-income
- (gnc:accountlist-get-comm-balance-interval-with-closing
- income-expense-accounts
- start-date end-date)) ; OK
- ;; revert the income/expense to its pre-closing balance
- (neg-net-income 'minusmerge income-expense-closing #f)
- (set! net-income (gnc:make-commodity-collector))
- (net-income 'minusmerge neg-net-income #f)
- ;; now we know the net income for the period
-
- ;; start and end (unadjusted) equity balances
- (set! neg-start-equity-balance
- (gnc:accounts-get-comm-total-assets
- equity-accounts get-start-balance-fn)) ; OK
- (set! neg-end-equity-balance
- (gnc:accounts-get-comm-total-assets
- equity-accounts get-end-balance-fn)) ; OK
- ;; neg-end-equity-balance is used to calculate unrealized
- ;; gains and investments/withdrawals
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;
- ;; believe it or not, i think this part is right...
- ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;; start and end unrealized gains
- (set! start-book-balance (gnc:make-commodity-collector))
- (start-book-balance 'merge start-asset-balance #f)
- (start-book-balance 'merge neg-start-liability-balance #f)
- (start-book-balance 'merge neg-start-equity-balance #f)
- (start-book-balance 'merge neg-pre-start-retained-earnings #f) ; OK
-
- (set! end-book-balance (gnc:make-commodity-collector))
- (end-book-balance 'merge end-asset-balance #f)
- (end-book-balance 'merge neg-end-liability-balance #f)
- (end-book-balance 'merge neg-end-equity-balance #f)
- (end-book-balance 'merge neg-pre-end-retained-earnings #f) ; OK
-
- (set! start-unrealized-gains
- (unrealized-gains-at-date start-book-balance
- start-exchange-fn
- start-date)) ; OK
- ;; I suspect that unrealized gains (since never realized)
- ;; must be counted from forever-ago....
- ;; ...yep, this appears to be correct.
- (set! start-unrealized-gains (gnc:make-commodity-collector))
- (set! end-unrealized-gains
- (unrealized-gains-at-date end-book-balance
- end-exchange-fn
- end-date)) ; OK
-
- ;; unrealized gains accrued during the reporting period...
- (set! net-unrealized-gains (gnc:make-commodity-collector))
- (net-unrealized-gains 'merge end-unrealized-gains #f)
- (net-unrealized-gains 'minusmerge start-unrealized-gains #f) ; OK
-
- ;;
- ;; calculate investments & draws...
- ;;
- ;; since, as this time, GnuCash does not have any
- ;; contra-account types, i'm gonna have to fudge this a
- ;; bit... i'll do a transaction query and classify the
- ;; splits by debit/credit.
- ;;
- ;; withdrawals = investments - (investments - withdrawals)
- ;; investments = withdrawals + (investments - withdrawals)
- ;;
- ;; assume that positive shares on an equity account are debits...
- ;;
-
- (set! equity-closing
- (gnc:account-get-trans-type-balance-interval-with-closing
- equity-accounts closing-pattern
- start-date end-date)
- )
- (set! neg-pre-closing-equity (gnc:make-commodity-collector))
- (neg-pre-closing-equity 'merge neg-end-equity-balance #f)
- (neg-pre-closing-equity 'minusmerge equity-closing #f)
-
- (set! net-investment (gnc:make-commodity-collector)) ;; 0
- (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! investments (gnc:make-commodity-collector))
- (investments 'merge net-investment #f)
- (investments 'merge withdrawals #f)
-
- ;; increase in equity
- (set! capital-increase (gnc:make-commodity-collector))
- (capital-increase 'merge net-income #f)
- (capital-increase 'merge investments #f)
- (capital-increase 'minusmerge withdrawals #f)
- (capital-increase 'merge net-unrealized-gains #f)
-
- ;; starting total equity
- (set! start-total-equity (gnc:make-commodity-collector))
- (start-total-equity 'minusmerge neg-start-equity-balance #f)
- (start-total-equity 'minusmerge neg-pre-start-retained-earnings #f)
- (start-total-equity 'merge start-unrealized-gains #f) ; OK
-
- ;; ending total equity
- (set! end-total-equity (gnc:make-commodity-collector))
- (end-total-equity 'merge start-total-equity #f)
- (end-total-equity 'merge capital-increase #f) ; OK
-
(gnc:report-percent-done 30)
-
+
(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"))
commit 187d383385b68030de13713f9ac6c5543929e1a5
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Sep 29 23:29:31 2019 +0800
[test-equity-statement] initial commit
diff --git a/gnucash/report/standard-reports/test/CMakeLists.txt b/gnucash/report/standard-reports/test/CMakeLists.txt
index 600105681..839fa946a 100644
--- a/gnucash/report/standard-reports/test/CMakeLists.txt
+++ b/gnucash/report/standard-reports/test/CMakeLists.txt
@@ -15,6 +15,7 @@ set(scm_test_with_srfi64_SOURCES
test-budget.scm
test-register.scm
test-trial-balance.scm
+ test-equity-statement.scm
test-average-balance.scm
test-portfolios.scm
)
diff --git a/gnucash/report/standard-reports/test/test-equity-statement.scm b/gnucash/report/standard-reports/test/test-equity-statement.scm
new file mode 100644
index 000000000..610a58c2f
--- /dev/null
+++ b/gnucash/report/standard-reports/test/test-equity-statement.scm
@@ -0,0 +1,120 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2 of
+;; the License, or (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, contact:
+;;
+;; Free Software Foundation Voice: +1-617-542-5942
+;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
+;; Boston, MA 02110-1301, USA gnu at gnu.org
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(use-modules (srfi srfi-1))
+(use-modules (srfi srfi-14))
+(use-modules (srfi srfi-64))
+(use-modules (gnucash gnc-module))
+(use-modules (gnucash engine test srfi64-extras))
+
+;; Guile 2 needs to load external modules at compile time
+;; otherwise the N_ syntax-rule won't be found at compile time
+;; causing the test to fail
+;; That's what the wrapper below is meant for:
+
+(gnc:module-begin-syntax (gnc:module-load "gnucash/report/report-system" 0))
+
+(use-modules (gnucash utilities))
+(use-modules (gnucash report report-system))
+(use-modules (gnucash app-utils))
+(use-modules (gnucash engine))
+(use-modules (sw_engine))
+(use-modules (gnucash report standard-reports equity-statement))
+(use-modules (gnucash report report-system test test-extras))
+(use-modules (gnucash report stylesheets))
+(use-modules (gnucash engine test test-extras))
+
+;; Explicitly set locale to make the report output predictable
+(setlocale LC_ALL "C")
+(define uuid "c2a996c8970f43448654ca84f17dda24")
+
+(define (run-test)
+ (test-runner-factory gnc:test-runner)
+ (test-begin "equity-statement")
+ (test-equity-statement)
+ (test-end "equity-statement"))
+
+(define (set-option options page tag value)
+ ((gnc:option-setter (gnc:lookup-option options page tag)) value))
+
+(define (teardown)
+ (gnc-clear-current-session))
+
+(define (options->sxml options test-title)
+ (gnc:options->sxml uuid options "test-equity-statement" test-title))
+
+(define (test-equity-statement)
+ (let* ((options (gnc:make-report-options uuid))
+ (account-alist (create-test-data))
+ (gbp-bank (assoc-ref account-alist "GBP Bank"))
+ (usd-bank (assoc-ref account-alist "Bank"))
+ (expense (assoc-ref account-alist "Expenses"))
+ (equity (assoc-ref account-alist "Equity"))
+ (income (assoc-ref account-alist "Income"))
+ (bank (assoc-ref account-alist "Bank")))
+
+ (gnc-commodity-set-user-symbol
+ (xaccAccountGetCommodity gbp-bank)
+ "#")
+
+ (let ((closing-txn (env-transfer #f 30 06 2003 expense equity
+ 111 #:description "Closing Entries")))
+ (xaccTransSetIsClosingTxn closing-txn #t))
+
+ (env-transfer #f 01 06 2003 expense equity
+ 33 #:description "Adjusting Entries")
+ (env-transfer #f 01 07 2003 income equity
+ -2500 #:description "Adjusting Entries")
+
+ (set-option options "General" "Start Date"
+ (cons 'absolute (gnc-dmy2time64 01 01 1970)))
+ (set-option options "General" "End Date"
+ (cons 'absolute (gnc-dmy2time64 01 01 2005)))
+ (let ((sxml (options->sxml options "current")))
+ (test-equal "current table has 22 cells"
+ 14
+ (length (sxml->table-row-col sxml 1 #f #f)))
+
+ (test-equal "capital"
+ '("Capital, 01/01/70" "$29.00")
+ (sxml->table-row-col sxml 1 2 #f))
+
+ (test-equal "income"
+ '("Net income for Period" "$620.00")
+ (sxml->table-row-col sxml 1 3 #f))
+
+ (test-equal "investments"
+ '("Investments for Period" "$2,722.00")
+ (sxml->table-row-col sxml 1 4 #f))
+
+ (test-equal "withdrawals"
+ '("Withdrawals for Period" "$255.00")
+ (sxml->table-row-col sxml 1 5 #f))
+
+ (test-equal "unrealized"
+ '("Unrealized Losses" "$0.25")
+ (sxml->table-row-col sxml 1 6 #f))
+
+ (test-equal "inc/dec in capital"
+ '("Increase in capital" "$3,086.75")
+ (sxml->table-row-col sxml 1 7 #f))
+
+ (test-equal "capital end"
+ '("Capital, 01/01/05" "$3,115.75")
+ (sxml->table-row-col sxml 1 8 #f)))))
Summary of changes:
gnucash/report/report-system/html-table.scm | 6 +
gnucash/report/report-system/report-system.scm | 1 +
gnucash/report/standard-reports/balance-sheet.scm | 18 +-
gnucash/report/standard-reports/balsheet-pnl.scm | 6 +-
.../standard-reports/budget-balance-sheet.scm | 52 +-
.../standard-reports/budget-income-statement.scm | 68 +--
.../report/standard-reports/equity-statement.scm | 530 ++++++++-------------
.../report/standard-reports/income-statement.scm | 45 +-
.../report/standard-reports/test/CMakeLists.txt | 1 +
.../test/test-equity-statement.scm | 120 +++++
gnucash/report/standard-reports/trial-balance.scm | 13 +-
11 files changed, 373 insertions(+), 487 deletions(-)
create mode 100644 gnucash/report/standard-reports/test/test-equity-statement.scm
More information about the gnucash-changes
mailing list