Fix float bug && account update stats bug
This commit is contained in:
parent
3ea364b22f
commit
224e1e6d99
|
@ -42,6 +42,16 @@
|
|||
|
||||
#define EXECUTE_SQL_UPDATE(req, return_value) EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, {}, {})
|
||||
|
||||
static inline wxString DoubleToString(double d)
|
||||
{
|
||||
wxString res;
|
||||
|
||||
res = wxString::Format(_("%.2lf"), d);
|
||||
res.Replace(_(","), _("."));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Database::Database()
|
||||
{
|
||||
std::ifstream bdd_file;
|
||||
|
@ -323,7 +333,7 @@ void Database::UpdateOperation(struct operation op)
|
|||
req += _(", year='") + wxString::Format(_("%d"), op.year) + _("'");
|
||||
req += _(", month='") + wxString::Format(_("%d"), op.month) + _("'");
|
||||
req += _(", day='") + wxString::Format(_("%d"), op.day) + _("'");
|
||||
req += _(", amount='") + wxString::Format(_("%.2lf"), op.amount) + _("'");
|
||||
req += _(", amount='") + DoubleToString(op.amount) + _("'");
|
||||
req += _(", description=\"") + op.description + _("\"");
|
||||
req += _(", category='") + op.category + _("'");
|
||||
if (op.checked)
|
||||
|
@ -348,7 +358,7 @@ wxString Database::AddOperation(User* user, struct operation op)
|
|||
req += _(", '") + wxString::Format(_("%d"), op.year) + _("'");
|
||||
req += _(", '") + wxString::Format(_("%d"), op.month) + _("'");
|
||||
req += _(", '") + wxString::Format(_("%d"), op.day) + _("'");
|
||||
req += _(", '") + wxString::Format(_("%.2lf"), op.amount) + _("'");
|
||||
req += _(", '") + DoubleToString(op.amount) + _("'");
|
||||
req += _(", \"") + op.description + _("\"");
|
||||
req += _(", '") + op.category + _("'");
|
||||
if (op.fix_cost)
|
||||
|
@ -365,7 +375,7 @@ wxString Database::AddOperation(User* user, struct operation op)
|
|||
req += _(" AND year='") + wxString::Format(_("%d"), op.year) + _("'");
|
||||
req += _(" AND month='") + wxString::Format(_("%d"), op.month) + _("'");
|
||||
req += _(" AND day='") + wxString::Format(_("%d"), op.day) + _("'");
|
||||
req += _(" AND amount='") + wxString::Format(_("%.2lf"), op.amount) + _("'");
|
||||
req += _(" AND amount='") + DoubleToString(op.amount) + _("'");
|
||||
req += _(" AND description=\"") + op.description + _("\"");
|
||||
req += _(" AND category='") + op.category + _("'");
|
||||
if (op.fix_cost)
|
||||
|
@ -433,8 +443,8 @@ void Database::SetAccountAmount(int month, int year, wxString accountId, double
|
|||
{
|
||||
wxString req;
|
||||
req = _("UPDATE account_amount SET ") ;
|
||||
req += _("amount='") + wxString::Format(_("%.2lf"), amount) + _("'");
|
||||
req += _(" WHERE id='") + accountId + _("'");
|
||||
req += _("amount='") + DoubleToString(amount) + _("'");
|
||||
req += _(" WHERE account='") + accountId + _("'");
|
||||
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
|
||||
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
|
||||
|
||||
|
@ -705,7 +715,7 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
|
|||
req += it->id + _("'");
|
||||
req += _(" ,'") + wxString::Format(_("%d"), yearTo) + _("'");
|
||||
req += _(" ,'") + wxString::Format(_("%d"), monthTo) + _("'");
|
||||
req += _(" ,'") + wxString::Format(_("%.2lf"), amount) + _("'");
|
||||
req += _(" ,'") + DoubleToString(amount) + _("'");
|
||||
req += _(")");
|
||||
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
|
|
|
@ -806,9 +806,14 @@ void AccountPanel::OnAccountModified(wxGridEvent& event)
|
|||
User* user = _kiss->GetUser();
|
||||
int row = event.GetRow();
|
||||
double amount;
|
||||
wxString id = user->GetAccountId(_accounts[row]);
|
||||
|
||||
_accountsGrid->GetCellValue(row, event.GetCol()).ToDouble(&amount);
|
||||
_kiss->SetAccountAmount(_curMonth, _curYear, user->GetAccountId(_accounts[row]), amount);
|
||||
_accountsGrid->GetCellValue(row, event.GetCol()).ToDouble(&amount);
|
||||
|
||||
_kiss->SetAccountAmount(_curMonth, _curYear, id, amount);
|
||||
_accountsInitValues[id] = amount;
|
||||
|
||||
UpdateStats();
|
||||
}
|
||||
|
||||
void AccountPanel::OnTreeRightClick(wxTreeEvent& event)
|
||||
|
|
Loading…
Reference in New Issue
Block a user