[equity-statement] compact and rename to add-report-line

This commit is contained in:
Christopher Lam 2019-09-30 15:30:20 +08:00
parent fd6b102f8e
commit 99b5d79a44

View File

@ -437,8 +437,8 @@
(period-for (string-append " " (_ "for Period")))) (period-for (string-append " " (_ "for Period"))))
;; a helper to add a line to our report ;; a helper to add a line to our report
(define (report-line (define (add-report-line
table pos-label neg-label amount col table pos-label neg-label amount col
exchange-fn rule? row-style) exchange-fn rule? row-style)
(let* ((neg? (and amount (let* ((neg? (and amount
neg-label neg-label
@ -468,67 +468,56 @@
(gnc:report-percent-done 30) (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! (gnc:html-table-cell-set-style!
wide "text-cell" 'attribute '("style" "min-width:60px")) 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 wide)))
(gnc:report-percent-done 80) (gnc:report-percent-done 80)
(report-line (add-report-line
build-table build-table
(string-append (_ "Capital") ", " (string-append (_ "Capital") ", " (qof-print-date start-date-printable))
(qof-print-date start-date-printable)) #f start-total-equity 1 start-exchange-fn #f "primary-subheading")
#f start-total-equity
1 start-exchange-fn #f "primary-subheading" (add-report-line
) build-table
(report-line (string-append (_ "Net income") period-for)
build-table (string-append (_ "Net loss") period-for)
(string-append (_ "Net income") period-for) net-income 0 end-exchange-fn #f #f)
(string-append (_ "Net loss") period-for)
net-income (add-report-line
0 end-exchange-fn #f #f build-table
) (string-append (_ "Investments") period-for) #f
(report-line investments 0 end-exchange-fn #f #f)
build-table
(string-append (_ "Investments") period-for) (add-report-line
#f build-table
investments (string-append (_ "Withdrawals") period-for)
0 end-exchange-fn #f #f #f withdrawals 0 end-exchange-fn #f #f)
)
(report-line (unless (gnc-commodity-collector-allzero? net-unrealized-gains)
build-table (add-report-line
(string-append (_ "Withdrawals") period-for) build-table
#f (_ "Unrealized Gains")
withdrawals (_ "Unrealized Losses")
0 end-exchange-fn #f #f net-unrealized-gains
) 0 end-exchange-fn #f #f))
(or (gnc-commodity-collector-allzero? net-unrealized-gains)
(report-line (add-report-line
build-table build-table
(_ "Unrealized Gains") (_ "Increase in capital")
(_ "Unrealized Losses") (_ "Decrease in capital")
net-unrealized-gains capital-increase
0 end-exchange-fn #f #f 1 end-exchange-fn use-rules? #f)
)
) (add-report-line
(report-line build-table
build-table (string-append (_ "Capital") ", " (qof-print-date end-date)) #f
(_ "Increase in capital") end-total-equity
(_ "Decrease in capital") 1 end-exchange-fn #f "primary-subheading")
capital-increase
1 end-exchange-fn use-rules? #f (gnc:html-document-add-object! doc build-table)
)
(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 ;; add currency information if requested
(gnc:report-percent-done 90) (gnc:report-percent-done 90)