GnuCash c935c2f+
Loading...
Searching...
No Matches
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
34extern "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
44typedef QofQuery Query;
45
46typedef 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
69SplitList * xaccQueryGetSplitsUniqueTrans(QofQuery *q);
70
92TransList * xaccQueryGetTransactions(QofQuery * q, query_txn_match_t type);
93
99LotList * xaccQueryGetLots(QofQuery * q, query_txn_match_t type);
100
101/*******************************************************************
102 * match-adding API
103 *******************************************************************/
104
105void xaccQueryAddAccountMatch(QofQuery *, AccountList *,
106 QofGuidMatch how, QofQueryOp op);
107
108void xaccQueryAddAccountGUIDMatch(QofQuery *, AccountGUIDList *,
110
111void xaccQueryAddSingleAccountMatch(QofQuery *, Account *, QofQueryOp);
112
113void xaccQueryAddStringMatch (QofQuery* q, const char *matchstring,
114 gboolean case_sens, gboolean use_regexp,
116 const char * path, ...);
117void
118xaccQueryAddDescriptionMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
120void
121xaccQueryAddNotesMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
123void
124xaccQueryAddNumberMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
126void
127xaccQueryAddActionMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
129void
130xaccQueryAddMemoMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
132void
133xaccQueryAddValueMatch(QofQuery *q, gnc_numeric amt, QofNumericMatch sgn,
135void
136xaccQueryAddSharePriceMatch(QofQuery *q, gnc_numeric amt, QofQueryCompare how,
137 QofQueryOp op);
138void
139xaccQueryAddSharesMatch(QofQuery *q, gnc_numeric amt, QofQueryCompare how,
140 QofQueryOp op);
141void
142xaccQueryAddBalanceMatch(QofQuery *q, QofQueryCompare bal, QofQueryOp op);
143
144void xaccQueryAddNumericMatch (QofQuery *q, gnc_numeric amount,
146 QofQueryOp op, const char * path, ...);
147
157void 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);
161void xaccQueryAddDateMatchTT(QofQuery * q,
162 gboolean use_start, time64 stt,
163 gboolean use_end, time64 ett,
164 QofQueryOp op);
165void xaccQueryGetDateMatchTT (QofQuery * q,
166 time64 * stt,
167 time64 * ett);
168
169void xaccQueryAddClosingTransMatch(QofQuery *q, gboolean value, QofQueryOp op);
170
171typedef 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
182void xaccQueryAddClearedMatch(QofQuery * q, cleared_match_t how, QofQueryOp op);
183cleared_match_t xaccQueryGetClearedMatch(QofQuery * q);
184
185void xaccQueryAddGUIDMatch(QofQuery * q, const GncGUID *guid,
186 QofIdType id_type, QofQueryOp op);
187
188
189/*******************************************************************
190 * compatibility interface with old QofQuery API
191 *******************************************************************/
192time64 xaccQueryGetEarliestDateFound(QofQuery * q);
193time64 xaccQueryGetLatestDateFound(QofQuery * q);
194
195#ifdef __cplusplus
196}
197#endif
198
199#endif
Account handling public routines.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition gnc-date.h:87
GList LotList
GList of GNCLots.
Definition gnc-engine.h:205
GList TransList
GList of Transaction.
Definition gnc-engine.h:209
GList AccountList
GList of Account.
Definition gnc-engine.h:203
GList AccountGUIDList
GList of GUIDs of a Account.
Definition gnc-engine.h:211
GList SplitList
GList of Split.
Definition gnc-engine.h:207
const gchar * QofIdType
QofIdType declaration.
Definition qofid.h:80
QofNumericMatch
Comparisons for QOF_TYPE_NUMERIC, QOF_TYPE_DEBCRED.
QofGuidMatch
QofQueryOp
Query Term Operators, for combining Query Terms.
Definition qofquery.h:93
QofQueryCompare
Standard Query comparators, for how to compare objects in a predicate.
STRUCTS.
The type used to store guids in C.
Definition guid.h:75
A Query.
Definition qofquery.cpp:75