TP->T64: gnucash/report/standard-reports/equity-statement.scm

This commit is contained in:
Christopher Lam 2017-11-25 00:33:04 +08:00
parent 7488565b9b
commit 1f61a6aaf4

View File

@ -207,9 +207,9 @@
(start-date-printable (gnc:date-option-absolute-time (start-date-printable (gnc:date-option-absolute-time
(get-option gnc:pagename-general (get-option gnc:pagename-general
optname-start-date))) optname-start-date)))
(start-date-tp (gnc:timepair-end-day-time (start-date (gnc:time64-end-day-time
(gnc:timepair-previous-day start-date-printable))) (gnc:time64-previous-day start-date-printable)))
(end-date-tp (gnc:timepair-end-day-time (end-date (gnc:time64-end-day-time
(gnc:date-option-absolute-time (gnc:date-option-absolute-time
(get-option gnc:pagename-general (get-option gnc:pagename-general
optname-end-date)))) optname-end-date))))
@ -270,10 +270,10 @@
;; exchange rates calculation parameters ;; exchange rates calculation parameters
(start-exchange-fn (start-exchange-fn
(gnc:case-exchange-fn (gnc:case-exchange-fn
price-source report-commodity start-date-tp)) price-source report-commodity start-date))
(end-exchange-fn (end-exchange-fn
(gnc:case-exchange-fn (gnc:case-exchange-fn
price-source report-commodity end-date-tp)) price-source report-commodity end-date))
) )
(gnc:html-document-set-title! (gnc:html-document-set-title!
@ -281,8 +281,8 @@
(string-append "%s %s " (string-append "%s %s "
(_ "For Period Covering %s to %s")) (_ "For Period Covering %s to %s"))
company-name report-title company-name report-title
(gnc-print-date start-date-printable) (qof-print-date start-date-printable)
(gnc-print-date end-date-tp))) (qof-print-date end-date)))
(if (null? accounts) (if (null? accounts)
@ -336,17 +336,17 @@
(get-start-balance-fn (get-start-balance-fn
(lambda (account) (lambda (account)
(gnc:account-get-comm-balance-at-date (gnc:account-get-comm-balance-at-date
account start-date-tp #f))) account start-date #f)))
(get-end-balance-fn (get-end-balance-fn
(lambda (account) (lambda (account)
(gnc:account-get-comm-balance-at-date (gnc:account-get-comm-balance-at-date
account end-date-tp #f))) account end-date #f)))
(terse-period? #t) (terse-period? #t)
(period-for (if terse-period? (period-for (if terse-period?
(string-append " " (_ "for Period")) (string-append " " (_ "for Period"))
(sprintf #f (string-append ", " (_ "%s to %s")) (sprintf #f (string-append ", " (_ "%s to %s"))
(gnc-print-date start-date-printable) (qof-print-date start-date-printable)
(gnc-print-date end-date-tp)) (qof-print-date end-date))
)) ))
) )
@ -396,11 +396,11 @@
;; equity constitutes an unrealized loss. I'm unsure about ;; equity constitutes an unrealized loss. I'm unsure about
;; that though.... ;; that though....
;; ;;
(define (unrealized-gains-at-date book-balance exchange-fn date-tp) (define (unrealized-gains-at-date book-balance exchange-fn date)
(let* ((unrealized-gain-collector (gnc:make-commodity-collector)) (let* ((unrealized-gain-collector (gnc:make-commodity-collector))
(weighted-fn (weighted-fn
(gnc:case-exchange-fn 'weighted-average (gnc:case-exchange-fn 'weighted-average
report-commodity date-tp)) report-commodity date))
(value (value
(gnc:gnc-monetary-amount (gnc:gnc-monetary-amount
@ -445,10 +445,10 @@
;; start and end retained earnings (income - expenses) ;; start and end retained earnings (income - expenses)
(set! neg-pre-start-retained-earnings (set! neg-pre-start-retained-earnings
(gnc:accountlist-get-comm-balance-at-date-with-closing (gnc:accountlist-get-comm-balance-at-date-with-closing
income-expense-accounts start-date-tp)) ; OK income-expense-accounts start-date)) ; OK
(set! neg-pre-end-retained-earnings (set! neg-pre-end-retained-earnings
(gnc:accountlist-get-comm-balance-at-date-with-closing (gnc:accountlist-get-comm-balance-at-date-with-closing
income-expense-accounts end-date-tp)) ; OK income-expense-accounts end-date)) ; OK
;; neg-pre-end-retained-earnings is not used to calculate ;; neg-pre-end-retained-earnings is not used to calculate
;; profit but is used to calculate unrealized gains ;; profit but is used to calculate unrealized gains
@ -457,13 +457,13 @@
(set! income-expense-closing (set! income-expense-closing
(gnc:account-get-trans-type-balance-interval-with-closing (gnc:account-get-trans-type-balance-interval-with-closing
income-expense-accounts closing-pattern income-expense-accounts closing-pattern
start-date-tp end-date-tp) start-date end-date)
) )
;; find retained earnings for the period ;; find retained earnings for the period
(set! neg-net-income (set! neg-net-income
(gnc:accountlist-get-comm-balance-interval-with-closing (gnc:accountlist-get-comm-balance-interval-with-closing
income-expense-accounts income-expense-accounts
start-date-tp end-date-tp)) ; OK start-date end-date)) ; OK
;; revert the income/expense to its pre-closing balance ;; revert the income/expense to its pre-closing balance
(neg-net-income 'minusmerge income-expense-closing #f) (neg-net-income 'minusmerge income-expense-closing #f)
(set! net-income (gnc:make-commodity-collector)) (set! net-income (gnc:make-commodity-collector))
@ -502,7 +502,7 @@
(set! start-unrealized-gains (set! start-unrealized-gains
(unrealized-gains-at-date start-book-balance (unrealized-gains-at-date start-book-balance
start-exchange-fn start-exchange-fn
start-date-tp)) ; OK start-date)) ; OK
;; I suspect that unrealized gains (since never realized) ;; I suspect that unrealized gains (since never realized)
;; must be counted from forever-ago.... ;; must be counted from forever-ago....
;; ...yep, this appears to be correct. ;; ...yep, this appears to be correct.
@ -510,7 +510,7 @@
(set! end-unrealized-gains (set! end-unrealized-gains
(unrealized-gains-at-date end-book-balance (unrealized-gains-at-date end-book-balance
end-exchange-fn end-exchange-fn
end-date-tp)) ; OK end-date)) ; OK
;; unrealized gains accrued during the reporting period... ;; unrealized gains accrued during the reporting period...
(set! net-unrealized-gains (gnc:make-commodity-collector)) (set! net-unrealized-gains (gnc:make-commodity-collector))
@ -534,7 +534,7 @@
(set! equity-closing (set! equity-closing
(gnc:account-get-trans-type-balance-interval-with-closing (gnc:account-get-trans-type-balance-interval-with-closing
equity-accounts closing-pattern equity-accounts closing-pattern
start-date-tp end-date-tp) start-date end-date)
) )
(set! neg-pre-closing-equity (gnc:make-commodity-collector)) (set! neg-pre-closing-equity (gnc:make-commodity-collector))
(neg-pre-closing-equity 'merge neg-end-equity-balance #f) (neg-pre-closing-equity 'merge neg-end-equity-balance #f)
@ -544,7 +544,7 @@
(net-investment 'minusmerge neg-pre-closing-equity #f);; > 0 (net-investment 'minusmerge neg-pre-closing-equity #f);; > 0
(net-investment 'merge neg-start-equity-balance #f) ;; net increase (net-investment 'merge neg-start-equity-balance #f) ;; net increase
(set! withdrawals (gnc:account-get-total-flow 'in equity-accounts start-date-tp end-date-tp)) (set! withdrawals (gnc:account-get-total-flow 'in equity-accounts start-date end-date))
(set! investments (gnc:make-commodity-collector)) (set! investments (gnc:make-commodity-collector))
(investments 'merge net-investment #f) (investments 'merge net-investment #f)
@ -584,7 +584,7 @@
(report-line (report-line
build-table build-table
(string-append (_ "Capital") ", " (string-append (_ "Capital") ", "
(gnc-print-date start-date-printable)) (qof-print-date start-date-printable))
#f start-total-equity #f start-total-equity
1 start-exchange-fn #f "primary-subheading" 1 start-exchange-fn #f "primary-subheading"
) )
@ -628,7 +628,7 @@
(report-line (report-line
build-table build-table
(string-append (_ "Capital") ", " (string-append (_ "Capital") ", "
(gnc-print-date end-date-tp)) (qof-print-date end-date))
#f #f
end-total-equity end-total-equity
1 end-exchange-fn #f "primary-subheading" 1 end-exchange-fn #f "primary-subheading"
@ -641,8 +641,8 @@
(and show-rates? (and show-rates?
(let* ((curr-tbl (gnc:make-html-table)) (let* ((curr-tbl (gnc:make-html-table))
(headers (list (headers (list
(gnc-print-date start-date-printable) (qof-print-date start-date-printable)
(gnc-print-date end-date-tp) (qof-print-date end-date)
) )
) )
(then (gnc:html-make-exchangerates (then (gnc:html-make-exchangerates