2010-07-10 16:34:30 +02:00
|
|
|
/*
|
2011-01-29 13:04:15 +01:00
|
|
|
Copyright 2010-2011 Grégory Soutadé
|
2010-07-10 16:34:30 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
This file is part of KissCount.
|
2010-07-10 16:34:30 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
KissCount 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2010-07-10 16:34:30 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
KissCount is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2010-07-10 16:34:30 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
2010-07-10 16:34:30 +02:00
|
|
|
*/
|
|
|
|
|
2010-05-14 15:04:01 +02:00
|
|
|
#ifndef KISSCOUNT_H
|
|
|
|
#define KISSCOUNT_H
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
2011-08-20 14:02:47 +02:00
|
|
|
#include <model/import/ImportEngine.hpp>
|
|
|
|
#include <model/export/ExportEngine.hpp>
|
|
|
|
#include <model/model.hpp>
|
2010-05-14 15:04:01 +02:00
|
|
|
|
2010-09-22 21:02:29 +02:00
|
|
|
#include <wx/display.h>
|
|
|
|
|
2011-08-20 14:02:47 +02:00
|
|
|
#include <view/wxUI.hpp>
|
2011-08-20 11:43:12 +02:00
|
|
|
|
2011-07-24 17:11:03 +02:00
|
|
|
#define APP_VERSION "0.3"
|
2010-08-14 22:04:03 +02:00
|
|
|
|
2011-07-03 07:56:48 +02:00
|
|
|
#define ESCAPE_CHARS(s) { \
|
|
|
|
if (s.Find(wxT("\\\"")) == wxNOT_FOUND) \
|
|
|
|
s.Replace(wxT("\""), wxT("\\\""), true); \
|
|
|
|
if (s.Find(wxT("\\\'")) == wxNOT_FOUND) \
|
|
|
|
s.Replace(wxT("\'"), wxT("\\\'"), true); \
|
|
|
|
}
|
|
|
|
|
2011-07-04 20:23:00 +02:00
|
|
|
#define UNESCAPE_CHARS(s) { \
|
|
|
|
s.Replace(wxT("\\\""), wxT("\""), true); \
|
|
|
|
s.Replace(wxT("\\\'"), wxT("\'"), true); \
|
|
|
|
}
|
2010-05-14 15:04:01 +02:00
|
|
|
class wxUI;
|
2010-09-08 11:02:03 +02:00
|
|
|
class Database;
|
2011-03-13 19:15:21 +01:00
|
|
|
class ImportEngine;
|
2011-07-03 07:56:48 +02:00
|
|
|
class ExportEngine;
|
2010-09-08 11:02:03 +02:00
|
|
|
|
2010-05-14 15:04:01 +02:00
|
|
|
class KissCount
|
|
|
|
{
|
2010-08-26 21:28:15 +02:00
|
|
|
public:
|
|
|
|
KissCount(const char* bdd_filename);
|
|
|
|
~KissCount();
|
2010-05-14 15:04:01 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
std::list<wxString> GetUsers();
|
|
|
|
bool IsValidUser(const wxString& user, const wxString& password);
|
|
|
|
void LoadUser(const wxString& user);
|
|
|
|
User* GetUser();
|
|
|
|
void ChangePassword(const wxString& password);
|
|
|
|
bool UserExists(const wxString& name);
|
|
|
|
void ChangeName(const wxString& name);
|
|
|
|
void NewUser(const wxString& name);
|
2010-06-22 11:35:21 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
void LoadYear(int year, bool force=false);
|
2010-06-22 11:35:21 +02:00
|
|
|
|
2011-07-04 20:23:00 +02:00
|
|
|
wxString AddOperation(Operation& op, bool checkTransfert=true);
|
|
|
|
void UpdateOperation(Operation& op, bool checkTransfert=true);
|
2010-08-26 21:28:15 +02:00
|
|
|
void DeleteOperation(Operation& op);
|
|
|
|
void DeleteOperations(int month, int year);
|
2010-10-24 16:04:56 +02:00
|
|
|
double MetaAmount(const wxString& id);
|
|
|
|
double MetaPositiveAmount(const wxString& id);
|
2010-06-22 11:35:21 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
double GetAccountAmount(const wxString& id, int month, int year);
|
2011-07-04 20:23:00 +02:00
|
|
|
void SetAccountAmount(const wxString& accountId, int month, int year, double value);
|
2011-01-29 20:53:44 +01:00
|
|
|
double CalcAccountAmount(const wxString& id, int month, int year, bool* had_values);
|
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
wxString AddAccount(Account& ac);
|
|
|
|
void UpdateAccount(Account& ac);
|
2011-02-08 21:17:35 +01:00
|
|
|
void DeleteAccount(Account& ac, const wxString& replacement);
|
2010-10-20 20:54:23 +02:00
|
|
|
void AddSharedAccount(Account& ac, const wxString& granted);
|
2010-10-24 16:04:56 +02:00
|
|
|
void RemoveSharedAccount(Account& ac, const wxString& granted);
|
|
|
|
std::map<wxString, wxString> getSharedAccountOwners(const wxString& account);
|
|
|
|
wxString getSharedAccountOwner(const wxString& account);
|
2010-06-02 22:14:11 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
wxString AddCategory(Category& category);
|
|
|
|
void UpdateCategory(Category& category);
|
2011-02-08 21:17:35 +01:00
|
|
|
void DeleteCategory(Category& category, const wxString& replacement);
|
2010-06-22 11:35:21 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
std::map<int, std::vector<int> > GetAllOperations();
|
2010-06-23 19:32:42 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
void GenerateMonth(int monthFrom, int yearFrom, int monthTo, int yearTo);
|
|
|
|
void KillMe();
|
2010-07-07 21:04:38 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
void SetLanguage(wxLanguage language);
|
|
|
|
void SetOperationOrder(const wxString& order);
|
2011-03-20 19:08:24 +01:00
|
|
|
const wxString& GetOperationOrder();
|
2010-07-14 16:22:02 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
std::vector<Operation>* Search(wxString* description, wxDateTime* dateFrom, wxDateTime* dateTo,
|
|
|
|
wxString* amountFrom, wxString* amountTo,
|
2010-12-01 20:30:34 +01:00
|
|
|
std::vector<wxString> categories, int types, std::vector<wxString> accounts);
|
2010-07-17 12:33:39 +02:00
|
|
|
|
2011-03-20 19:08:24 +01:00
|
|
|
bool SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType);
|
2010-08-17 18:59:19 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
void GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
|
|
|
std::map<wxString, std::map<int, std::map<int, double> > >* accountAmounts,
|
|
|
|
std::map<wxString, double>* categories);
|
2010-08-17 18:59:19 +02:00
|
|
|
|
2010-11-19 19:58:02 +01:00
|
|
|
void GetMonthStats(int month, int year, int nbDays,
|
|
|
|
std::map<wxString, std::vector<double> >* operations,
|
|
|
|
std::map<wxString, double>* categories);
|
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
std::map<wxString, double>* GetNotChecked(int month, int year);
|
2011-02-14 20:56:59 +01:00
|
|
|
std::map<wxString, double>* GetVirtualAmount(int month, int year);
|
2010-08-21 11:49:03 +02:00
|
|
|
|
2010-10-24 16:04:56 +02:00
|
|
|
static wxFont ExtractFont(wxString strFont);
|
|
|
|
static wxString CompactFont(const wxFont& font);
|
2010-09-08 11:02:03 +02:00
|
|
|
|
2011-03-13 19:15:21 +01:00
|
|
|
static void RegisterImportEngine(ImportEngine* engine);
|
|
|
|
static void UnRegisterImportEngine(ImportEngine* engine);
|
|
|
|
|
|
|
|
wxString GetImportEngineExtensions();
|
|
|
|
ImportEngine* GetImportEngine(wxString path);
|
|
|
|
|
2011-07-03 07:56:48 +02:00
|
|
|
static void RegisterExportEngine(ExportEngine* engine);
|
|
|
|
static void UnRegisterExportEngine(ExportEngine* engine);
|
|
|
|
|
|
|
|
wxString GetExportEngineExtensions();
|
|
|
|
ExportEngine* GetExportEngine(wxString path);
|
|
|
|
|
2011-03-23 20:35:29 +01:00
|
|
|
void UpdateImportPattern();
|
2011-07-03 07:56:48 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
private:
|
|
|
|
wxUI* _wxUI;
|
|
|
|
Database* _db;
|
|
|
|
User* _user;
|
2011-07-03 07:56:48 +02:00
|
|
|
|
|
|
|
static std::vector<ImportEngine*> *GetImportEngines();
|
|
|
|
static std::vector<ExportEngine*> *GetExportEngines();
|
|
|
|
|
|
|
|
static std::vector<ImportEngine*> *_importEngines;
|
|
|
|
static std::vector<ExportEngine*> *_exportEngines;
|
2010-05-14 15:04:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|