Merge branch 'maint'

This commit is contained in:
Christopher Lam 2019-09-30 22:15:08 +08:00
commit 98be5c87a4
13 changed files with 926 additions and 1127 deletions

View File

@ -142,6 +142,7 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
GNC_AB_JOB_STATUS job_status;
GncABImExContextImport *ieci = NULL;
#ifndef AQBANKING6
/* Get a GUI object */
gui = gnc_GWEN_Gui_get(parent);
if (!gui)
@ -150,6 +151,7 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
aborted = TRUE;
goto repeat;
}
#endif
/* Let the user enter the values */
result = gnc_ab_trans_dialog_run_until_ok(td);

View File

@ -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)))

View File

@ -559,6 +559,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!)

View File

@ -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,16 +473,10 @@
(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"))
(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?

View File

@ -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))

View File

@ -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)
@ -675,15 +654,12 @@
)
)
(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)
(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

View File

@ -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)
@ -618,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?

View File

@ -265,22 +265,12 @@
(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)
(investments #f)
(withdrawals #f)
(net-investment #f)
(income-expense-closing #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
@ -292,6 +282,20 @@
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,343 +315,201 @@
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)
(let* ((start-asset-balance
(gnc:accounts-get-comm-total-assets
asset-accounts get-start-balance-fn))
(neg-start-equity-balance #f)
(neg-end-equity-balance #f)
(end-asset-balance
(gnc:accounts-get-comm-total-assets
asset-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)
(neg-start-liability-balance
(gnc:accounts-get-comm-total-assets
liability-accounts get-start-balance-fn))
(start-book-balance #f)
(end-book-balance #f)
(neg-end-liability-balance
(gnc:accounts-get-comm-total-assets
liability-accounts get-end-balance-fn))
(start-unrealized-gains #f)
(end-unrealized-gains #f)
(net-unrealized-gains #f)
(neg-pre-start-retained-earnings
(gnc:accountlist-get-comm-balance-at-date-with-closing
income-expense-accounts start-date))
(equity-closing #f)
(neg-pre-closing-equity #f)
(neg-pre-end-retained-earnings
(gnc:accountlist-get-comm-balance-at-date-with-closing
income-expense-accounts end-date))
(capital-increase #f)
(income-expense-closing
(gnc:account-get-trans-type-balance-interval-with-closing
income-expense-accounts closing-pattern start-date end-date))
(start-total-equity #f)
(end-total-equity #f)
(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))
(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
(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")
)
)
;; 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
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)
(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)
(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"
)
(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")
(gnc:html-document-add-object! doc build-table)
(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)
(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)))

View File

@ -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,11 +362,7 @@
(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))
@ -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
@ -571,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?

View File

@ -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-invoice.scm
test-owner-report.scm

View File

@ -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@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" 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 reports standard equity-statement))
(use-modules (gnucash report stylesheets plain))
(use-modules (tests test-engine-extras))
(use-modules (tests test-report-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)))))

View File

@ -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))
@ -559,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)

1191
po/de.po

File diff suppressed because it is too large Load Diff