1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
/***************************************************************************
imymoneyserialize.h - description
-------------------
begin : Fri May 10 2002
copyright : (C) 2000-2002 by Michael Edwardes
email : [email protected]
Javier Campos Morales <[email protected]>
Felix Rodriguez <[email protected]>
John C <[email protected]>
Thomas Baumgart <[email protected]>
Kevin Tambascio <[email protected]>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef IMYMONEYSERIALIZE_H
#define IMYMONEYSERIALIZE_H
// ----------------------------------------------------------------------------
// QT Includes
#include <tqstring.h>
#include <tqvaluelist.h>
// ----------------------------------------------------------------------------
// Project Includes
#include <kmymoney/mymoneyutils.h>
#include <kmymoney/mymoneyinstitution.h>
#include <kmymoney/mymoneyaccount.h>
#include <kmymoney/mymoneytransaction.h>
#include <kmymoney/mymoneypayee.h>
#include <kmymoney/mymoneyscheduled.h>
#include <kmymoney/mymoneytransactionfilter.h>
#include <kmymoney/mymoneysecurity.h>
#include <kmymoney/mymoneyprice.h>
#include <kmymoney/mymoneyreport.h>
#include <kmymoney/mymoneybudget.h>
#include "mymoneystoragesql.h"
/**
* @author Thomas Baumgart
*/
/**
* This class represents the interface to serialize a MyMoneyStorage object
*/
class IMyMoneySerialize {
public:
IMyMoneySerialize();
virtual ~IMyMoneySerialize();
// general get functions
virtual const MyMoneyPayee user(void) const = 0;
virtual const TQDate creationDate(void) const = 0;
virtual const TQDate lastModificationDate(void) const = 0;
virtual unsigned int currentFixVersion(void) const = 0;
virtual unsigned int fileFixVersion(void) const = 0;
// general set functions
virtual void setUser(const MyMoneyPayee& val) = 0;
virtual void setCreationDate(const TQDate& val) = 0;
virtual void setFileFixVersion(const unsigned int v) = 0;
/**
* This method is used to get a SQL reader for subsequent database access
*/
virtual TDESharedPtr <MyMoneyStorageSql> connectToDatabase
(const KURL& url) = 0;
/**
* This method is used when a database file is open, and the data is to
* be saved in a different file or format. It will ensure that all data
* from the database is available in memory to enable it to be written.
*/
virtual void fillStorage() = 0;
/**
* This method is used to set the last modification date of
* the storage object. It also clears the dirty flag and should
* therefor be called as last operation when loading from a
* file.
*
* @param val TQDate of last modification
*/
virtual void setLastModificationDate(const TQDate& val) = 0;
/**
* This method returns a list of accounts inside the storage object.
*
* @param list reference to TQValueList receiving the account objects
*
* @note The standard accounts will not be returned
*/
virtual void accountList(TQValueList<MyMoneyAccount>& list) const = 0;
/**
* This method returns a list of the institutions
* inside a MyMoneyStorage object
*
* @return TQMap containing the institution information
*/
virtual const TQValueList<MyMoneyInstitution> institutionList(void) const = 0;
/**
* This method is used to pull a list of transactions from the file
* global transaction pool. It returns all those transactions
* that match the filter passed as argument. If the filter is empty,
* the whole journal will be returned.
*
* @param list reference to TQValueList<MyMoneyTransaction> receiving
* the set of transactions
* @param filter MyMoneyTransactionFilter object with the match criteria
*/
virtual void transactionList(TQValueList<MyMoneyTransaction>& list, MyMoneyTransactionFilter& filter) const = 0;
/**
* This method returns whether a given transaction is already in memory, to avoid
* reloading it from the database
*/
virtual bool isDuplicateTransaction(const TQString&) const = 0;
/**
* This method returns a list of the payees
* inside a MyMoneyStorage object
*
* @return TQValueList<MyMoneyPayee> containing the payee information
*/
virtual const TQValueList<MyMoneyPayee> payeeList(void) const = 0;
/**
* This method returns a list of the scheduled transactions
* inside a MyMoneyStorage object. In order to retrieve a complete
* list of the transactions, all arguments should be used with their
* default arguments.
*/
virtual const TQValueList<MyMoneySchedule> scheduleList(const TQString& = TQString(),
const MyMoneySchedule::typeE = MyMoneySchedule::TYPE_ANY,
const MyMoneySchedule::occurenceE = MyMoneySchedule::OCCUR_ANY,
const MyMoneySchedule::paymentTypeE = MyMoneySchedule::STYPE_ANY,
const TQDate& = TQDate(),
const TQDate& = TQDate(),
const bool = false) const = 0;
/**
* This method returns a list of security objects that the engine has
* knowledge of.
*/
virtual const TQValueList<MyMoneySecurity> securityList(void) const = 0;
/**
* This method is used to return the standard liability account
* @return MyMoneyAccount liability account(group)
*/
virtual const MyMoneyAccount liability(void) const = 0;
/**
* This method is used to return the standard asset account
* @return MyMoneyAccount asset account(group)
*/
virtual const MyMoneyAccount asset(void) const = 0;
/**
* This method is used to return the standard expense account
* @return MyMoneyAccount expense account(group)
*/
virtual const MyMoneyAccount expense(void) const = 0;
/**
* This method is used to return the standard income account
* @return MyMoneyAccount income account(group)
*/
virtual const MyMoneyAccount income(void) const = 0;
/**
* This method is used to return the standard equity account
* @return MyMoneyAccount equity account(group)
*/
virtual const MyMoneyAccount equity(void) const = 0;
/**
* This method is used to create a new account
*
* An exception will be thrown upon error conditions.
*
* @param account MyMoneyAccount filled with data
*/
virtual void addAccount(MyMoneyAccount& account) = 0;
/**
* This method is used to add one account as sub-ordinate to another
* (parent) account. The objects that are passed will be modified
* accordingly.
*
* An exception will be thrown upon error conditions.
*
* @param parent parent account the account should be added to
* @param account the account to be added
*
* @deprecated This method is only provided as long as we provide
* the version 0.4 binary reader. As soon as we deprecate
* this compatability mode this method will disappear from
* this interface!
*/
virtual void addAccount(MyMoneyAccount& parent, MyMoneyAccount& account) = 0;
/**
* This method is used to create a new payee
*
* An exception will be thrown upon error conditions
*
* @param payee MyMoneyPayee reference to payee information
*
* @deprecated This method is only provided as long as we provide
* the version 0.4 binary reader. As soon as we deprecate
* this compatability mode this method will disappear from
* this interface!
*
*/
virtual void addPayee(MyMoneyPayee& payee) = 0;
/**
* Adds an institution to the storage. A
* respective institution-ID will be generated within this record.
* The ID is stored as TQString in the object passed as argument.
*
* An exception will be thrown upon error conditions.
*
* @param institution The complete institution information in a
* MyMoneyInstitution object
*
* @deprecated This method is only provided as long as we provide
* the version 0.4 binary reader. As soon as we deprecate
* this compatability mode this method will disappear from
* this interface!
*/
virtual void addInstitution(MyMoneyInstitution& institution) = 0;
/**
* Adds a transaction to the file-global transaction pool. A respective
* transaction-ID will be generated within this record. The ID is stored
* as TQString with the object.
*
* An exception will be thrown upon error conditions.
*
* @param transaction reference to the transaction
* @param skipAccountUpdate if set, the transaction lists of the accounts
* referenced in the splits are not updated. This is used for
* bulk loading a lot of transactions but not during normal operation.
* Refreshing the account's transaction list can be done using
* refreshAllAccountTransactionList().
*
* @deprecated This method is only provided as long as we provide
* the version 0.4 binary reader. As soon as we deprecate
* this compatability mode this method will disappear from
* this interface!
*/
virtual void addTransaction(MyMoneyTransaction& transaction, const bool skipAccountUpdate = false) = 0;
virtual void loadAccounts(const TQMap<TQString, MyMoneyAccount>& map) = 0;
virtual void loadTransactions(const TQMap<TQString, MyMoneyTransaction>& map) = 0;
virtual void loadInstitutions(const TQMap<TQString, MyMoneyInstitution>& map) = 0;
virtual void loadPayees(const TQMap<TQString, MyMoneyPayee>& map) = 0;
virtual void loadSchedules(const TQMap<TQString, MyMoneySchedule>& map) = 0;
virtual void loadSecurities(const TQMap<TQString, MyMoneySecurity>& map) = 0;
virtual void loadCurrencies(const TQMap<TQString, MyMoneySecurity>& map) = 0;
virtual void loadReports( const TQMap<TQString, MyMoneyReport>& reports ) = 0;
virtual void loadBudgets( const TQMap<TQString, MyMoneyBudget>& budgets ) = 0;
virtual void loadPrices(const MyMoneyPriceList& list) = 0;
virtual unsigned long accountId(void) const = 0;
virtual unsigned long transactionId(void) const = 0;
virtual unsigned long payeeId(void) const = 0;
virtual unsigned long institutionId(void) const = 0;
virtual unsigned long scheduleId(void) const = 0;
virtual unsigned long securityId(void) const = 0;
virtual unsigned long reportId(void) const = 0;
virtual unsigned long budgetId(void) const = 0;
virtual void loadAccountId(const unsigned long id) = 0;
virtual void loadTransactionId(const unsigned long id) = 0;
virtual void loadPayeeId(const unsigned long id) = 0;
virtual void loadInstitutionId(const unsigned long id) = 0;
virtual void loadScheduleId(const unsigned long id) = 0;
virtual void loadSecurityId(const unsigned long id) = 0;
virtual void loadReportId(const unsigned long id) = 0;
virtual void loadBudgetId(const unsigned long id) = 0;
/**
* This method is used to retrieve the whole set of key/value pairs
* from the container. It is meant to be used for permanent storage
* functionality. See MyMoneyKeyValueContainer::pairs() for details.
*
* @return TQMap<TQString, TQString> containing all key/value pairs of
* this container.
*/
virtual const TQMap<TQString, TQString> pairs(void) const = 0;
/**
* This method is used to initially store a set of key/value pairs
* in the container. It is meant to be used for loading functionality
* from permanent storage. See MyMoneyKeyValueContainer::setPairs()
* for details
*
* @param list const TQMap<TQString, TQString> containing the set of
* key/value pairs to be loaded into the container.
*
* @note All existing key/value pairs in the container will be deleted.
*/
virtual void setPairs(const TQMap<TQString, TQString>& list) = 0;
virtual const TQValueList<MyMoneySchedule> scheduleListEx( int scheduleTypes,
int scheduleOcurrences,
int schedulePaymentTypes,
TQDate startDate,
const TQStringList& accounts=TQStringList()) const = 0;
/**
* This method is used to retrieve the list of all currencies
* known to the engine.
*
* An exception will be thrown upon erronous situations.
*
* @return TQValueList of all MyMoneySecurity objects representing a currency.
*/
virtual const TQValueList<MyMoneySecurity> currencyList(void) const = 0;
/**
* This method is used to retrieve the list of all reports
* known to the engine.
*
* An exception will be thrown upon erronous situations.
*
* @return TQValueList of all MyMoneyReport objects.
*/
virtual const TQValueList<MyMoneyReport> reportList( void ) const = 0;
/**
* This method is used to retrieve the list of all budgets
* known to the engine.
*
* An exception will be thrown upon erronous situations.
*
* @return TQValueList of all MyMoneyBudget objects.
*/
virtual const TQValueList<MyMoneyBudget> budgetList( void ) const = 0;
/**
* This method adds a price entry to the price list.
*/
virtual void addPrice(const MyMoneyPrice& price) = 0;
/**
* This method returns a list of all prices.
*
* @return MyMoneyPriceList of all MyMoneyPrice objects.
*/
virtual const MyMoneyPriceList priceList(void) const = 0;
/**
* This method recalculates the balances of all accounts
* based on the transactions stored in the engine.
*/
virtual void rebuildAccountBalances(void) = 0;
};
#endif
|