mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Change various reports to find book closing transactions without pattern matching
Several reports need to find book closing transactions and let you specify a pattern to match against the description of the transaction to detect them. The Close Book tool marks the transactions it creates so they can be found without pattern matching. This changes makes those reports use that mark to find them even if the pattern match doesn't. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23536 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9f5f1320be
commit
2182d04dad
@ -587,6 +587,20 @@ xaccQueryAddKVPMatch(QofQuery *q, GSList *path, const KvpValue *value,
|
||||
qof_query_add_term (q, param_list, pred_data, op);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* xaccQueryAddClosingTransMatch
|
||||
* Add a filter that matches book closing entries to an existing query.
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
xaccQueryAddClosingTransMatch(QofQuery *q, gboolean value, QofQueryOp op)
|
||||
{
|
||||
GSList *param_list;
|
||||
|
||||
param_list = qof_query_build_param_list(SPLIT_TRANS, TRANS_IS_CLOSING, NULL);
|
||||
qof_query_add_boolean_match(q, param_list, value, op);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* xaccQueryGetEarliestDateFound
|
||||
*******************************************************************/
|
||||
|
@ -166,6 +166,8 @@ void xaccQueryGetDateMatchTT (QofQuery * q,
|
||||
time64 * stt,
|
||||
time64 * ett);
|
||||
|
||||
void xaccQueryAddClosingTransMatch(QofQuery *q, gboolean value, QofQueryOp op);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CLEARED_NONE = 0x0000,
|
||||
|
@ -890,7 +890,13 @@
|
||||
)
|
||||
|
||||
;; Return the splits that match an account list, date range, and (optionally) type
|
||||
;; where type is defined as an alist '((str "match me") (cased #f) (regexp #f))
|
||||
;; where type is defined as an alist like:
|
||||
;; '((str "match me") (cased #f) (regexp #f) (closing #f))
|
||||
;; where str, cased, and regexp define a pattern match on transaction deseriptions
|
||||
;; and "closing" matches transactions created by the book close command. If "closing"
|
||||
;; is given as #t then only closing transactions will be returned, if it is #f then
|
||||
;; only non-closing transactions will be returned, and if it is omitted then both
|
||||
;; kinds of transactions will be returned.
|
||||
(define (gnc:account-get-trans-type-splits-interval
|
||||
account-list type start-date-tp end-date-tp)
|
||||
(if (null? account-list)
|
||||
@ -898,6 +904,7 @@
|
||||
'()
|
||||
;; The normal case: There are accounts given.
|
||||
(let* ((query (qof-query-create-for-splits))
|
||||
(query2 #f)
|
||||
(splits #f)
|
||||
(get-val (lambda (alist key)
|
||||
(let ((lst (assoc-ref alist key)))
|
||||
@ -905,6 +912,7 @@
|
||||
(matchstr (get-val type 'str))
|
||||
(case-sens (if (get-val type 'cased) #t #f))
|
||||
(regexp (if (get-val type 'regexp) #t #f))
|
||||
(closing (if (get-val type 'closing) #t #f))
|
||||
)
|
||||
(qof-query-set-book query (gnc-get-current-book))
|
||||
(gnc:query-set-match-non-voids-only! query (gnc-get-current-book))
|
||||
@ -913,8 +921,15 @@
|
||||
query
|
||||
(and start-date-tp #t) start-date-tp
|
||||
(and end-date-tp #t) end-date-tp QOF-QUERY-AND)
|
||||
(if type (xaccQueryAddDescriptionMatch
|
||||
query matchstr case-sens regexp QOF-QUERY-AND))
|
||||
(if (or matchstr closing)
|
||||
(begin
|
||||
(set! query2 (qof-query-create-for-splits))
|
||||
(if matchstr (xaccQueryAddDescriptionMatch
|
||||
query2 matchstr case-sens regexp QOF-QUERY-OR))
|
||||
(if closing (xaccQueryAddClosingTransMatch query2 1 QOF-QUERY-OR))
|
||||
(qof-query-merge-in-place query query2 QOF-QUERY-AND)
|
||||
(qof-query-destroy query2)
|
||||
))
|
||||
|
||||
(set! splits (qof-query-run query))
|
||||
(qof-query-destroy query)
|
||||
|
@ -261,6 +261,7 @@
|
||||
(list 'cased closing-cased)
|
||||
(list 'regexp closing-regexp)
|
||||
(list 'positive #f)
|
||||
(list 'closing #t)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -364,6 +364,7 @@
|
||||
(list (list 'str closing-str)
|
||||
(list 'cased closing-cased)
|
||||
(list 'regexp closing-regexp)
|
||||
(list 'closing #t)
|
||||
)
|
||||
)
|
||||
(indent 0)
|
||||
|
@ -702,20 +702,22 @@
|
||||
(group (list acct))
|
||||
(curr-bal (get-val env 'account-bal))
|
||||
(closing
|
||||
(gnc:account-get-trans-type-balance-interval
|
||||
(gnc:account-get-trans-type-balance-interval-with-closing
|
||||
group
|
||||
(list (list 'str closing-str)
|
||||
(list 'cased closing-cased)
|
||||
(list 'regexp closing-regexp)
|
||||
(list 'closing #t)
|
||||
)
|
||||
start-date-tp end-date-tp
|
||||
))
|
||||
(adjusting
|
||||
(gnc:account-get-trans-type-balance-interval
|
||||
(gnc:account-get-trans-type-balance-interval-with-closing
|
||||
group
|
||||
(list (list 'str adjusting-str)
|
||||
(list 'cased adjusting-cased)
|
||||
(list 'regexp adjusting-regexp)
|
||||
(list 'closing #t)
|
||||
)
|
||||
start-date-tp end-date-tp
|
||||
))
|
||||
|
Loading…
Reference in New Issue
Block a user