|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * Query.h : api for finding transactions * 00003 * Copyright 2000 Bill Gribble <grib@billgribble.com> * 00004 * Copyright 2002 Linas Vepstas <linas@linas.org> * 00005 * * 00006 * This program is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU General Public License as * 00008 * published by the Free Software Foundation; either version 2 of * 00009 * the License, or (at your option) any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License* 00017 * along with this program; if not, contact: * 00018 * * 00019 * Free Software Foundation Voice: +1-617-542-5942 * 00020 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00021 * Boston, MA 02110-1301, USA gnu@gnu.org * 00022 \********************************************************************/ 00023 00024 #ifndef GNUCASH_QUERY_H 00025 #define GNUCASH_QUERY_H 00026 00027 #include <sys/types.h> 00028 #include <time.h> 00029 #include <glib.h> 00030 #include "qof.h" 00031 #include "Account.h" 00032 00033 /* 00034 * This function defines a compatibility API from the old Query API to 00035 * the new Query API. Note that it is not a 100% complete equivalent. 00036 * Many functions have a one-to-one mapping in the new API, but many 00037 * others do not. 00038 */ 00039 00040 typedef QofQuery Query; 00041 00042 typedef enum 00043 { 00044 QUERY_TXN_MATCH_ALL = 1, /* match all accounts */ 00045 QUERY_TXN_MATCH_ANY = 2 /* match any account */ 00046 } query_txn_match_t; 00047 00048 /* After the query has been set up, call one of these to run the query. 00049 * XXX The routines below should be replaced by a query 00050 * that explicitly asks for a list of the desired item. 00051 * 00052 * The xaccQueryGetSplits() routine returns all splits matching the 00053 * query. Any given split will appear at most once in the result; 00054 * however, several splits from one transaction may appear in the list. 00055 * The caller MUST NOT change the GList. 00056 */ 00057 00065 SplitList * xaccQueryGetSplitsUniqueTrans(QofQuery *q); 00066 00088 TransList * xaccQueryGetTransactions(QofQuery * q, query_txn_match_t type); 00089 00095 LotList * xaccQueryGetLots(QofQuery * q, query_txn_match_t type); 00096 00097 /******************************************************************* 00098 * match-adding API 00099 *******************************************************************/ 00100 00101 void xaccQueryAddAccountMatch(QofQuery *, AccountList *, 00102 QofGuidMatch how, QofQueryOp op); 00103 00104 void xaccQueryAddAccountGUIDMatch(QofQuery *, AccountGUIDList *, 00105 QofGuidMatch, QofQueryOp); 00106 00107 void xaccQueryAddSingleAccountMatch(QofQuery *, Account *, QofQueryOp); 00108 00109 void xaccQueryAddStringMatch (QofQuery* q, const char *matchstring, 00110 gboolean case_sens, gboolean use_regexp, 00111 QofQueryOp op, 00112 const char * path, ...); 00113 void 00114 xaccQueryAddDescriptionMatch(QofQuery *q, const char *m, gboolean c, gboolean r, 00115 QofQueryOp o); 00116 void 00117 xaccQueryAddNumberMatch(QofQuery *q, const char *m, gboolean c, gboolean r, 00118 QofQueryOp o); 00119 void 00120 xaccQueryAddActionMatch(QofQuery *q, const char *m, gboolean c, gboolean r, 00121 QofQueryOp o); 00122 void 00123 xaccQueryAddMemoMatch(QofQuery *q, const char *m, gboolean c, gboolean r, 00124 QofQueryOp o); 00125 void 00126 xaccQueryAddValueMatch(QofQuery *q, gnc_numeric amt, QofNumericMatch sgn, 00127 QofQueryCompare how, QofQueryOp op); 00128 void 00129 xaccQueryAddSharePriceMatch(QofQuery *q, gnc_numeric amt, QofQueryCompare how, 00130 QofQueryOp op); 00131 void 00132 xaccQueryAddSharesMatch(QofQuery *q, gnc_numeric amt, QofQueryCompare how, 00133 QofQueryOp op); 00134 void 00135 xaccQueryAddBalanceMatch(QofQuery *q, QofQueryCompare bal, QofQueryOp op); 00136 00137 void xaccQueryAddNumericMatch (QofQuery *q, gnc_numeric amount, 00138 QofNumericMatch sign, QofQueryCompare how, 00139 QofQueryOp op, const char * path, ...); 00140 00150 void xaccQueryAddDateMatch(QofQuery * q, gboolean use_start, 00151 int sday, int smonth, int syear, 00152 gboolean use_end, int eday, int emonth, int eyear, 00153 QofQueryOp op); 00154 void xaccQueryAddDateMatchTS(QofQuery * q, 00155 gboolean use_start, Timespec sts, 00156 gboolean use_end, Timespec ets, 00157 QofQueryOp op); 00158 void xaccQueryAddDateMatchTT(QofQuery * q, 00159 gboolean use_start, time_t stt, 00160 gboolean use_end, time_t ett, 00161 QofQueryOp op); 00162 void xaccQueryGetDateMatchTS (QofQuery * q, 00163 Timespec * sts, 00164 Timespec * ets); 00165 void xaccQueryGetDateMatchTT (QofQuery * q, 00166 time_t * stt, 00167 time_t * ett); 00168 00169 typedef enum 00170 { 00171 CLEARED_NONE = 0x0000, 00172 CLEARED_NO = 0x0001, 00173 CLEARED_CLEARED = 0x0002, 00174 CLEARED_RECONCILED = 0x0004, 00175 CLEARED_FROZEN = 0x0008, 00176 CLEARED_VOIDED = 0x0010, 00177 CLEARED_ALL = 0x001F 00178 } cleared_match_t; 00179 00180 void xaccQueryAddClearedMatch(QofQuery * q, cleared_match_t how, QofQueryOp op); 00181 void xaccQueryAddGUIDMatch(QofQuery * q, const GncGUID *guid, 00182 QofIdType id_type, QofQueryOp op); 00183 00185 void xaccQueryAddKVPMatch(QofQuery *q, GSList *path, const KvpValue *value, 00186 QofQueryCompare how, QofIdType id_type, 00187 QofQueryOp op); 00188 00189 /******************************************************************* 00190 * compatibility interface with old QofQuery API 00191 *******************************************************************/ 00192 time_t xaccQueryGetEarliestDateFound(QofQuery * q); 00193 time_t xaccQueryGetLatestDateFound(QofQuery * q); 00194 00195 #endif
1.7.4