[test-average-balance] test ignore-internal? algorithms

tests gain/loss ignore-internal? algorithms
This commit is contained in:
Christopher Lam 2019-03-25 17:12:52 +08:00
parent 480d13ba27
commit dedccd56f3

View File

@ -37,6 +37,7 @@
(define structure
(list "Root" (list (cons 'type ACCT-TYPE-ASSET))
(list "Bank")
(list "Another Bank")
(list "Income" (list (cons 'type ACCT-TYPE-INCOME)))))
(define (get-row-col sxml row col)
@ -47,6 +48,7 @@
(account-alist (env-create-account-structure-alist env structure))
(options (gnc:make-report-options uuid))
(bank (cdr (assoc "Bank" account-alist)))
(bank2 (cdr (assoc "Another Bank" account-alist)))
(income (cdr (assoc "Income" account-alist))))
(define (default-testing-options)
@ -56,7 +58,7 @@
;; disable indenting. These options will be tested separately as
;; the first test group. By default, we'll select the modern dates.
(let ((options (gnc:make-report-options uuid)))
(set-option! options "Accounts" "Accounts" (list bank))
(set-option! options "Accounts" "Accounts" (list bank bank2))
(set-option! options "Display" "Show table" #t)
(set-option! options "General" "Start Date"
(cons 'absolute (gnc-dmy2time64 01 01 1979)))
@ -81,4 +83,24 @@
(test-equal "net"
'("0.00" "100.00" "0.00" "100.00" "0.00" "0.00")
(get-row-col sxml #f 8)))
(env-transfer env 15 03 1979 bank bank2 25)
(let* ((options (default-testing-options))
(sxml (options->sxml options "include-internal")))
(test-equal "gains-include-internal"
'("0.00" "100.00" "25.00" "100.00" "0.00" "0.00")
(get-row-col sxml #f 6))
(test-equal "loss-include-internal"
'("0.00" "0.00" "25.00" "0.00" "0.00" "0.00")
(get-row-col sxml #f 7)))
(let* ((options (default-testing-options)))
(set-option! options "Accounts" "Exclude transactions between selected accounts" #t)
(let ((sxml (options->sxml options "exclude-internal")))
(test-equal "gain-exclude-internal"
'("0.00" "100.00" "0.00" "100.00" "0.00" "0.00")
(get-row-col sxml #f 6))
(test-equal "loss-exclude-internal"
'("0.00" "0.00" "0.00" "0.00" "0.00" "0.00")
(get-row-col sxml #f 7))))
(teardown)))