Fix some bugs and resize images
|
@ -448,8 +448,26 @@ void Database::SetAccountAmount(int month, int year, wxString accountId, double
|
||||||
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
|
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
|
||||||
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
|
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
|
||||||
|
|
||||||
|
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, );
|
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)
|
wxString Database::AddAccount(User* user, struct Account ac)
|
||||||
{
|
{
|
||||||
|
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 16 KiB |
|
@ -355,8 +355,6 @@ void AccountPanel::ShowMonth(int month, int year)
|
||||||
|
|
||||||
InitAccountsGrid(user, month, year);
|
InitAccountsGrid(user, month, year);
|
||||||
|
|
||||||
UpdateStats();
|
|
||||||
|
|
||||||
_calendar->EnableMonthChange(true);
|
_calendar->EnableMonthChange(true);
|
||||||
_calendar->EnableYearChange(true);
|
_calendar->EnableYearChange(true);
|
||||||
if (curDate.GetMonth() == month && curDate.GetYear() == year)
|
if (curDate.GetMonth() == month && curDate.GetYear() == year)
|
||||||
|
@ -370,6 +368,8 @@ void AccountPanel::ShowMonth(int month, int year)
|
||||||
_calendar->EnableYearChange(false);
|
_calendar->EnableYearChange(false);
|
||||||
_calendar->SetSize(_calendar->GetMinSize());
|
_calendar->SetSize(_calendar->GetMinSize());
|
||||||
|
|
||||||
|
UpdateStats();
|
||||||
|
|
||||||
// Fit();
|
// Fit();
|
||||||
// SetMinSize(GetSize());
|
// 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_NUMBER, it->number);
|
||||||
_accountsGrid->SetCellValue(curLine, ACCOUNT_NAME, it->name);
|
_accountsGrid->SetCellValue(curLine, ACCOUNT_NAME, it->name);
|
||||||
value = _kiss->GetAccountAmount(it->id, month, year);
|
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->SetCellEditor(curLine, ACCOUNT_INIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
|
_accountsGrid->SetCellValue(curLine, ACCOUNT_INIT, wxString::Format(wxT("%.2lf"), value));
|
||||||
for (a=0; a<NUMBER_COLS_ACCOUNTS; a++)
|
for (a=0; a<NUMBER_COLS_ACCOUNTS; a++)
|
||||||
_accountsGrid->SetReadOnly(curLine, a, a != ACCOUNT_INIT);
|
_accountsGrid->SetReadOnly(curLine, a, a != ACCOUNT_INIT);
|
||||||
_accountsGrid->SetCellFont(curLine, ACCOUNT_CUR, font);
|
_accountsGrid->SetCellFont(curLine, ACCOUNT_CUR, font);
|
||||||
|
@ -510,18 +510,13 @@ void AccountPanel::UpdateStats()
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
std::vector<operation>::iterator it;
|
std::vector<operation>::iterator it;
|
||||||
double curCredit, curDebit, totalCredit, totalDebit, remains, value;
|
double curCredit, curDebit, totalCredit, totalDebit, remains, value;
|
||||||
wxDateTime date;
|
|
||||||
std::map<wxString, double> curAccountAmount, finalAccountAmount;
|
std::map<wxString, double> curAccountAmount, finalAccountAmount;
|
||||||
std::map<wxString, double>::iterator doubleIt;
|
std::map<wxString, double>::iterator doubleIt;
|
||||||
std::map<wxString, int>::iterator intIt;
|
std::map<wxString, int>::iterator intIt;
|
||||||
std::vector<Account>::iterator accountIt;
|
std::vector<Account>::iterator accountIt;
|
||||||
unsigned int day, month, year ;
|
unsigned int day;
|
||||||
|
|
||||||
date = _calendar->GetDate();
|
|
||||||
day = date.GetDay()-1;
|
|
||||||
month = date.GetMonth();
|
|
||||||
year = date.GetYear();
|
|
||||||
|
|
||||||
|
day = _calendar->GetDate().GetDay()-1;
|
||||||
curCredit = curDebit = totalCredit = totalDebit = 0.0;
|
curCredit = curDebit = totalCredit = totalDebit = 0.0;
|
||||||
|
|
||||||
for (i=0; i<user->GetCategoriesNumber(); i++)
|
for (i=0; i<user->GetCategoriesNumber(); i++)
|
||||||
|
@ -537,7 +532,7 @@ void AccountPanel::UpdateStats()
|
||||||
{
|
{
|
||||||
if (it->amount > 0)
|
if (it->amount > 0)
|
||||||
{
|
{
|
||||||
if (day >= it->day && month >= it->month && year >= it->year)
|
if (day >= it->day)
|
||||||
{
|
{
|
||||||
curCredit += it->amount;
|
curCredit += it->amount;
|
||||||
curAccountAmount[it->account] += it->amount;
|
curAccountAmount[it->account] += it->amount;
|
||||||
|
@ -548,7 +543,7 @@ void AccountPanel::UpdateStats()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(it->category)]] += -it->amount ;
|
_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;
|
curDebit += -it->amount;
|
||||||
curAccountAmount[it->account] += it->amount;
|
curAccountAmount[it->account] += it->amount;
|
||||||
|
|