diff --git a/model/Database.cpp b/model/Database.cpp index 2fed959..896b9da 100644 --- a/model/Database.cpp +++ b/model/Database.cpp @@ -448,7 +448,25 @@ void Database::SetAccountAmount(int month, int year, wxString accountId, double req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'"); req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'"); - EXECUTE_SQL_UPDATE(req, ); + try + { + if (!_db.ExecuteUpdate(req)) + { + req = _("INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('") ; + req += accountId + _("'"); + req += _(" ,'") + wxString::Format(_("%d"), year) + _("'"); + req += _(" ,'") + wxString::Format(_("%d"), month) + _("'"); + req += _(" ,'") + DoubleToString(amount) + _("'"); + req += _(")"); + EXECUTE_SQL_UPDATE(req, ); + } + } + catch (wxSQLite3Exception e) + { + std::cerr << req.mb_str() << "\n" ; + std::cerr << e.GetMessage().mb_str() << "\n" ; + return ; + } } wxString Database::AddAccount(User* user, struct Account ac) diff --git a/ressources/Clients-icon.png b/ressources/Clients-icon.png index 7f813f4..a2c79bf 100644 Binary files a/ressources/Clients-icon.png and b/ressources/Clients-icon.png differ diff --git a/ressources/administrator-icon.png b/ressources/administrator-icon.png index 1c32321..4ebab8a 100644 Binary files a/ressources/administrator-icon.png and b/ressources/administrator-icon.png differ diff --git a/ressources/chart-icon.png b/ressources/chart-icon.png index 3e7b386..308bcbe 100644 Binary files a/ressources/chart-icon.png and b/ressources/chart-icon.png differ diff --git a/ressources/options-icon.png b/ressources/options-icon.png index 18c6f75..21e12e6 100644 Binary files a/ressources/options-icon.png and b/ressources/options-icon.png differ diff --git a/view/AccountPanel.cpp b/view/AccountPanel.cpp index 357a1bc..82cc8c9 100644 --- a/view/AccountPanel.cpp +++ b/view/AccountPanel.cpp @@ -355,8 +355,6 @@ void AccountPanel::ShowMonth(int month, int year) InitAccountsGrid(user, month, year); - UpdateStats(); - _calendar->EnableMonthChange(true); _calendar->EnableYearChange(true); if (curDate.GetMonth() == month && curDate.GetYear() == year) @@ -370,6 +368,8 @@ void AccountPanel::ShowMonth(int month, int year) _calendar->EnableYearChange(false); _calendar->SetSize(_calendar->GetMinSize()); + UpdateStats(); + // Fit(); // SetMinSize(GetSize()); } @@ -489,8 +489,8 @@ void AccountPanel::InitAccountsGrid(User* user, int month, int year) _accountsGrid->SetCellValue(curLine, ACCOUNT_NUMBER, it->number); _accountsGrid->SetCellValue(curLine, ACCOUNT_NAME, it->name); value = _kiss->GetAccountAmount(it->id, month, year); - _accountsGrid->SetCellValue(curLine, ACCOUNT_INIT, wxString::Format(wxT("%.2lf"), value)); _accountsGrid->SetCellEditor(curLine, ACCOUNT_INIT, new wxGridCellFloatEditor(-1, 2)); + _accountsGrid->SetCellValue(curLine, ACCOUNT_INIT, wxString::Format(wxT("%.2lf"), value)); for (a=0; aSetReadOnly(curLine, a, a != ACCOUNT_INIT); _accountsGrid->SetCellFont(curLine, ACCOUNT_CUR, font); @@ -510,18 +510,13 @@ void AccountPanel::UpdateStats() User* user = _kiss->GetUser(); std::vector::iterator it; double curCredit, curDebit, totalCredit, totalDebit, remains, value; - wxDateTime date; std::map curAccountAmount, finalAccountAmount; std::map::iterator doubleIt; std::map::iterator intIt; std::vector::iterator accountIt; - unsigned int day, month, year ; - - date = _calendar->GetDate(); - day = date.GetDay()-1; - month = date.GetMonth(); - year = date.GetYear(); + unsigned int day; + day = _calendar->GetDate().GetDay()-1; curCredit = curDebit = totalCredit = totalDebit = 0.0; for (i=0; iGetCategoriesNumber(); i++) @@ -537,7 +532,7 @@ void AccountPanel::UpdateStats() { if (it->amount > 0) { - if (day >= it->day && month >= it->month && year >= it->year) + if (day >= it->day) { curCredit += it->amount; curAccountAmount[it->account] += it->amount; @@ -548,7 +543,7 @@ void AccountPanel::UpdateStats() else { _categoriesValues[_categoriesIndexes[user->GetCategoryName(it->category)]] += -it->amount ; - if (day >= it->day && month >= it->month && year >= it->year) + if (day >= it->day) { curDebit += -it->amount; curAccountAmount[it->account] += it->amount;