[report-utilities] deprecate gnc:account-get-pos-trans-total-interval

this function is only used in trial-balance. move function locally and
deprecate exported function.
This commit is contained in:
Christopher Lam 2018-12-30 08:55:46 +08:00
parent 0f53b6c82f
commit cc3bb4ef20
2 changed files with 54 additions and 1 deletions

View File

@ -754,6 +754,8 @@ flawed. see report-utilities.scm. please update reports.")
;; *ignores* any closing entries
(define (gnc:account-get-pos-trans-total-interval
account-list type start-date end-date)
(issue-deprecation-warning
"(gnc:account-get-pos-trans-total-interval) is deprecated.")
(let* ((str-query (qof-query-create-for-splits))
(sign-query (qof-query-create-for-splits))
(total-query #f)

View File

@ -320,6 +320,57 @@
options))
(define (account-get-pos-trans-total-interval
account-list type start-date end-date)
(let* ((str-query (qof-query-create-for-splits))
(sign-query (qof-query-create-for-splits))
(total-query #f)
(get-val (lambda (alist key)
(let ((lst (assoc-ref alist key)))
(and lst (car lst)))))
(matchstr (get-val type 'str))
(case-sens (and (get-val type 'cased) #t))
(regexp (and (get-val type 'regexp) #t))
(pos? (and (get-val type 'positive) #t))
(total (gnc:make-commodity-collector)))
(qof-query-set-book str-query (gnc-get-current-book))
(qof-query-set-book sign-query (gnc-get-current-book))
(gnc:query-set-match-non-voids-only! str-query (gnc-get-current-book))
(gnc:query-set-match-non-voids-only! sign-query (gnc-get-current-book))
(xaccQueryAddAccountMatch str-query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
(xaccQueryAddAccountMatch sign-query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
(xaccQueryAddDateMatchTT str-query
(and start-date #t) (or start-date 0)
(and end-date #t) (or end-date 0)
QOF-QUERY-AND)
(xaccQueryAddDateMatchTT sign-query
(and start-date #t) (or start-date 0)
(and end-date #t) (or end-date 0)
QOF-QUERY-AND)
(xaccQueryAddDescriptionMatch
str-query matchstr case-sens regexp QOF-COMPARE-CONTAINS QOF-QUERY-AND)
(set! total-query
;; this is a tad inefficient, but its a simple way to accomplish
;; description match inversion...
(if pos?
(qof-query-merge-in-place sign-query str-query QOF-QUERY-AND)
(let ((inv-query (qof-query-invert str-query)))
(qof-query-merge-in-place
sign-query inv-query QOF-QUERY-AND)
qof-query-destroy inv-query)))
(qof-query-destroy str-query)
(map
(lambda (split)
(let* ((shares (xaccSplitGetAmount split))
(acct-comm (xaccAccountGetCommodity
(xaccSplitGetAccount split))))
(unless (negative? shares)
(total 'add acct-comm shares))))
(qof-query-run total-query))
(qof-query-destroy total-query)
total))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; trial-balance-renderer
;; set up the document and add the table
@ -766,7 +817,7 @@
(pos-adjusting
(and ga-or-is?
adjusting
(gnc:account-get-pos-trans-total-interval
(account-get-pos-trans-total-interval
group
(list (list 'str adjusting-str)
(list 'cased adjusting-cased)