Project

General

Profile

Download (6.67 KB) Statistics
| Branch: | Tag: | Revision:

aqfinance / src / fox / lib / ff_app.hpp @ 200398b3

1
/****************************************************************************
2
 * This file is part of the project AqFinance.
3
 * AqFinance (c) by 2018 Martin Preuss, all rights reserved.
4
 *
5
 * The license for this file can be found in the file COPYING which you
6
 * should have received along with this file.
7
 ****************************************************************************/
8

    
9
#ifndef FF_APP_HPP
10
#define FF_APP_HPP
11

    
12

    
13

    
14
#include <fx.h>
15

    
16
#include <aqfoxext/fxx_app.hpp>
17

    
18
#include <aqfinance/engine/lib/book/ae_book.h>
19

    
20
#include <aqbanking/banking.h>
21

    
22

    
23
class FF_ModuleManager;
24

    
25
class FXXIconSet;
26

    
27

    
28
#include "ff_appspec.h"
29

    
30

    
31
#define FF_APP_CACHE_MAX_ENTRIES ((uint32_t)(10000))
32
#define FF_APP_CACHE_MAX_SIZE    ((uint32_t)(10*1024*1024))
33

    
34

    
35
#define FF_APP_YELLOW1 (FXRGB(255, 234, 84))
36
#define FF_APP_YELLOW2 (FXRGB(255, 244, 164))
37

    
38

    
39

    
40

    
41
class FF_App: public FXXApp {
42
public:
43
  FF_App(const FXString& name="AqFinance",
44
         const FXString& vendor="Aquamaniac");
45
  ~FF_App();
46

    
47
  void init(int& argc, char** argv, bool connect=true);
48
  void fini();
49

    
50
  int loadSettings();
51
  int saveSettings();
52

    
53
  void setBook(AE_BOOK *b) { m_book=b;};
54
  AE_BOOK *getBook() const { return m_book;};
55

    
56
  FF_ModuleManager *getModuleManager() const { return m_moduleManager;};
57
  void setModuleManager(FF_ModuleManager *mm) { m_moduleManager=mm;};
58

    
59
  AB_BANKING *getBanking() const { return m_banking;};
60
  void setBanking(AB_BANKING *ab) { m_banking=ab;};
61

    
62
  /**
63
   * Get a unique id for the given name.
64
   * AqFinance stores a uniqueId counter for every "idName" for which such an id is requested.
65
   * The first id returned for every name is "1".
66
   */
67
  int getNamedUniqueId(const char *idName);
68

    
69

    
70
  FXXIconSet *getIconSet(const FXString &name);
71

    
72
  void signalDbOpened(AE_BOOK *bk);
73
  void signalDbClosing();
74
  void signalDbClosed();
75
  void signalDbReload(AE_BOOK_TABLE_TYPE tt);
76

    
77
  void signalJobListUpdated();
78
  void signalAboutToSendJobs();
79

    
80
  bool dbCheckDeleteObject(FXWindow *parent,
81
                           AE_BOOK_TABLE_TYPE tt,
82
                           AQDB_ID id);
83

    
84
  AB_TRANSACTION_LIST *getJobList() const { return m_jobList;};
85
  void addJobToList(AB_TRANSACTION *j);
86
  int cancelJob(AB_TRANSACTION *j, bool doLock);
87

    
88

    
89
  int importContext(FXWindow *p, AB_IMEXPORTER_CONTEXT *ctx);
90
  int importAsTransactions(FXWindow *p, AE_STATEMENT_LIST *sl);
91

    
92
  AE_ACCOUNT *getPartnerReceivableAccount(FXWindow *p,
93
                                          AE_ACCOUNT_TREE *at,
94
                                          const AE_PARTNER *pt,
95
                                          int doLock);
96
  AE_ACCOUNT *getPartnerPayableAccount(FXWindow *p,
97
                                       AE_ACCOUNT_TREE *at,
98
                                       const AE_PARTNER *pt,
99
                                       int doLock);
100

    
101
  AE_ACCOUNT *getCashAccount(FXWindow *p,
102
                             AE_ACCOUNT_TREE *at,
103
                             const AE_COMMODITY *co,
104
                             int doLock);
105

    
106
  int addAccount(FXWindow *p,
107
                 AE_ACCOUNT_TREE *at,
108
                 AE_BOOK_TABLE_TYPE tt,
109
                 AE_ACCOUNT *acc,
110
                 int doLock);
111

    
112
  //int addAccount(AE_BOOK_TABLE_TYPE tt, AE_ACCOUINT *acc, int doLock);
113

    
114
  int execStatement(FXWindow *p, AE_STATEMENT *st, AQDB_ID tid);
115

    
116

    
117
  bool checkTransaction(FXWindow *p,
118
                        AE_ACCOUNT_TREE *at,
119
                        AE_COMMODITY_LIST *cl,
120
                        const AE_TRANSACTION *t,
121
                        bool quiet);
122

    
123
  bool checkTransaction(FXWindow *p,
124
                        const AE_TRANSACTION *t,
125
                        bool quiet);
126

    
127
  FXColor getAccountColorAsset() const { return m_accountColor_asset;};
128
  FXColor getAccountColorLiability() const { return m_accountColor_liability;};
129
  FXColor getAccountColorEquity() const { return m_accountColor_equity;};
130
  FXColor getAccountColorIncome() const { return m_accountColor_income;};
131
  FXColor getAccountColorExpense() const { return m_accountColor_expense;};
132
  FXColor getAccountColor(AE_ACCOUNT_TYPE t) const;
133

    
134
  bool getUseAccountingTerms() const { return m_useAccountingTerms;};
135
  void setUseAccountingTerms(bool b) { m_useAccountingTerms=b;};
136

    
137
  bool getShowBankAccountGraphs() const { return m_showBankAccountGraphs;};
138
  void setShowBankAccountGraphs(bool b) { m_showBankAccountGraphs=b;};
139

    
140
  uint32_t getCacheMaxEntries() const { return m_cacheMaxEntries;};
141
  void setCacheMaxEntries(uint32_t i) { m_cacheMaxEntries=i;};
142

    
143
  uint32_t getCacheMaxSize() const { return m_cacheMaxSize;};
144
  void setCacheMaxSize(uint32_t i) { m_cacheMaxSize=i;};
145

    
146
  bool getUsePasswordStore() const { return m_usePasswordStore;};
147
  void setUsePasswordStore(bool b) { m_usePasswordStore=b;};
148

    
149
  int getAcceptedMaturity() const { return m_acceptedMaturity;};
150
  void setAcceptedMaturity(int m) { m_acceptedMaturity=m;};
151

    
152

    
153
  const FF_APPSPEC_LIST *getAppSpecsPdfViewer() const { return m_appSpecsPdfViewer;};
154
  const FXString &getPdfViewerName() const { return m_pdfViewerName;};
155
  void setPdfViewerName(const FXString &s) { m_pdfViewerName=s;};
156

    
157
  const FF_APPSPEC_LIST *getAppSpecsEmailClient() const { return m_appSpecsEmailClient;};
158
  const FXString &getEmailClientName() const { return m_emailClientName;};
159
  void setEmailClientName(const FXString &s) { m_emailClientName=s;};
160

    
161
  bool deleteAccount(AQDB_ID id);
162
  bool deleteBankAccount(AQDB_ID id);
163
  bool deleteTransaction(AQDB_ID id);
164
  bool deleteJob(AQDB_ID id);
165
  bool deleteTask(AQDB_ID id);
166
  bool deletePartner(AQDB_ID id);
167
  bool deletePartnerGroup(AQDB_ID id);
168

    
169
  int presentConflictList(const FXString &title,
170
                          const FXString &text,
171
                          AE_DBCONFLICT_LIST *tmpList);
172

    
173
  int viewPdfFile(const char *fname, GWEN_DB_NODE *db);
174
  int emailPdfFile(const char *fname, GWEN_DB_NODE *db);
175

    
176
  int createLoadCellPhoneJob(const AE_LOAD_CELLPHONE *lc, AB_TRANSACTION **pJob);
177

    
178
  GWEN_CONFIGMGR *getConfigManager();
179

    
180
protected:
181
  int _importContext(FXWindow *p, AB_IMEXPORTER_CONTEXT *ctx,
182
                     AE_STATEMENT_LIST *statementsToImport);
183
  int _handleConflicts(const FXString &title,
184
                       const FXString &text,
185
                       AQDB_ACTION_TYPE action,
186
                       AE_BOOK_TABLE_TYPE tt,
187
                       AQDB_ID oid);
188

    
189
  int _loadAppSpecs(const char *typeName, FF_APPSPEC_LIST *spList);
190
  void _genPdfAppSpecs();
191
  void _genEmailAppSpecs();
192

    
193
  int _execWithArgs(const FF_APPSPEC_LIST *asl, const FXString &an,
194
                    const char *fname, GWEN_DB_NODE *db);
195

    
196
  int _cancelSingleTransferJob(AB_TRANSACTION *j, bool doLock);
197
  int _cancelCreateStoJob(AB_TRANSACTION *j, bool doLock);
198
  int _cancelModifyStoJob(AB_TRANSACTION *j, bool doLock);
199

    
200

    
201
  AE_BOOK *m_book;
202
  FF_ModuleManager *m_moduleManager;
203
  AB_BANKING *m_banking;
204

    
205
  FXColor m_accountColor_asset;
206
  FXColor m_accountColor_liability;
207
  FXColor m_accountColor_equity;
208
  FXColor m_accountColor_income;
209
  FXColor m_accountColor_expense;
210

    
211
  bool m_useAccountingTerms;
212
  bool m_showBankAccountGraphs;
213
  FF_APPSPEC_LIST *m_appSpecsPdfViewer;
214
  FXString m_pdfViewerName;
215

    
216
  FF_APPSPEC_LIST *m_appSpecsEmailClient;
217
  FXString m_emailClientName;
218

    
219
  uint32_t m_cacheMaxEntries;
220
  uint32_t m_cacheMaxSize;
221
  bool m_usePasswordStore;
222
  int m_acceptedMaturity;
223

    
224
  AB_TRANSACTION_LIST *m_jobList;
225
};
226

    
227

    
228

    
229
#endif
230