Simplify UpdateNextMonths function

Add "create_if_not_exsits" to Database::GetAccountAmount
This commit is contained in:
2013-02-17 18:58:32 +01:00
parent fcc7d09071
commit e0efe42b14
6 changed files with 48 additions and 93 deletions

View File

@@ -379,7 +379,7 @@ void Database::LoadYear(User* user, int year)
query.clear();
}
int Database::GetAccountAmount(int id, int month, int year, bool* had_value)
int Database::GetAccountAmount(int id, int month, int year, bool* had_value, bool create_if_not_exsits)
{
QSqlRecord set;
QString req;
@@ -400,7 +400,8 @@ int Database::GetAccountAmount(int id, int month, int year, bool* had_value)
}
else
{
SetAccountAmount(id, month, year, 0);
if (create_if_not_exsits)
SetAccountAmount(id, month, year, 0);
if (had_value)
*had_value = false;
}

View File

@@ -113,7 +113,7 @@ public:
int MetaAmount(int id);
int MetaPositiveAmount(int id);
int GetAccountAmount(int id, int month, int year, bool* had_value=0);
int GetAccountAmount(int id, int month, int year, bool* had_value=0, bool create_if_not_exsits=true);
void SetAccountAmount(int accountId, int month, int year, int amount);
int CalcAccountAmount(int id, int month, int year, bool* had_values);