r23536 - gnucash/trunk/src - Change various reports to find book closing transactions without pattern matching
Mike Alexander
mta at code.gnucash.org
Tue Dec 10 17:17:51 EST 2013
Author: mta
Date: 2013-12-10 17:17:50 -0500 (Tue, 10 Dec 2013)
New Revision: 23536
Trac: http://svn.gnucash.org/trac/changeset/23536
Modified:
gnucash/trunk/src/engine/Query.c
gnucash/trunk/src/engine/Query.h
gnucash/trunk/src/report/report-system/report-utilities.scm
gnucash/trunk/src/report/standard-reports/equity-statement.scm
gnucash/trunk/src/report/standard-reports/income-statement.scm
gnucash/trunk/src/report/standard-reports/trial-balance.scm
Log:
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.
Modified: gnucash/trunk/src/engine/Query.c
===================================================================
--- gnucash/trunk/src/engine/Query.c 2013-12-10 22:17:00 UTC (rev 23535)
+++ gnucash/trunk/src/engine/Query.c 2013-12-10 22:17:50 UTC (rev 23536)
@@ -587,6 +587,20 @@
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
*******************************************************************/
Modified: gnucash/trunk/src/engine/Query.h
===================================================================
--- gnucash/trunk/src/engine/Query.h 2013-12-10 22:17:00 UTC (rev 23535)
+++ gnucash/trunk/src/engine/Query.h 2013-12-10 22:17:50 UTC (rev 23536)
@@ -166,6 +166,8 @@
time64 * stt,
time64 * ett);
+void xaccQueryAddClosingTransMatch(QofQuery *q, gboolean value, QofQueryOp op);
+
typedef enum
{
CLEARED_NONE = 0x0000,
Modified: gnucash/trunk/src/report/report-system/report-utilities.scm
===================================================================
--- gnucash/trunk/src/report/report-system/report-utilities.scm 2013-12-10 22:17:00 UTC (rev 23535)
+++ gnucash/trunk/src/report/report-system/report-utilities.scm 2013-12-10 22:17:50 UTC (rev 23536)
@@ -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,9 +921,16 @@
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)
splits
Modified: gnucash/trunk/src/report/standard-reports/equity-statement.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/equity-statement.scm 2013-12-10 22:17:00 UTC (rev 23535)
+++ gnucash/trunk/src/report/standard-reports/equity-statement.scm 2013-12-10 22:17:50 UTC (rev 23536)
@@ -261,6 +261,7 @@
(list 'cased closing-cased)
(list 'regexp closing-regexp)
(list 'positive #f)
+ (list 'closing #t)
)
)
Modified: gnucash/trunk/src/report/standard-reports/income-statement.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/income-statement.scm 2013-12-10 22:17:00 UTC (rev 23535)
+++ gnucash/trunk/src/report/standard-reports/income-statement.scm 2013-12-10 22:17:50 UTC (rev 23536)
@@ -364,6 +364,7 @@
(list (list 'str closing-str)
(list 'cased closing-cased)
(list 'regexp closing-regexp)
+ (list 'closing #t)
)
)
(indent 0)
Modified: gnucash/trunk/src/report/standard-reports/trial-balance.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/trial-balance.scm 2013-12-10 22:17:00 UTC (rev 23535)
+++ gnucash/trunk/src/report/standard-reports/trial-balance.scm 2013-12-10 22:17:50 UTC (rev 23536)
@@ -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
))
More information about the gnucash-changes
mailing list