mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'maint'
This commit is contained in:
commit
98be5c87a4
@ -142,6 +142,7 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
|||||||
GNC_AB_JOB_STATUS job_status;
|
GNC_AB_JOB_STATUS job_status;
|
||||||
GncABImExContextImport *ieci = NULL;
|
GncABImExContextImport *ieci = NULL;
|
||||||
|
|
||||||
|
#ifndef AQBANKING6
|
||||||
/* Get a GUI object */
|
/* Get a GUI object */
|
||||||
gui = gnc_GWEN_Gui_get(parent);
|
gui = gnc_GWEN_Gui_get(parent);
|
||||||
if (!gui)
|
if (!gui)
|
||||||
@ -150,6 +151,7 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
|||||||
aborted = TRUE;
|
aborted = TRUE;
|
||||||
goto repeat;
|
goto repeat;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Let the user enter the values */
|
/* Let the user enter the values */
|
||||||
result = gnc_ab_trans_dialog_run_until_ok(td);
|
result = gnc_ab_trans_dialog_run_until_ok(td);
|
||||||
|
@ -73,6 +73,12 @@
|
|||||||
(gnc:make-html-table-cell-internal rowspan colspan markup
|
(gnc:make-html-table-cell-internal rowspan colspan markup
|
||||||
objects (gnc:make-html-style-table)))
|
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)
|
(define (gnc:make-html-table-header-cell . objects)
|
||||||
(gnc:make-html-table-cell-internal 1 1 "th" objects
|
(gnc:make-html-table-cell-internal 1 1 "th" objects
|
||||||
(gnc:make-html-style-table)))
|
(gnc:make-html-style-table)))
|
||||||
|
@ -559,6 +559,7 @@
|
|||||||
(export gnc:make-html-table-header-cell)
|
(export gnc:make-html-table-header-cell)
|
||||||
(export gnc:make-html-table-header-cell/markup)
|
(export gnc:make-html-table-header-cell/markup)
|
||||||
(export gnc:make-html-table-header-cell/size)
|
(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?)
|
||||||
(export gnc:html-table-cell-rowspan)
|
(export gnc:html-table-cell-rowspan)
|
||||||
(export gnc:html-table-cell-set-rowspan!)
|
(export gnc:html-table-cell-set-rowspan!)
|
||||||
|
@ -356,9 +356,7 @@
|
|||||||
(gnc:sum-collector-commodity
|
(gnc:sum-collector-commodity
|
||||||
signed-balance report-commodity exchange-fn)))))
|
signed-balance report-commodity exchange-fn)))))
|
||||||
(label (if neg? (or neg-label pos-label) pos-label))
|
(label (if neg? (or neg-label pos-label) pos-label))
|
||||||
(balance (if neg?
|
(balance (if neg? (gnc:collector- signed-balance) signed-balance)))
|
||||||
(gnc:collector- signed-balance)
|
|
||||||
signed-balance)))
|
|
||||||
(gnc:html-table-add-labeled-amount-line!
|
(gnc:html-table-add-labeled-amount-line!
|
||||||
table (* tree-depth 2) "primary-subheading" #f label 0 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)
|
(gnc:sum-collector-commodity balance report-commodity exchange-fn)
|
||||||
@ -475,16 +473,10 @@
|
|||||||
(equity-table
|
(equity-table
|
||||||
(gnc:make-html-acct-table/env/accts table-env equity-accounts)))
|
(gnc:make-html-acct-table/env/accts table-env equity-accounts)))
|
||||||
|
|
||||||
(define (get-total-balance-fn account)
|
(let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
|
||||||
(gnc:account-get-comm-balance-at-date account reportdate #f))
|
(gnc:html-table-append-row! left-table space)
|
||||||
|
(unless report-form?
|
||||||
(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
|
(gnc:html-table-append-row! right-table space)))
|
||||||
(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)
|
(gnc:report-percent-done 80)
|
||||||
|
|
||||||
(when label-assets?
|
(when label-assets?
|
||||||
|
@ -419,11 +419,7 @@ also show overall period profit & loss."))
|
|||||||
(loop (cons (thunk) result) (1- n)))))
|
(loop (cons (thunk) result) (1- n)))))
|
||||||
|
|
||||||
(define (make-narrow-cell)
|
(define (make-narrow-cell)
|
||||||
(let ((narrow (gnc:make-html-table-cell/markup "text-cell" #f)))
|
(gnc:make-html-table-cell/min-width 1))
|
||||||
(gnc:html-table-cell-set-style!
|
|
||||||
narrow "text-cell"
|
|
||||||
'attribute '("style" "width:1px"))
|
|
||||||
narrow))
|
|
||||||
|
|
||||||
(define (add-indented-row indent label label-markup amount-indent rest)
|
(define (add-indented-row indent label label-markup amount-indent rest)
|
||||||
(when (or (not depth-limit) (<= indent depth-limit))
|
(when (or (not depth-limit) (<= indent depth-limit))
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
(define optname-report-form (N_ "Single column Balance Sheet"))
|
(define optname-report-form (N_ "Single column Balance Sheet"))
|
||||||
(define opthelp-report-form
|
(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."))
|
(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 optname-accounts (N_ "Accounts"))
|
||||||
(define opthelp-accounts
|
(define opthelp-accounts
|
||||||
@ -333,8 +332,6 @@
|
|||||||
optname-account-links))
|
optname-account-links))
|
||||||
(use-rules? (get-option gnc:pagename-display
|
(use-rules? (get-option gnc:pagename-display
|
||||||
optname-use-rules))
|
optname-use-rules))
|
||||||
(indent 0)
|
|
||||||
(tabbing #f)
|
|
||||||
|
|
||||||
;; decompose the account list
|
;; decompose the account list
|
||||||
(split-up-accounts (gnc:decompose-accountlist accounts))
|
(split-up-accounts (gnc:decompose-accountlist accounts))
|
||||||
@ -359,42 +356,24 @@
|
|||||||
(gnc:case-exchange-fn price-source report-commodity date-t64))
|
(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 (add-subtotal-line table pos-label neg-label signed-balance)
|
||||||
(define allow-same-column-totals #t)
|
(let* ((neg? (and signed-balance neg-label
|
||||||
(let* ((neg? (and signed-balance
|
(negative?
|
||||||
neg-label
|
|
||||||
(gnc-numeric-negative-p
|
|
||||||
(gnc:gnc-monetary-amount
|
(gnc:gnc-monetary-amount
|
||||||
(gnc:sum-collector-commodity
|
(gnc:sum-collector-commodity
|
||||||
signed-balance report-commodity exchange-fn)))))
|
signed-balance report-commodity exchange-fn)))))
|
||||||
(label (if neg? (or neg-label pos-label) pos-label))
|
(label (if neg? (or neg-label pos-label) pos-label))
|
||||||
(balance (if neg?
|
(balance (if neg? (gnc:collector- signed-balance) signed-balance)))
|
||||||
(gnc:collector- signed-balance)
|
|
||||||
signed-balance))
|
|
||||||
)
|
|
||||||
(gnc:html-table-add-labeled-amount-line!
|
(gnc:html-table-add-labeled-amount-line!
|
||||||
table
|
table (* tree-depth 2) "primary-subheading" #f label 0 1 "total-label-cell"
|
||||||
(+ 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)
|
(gnc:sum-collector-commodity balance report-commodity exchange-fn)
|
||||||
(+ indent (* tree-depth 2) (- 0 1)
|
(1- (* tree-depth 2)) 1 "total-number-cell")))
|
||||||
(if (equal? tabbing 'canonically-tabbed) 1 0))
|
|
||||||
1 "total-number-cell")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Wrapper around gnc:html-table-append-ruler! since we call it so
|
;; Wrapper around gnc:html-table-append-ruler! since we call it so
|
||||||
;; often.
|
;; often.
|
||||||
(define (add-rule table)
|
(define (add-rule table)
|
||||||
(gnc:html-table-append-ruler!
|
(gnc:html-table-append-ruler!
|
||||||
table
|
table (* 2 tree-depth)))
|
||||||
(+ (* 2 tree-depth)
|
|
||||||
(if (equal? tabbing 'canonically-tabbed) 1 0))))
|
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((null? accounts)
|
((null? accounts)
|
||||||
@ -674,16 +653,13 @@
|
|||||||
(list 'rule-mode use-rules?)
|
(list 'rule-mode use-rules?)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
|
(let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
|
||||||
(gnc:html-table-cell-set-style!
|
(gnc:html-table-append-row! left-table space)
|
||||||
wide "text-cell" 'attribute '("style" "min-width:60px"))
|
(unless report-form?
|
||||||
(let ((space (make-list tree-depth wide)))
|
(gnc:html-table-append-row! right-table space)))
|
||||||
(gnc:html-table-append-row! left-table space)
|
|
||||||
(unless report-form?
|
(gnc:report-percent-done 80)
|
||||||
(gnc:html-table-append-row! right-table space))))
|
|
||||||
|
|
||||||
(gnc:report-percent-done 80)
|
|
||||||
(if label-assets? (add-subtotal-line left-table (_ "Assets") #f #f))
|
(if label-assets? (add-subtotal-line left-table (_ "Assets") #f #f))
|
||||||
(set! asset-table
|
(set! asset-table
|
||||||
(gnc:make-html-acct-table/env/accts
|
(gnc:make-html-acct-table/env/accts
|
||||||
|
@ -71,8 +71,6 @@
|
|||||||
(define opthelp-budget-period-end
|
(define opthelp-budget-period-end
|
||||||
(N_ "Select a budget period that ends the reporting range."))
|
(N_ "Select a budget period that ends the reporting range."))
|
||||||
|
|
||||||
;; FIXME this could use an indent option
|
|
||||||
|
|
||||||
(define optname-accounts (N_ "Accounts"))
|
(define optname-accounts (N_ "Accounts"))
|
||||||
(define opthelp-accounts
|
(define opthelp-accounts
|
||||||
(N_ "Report on these accounts, if display depth allows."))
|
(N_ "Report on these accounts, if display depth allows."))
|
||||||
@ -384,8 +382,6 @@
|
|||||||
optname-two-column))
|
optname-two-column))
|
||||||
(standard-order? (get-option gnc:pagename-display
|
(standard-order? (get-option gnc:pagename-display
|
||||||
optname-standard-order))
|
optname-standard-order))
|
||||||
(indent 0)
|
|
||||||
(tabbing #f)
|
|
||||||
|
|
||||||
;; decompose the account list
|
;; decompose the account list
|
||||||
(split-up-accounts (gnc:decompose-accountlist accounts))
|
(split-up-accounts (gnc:decompose-accountlist accounts))
|
||||||
@ -406,41 +402,23 @@
|
|||||||
(gnc:case-exchange-fn price-source report-commodity date-t64))
|
(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 (add-subtotal-line table pos-label neg-label signed-balance)
|
||||||
(define allow-same-column-totals #t)
|
(let* ((neg? (and signed-balance neg-label
|
||||||
(let* ((neg? (and signed-balance
|
(negative?
|
||||||
neg-label
|
|
||||||
(gnc-numeric-negative-p
|
|
||||||
(gnc:gnc-monetary-amount
|
(gnc:gnc-monetary-amount
|
||||||
(gnc:sum-collector-commodity
|
(gnc:sum-collector-commodity
|
||||||
signed-balance report-commodity exchange-fn)))))
|
signed-balance report-commodity exchange-fn)))))
|
||||||
(label (if neg? (or neg-label pos-label) pos-label))
|
(label (if neg? (or neg-label pos-label) pos-label))
|
||||||
(balance (if neg?
|
(balance (if neg? (gnc:collector- signed-balance) signed-balance)))
|
||||||
(gnc:collector- signed-balance)
|
|
||||||
signed-balance))
|
|
||||||
)
|
|
||||||
(gnc:html-table-add-labeled-amount-line!
|
(gnc:html-table-add-labeled-amount-line!
|
||||||
table
|
table (* tree-depth 2) "primary-subheading" #f label 0 1 "total-label-cell"
|
||||||
(+ 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)
|
(gnc:sum-collector-commodity balance report-commodity exchange-fn)
|
||||||
(+ indent (* tree-depth 2) (- 0 1)
|
(1- (* tree-depth 2)) 1 "total-number-cell")))
|
||||||
(if (equal? tabbing 'canonically-tabbed) 1 0))
|
|
||||||
1 "total-number-cell")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; wrapper around gnc:html-table-append-ruler!
|
;; wrapper around gnc:html-table-append-ruler!
|
||||||
(define (add-rule table)
|
(define (add-rule table)
|
||||||
(gnc:html-table-append-ruler!
|
(gnc:html-table-append-ruler!
|
||||||
table
|
table (* 2 tree-depth)))
|
||||||
(+ (* 2 tree-depth)
|
|
||||||
(if (equal? tabbing 'canonically-tabbed) 1 0))))
|
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((null? accounts)
|
((null? accounts)
|
||||||
@ -507,34 +485,20 @@
|
|||||||
|
|
||||||
;; a helper to add a line to our report
|
;; a helper to add a line to our report
|
||||||
(define (report-line
|
(define (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 neg-label
|
||||||
(let* ((neg? (and amount
|
(negative?
|
||||||
neg-label
|
|
||||||
(gnc-numeric-negative-p
|
|
||||||
(gnc:gnc-monetary-amount
|
(gnc:gnc-monetary-amount
|
||||||
(gnc:sum-collector-commodity
|
(gnc:sum-collector-commodity
|
||||||
amount report-commodity exchange-fn)))))
|
amount report-commodity exchange-fn)))))
|
||||||
(label (if neg? (or neg-label pos-label) pos-label))
|
(label (if neg? (or neg-label pos-label) pos-label))
|
||||||
(pos-bal (if neg?
|
(abs-amt (if neg? (gnc:collector- amount) amount))
|
||||||
(gnc:collector- amount)
|
|
||||||
amount))
|
|
||||||
(bal (gnc:sum-collector-commodity
|
(bal (gnc:sum-collector-commodity
|
||||||
pos-bal report-commodity exchange-fn))
|
abs-amt 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))
|
|
||||||
)
|
|
||||||
(gnc:html-table-add-labeled-amount-line!
|
(gnc:html-table-add-labeled-amount-line!
|
||||||
table (* 2 tree-depth) row-style rule?
|
table (* 2 tree-depth) row-style rule?
|
||||||
label 0 1 "text-cell"
|
label 0 1 "text-cell"
|
||||||
bal (+ col 1) 1 "number-cell")
|
bal (1+ col) 1 "number-cell")))
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(gnc:report-percent-done 5)
|
(gnc:report-percent-done 5)
|
||||||
|
|
||||||
@ -618,11 +582,9 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
|
(let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
|
||||||
(gnc:html-table-cell-set-style!
|
(gnc:html-table-append-row! inc-table space)
|
||||||
wide "text-cell" 'attribute '("style" "min-width:60px"))
|
(gnc:html-table-append-row! exp-table space))
|
||||||
(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)
|
(gnc:report-percent-done 80)
|
||||||
(if label-revenue?
|
(if label-revenue?
|
||||||
|
@ -265,23 +265,13 @@
|
|||||||
(equity-accounts
|
(equity-accounts
|
||||||
(assoc-ref split-up-accounts ACCT-TYPE-EQUITY))
|
(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
|
(closing-pattern
|
||||||
(list (list 'str closing-str)
|
(list (list 'str closing-str)
|
||||||
(list 'cased closing-cased)
|
(list 'cased closing-cased)
|
||||||
(list 'regexp closing-regexp)
|
(list 'regexp closing-regexp)
|
||||||
(list 'positive #f)
|
(list 'positive #f)
|
||||||
(list 'closing #t)
|
(list 'closing #t)))
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(doc (gnc:make-html-document))
|
(doc (gnc:make-html-document))
|
||||||
;; exchange rates calculation parameters
|
;; exchange rates calculation parameters
|
||||||
(start-exchange-fn
|
(start-exchange-fn
|
||||||
@ -291,7 +281,21 @@
|
|||||||
(gnc:case-exchange-fn
|
(gnc:case-exchange-fn
|
||||||
price-source report-commodity end-date))
|
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!
|
(gnc:html-document-set-title!
|
||||||
doc (format #f
|
doc (format #f
|
||||||
(string-append "~a ~a "
|
(string-append "~a ~a "
|
||||||
@ -311,343 +315,201 @@
|
|||||||
reportname (gnc:report-id report-obj)))
|
reportname (gnc:report-id report-obj)))
|
||||||
|
|
||||||
;; Get all the balances for each account group.
|
;; Get all the balances for each account group.
|
||||||
(let* ((book-balance #f) ;; assets - liabilities - equity, norm 0
|
(let* ((start-asset-balance
|
||||||
(start-asset-balance #f)
|
(gnc:accounts-get-comm-total-assets
|
||||||
(end-asset-balance #f)
|
asset-accounts get-start-balance-fn))
|
||||||
(neg-start-liability-balance #f) ;; credit balances are < 0
|
|
||||||
(neg-end-liability-balance #f)
|
(end-asset-balance
|
||||||
(neg-pre-start-retained-earnings #f)
|
(gnc:accounts-get-comm-total-assets
|
||||||
(neg-pre-end-retained-earnings #f)
|
asset-accounts get-end-balance-fn))
|
||||||
(neg-net-income #f)
|
|
||||||
(net-income #f)
|
(neg-start-liability-balance
|
||||||
|
(gnc:accounts-get-comm-total-assets
|
||||||
(neg-start-equity-balance #f)
|
liability-accounts get-start-balance-fn))
|
||||||
(neg-end-equity-balance #f)
|
|
||||||
|
(neg-end-liability-balance
|
||||||
;; these variables wont be used until gnucash gets
|
(gnc:accounts-get-comm-total-assets
|
||||||
;; conta account types
|
liability-accounts get-end-balance-fn))
|
||||||
(start-capital-balance #f)
|
|
||||||
(end-capital-balance #f)
|
(neg-pre-start-retained-earnings
|
||||||
(start-drawing-balance #f)
|
(gnc:accountlist-get-comm-balance-at-date-with-closing
|
||||||
(end-drawing-balance #f)
|
income-expense-accounts start-date))
|
||||||
|
|
||||||
(start-book-balance #f)
|
(neg-pre-end-retained-earnings
|
||||||
(end-book-balance #f)
|
(gnc:accountlist-get-comm-balance-at-date-with-closing
|
||||||
|
income-expense-accounts end-date))
|
||||||
(start-unrealized-gains #f)
|
|
||||||
(end-unrealized-gains #f)
|
(income-expense-closing
|
||||||
(net-unrealized-gains #f)
|
(gnc:account-get-trans-type-balance-interval-with-closing
|
||||||
|
income-expense-accounts closing-pattern start-date end-date))
|
||||||
(equity-closing #f)
|
|
||||||
(neg-pre-closing-equity #f)
|
(net-income
|
||||||
|
(gnc:collector-
|
||||||
(capital-increase #f)
|
income-expense-closing
|
||||||
|
(gnc:accountlist-get-comm-balance-interval-with-closing
|
||||||
(start-total-equity #f)
|
income-expense-accounts start-date end-date)))
|
||||||
(end-total-equity #f)
|
|
||||||
|
(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
|
;; Create the account table below where its
|
||||||
;; percentage time can be tracked.
|
;; percentage time can be tracked.
|
||||||
(build-table (gnc:make-html-table)) ;; gnc:html-table
|
(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"))))
|
(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
|
(negative?
|
||||||
(gnc-numeric-negative-p
|
|
||||||
(gnc:gnc-monetary-amount
|
(gnc:gnc-monetary-amount
|
||||||
(gnc:sum-collector-commodity
|
(gnc:sum-collector-commodity
|
||||||
amount report-commodity exchange-fn)))))
|
amount report-commodity exchange-fn)))))
|
||||||
(label (if neg? (or neg-label pos-label) pos-label))
|
(label (if neg? (or neg-label pos-label) pos-label))
|
||||||
(pos-bal (if neg?
|
(pos-bal (if neg? (gnc:collector- amount) amount)))
|
||||||
(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)))
|
|
||||||
(gnc:html-table-add-labeled-amount-line!
|
(gnc:html-table-add-labeled-amount-line!
|
||||||
table 3 row-style rule?
|
table 3 row-style rule? label 0 1 "text-cell"
|
||||||
label 0 1 "text-cell"
|
(gnc:sum-collector-commodity pos-bal report-commodity exchange-fn)
|
||||||
bal (+ col 1) 1 "number-cell")
|
(1+ col) 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)
|
(gnc:report-percent-done 30)
|
||||||
|
|
||||||
(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
|
(gnc:html-table-append-row!
|
||||||
(gnc:html-table-cell-set-style!
|
build-table (make-list 2 (gnc:make-html-table-cell/min-width 60)))
|
||||||
wide "text-cell" 'attribute '("style" "min-width:60px"))
|
|
||||||
(gnc:html-table-append-row! build-table (make-list 2 wide)))
|
(gnc:report-percent-done 80)
|
||||||
|
|
||||||
(gnc:report-percent-done 80)
|
(add-report-line
|
||||||
|
build-table
|
||||||
(report-line
|
(string-append (_ "Capital") ", " (qof-print-date start-date-printable))
|
||||||
build-table
|
#f start-total-equity 1 start-exchange-fn #f "primary-subheading")
|
||||||
(string-append (_ "Capital") ", "
|
|
||||||
(qof-print-date start-date-printable))
|
(add-report-line
|
||||||
#f start-total-equity
|
build-table
|
||||||
1 start-exchange-fn #f "primary-subheading"
|
(string-append (_ "Net income") period-for)
|
||||||
)
|
(string-append (_ "Net loss") period-for)
|
||||||
(report-line
|
net-income 0 end-exchange-fn #f #f)
|
||||||
build-table
|
|
||||||
(string-append (_ "Net income") period-for)
|
(add-report-line
|
||||||
(string-append (_ "Net loss") period-for)
|
build-table
|
||||||
net-income
|
(string-append (_ "Investments") period-for) #f
|
||||||
0 end-exchange-fn #f #f
|
investments 0 end-exchange-fn #f #f)
|
||||||
)
|
|
||||||
(report-line
|
(add-report-line
|
||||||
build-table
|
build-table
|
||||||
(string-append (_ "Investments") period-for)
|
(string-append (_ "Withdrawals") period-for)
|
||||||
#f
|
#f withdrawals 0 end-exchange-fn #f #f)
|
||||||
investments
|
|
||||||
0 end-exchange-fn #f #f
|
(unless (gnc-commodity-collector-allzero? net-unrealized-gains)
|
||||||
)
|
(add-report-line
|
||||||
(report-line
|
build-table
|
||||||
build-table
|
(_ "Unrealized Gains")
|
||||||
(string-append (_ "Withdrawals") period-for)
|
(_ "Unrealized Losses")
|
||||||
#f
|
net-unrealized-gains
|
||||||
withdrawals
|
0 end-exchange-fn #f #f))
|
||||||
0 end-exchange-fn #f #f
|
|
||||||
)
|
(add-report-line
|
||||||
(or (gnc-commodity-collector-allzero? net-unrealized-gains)
|
build-table
|
||||||
(report-line
|
(_ "Increase in capital")
|
||||||
build-table
|
(_ "Decrease in capital")
|
||||||
(_ "Unrealized Gains")
|
capital-increase
|
||||||
(_ "Unrealized Losses")
|
1 end-exchange-fn use-rules? #f)
|
||||||
net-unrealized-gains
|
|
||||||
0 end-exchange-fn #f #f
|
(add-report-line
|
||||||
)
|
build-table
|
||||||
)
|
(string-append (_ "Capital") ", " (qof-print-date end-date)) #f
|
||||||
(report-line
|
end-total-equity
|
||||||
build-table
|
1 end-exchange-fn #f "primary-subheading")
|
||||||
(_ "Increase in capital")
|
|
||||||
(_ "Decrease in capital")
|
(gnc:html-document-add-object! doc build-table)
|
||||||
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)
|
|
||||||
|
|
||||||
;; add currency information if requested
|
;; add currency information if requested
|
||||||
(gnc:report-percent-done 90)
|
(gnc:report-percent-done 90)
|
||||||
(and show-rates?
|
(when show-rates?
|
||||||
(let* ((curr-tbl (gnc:make-html-table))
|
(let* ((curr-tbl (gnc:make-html-table))
|
||||||
(headers (list
|
(headers (list
|
||||||
(qof-print-date start-date-printable)
|
(qof-print-date start-date-printable)
|
||||||
(qof-print-date end-date)
|
(qof-print-date end-date)))
|
||||||
)
|
(then (gnc:html-make-exchangerates
|
||||||
)
|
report-commodity start-exchange-fn accounts))
|
||||||
(then (gnc:html-make-exchangerates
|
(now (gnc:html-make-exchangerates
|
||||||
report-commodity start-exchange-fn accounts))
|
report-commodity end-exchange-fn accounts)))
|
||||||
(now (gnc:html-make-exchangerates
|
(gnc:html-table-set-col-headers! curr-tbl headers)
|
||||||
report-commodity end-exchange-fn accounts))
|
(gnc:html-table-set-style!
|
||||||
)
|
curr-tbl "table" 'attribute '("border" "1"))
|
||||||
|
(gnc:html-table-set-style!
|
||||||
(gnc:html-table-set-col-headers! curr-tbl headers)
|
then "table" 'attribute '("border" "0"))
|
||||||
(gnc:html-table-set-style!
|
(gnc:html-table-set-style!
|
||||||
curr-tbl "table" 'attribute '("border" "1"))
|
now "table" 'attribute '("border" "0"))
|
||||||
(gnc:html-table-set-style!
|
(gnc:html-table-append-ruler! build-table 3)
|
||||||
then "table" 'attribute '("border" "0"))
|
(gnc:html-table-append-row! curr-tbl (list then now))
|
||||||
(gnc:html-table-set-style!
|
(gnc:html-document-add-object! doc curr-tbl)))
|
||||||
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)))
|
(gnc:report-percent-done 100)))
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
|
|
||||||
(define optname-start-date (N_ "Start Date"))
|
(define optname-start-date (N_ "Start Date"))
|
||||||
(define optname-end-date (N_ "End Date"))
|
(define optname-end-date (N_ "End Date"))
|
||||||
;; FIXME this could use an indent option
|
|
||||||
|
|
||||||
(define optname-accounts (N_ "Accounts"))
|
(define optname-accounts (N_ "Accounts"))
|
||||||
(define opthelp-accounts
|
(define opthelp-accounts
|
||||||
@ -363,12 +362,8 @@
|
|||||||
(list (list 'str closing-str)
|
(list (list 'str closing-str)
|
||||||
(list 'cased closing-cased)
|
(list 'cased closing-cased)
|
||||||
(list 'regexp closing-regexp)
|
(list 'regexp closing-regexp)
|
||||||
(list 'closing #t)
|
(list 'closing #t)))
|
||||||
)
|
|
||||||
)
|
|
||||||
(indent 0)
|
|
||||||
(tabbing #f)
|
|
||||||
|
|
||||||
;; decompose the account list
|
;; decompose the account list
|
||||||
(split-up-accounts (gnc:decompose-accountlist accounts))
|
(split-up-accounts (gnc:decompose-accountlist accounts))
|
||||||
(revenue-accounts (assoc-ref split-up-accounts ACCT-TYPE-INCOME))
|
(revenue-accounts (assoc-ref split-up-accounts ACCT-TYPE-INCOME))
|
||||||
@ -392,7 +387,6 @@
|
|||||||
;; Wrapper to call gnc:html-table-add-labeled-amount-line!
|
;; Wrapper to call gnc:html-table-add-labeled-amount-line!
|
||||||
;; with the proper arguments.
|
;; with the proper arguments.
|
||||||
(define (add-subtotal-line table pos-label neg-label signed-balance)
|
(define (add-subtotal-line table pos-label neg-label signed-balance)
|
||||||
(define allow-same-column-totals #t)
|
|
||||||
(let* ((neg? (and signed-balance
|
(let* ((neg? (and signed-balance
|
||||||
neg-label
|
neg-label
|
||||||
(gnc-numeric-negative-p
|
(gnc-numeric-negative-p
|
||||||
@ -400,32 +394,15 @@
|
|||||||
(gnc:sum-collector-commodity
|
(gnc:sum-collector-commodity
|
||||||
signed-balance report-commodity exchange-fn)))))
|
signed-balance report-commodity exchange-fn)))))
|
||||||
(label (if neg? (or neg-label pos-label) pos-label))
|
(label (if neg? (or neg-label pos-label) pos-label))
|
||||||
(balance (if neg?
|
(balance (if neg? (gnc:collector- signed-balance) signed-balance)))
|
||||||
(let ((bal (gnc:make-commodity-collector)))
|
|
||||||
(bal 'minusmerge signed-balance #f)
|
|
||||||
bal)
|
|
||||||
signed-balance))
|
|
||||||
)
|
|
||||||
(gnc:html-table-add-labeled-amount-line!
|
(gnc:html-table-add-labeled-amount-line!
|
||||||
table
|
table (* tree-depth 2) "primary-subheading" #f label 0 1 "total-label-cell"
|
||||||
(+ 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)
|
(gnc:sum-collector-commodity balance report-commodity exchange-fn)
|
||||||
(+ indent (* tree-depth 2) (- 0 1)
|
(1- (* tree-depth 2)) 1 "total-number-cell")))
|
||||||
(if (equal? tabbing 'canonically-tabbed) 1 0))
|
|
||||||
1 "total-number-cell")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; wrapper around gnc:html-table-append-ruler!
|
;; wrapper around gnc:html-table-append-ruler!
|
||||||
(define (add-rule table)
|
(define (add-rule table)
|
||||||
(gnc:html-table-append-ruler!
|
(gnc:html-table-append-ruler! table (* 2 tree-depth)))
|
||||||
table
|
|
||||||
(+ (* 2 tree-depth)
|
|
||||||
(if (equal? tabbing 'canonically-tabbed) 1 0))))
|
|
||||||
|
|
||||||
(gnc:html-document-set-title!
|
(gnc:html-document-set-title!
|
||||||
doc (format #f
|
doc (format #f
|
||||||
@ -571,12 +548,10 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f)))
|
(let ((space (make-list tree-depth (gnc:make-html-table-cell/min-width 60))))
|
||||||
(gnc:html-table-cell-set-style!
|
(gnc:html-table-append-row! inc-table space)
|
||||||
wide "text-cell" 'attribute '("style" "min-width:60px"))
|
(gnc:html-table-append-row! exp-table space)
|
||||||
(gnc:html-table-append-row! inc-table (make-list tree-depth wide))
|
(gnc:html-table-append-row! tra-table space))
|
||||||
(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)
|
(gnc:report-percent-done 80)
|
||||||
(if label-revenue?
|
(if label-revenue?
|
||||||
|
@ -15,6 +15,7 @@ set(scm_test_with_srfi64_SOURCES
|
|||||||
test-budget.scm
|
test-budget.scm
|
||||||
test-register.scm
|
test-register.scm
|
||||||
test-trial-balance.scm
|
test-trial-balance.scm
|
||||||
|
test-equity-statement.scm
|
||||||
test-average-balance.scm
|
test-average-balance.scm
|
||||||
test-invoice.scm
|
test-invoice.scm
|
||||||
test-owner-report.scm
|
test-owner-report.scm
|
||||||
|
120
gnucash/report/reports/standard/test/test-equity-statement.scm
Normal file
120
gnucash/report/reports/standard/test/test-equity-statement.scm
Normal 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)))))
|
@ -72,7 +72,6 @@
|
|||||||
(define optname-end-date (N_ "Date of Report"))
|
(define optname-end-date (N_ "Date of Report"))
|
||||||
(define optname-report-variant (N_ "Report variation"))
|
(define optname-report-variant (N_ "Report variation"))
|
||||||
(define opthelp-report-variant (N_ "Kind of trial balance to generate."))
|
(define opthelp-report-variant (N_ "Kind of trial balance to generate."))
|
||||||
;; FIXME this needs an indent option
|
|
||||||
|
|
||||||
(define optname-accounts (N_ "Accounts"))
|
(define optname-accounts (N_ "Accounts"))
|
||||||
(define opthelp-accounts
|
(define opthelp-accounts
|
||||||
@ -361,7 +360,6 @@
|
|||||||
(show-rates? (get-option pagename-commodities optname-show-rates))
|
(show-rates? (get-option pagename-commodities optname-show-rates))
|
||||||
(show-zb-accts? #t)
|
(show-zb-accts? #t)
|
||||||
(use-links? (get-option gnc:pagename-display optname-account-links))
|
(use-links? (get-option gnc:pagename-display optname-account-links))
|
||||||
(indent 0)
|
|
||||||
|
|
||||||
;; decompose the account list
|
;; decompose the account list
|
||||||
(split-up-accounts (gnc:decompose-accountlist accounts))
|
(split-up-accounts (gnc:decompose-accountlist accounts))
|
||||||
@ -559,13 +557,10 @@
|
|||||||
(let* ((env (gnc:html-acct-table-get-row-env acct-table 0)))
|
(let* ((env (gnc:html-acct-table-get-row-env acct-table 0)))
|
||||||
(set! account-cols (get-val env 'account-cols)))
|
(set! account-cols (get-val env 'account-cols)))
|
||||||
|
|
||||||
(let ((wide (gnc:make-html-table-cell/markup "text-cell" #f))
|
(let* ((ncols (+ account-cols (if (eq? report-variant 'work-sheet) 10 2)))
|
||||||
(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-cell-set-style!
|
(gnc:html-table-append-row! build-table space)
|
||||||
wide "text-cell" 'attribute '("style" "min-width:60px"))
|
(set! header-rows (1+ header-rows)))
|
||||||
(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
|
;; add the double-column headers if required
|
||||||
(if (eq? report-variant 'work-sheet)
|
(if (eq? report-variant 'work-sheet)
|
||||||
|
Loading…
Reference in New Issue
Block a user