Month generation in progress
This commit is contained in:
parent
391aef379b
commit
ac5c26bc4f
|
@ -137,3 +137,8 @@ void KissCount::DeleteCategory(struct category category)
|
|||
{
|
||||
_db->DeleteCategory(_user, category);
|
||||
}
|
||||
|
||||
std::map<int, std::vector<int> > KissCount::GetAllOperations()
|
||||
{
|
||||
return _db->GetAllOperations(_user);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class KissCount
|
|||
void UpdateCategory(wxString oldName, struct category category);
|
||||
void DeleteCategory(struct category category);
|
||||
|
||||
std::map<int, std::vector<int> > GetAllOperations();
|
||||
private:
|
||||
wxUI* _wxUI;
|
||||
Database* _db;
|
||||
|
|
|
@ -555,3 +555,53 @@ void Database::DeleteCategory(User* user, struct category category)
|
|||
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
}
|
||||
|
||||
std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||
{
|
||||
wxString req;
|
||||
wxSQLite3ResultSet set, set2;
|
||||
std::vector<Account>::iterator it;
|
||||
std::map<int, std::vector<int> > res;
|
||||
int year;
|
||||
|
||||
if (!user->_accounts.empty())
|
||||
{
|
||||
it = user->_accounts.begin();
|
||||
req = _("SELECT DISTINCT year FROM account_amount WHERE account IN('") + it->id;
|
||||
it++;
|
||||
for (;it != user->_accounts.end(); it++)
|
||||
{
|
||||
req += _("', '") + it->id ;
|
||||
}
|
||||
req += _("') ORDER BY year ASC");
|
||||
|
||||
EXECUTE_SQL_QUERY(req, set, res);
|
||||
|
||||
while (set.NextRow())
|
||||
{
|
||||
year = set.GetInt(_("year"));
|
||||
|
||||
it = user->_accounts.begin();
|
||||
req = _("SELECT DISTINCT month FROM account_amount WHERE account IN('") + it->id;
|
||||
it++;
|
||||
for (;it != user->_accounts.end(); it++)
|
||||
{
|
||||
req += _("', '") + it->id ;
|
||||
}
|
||||
req += _("')");
|
||||
req += _(" AND year='") + set.GetAsString(_("year")) + _("'");
|
||||
req += _(" ORDER BY month ASC");
|
||||
|
||||
EXECUTE_SQL_QUERY(req, set2, res);
|
||||
|
||||
while (set2.NextRow())
|
||||
{
|
||||
res[year].push_back(set2.GetInt(_("month")));
|
||||
}
|
||||
set2.Finalize();
|
||||
}
|
||||
set.Finalize();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ class Database
|
|||
void UpdateCategory(User* user, wxString oldName, wxString name, wxString color);
|
||||
void DeleteCategory(User* user, struct category category);
|
||||
|
||||
std::map<int, std::vector<int> > GetAllOperations(User* user);
|
||||
|
||||
private:
|
||||
wxSQLite3Database _db;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, DELETE, CHECKED, NUMBER_COLS_OPS};
|
||||
enum {ACCOUNT_NUMBER, ACCOUNT_NAME, ACCOUNT_INIT, ACCOUNT_CUR, ACCOUNT_FINAL, NUMBER_COLS_ACCOUNTS};
|
||||
enum {CUR_CREDIT, CUR_DEBIT, TOTAL_CREDIT, TOTAL_DEBIT, REMAINS, STATS_ROW, CATS_STATS};
|
||||
enum {CALENDAR_TREE_ID=10, OPS_GRID_ID, ACCOUNTS_GRID_ID};
|
||||
enum {CALENDAR_TREE_ID=10, OPS_GRID_ID, ACCOUNTS_GRID_ID, MENU_GENERATE_ID, MENU_DELETE_ID};
|
||||
|
||||
static wxString colsName[] = {_("Description"), _("Date"), _("Debit"), _("Credit"), _("Category"), _("Account"), _(""), _("")};
|
||||
|
||||
|
@ -13,6 +13,8 @@ BEGIN_EVENT_TABLE(AccountPanel, wxPanel)
|
|||
EVT_TREE_ITEM_RIGHT_CLICK(CALENDAR_TREE_ID, AccountPanel::OnTreeRightClick)
|
||||
EVT_TREE_SEL_CHANGED(CALENDAR_TREE_ID, AccountPanel::OnTreeChange)
|
||||
EVT_TREE_KEY_DOWN(CALENDAR_TREE_ID, AccountPanel::OnTreeChange)
|
||||
EVT_MENU(MENU_GENERATE_ID, AccountPanel::OnMenuGenerate)
|
||||
EVT_MENU(MENU_DELETE_ID, AccountPanel::OnMenuDelete)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _tree(this, CALENDAR_TREE_ID, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT)
|
||||
|
@ -781,6 +783,14 @@ void AccountPanel::OnAccountModified(wxGridEvent& event)
|
|||
void AccountPanel::OnTreeRightClick(wxTreeEvent& event)
|
||||
{
|
||||
// ShowMonth(2010,4);
|
||||
wxMenu menu(0);
|
||||
|
||||
menu.Append(MENU_GENERATE_ID, _("Generate month"));
|
||||
menu.AppendSeparator();
|
||||
if (_tree.GetCount() > 1)
|
||||
menu.Append(MENU_DELETE_ID, _("Delete"));
|
||||
|
||||
PopupMenu(&menu, event.GetPoint());
|
||||
}
|
||||
|
||||
void AccountPanel::OnTreeChange(wxTreeEvent& event)
|
||||
|
@ -842,3 +852,44 @@ void AccountPanel::OnTreeChange(wxTreeEvent& event)
|
|||
|
||||
inModification = false;
|
||||
}
|
||||
|
||||
void AccountPanel::OnMenuGenerate(wxCommandEvent& event)
|
||||
{
|
||||
wxString monthString;
|
||||
int month, year, i;
|
||||
|
||||
month = year = -1;
|
||||
|
||||
monthString = _tree.GetItemText(_tree.GetSelection());
|
||||
for (i=0; i<12; i++)
|
||||
if (monthString == months[i])
|
||||
{
|
||||
month = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (month == -1)
|
||||
{
|
||||
year = wxAtoi(monthString);
|
||||
|
||||
// Error
|
||||
if (year == 0)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
year = wxAtoi(_tree.GetItemText(_tree.GetItemParent(_tree.GetSelection())));
|
||||
|
||||
// Error
|
||||
if (year == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
GenerateDialog g(_kiss, _wxUI, month, year);
|
||||
g.ShowModal();
|
||||
}
|
||||
|
||||
void AccountPanel::OnMenuDelete(wxCommandEvent& event)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
void OnAccountModified(wxGridEvent& event);
|
||||
void OnTreeRightClick(wxTreeEvent& event);
|
||||
void OnTreeChange(wxTreeEvent& event);
|
||||
void OnMenuGenerate(wxCommandEvent& event);
|
||||
void OnMenuDelete(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
|
|
|
@ -268,8 +268,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
|
|||
|
||||
if (user->GetAccountId(new_account.name) != _("0"))
|
||||
{
|
||||
wxMessageDialog dialog(_wxUI, _("Account ")+new_account.name+_(" already exists"), _("Error"), wxOK);
|
||||
dialog.ShowModal();
|
||||
wxMessageBox(_("Account ")+new_account.name+_(" already exists"), _("Error"), wxICON_ERROR | wxOK );
|
||||
inModification = false;
|
||||
return ;
|
||||
}
|
||||
|
@ -363,6 +362,13 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
|
|||
return ;
|
||||
}
|
||||
|
||||
if (user->GetCategoryId(new_cat.name) != _("0"))
|
||||
{
|
||||
wxMessageBox(_("Category ")+new_cat.name+_(" already exists"), _("Error"), wxICON_ERROR | wxOK );
|
||||
inModification = false;
|
||||
return ;
|
||||
}
|
||||
|
||||
_kiss->AddCategory(new_cat);
|
||||
_categoriesGrid->SetReadOnly(row, CATEGORY_COLOR, false);
|
||||
_categoriesGrid->SetReadOnly(row, CATEGORY_FONT, false);
|
||||
|
|
|
@ -44,11 +44,11 @@ UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), -
|
|||
vbox->Add(-1, 40);
|
||||
vbox->Add(hbox1, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10);
|
||||
|
||||
Center();
|
||||
SetSizer(vbox);
|
||||
|
||||
_users->SetFocus();
|
||||
Layout();
|
||||
Center();
|
||||
}
|
||||
|
||||
void UsersDialog::OnOK(wxCommandEvent& event)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "ButtonPanel.h"
|
||||
#include "PreferencesPanel.h"
|
||||
#include "UsersDialog.h"
|
||||
#include "GenerateDialog.h"
|
||||
#include <controller/KissCount.h>
|
||||
|
||||
class KissCount;
|
||||
|
|
Loading…
Reference in New Issue
Block a user