GnuCash  5.6-150-g038405b370+
Query.h
1 /********************************************************************\
2  * Query.h : api for finding transactions *
3  * Copyright 2000 Bill Gribble <grib@billgribble.com> *
4  * Copyright 2002 Linas Vepstas <linas@linas.org> *
5  * *
6  * This program is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation; either version 2 of *
9  * the License, or (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License*
17  * along with this program; if not, contact: *
18  * *
19  * Free Software Foundation Voice: +1-617-542-5942 *
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21  * Boston, MA 02110-1301, USA gnu@gnu.org *
22 \********************************************************************/
23 
24 #ifndef GNUCASH_QUERY_H
25 #define GNUCASH_QUERY_H
26 
27 #include <sys/types.h>
28 #include <time.h>
29 #include <glib.h>
30 #include "qof.h"
31 #include "Account.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * This function defines a compatibility API from the old Query API to
39  * the new Query API. Note that it is not a 100% complete equivalent.
40  * Many functions have a one-to-one mapping in the new API, but many
41  * others do not.
42  */
43 
44 typedef QofQuery Query;
45 
46 typedef enum
47 {
48  QUERY_TXN_MATCH_ALL = 1, /* match all accounts */
49  QUERY_TXN_MATCH_ANY = 2 /* match any account */
50 } query_txn_match_t;
51 
52 /* After the query has been set up, call one of these to run the query.
53  * XXX The routines below should be replaced by a query
54  * that explicitly asks for a list of the desired item.
55  *
56  * The xaccQueryGetSplits() routine returns all splits matching the
57  * query. Any given split will appear at most once in the result;
58  * however, several splits from one transaction may appear in the list.
59  * The caller MUST NOT change the GList.
60  */
61 
69 SplitList * xaccQueryGetSplitsUniqueTrans(QofQuery *q);
70 
92 TransList * xaccQueryGetTransactions(QofQuery * q, query_txn_match_t type);
93 
99 LotList * xaccQueryGetLots(QofQuery * q, query_txn_match_t type);
100 
101 /*******************************************************************
102  * match-adding API
103  *******************************************************************/
104 
105 void xaccQueryAddAccountMatch(QofQuery *, AccountList *,
106  QofGuidMatch how, QofQueryOp op);
107 
108 void xaccQueryAddAccountGUIDMatch(QofQuery *, AccountGUIDList *,
110 
111 void xaccQueryAddSingleAccountMatch(QofQuery *, Account *, QofQueryOp);
112 
113 void xaccQueryAddStringMatch (QofQuery* q, const char *matchstring,
114  gboolean case_sens, gboolean use_regexp,
115  QofQueryCompare how, QofQueryOp op,
116  const char * path, ...);
117 void
118 xaccQueryAddDescriptionMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
119  QofQueryCompare how, QofQueryOp o);
120 void
121 xaccQueryAddNotesMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
122  QofQueryCompare how, QofQueryOp o);
123 void
124 xaccQueryAddNumberMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
125  QofQueryCompare how, QofQueryOp o);
126 void
127 xaccQueryAddActionMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
128  QofQueryCompare how, QofQueryOp o);
129 void
130 xaccQueryAddMemoMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
131  QofQueryCompare how, QofQueryOp o);
132 void
133 xaccQueryAddValueMatch(QofQuery *q, gnc_numeric amt, QofNumericMatch sgn,
134  QofQueryCompare how, QofQueryOp op);
135 void
136 xaccQueryAddSharePriceMatch(QofQuery *q, gnc_numeric amt, QofQueryCompare how,
137  QofQueryOp op);
138 void
139 xaccQueryAddSharesMatch(QofQuery *q, gnc_numeric amt, QofQueryCompare how,
140  QofQueryOp op);
141 void
142 xaccQueryAddBalanceMatch(QofQuery *q, QofQueryCompare bal, QofQueryOp op);
143 
144 void xaccQueryAddNumericMatch (QofQuery *q, gnc_numeric amount,
146  QofQueryOp op, const char * path, ...);
147 
157 void xaccQueryAddDateMatch(QofQuery * q, gboolean use_start,
158  int sday, int smonth, int syear,
159  gboolean use_end, int eday, int emonth, int eyear,
160  QofQueryOp op);
161 void xaccQueryAddDateMatchTT(QofQuery * q,
162  gboolean use_start, time64 stt,
163  gboolean use_end, time64 ett,
164  QofQueryOp op);
165 void xaccQueryGetDateMatchTT (QofQuery * q,
166  time64 * stt,
167  time64 * ett);
168 
169 void xaccQueryAddClosingTransMatch(QofQuery *q, gboolean value, QofQueryOp op);
170 
171 typedef enum
172 {
173  CLEARED_NONE = 0x0000,
174  CLEARED_NO = 0x0001,
175  CLEARED_CLEARED = 0x0002,
176  CLEARED_RECONCILED = 0x0004,
177  CLEARED_FROZEN = 0x0008,
178  CLEARED_VOIDED = 0x0010,
179  CLEARED_ALL = 0x001F
180 } cleared_match_t;
181 
182 void xaccQueryAddClearedMatch(QofQuery * q, cleared_match_t how, QofQueryOp op);
183 cleared_match_t xaccQueryGetClearedMatch(QofQuery * q);
184 
185 void xaccQueryAddGUIDMatch(QofQuery * q, const GncGUID *guid,
186  QofIdType id_type, QofQueryOp op);
187 
188 
189 /*******************************************************************
190  * compatibility interface with old QofQuery API
191  *******************************************************************/
192 time64 xaccQueryGetEarliestDateFound(QofQuery * q);
193 time64 xaccQueryGetLatestDateFound(QofQuery * q);
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif
GList TransList
GList of Transaction.
Definition: gnc-engine.h:209
GList LotList
GList of GNCLots.
Definition: gnc-engine.h:205
STRUCTS.
const gchar * QofIdType
QofIdType declaration.
Definition: qofid.h:80
GList SplitList
GList of Split.
Definition: gnc-engine.h:207
Account handling public routines.
QofGuidMatch
Definition: qofquerycore.h:109
QofQueryCompare
Standard Query comparators, for how to compare objects in a predicate.
Definition: qofquerycore.h:54
QofQueryOp
Query Term Operators, for combining Query Terms.
Definition: qofquery.h:92
GList AccountList
GList of Account.
Definition: gnc-engine.h:203
GList AccountGUIDList
GList of GUIDs of a Account.
Definition: gnc-engine.h:211
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
The type used to store guids in C.
Definition: guid.h:75
QofNumericMatch
Comparisons for QOF_TYPE_NUMERIC, QOF_TYPE_DEBCRED.
Definition: qofquerycore.h:101
A Query.
Definition: qofquery.cpp:74