mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[trep-engine] add transaction filter exclude option
add boolean option which converts the transaction filter from 'include' to 'exclude'.
This commit is contained in:
parent
509c542a9a
commit
58258b9400
@ -89,6 +89,8 @@
|
|||||||
(define optname-transaction-matcher (N_ "Transaction Filter"))
|
(define optname-transaction-matcher (N_ "Transaction Filter"))
|
||||||
(define optname-transaction-matcher-regex
|
(define optname-transaction-matcher-regex
|
||||||
(N_ "Use regular expressions for transaction filter"))
|
(N_ "Use regular expressions for transaction filter"))
|
||||||
|
(define optname-transaction-matcher-exclude
|
||||||
|
(N_ "Transaction Filter excludes matched strings"))
|
||||||
(define optname-reconcile-status (N_ "Reconcile Status"))
|
(define optname-reconcile-status (N_ "Reconcile Status"))
|
||||||
(define optname-void-transactions (N_ "Void Transactions"))
|
(define optname-void-transactions (N_ "Void Transactions"))
|
||||||
(define optname-closing-transactions (N_ "Closing transactions"))
|
(define optname-closing-transactions (N_ "Closing transactions"))
|
||||||
@ -604,6 +606,13 @@ enable full POSIX regular expressions capabilities. '#work|#family' will match b
|
|||||||
tags within description, notes or memo. ")
|
tags within description, notes or memo. ")
|
||||||
#f))
|
#f))
|
||||||
|
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-simple-boolean-option
|
||||||
|
pagename-filter optname-transaction-matcher-exclude
|
||||||
|
"i3"
|
||||||
|
(_ "If this option is selected, transactions matching filter are excluded.")
|
||||||
|
#f))
|
||||||
|
|
||||||
(gnc:register-trep-option
|
(gnc:register-trep-option
|
||||||
(gnc:make-multichoice-option
|
(gnc:make-multichoice-option
|
||||||
pagename-filter optname-reconcile-status
|
pagename-filter optname-reconcile-status
|
||||||
@ -1969,6 +1978,8 @@ be excluded from periodic reporting.")
|
|||||||
(lambda () (make-regexp transaction-matcher))
|
(lambda () (make-regexp transaction-matcher))
|
||||||
(const 'invalid-transaction-regex))
|
(const 'invalid-transaction-regex))
|
||||||
'no-guile-regex-support)))
|
'no-guile-regex-support)))
|
||||||
|
(transaction-filter-exclude?
|
||||||
|
(opt-val pagename-filter optname-transaction-matcher-exclude))
|
||||||
(reconcile-status-filter
|
(reconcile-status-filter
|
||||||
(keylist-get-info reconcile-status-list
|
(keylist-get-info reconcile-status-list
|
||||||
(opt-val pagename-filter optname-reconcile-status)
|
(opt-val pagename-filter optname-reconcile-status)
|
||||||
@ -2044,6 +2055,11 @@ be excluded from periodic reporting.")
|
|||||||
(define (date-comparator? X Y)
|
(define (date-comparator? X Y)
|
||||||
(generic-less? X Y 'date 'none #t))
|
(generic-less? X Y 'date 'none #t))
|
||||||
|
|
||||||
|
(define (transaction-filter-match split)
|
||||||
|
(or (match? (xaccTransGetDescription (xaccSplitGetParent split)))
|
||||||
|
(match? (xaccTransGetNotes (xaccSplitGetParent split)))
|
||||||
|
(match? (xaccSplitGetMemo split))))
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((or (null? c_account_1)
|
((or (null? c_account_1)
|
||||||
(symbol? account-matcher-regexp)
|
(symbol? account-matcher-regexp)
|
||||||
@ -2129,9 +2145,9 @@ be excluded from periodic reporting.")
|
|||||||
((include) (is-filter-member split c_account_2))
|
((include) (is-filter-member split c_account_2))
|
||||||
((exclude) (not (is-filter-member split c_account_2))))
|
((exclude) (not (is-filter-member split c_account_2))))
|
||||||
(or (string-null? transaction-matcher)
|
(or (string-null? transaction-matcher)
|
||||||
(match? (xaccTransGetDescription trans))
|
(if transaction-filter-exclude?
|
||||||
(match? (xaccTransGetNotes trans))
|
(not (transaction-filter-match split))
|
||||||
(match? (xaccSplitGetMemo split)))
|
(transaction-filter-match split)))
|
||||||
(or (not custom-split-filter)
|
(or (not custom-split-filter)
|
||||||
(custom-split-filter split)))))
|
(custom-split-filter split)))))
|
||||||
splits))
|
splits))
|
||||||
|
@ -349,6 +349,12 @@
|
|||||||
'("-$23.00")
|
'("-$23.00")
|
||||||
(get-row-col sxml -1 -1)))
|
(get-row-col sxml -1 -1)))
|
||||||
|
|
||||||
|
(set-option! options "Filter" "Transaction Filter excludes matched strings" #t)
|
||||||
|
(let ((sxml (options->sxml options "negate transaction filter not.s?")))
|
||||||
|
(test-equal "transaction filter in bank to 'not.s?' and switch regex, sum = -$23.00"
|
||||||
|
'("$24.00")
|
||||||
|
(get-row-col sxml -1 -1)))
|
||||||
|
|
||||||
;; Test Reconcile Status Filters
|
;; Test Reconcile Status Filters
|
||||||
(set! options (default-testing-options))
|
(set! options (default-testing-options))
|
||||||
(set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 01 01 1969)))
|
(set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 01 01 1969)))
|
||||||
|
Loading…
Reference in New Issue
Block a user