All Values are now in fix point
This commit is contained in:
@@ -98,12 +98,12 @@ User* KissCount::GetUser()
|
||||
return _user;
|
||||
}
|
||||
|
||||
double KissCount::GetAccountAmount(int id, int month, int year, bool* had_value)
|
||||
int KissCount::GetAccountAmount(int id, int month, int year, bool* had_value)
|
||||
{
|
||||
return _db->GetAccountAmount(id, month, year, had_value);
|
||||
}
|
||||
|
||||
double KissCount::CalcAccountAmount(int id, int month, int year, bool* had_values)
|
||||
int KissCount::CalcAccountAmount(int id, int month, int year, bool* had_values)
|
||||
{
|
||||
return _db->CalcAccountAmount(id, month, year, had_values);
|
||||
}
|
||||
@@ -157,17 +157,17 @@ void KissCount::DeleteOperations(int month, int year)
|
||||
}
|
||||
}
|
||||
|
||||
double KissCount::MetaAmount(int id)
|
||||
int KissCount::MetaAmount(int id)
|
||||
{
|
||||
return _db->MetaAmount(id);
|
||||
}
|
||||
|
||||
double KissCount::MetaPositiveAmount(int id)
|
||||
int KissCount::MetaPositiveAmount(int id)
|
||||
{
|
||||
return _db->MetaPositiveAmount(id);
|
||||
}
|
||||
|
||||
void KissCount::SetAccountAmount(int accountId, int month, int year, double amount)
|
||||
void KissCount::SetAccountAmount(int accountId, int month, int year, int amount)
|
||||
{
|
||||
_db->SetAccountAmount(accountId, month, year, amount);
|
||||
}
|
||||
@@ -398,7 +398,7 @@ const QString& KissCount::GetOperationOrder()
|
||||
}
|
||||
|
||||
std::vector<Operation>* KissCount::Search(QString* description, QDate* dateFrom, QDate* dateTo,
|
||||
double* amountFrom, double* amountTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts)
|
||||
{
|
||||
|
||||
@@ -458,15 +458,15 @@ void KissCount::GetHistory(int month, int year, QStringList& list)
|
||||
}
|
||||
|
||||
void KissCount::GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
||||
std::map<int, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<int, double>* categories)
|
||||
std::map<int, std::map<int, std::map<int, int> > >* accountAmounts,
|
||||
std::map<int, int>* categories)
|
||||
{
|
||||
_db->GetStats(_user, monthFrom, yearFrom, monthTo, yearTo, accountAmounts, categories);
|
||||
}
|
||||
|
||||
void KissCount::GetMonthStats(int month, int year, int nbDays,
|
||||
std::map<int, std::vector<double> >* operations,
|
||||
std::map<int, double>* categories)
|
||||
std::map<int, std::vector<int> >* operations,
|
||||
std::map<int, int>* categories)
|
||||
{
|
||||
_db->GetMonthStats(_user, month, year, nbDays, operations, categories);
|
||||
}
|
||||
@@ -476,12 +476,12 @@ void KissCount::UpdateStats()
|
||||
_wxUI->UpdateStats();
|
||||
}
|
||||
|
||||
std::map<int, double>* KissCount::GetNotChecked(int month, int year)
|
||||
std::map<int, int>* KissCount::GetNotChecked(int month, int year)
|
||||
{
|
||||
return _db->GetNotChecked(_user, month, year);
|
||||
}
|
||||
|
||||
std::map<int, double>* KissCount::GetVirtualAmount(int month, int year)
|
||||
std::map<int, int>* KissCount::GetVirtualAmount(int month, int year)
|
||||
{
|
||||
return _db->GetVirtualAmount(_user, month, year);
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ public:
|
||||
void UpdateOperation(Operation& op, bool checkTransfert=true);
|
||||
void DeleteOperation(Operation& op);
|
||||
void DeleteOperations(int month, int year);
|
||||
double MetaAmount(int id);
|
||||
double MetaPositiveAmount(int id);
|
||||
int MetaAmount(int id);
|
||||
int MetaPositiveAmount(int id);
|
||||
|
||||
double GetAccountAmount(int id, int month, int year, bool* had_values=NULL);
|
||||
void SetAccountAmount(int accountId, int month, int year, double value);
|
||||
double CalcAccountAmount(int id, int month, int year, bool* had_values);
|
||||
int GetAccountAmount(int id, int month, int year, bool* had_values=NULL);
|
||||
void SetAccountAmount(int accountId, int month, int year, int value);
|
||||
int CalcAccountAmount(int id, int month, int year, bool* had_values);
|
||||
|
||||
int AddAccount(Account& ac);
|
||||
void UpdateAccount(Account& ac);
|
||||
@@ -101,22 +101,22 @@ public:
|
||||
const QString& GetOperationOrder();
|
||||
|
||||
std::vector<Operation>* Search(QString* description, QDate* dateFrom, QDate* dateTo,
|
||||
double* amountFrom, double* amountTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts);
|
||||
|
||||
bool SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType, int index);
|
||||
|
||||
void GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
||||
std::map<int, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<int, double>* categories);
|
||||
std::map<int, std::map<int, std::map<int, int> > >* accountAmounts,
|
||||
std::map<int, int>* categories);
|
||||
|
||||
void GetMonthStats(int month, int year, int nbDays,
|
||||
std::map<int, std::vector<double> >* operations,
|
||||
std::map<int, double>* categories);
|
||||
std::map<int, std::vector<int> >* operations,
|
||||
std::map<int, int>* categories);
|
||||
void UpdateStats();
|
||||
|
||||
std::map<int, double>* GetNotChecked(int month, int year);
|
||||
std::map<int, double>* GetVirtualAmount(int month, int year);
|
||||
std::map<int, int>* GetNotChecked(int month, int year);
|
||||
std::map<int, int>* GetVirtualAmount(int month, int year);
|
||||
|
||||
static QFont ExtractFont(QString);
|
||||
static QString CompactFont(const QFont& font);
|
||||
|
||||
+42
-51
@@ -30,15 +30,6 @@
|
||||
|
||||
#include "Database.hpp"
|
||||
|
||||
static inline QString DoubleToString(double d)
|
||||
{
|
||||
QString res;
|
||||
|
||||
res = res.sprintf("%.2lf", d);
|
||||
|
||||
return res.replace(",", ".");
|
||||
}
|
||||
|
||||
Database::Database(const char* filename, KissCount* kiss) : _kiss(kiss)
|
||||
{
|
||||
std::ifstream bdd_file;
|
||||
@@ -211,7 +202,7 @@ static inline void fillOperation(Operation* op, const QSqlRecord& set)
|
||||
op->day = set.value("day").toInt();
|
||||
op->month = set.value("month").toInt();
|
||||
op->year = set.value("year").toInt();
|
||||
op->amount = set.value("amount").toDouble();
|
||||
op->amount = set.value("amount").toInt();
|
||||
op->description = set.value("description").toString();
|
||||
op->category = set.value("category").toInt();
|
||||
op->fix_cost = set.value("fix_cost").toBool();
|
||||
@@ -406,28 +397,28 @@ void Database::LoadYear(User* user, int year)
|
||||
query.clear();
|
||||
}
|
||||
|
||||
double Database::GetAccountAmount(int id, int month, int year, bool* had_value)
|
||||
int Database::GetAccountAmount(int id, int month, int year, bool* had_value)
|
||||
{
|
||||
QSqlRecord set;
|
||||
QString req;
|
||||
double res = 0.0;
|
||||
int res = 0;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
req = QString("SELECT amount FROM account_amount WHERE account='%1' AND month='%2' AND year='%3'")
|
||||
.arg(QString::number(id), QString::number(month), QString::number(year)) ;
|
||||
|
||||
EXECUTE_SQL_QUERY(req, 0.0);
|
||||
EXECUTE_SQL_QUERY(req, 0);
|
||||
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
res = set.value("amount").toDouble();
|
||||
res = set.value("amount").toInt();
|
||||
if (had_value)
|
||||
*had_value = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAccountAmount(id, month, year, 0.0);
|
||||
SetAccountAmount(id, month, year, 0);
|
||||
if (had_value)
|
||||
*had_value = false;
|
||||
}
|
||||
@@ -437,22 +428,22 @@ double Database::GetAccountAmount(int id, int month, int year, bool* had_value)
|
||||
return res;
|
||||
}
|
||||
|
||||
double Database::CalcAccountAmount(int id, int month, int year, bool* had_values)
|
||||
int Database::CalcAccountAmount(int id, int month, int year, bool* had_values)
|
||||
{
|
||||
QSqlRecord set;
|
||||
QString req;
|
||||
double res = 0.0;
|
||||
int res = 0;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
req = QString("SELECT SUM(id) AS id, SUM(amount) AS amount FROM operation WHERE account='%1' AND month='%2' AND year='%3' AND meta='0'").
|
||||
arg(QString::number(id), QString::number(month), QString::number(year)) ;
|
||||
|
||||
EXECUTE_SQL_QUERY(req, 0.0);
|
||||
EXECUTE_SQL_QUERY(req, 0);
|
||||
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
res = set.value("amount").toDouble();
|
||||
res = set.value("amount").toInt();
|
||||
if (had_values)
|
||||
*had_values = set.value("id").toInt() > 0 ;
|
||||
}
|
||||
@@ -525,7 +516,7 @@ void Database::LinkOrUnlinkOperation(User* user, Operation& op)
|
||||
query.clear();
|
||||
|
||||
req = QString("SELECT id, account FROM operation WHERE description=\"%1\" AND month='%2' AND year='%3' AND amount='%4' AND meta='0' AND account !='%5' AND transfert=''")
|
||||
.arg(op.description, QString::number(op.month), QString::number(op.year), DoubleToString(-op.amount), QString::number(op.account));
|
||||
.arg(op.description, QString::number(op.month), QString::number(op.year), QString::number(-op.amount), QString::number(op.account));
|
||||
|
||||
EXECUTE_SQL_QUERY(req, );
|
||||
|
||||
@@ -577,7 +568,7 @@ void Database::UpdateOperation(User* user, Operation& op, bool checkTransfert)
|
||||
|
||||
req = "UPDATE operation SET parent='%1', account='%2', year='%3', month='%4', day='%5', amount='%6', description=\"%7\", category='%8'" ;
|
||||
req = req.arg((op.parent) ? QString::number(op.parent) : "", QString::number(op.account), QString::number(op.year), QString::number(op.month),
|
||||
QString::number(op.day), DoubleToString(op.amount), op.description, QString::number(op.category));
|
||||
QString::number(op.day), QString::number(op.amount), op.description, QString::number(op.category));
|
||||
req += ", fix_cost='%1', checked='%2', transfert='%3', meta='%4', virtual='%5', formula='%6' WHERE id='%7'";
|
||||
req = req.arg(QString::number(op.fix_cost), QString::number(op.checked), (op.transfert) ? QString::number(op.transfert): "",
|
||||
QString::number(op.meta), QString::number(op._virtual), op.formula, QString::number(op.id));
|
||||
@@ -599,7 +590,7 @@ int Database::AddOperation(User* user, Operation& op, bool checkTransfert)
|
||||
|
||||
req = "INSERT INTO operation ('user', 'parent', 'account', 'year', 'month', 'day', 'amount', 'description', 'category', 'fix_cost', 'formula', 'transfert', 'meta', 'virtual', 'checked') VALUES ('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8'" ;
|
||||
req = req.arg(QString::number(user->_id), (op.parent) ? QString::number(op.parent): "", QString::number(op.account), QString::number(op.year),
|
||||
QString::number(op.month), QString::number(op.day), DoubleToString(op.amount), op.description);
|
||||
QString::number(op.month), QString::number(op.day), QString::number(op.amount), op.description);
|
||||
req += ", '%1', '%2', '%3', '%4', '%5', '%6', '%7')";
|
||||
req = req.arg(QString::number(op.category), QString::number(op.fix_cost), op.formula, (op.transfert) ? QString::number(op.transfert): "",
|
||||
QString::number(op.meta), QString::number(op._virtual), QString::number(op.checked));
|
||||
@@ -715,11 +706,11 @@ bool Database::LoadOperation(User* user, int id)
|
||||
}
|
||||
|
||||
// We may not have access to all operations if we have a shared account
|
||||
double Database::MetaAmount(int id)
|
||||
int Database::MetaAmount(int id)
|
||||
{
|
||||
QSqlRecord set;
|
||||
QString req;
|
||||
double res = 0.0;
|
||||
int res = 0;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
req = QString("SELECT SUM(amount) as amount FROM operation WHERE parent='%1'").arg(id);
|
||||
@@ -729,7 +720,7 @@ double Database::MetaAmount(int id)
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
res = set.value("amount").toDouble();
|
||||
res = set.value("amount").toInt();
|
||||
}
|
||||
|
||||
query.clear();
|
||||
@@ -738,11 +729,11 @@ double Database::MetaAmount(int id)
|
||||
}
|
||||
|
||||
// Idem
|
||||
double Database::MetaPositiveAmount(int id)
|
||||
int Database::MetaPositiveAmount(int id)
|
||||
{
|
||||
QSqlRecord set;
|
||||
QString req;
|
||||
double res = 0.0;
|
||||
int res = 0;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
req = QString("SELECT SUM(amount) as amount FROM operation WHERE amount > 0 AND parent='%1'").arg(id);
|
||||
@@ -752,7 +743,7 @@ double Database::MetaPositiveAmount(int id)
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
res = set.value("amount").toDouble();
|
||||
res = set.value("amount").toInt();
|
||||
}
|
||||
|
||||
query.clear();
|
||||
@@ -760,13 +751,13 @@ double Database::MetaPositiveAmount(int id)
|
||||
return res;
|
||||
}
|
||||
|
||||
void Database::SetAccountAmount(int accountId, int month, int year, double amount)
|
||||
void Database::SetAccountAmount(int accountId, int month, int year, int amount)
|
||||
{
|
||||
QString req;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
req = "INSERT or REPLACE INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('%1', '%2', '%3', '%4')" ;
|
||||
req = req.arg(QString::number(accountId), QString::number(year), QString::number(month), DoubleToString(amount));
|
||||
req = req.arg(QString::number(accountId), QString::number(year), QString::number(month), QString::number(amount));
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
}
|
||||
|
||||
@@ -1113,12 +1104,12 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
|
||||
std::vector<Account>::iterator it;
|
||||
QString req;
|
||||
QSqlRecord set;
|
||||
double amount;
|
||||
int amount;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
for (it = user->_accounts.begin(); it != user->_accounts.end(); it++)
|
||||
{
|
||||
amount = 0.0;
|
||||
amount = 0;
|
||||
req = "SELECT SUM(amount) AS total FROM operation WHERE account='%1' AND year='%2' AND month='%3' AND meta='0'" ;
|
||||
req = req.arg(QString::number(it->id), QString::number(yearFrom), QString::number(monthFrom));
|
||||
|
||||
@@ -1127,7 +1118,7 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
amount += set.value("total").toDouble();
|
||||
amount += set.value("total").toInt();
|
||||
}
|
||||
|
||||
query.clear();
|
||||
@@ -1140,14 +1131,14 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
amount += set.value("amount").toDouble();
|
||||
amount += set.value("amount").toInt();
|
||||
}
|
||||
|
||||
query.clear();
|
||||
|
||||
req = "INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES " ;
|
||||
req += "('%1', '%2', '%3', '%4')";
|
||||
req = req.arg(QString::number(it->id), QString::number(yearTo), QString::number(monthTo), DoubleToString(amount));
|
||||
req = req.arg(QString::number(it->id), QString::number(yearTo), QString::number(monthTo), QString::number(amount));
|
||||
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
}
|
||||
@@ -1253,7 +1244,7 @@ void Database::UpdatePreference(User* user, const QString& preference)
|
||||
}
|
||||
|
||||
std::vector<Operation>* Database::Search(User* user, QString* description, QDate* dateFrom, QDate* dateTo,
|
||||
double* amountFrom, double* amountTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts, bool wildcards)
|
||||
{
|
||||
QSqlRecord set;
|
||||
@@ -1423,8 +1414,8 @@ std::vector<Operation>* Database::Search(User* user, QString* description, QDate
|
||||
}
|
||||
|
||||
void Database::GetStats(User* user, int monthFrom, int yearFrom, int monthTo,
|
||||
int yearTo, std::map<int, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<int, double>* categories)
|
||||
int yearTo, std::map<int, std::map<int, std::map<int, int> > >* accountAmounts,
|
||||
std::map<int, int>* categories)
|
||||
{
|
||||
QSqlRecord set;
|
||||
QSqlQuery query(_db);
|
||||
@@ -1447,7 +1438,7 @@ void Database::GetStats(User* user, int monthFrom, int yearFrom, int monthTo,
|
||||
while (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
(*accountAmounts)[accountIt->id][set.value("year").toInt()][set.value("month").toInt()] = set.value("amount").toDouble();
|
||||
(*accountAmounts)[accountIt->id][set.value("year").toInt()][set.value("month").toInt()] = set.value("amount").toInt();
|
||||
}
|
||||
query.clear();
|
||||
}
|
||||
@@ -1480,7 +1471,7 @@ void Database::GetStats(User* user, int monthFrom, int yearFrom, int monthTo,
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
(*categories)[categoryIt->id] = -set.value("amount").toDouble();
|
||||
(*categories)[categoryIt->id] = -set.value("amount").toInt();
|
||||
}
|
||||
query.clear();
|
||||
|
||||
@@ -1494,7 +1485,7 @@ void Database::GetStats(User* user, int monthFrom, int yearFrom, int monthTo,
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
(*categories)[categoryIt->id] += set.value("amount").toDouble();
|
||||
(*categories)[categoryIt->id] += set.value("amount").toInt();
|
||||
}
|
||||
query.clear();
|
||||
}
|
||||
@@ -1503,8 +1494,8 @@ void Database::GetStats(User* user, int monthFrom, int yearFrom, int monthTo,
|
||||
}
|
||||
|
||||
void Database::GetMonthStats(User* user, int month, int year, int nbDays,
|
||||
std::map<int, std::vector<double> >* operations,
|
||||
std::map<int, double>* categories)
|
||||
std::map<int, std::vector<int> >* operations,
|
||||
std::map<int, int>* categories)
|
||||
{
|
||||
QSqlRecord set;
|
||||
QSqlQuery query(_db);
|
||||
@@ -1526,7 +1517,7 @@ void Database::GetMonthStats(User* user, int month, int year, int nbDays,
|
||||
set = query.record();
|
||||
(*operations)[accountIt->id].clear();
|
||||
|
||||
previous_amount = set.value("amount").toDouble();
|
||||
previous_amount = set.value("amount").toInt();
|
||||
}
|
||||
query.clear();
|
||||
|
||||
@@ -1547,7 +1538,7 @@ void Database::GetMonthStats(User* user, int month, int year, int nbDays,
|
||||
previous_day++;
|
||||
}
|
||||
|
||||
previous_amount += set.value("amount").toDouble();
|
||||
previous_amount += set.value("amount").toInt();
|
||||
(*operations)[accountIt->id][cur_day] = previous_amount;
|
||||
}
|
||||
query.clear();
|
||||
@@ -1564,10 +1555,10 @@ void Database::GetMonthStats(User* user, int month, int year, int nbDays,
|
||||
GetStats(user, month, year, month, year, 0, categories) ;
|
||||
}
|
||||
|
||||
std::map<int, double>* Database::GetNotChecked(User* user, int month, int year)
|
||||
std::map<int, int>* Database::GetNotChecked(User* user, int month, int year)
|
||||
{
|
||||
std::vector<Account>::iterator accountIt;
|
||||
std::map<int, double>* res = new std::map<int, double>;
|
||||
std::map<int, int>* res = new std::map<int, int>;
|
||||
QSqlRecord set;
|
||||
QSqlQuery query(_db);
|
||||
QString req;
|
||||
@@ -1587,7 +1578,7 @@ std::map<int, double>* Database::GetNotChecked(User* user, int month, int year)
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
(*res)[accountIt->id] = set.value("amount").toDouble();
|
||||
(*res)[accountIt->id] = set.value("amount").toInt();
|
||||
}
|
||||
|
||||
query.clear();
|
||||
@@ -1596,10 +1587,10 @@ std::map<int, double>* Database::GetNotChecked(User* user, int month, int year)
|
||||
return res;
|
||||
}
|
||||
|
||||
std::map<int, double>* Database::GetVirtualAmount(User* user, int month, int year)
|
||||
std::map<int, int>* Database::GetVirtualAmount(User* user, int month, int year)
|
||||
{
|
||||
std::vector<Account>::iterator accountIt;
|
||||
std::map<int, double>* res = new std::map<int, double>;
|
||||
std::map<int, int>* res = new std::map<int, int>;
|
||||
QSqlRecord set;
|
||||
QSqlQuery query(_db);
|
||||
QString req;
|
||||
@@ -1619,7 +1610,7 @@ std::map<int, double>* Database::GetVirtualAmount(User* user, int month, int yea
|
||||
if (query.next())
|
||||
{
|
||||
set = query.record();
|
||||
(*res)[accountIt->id] = set.value("amount").toDouble();
|
||||
(*res)[accountIt->id] = set.value("amount").toInt();
|
||||
}
|
||||
|
||||
query.clear();
|
||||
|
||||
+12
-12
@@ -106,12 +106,12 @@ public:
|
||||
void DeleteOperation(User* user, Operation& op);
|
||||
void DeleteOperations(User* user, int month, int year);
|
||||
bool LoadOperation(User* user, int id);
|
||||
double MetaAmount(int id);
|
||||
double MetaPositiveAmount(int id);
|
||||
int MetaAmount(int id);
|
||||
int MetaPositiveAmount(int id);
|
||||
|
||||
double GetAccountAmount(int id, int month, int year, bool* had_value=NULL);
|
||||
void SetAccountAmount(int accountId, int month, int year, double amount);
|
||||
double CalcAccountAmount(int id, int month, int year, bool* had_values);
|
||||
int GetAccountAmount(int id, int month, int year, bool* had_value=NULL);
|
||||
void SetAccountAmount(int accountId, int month, int year, int amount);
|
||||
int CalcAccountAmount(int id, int month, int year, bool* had_values);
|
||||
|
||||
int AddAccount(User* user, Account& ac);
|
||||
void UpdateAccount(Account& ac);
|
||||
@@ -135,24 +135,24 @@ public:
|
||||
void UpdatePreference(User* user, const QString& preference);
|
||||
|
||||
std::vector<Operation>* Search(User* user, QString* description, QDate* dateFrom, QDate* dateTo,
|
||||
double* amountFrom, double* amountTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts, bool wildcards);
|
||||
|
||||
void GetStats(User* user, int monthFrom, int yearFrom, int monthTo,
|
||||
int yearTo, std::map<int, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<int, double>* categories);
|
||||
int yearTo, std::map<int, std::map<int, std::map<int, int> > >* accountAmounts,
|
||||
std::map<int, int>* categories);
|
||||
|
||||
void GetMonthStats(User* user, int month, int year, int nbDays,
|
||||
std::map<int, std::vector<double> >* operations,
|
||||
std::map<int, double>* categories);
|
||||
std::map<int, std::vector<int> >* operations,
|
||||
std::map<int, int>* categories);
|
||||
|
||||
void KillMe(User* user);
|
||||
bool GetOperation(int id, Operation* op);
|
||||
std::map<QString, QString> getSharedAccountOwners(int account);
|
||||
QString getSharedAccountOwner(int account);
|
||||
|
||||
std::map<int, double>* GetNotChecked(User* user, int month, int year);
|
||||
std::map<int, double>* GetVirtualAmount(User* user, int month, int year);
|
||||
std::map<int, int>* GetNotChecked(User* user, int month, int year);
|
||||
std::map<int, int>* GetVirtualAmount(User* user, int month, int year);
|
||||
|
||||
void UpdateImportPattern(User* user);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ struct Operation {
|
||||
unsigned int day;
|
||||
unsigned int month;
|
||||
unsigned int year;
|
||||
double amount;
|
||||
int amount;
|
||||
QString description;
|
||||
int category;
|
||||
bool fix_cost;
|
||||
|
||||
@@ -137,7 +137,7 @@ bool XMLExportEngine::SaveOperations(std::vector<Operation>* operations)
|
||||
_writer->writeAttribute("day", QString::number(it->day));
|
||||
_writer->writeAttribute("month", QString::number(it->month));
|
||||
_writer->writeAttribute("year", QString::number(it->year));
|
||||
_writer->writeAttribute("amount", v.sprintf("%.2lf", it->amount));
|
||||
_writer->writeAttribute("amount", QString::number(it->amount));
|
||||
_writer->writeAttribute("description", it->description);
|
||||
_writer->writeAttribute("category", QString::number(it->category));
|
||||
_writer->writeAttribute("fix_cost", (it->fix_cost ? "1" : "0"));
|
||||
|
||||
@@ -114,7 +114,7 @@ void GrisbiImportEngine::LoadOperation(const QXmlAttributes& attrs)
|
||||
op.day = date.day();
|
||||
op.month = date.month();
|
||||
op.year = date.year();
|
||||
op.amount = attrs.value("Am").toDouble();
|
||||
op.amount = attrs.value("Am").toInt();
|
||||
op.category = _categories[attrs.value("Ca").toInt()];
|
||||
op.description = attrs.value("No");
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ std::vector<Operation>* ImportEngine::GetOperations(std::map<int, int>& accounts
|
||||
return &_operations;
|
||||
}
|
||||
|
||||
const std::map<AccountAmount, double, AccountAmount>& ImportEngine::GetAccountAmounts()
|
||||
const std::map<AccountAmount, int, AccountAmount>& ImportEngine::GetAccountAmounts()
|
||||
{
|
||||
return _accountAmounts;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
// Final Step
|
||||
virtual std::vector<Operation>* GetOperations(std::map<int, int>& accounts, std::map<int, int>& categories);
|
||||
|
||||
const std::map<AccountAmount, double, AccountAmount>& GetAccountAmounts();
|
||||
const std::map<AccountAmount, int, AccountAmount>& GetAccountAmounts();
|
||||
|
||||
void MatchPattern(QString& key, Operation& op);
|
||||
int UpdatePattern(int pos);
|
||||
@@ -77,7 +77,7 @@ protected:
|
||||
std::vector<Category> _unresolvedCategories;
|
||||
std::vector<Operation> _operations;
|
||||
std::map<int, QString> _descriptions;
|
||||
std::map<AccountAmount, double, AccountAmount> _accountAmounts;
|
||||
std::map<AccountAmount, int, AccountAmount> _accountAmounts;
|
||||
|
||||
void ApplyPattern(ImportPattern& pattern, Operation& op);
|
||||
QString FindPattern(QString& s1, QString& s2);
|
||||
|
||||
@@ -142,12 +142,12 @@ void XMLImportEngine::LoadAccount(const QXmlAttributes& attrs)
|
||||
void XMLImportEngine::LoadAccountAmount(const QXmlAttributes& attrs)
|
||||
{
|
||||
AccountAmount accountAmount;
|
||||
double amount;
|
||||
int amount;
|
||||
|
||||
accountAmount.account = attrs.value("account").toInt();
|
||||
accountAmount.month = attrs.value("month").toInt();
|
||||
accountAmount.year = attrs.value("year").toInt();
|
||||
amount = attrs.value("amount").toDouble();
|
||||
amount = attrs.value("amount").toInt();
|
||||
|
||||
_accountAmounts[accountAmount] = amount;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ void XMLImportEngine::LoadOperation(const QXmlAttributes& attrs)
|
||||
op.day = attrs.value("day").toInt();
|
||||
op.month = attrs.value("month").toInt();
|
||||
op.year = attrs.value("year").toInt();
|
||||
op.amount = attrs.value("amount").toDouble();
|
||||
op.amount = attrs.value("amount").toInt();
|
||||
op.description = attrs.value("description");
|
||||
op.category = attrs.value("category").toInt();
|
||||
op.category = (attrs.value("fix_cost") == "1");
|
||||
|
||||
+33
-34
@@ -110,7 +110,7 @@ void AccountPanel::Init(KissCount* kiss, wxUI *parent, int curMode)
|
||||
QVector< double > vec;
|
||||
vec << 0.0;
|
||||
_dataset = new QStandardItemModel(nbCategories, 2, this);
|
||||
_categoriesValues = new double[nbCategories];
|
||||
_categoriesValues = new int[nbCategories];
|
||||
for(i=0; i<nbCategories; i++)
|
||||
{
|
||||
_categoriesValues[i] = 0.0;
|
||||
@@ -486,7 +486,7 @@ void AccountPanel::InitAccountsGrid(User* user, int month, int year)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
int curLine = 0;
|
||||
double value;
|
||||
int value;
|
||||
int i, nbAccounts;
|
||||
QTableWidgetItem* item;
|
||||
QString v;
|
||||
@@ -537,7 +537,7 @@ void AccountPanel::InitAccountsGrid(User* user, int month, int year)
|
||||
_accountsGrid->setItem(curLine, ACCOUNT_NAME, new QTableWidgetItem(it->name));
|
||||
value = _kiss->GetAccountAmount(it->id, month, year);
|
||||
|
||||
_accountsGrid->setItem(curLine, ACCOUNT_INIT, new QTableWidgetItem(v.sprintf("%.2lf", value)));
|
||||
_accountsGrid->setItem(curLine, ACCOUNT_INIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)value/100)));
|
||||
_accountsGrid->setItem(curLine, ACCOUNT_CUR, new QTableWidgetItem(""));
|
||||
_accountsGrid->setItem(curLine, ACCOUNT_FINAL, new QTableWidgetItem(""));
|
||||
for (i=0; i<NUMBER_COLS_ACCOUNTS; i++)
|
||||
@@ -562,15 +562,14 @@ void AccountPanel::UpdateStats()
|
||||
int i;
|
||||
User* user = _kiss->GetUser();
|
||||
std::vector<Operation>::iterator it;
|
||||
double curCredit, curDebit, totalCredit, totalDebit, balance, value, value2, percents;
|
||||
std::map<int, double> curAccountAmount, finalAccountAmount;
|
||||
std::map<int, double>::iterator doubleIt;
|
||||
int curCredit, curDebit, totalCredit, totalDebit, balance, value, value2, percents;
|
||||
std::map<int, int> curAccountAmount, finalAccountAmount;
|
||||
std::map<int, int>::iterator intIt;
|
||||
std::vector<Account>::iterator accountIt;
|
||||
unsigned int day;
|
||||
int mode;
|
||||
std::map<int, double>* notChecked = 0;
|
||||
std::map<int, double>* virtuals = 0;
|
||||
std::map<int, int>* notChecked = 0;
|
||||
std::map<int, int>* virtuals = 0;
|
||||
Account account;
|
||||
Operation op;
|
||||
bool blocked_account ;
|
||||
@@ -595,15 +594,15 @@ void AccountPanel::UpdateStats()
|
||||
for (i=0; i<user->GetCategoriesNumber(); i++)
|
||||
_categoriesValues[i] = 0.0;
|
||||
|
||||
for (doubleIt=_accountsInitValues.begin(); doubleIt!=_accountsInitValues.end(); doubleIt++)
|
||||
for (intIt=_accountsInitValues.begin(); intIt!=_accountsInitValues.end(); intIt++)
|
||||
{
|
||||
curAccountAmount[doubleIt->first] = _accountsInitValues[doubleIt->first];
|
||||
finalAccountAmount[doubleIt->first] = _accountsInitValues[doubleIt->first];
|
||||
curAccountAmount[intIt->first] = _accountsInitValues[intIt->first];
|
||||
finalAccountAmount[intIt->first] = _accountsInitValues[intIt->first];
|
||||
|
||||
if (mode == REAL_MODE || mode == CHECK_MODE)
|
||||
{
|
||||
curAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first];
|
||||
finalAccountAmount[doubleIt->first] += -(*virtuals)[doubleIt->first];
|
||||
curAccountAmount[intIt->first] += -(*virtuals)[intIt->first];
|
||||
finalAccountAmount[intIt->first] += -(*virtuals)[intIt->first];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,28 +743,28 @@ void AccountPanel::UpdateStats()
|
||||
}
|
||||
|
||||
balance = totalCredit - totalDebit;
|
||||
_statsGrid->item(CUR_CREDIT, 1)->setText(v.sprintf("%.2lf", curCredit));
|
||||
_statsGrid->item(CUR_DEBIT, 1)->setText(v.sprintf("%.2lf", curDebit));
|
||||
_statsGrid->item(TOTAL_CREDIT, 1)->setText(v.sprintf("%.2lf", totalCredit));
|
||||
_statsGrid->item(TOTAL_DEBIT, 1)->setText(v.sprintf("%.2lf", totalDebit));
|
||||
_statsGrid->item(CUR_CREDIT, 1)->setText(v.sprintf("%.2lf", (double)curCredit/100));
|
||||
_statsGrid->item(CUR_DEBIT, 1)->setText(v.sprintf("%.2lf", (double)curDebit/100));
|
||||
_statsGrid->item(TOTAL_CREDIT, 1)->setText(v.sprintf("%.2lf", (double)totalCredit/100));
|
||||
_statsGrid->item(TOTAL_DEBIT, 1)->setText(v.sprintf("%.2lf", (double)totalDebit/100));
|
||||
|
||||
_statsGrid->item(BALANCE, 1)->setText(v.sprintf("%.2lf", balance));
|
||||
_statsGrid->item(BALANCE, 1)->setText(v.sprintf("%.2lf", (double)balance/100));
|
||||
_statsGrid->item(BALANCE, 1)->setForeground((balance >= 0) ? QBrush(Qt::green) : QBrush(Qt::red));
|
||||
|
||||
// KDChart::Legend* legend = _pie->legend();
|
||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||
{
|
||||
if (totalDebit != 0)
|
||||
percents = ((double) (_categoriesValues[i]*100))/totalDebit;
|
||||
percents = (_categoriesValues[i]*100)/totalDebit;
|
||||
else
|
||||
percents = 0.0;
|
||||
if (i)
|
||||
_statsGrid->item(CATS_STATS+i+1, 1)->setText(v.sprintf("%.2lf (%02d %%)", _categoriesValues[i], (int)percents));
|
||||
_statsGrid->item(CATS_STATS+i+1, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)_categoriesValues[i]/100, (int)percents));
|
||||
else
|
||||
_statsGrid->item(CATS_STATS+i, 1)->setText(v.sprintf("%.2lf (%02d %%)", _categoriesValues[i], (int)percents));
|
||||
_statsGrid->item(CATS_STATS+i, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)_categoriesValues[i]/100, (int)percents));
|
||||
|
||||
QVector< double > vec;
|
||||
vec << _categoriesValues[i];
|
||||
vec << (double) _categoriesValues[i] / 100;
|
||||
_pie->setDataset( i, vec, _categories[i] );
|
||||
// if (_categoriesValues[i] == 0.0)
|
||||
// legend->setDatasetHidden(i, true);
|
||||
@@ -776,10 +775,10 @@ void AccountPanel::UpdateStats()
|
||||
|
||||
value = totalDebit - _categoriesValues[0];
|
||||
if (totalDebit != 0)
|
||||
percents = ((double) (value*100))/totalDebit;
|
||||
percents = (value*100)/totalDebit;
|
||||
else
|
||||
percents = 0.0;
|
||||
_statsGrid->item(NON_FIX, 1)->setText(v.sprintf("%.2lf (%02d %%)", value, (int)percents));
|
||||
_statsGrid->item(NON_FIX, 1)->setText(v.sprintf("%.2lf (%02d %%)", (double)value/100, (int)percents));
|
||||
|
||||
for (i=0, accountIt=user->_accounts.begin(); accountIt!=user->_accounts.end(); accountIt++, i++)
|
||||
{
|
||||
@@ -794,24 +793,24 @@ void AccountPanel::UpdateStats()
|
||||
value = _accountsInitValues[accountIt->id];
|
||||
if (mode == REAL_MODE)
|
||||
value -= (*virtuals)[accountIt->id];
|
||||
_accountsGrid->item(i, ACCOUNT_INIT)->setText(v.sprintf("%.2lf", value));
|
||||
_accountsGrid->item(i, ACCOUNT_INIT)->setText(v.sprintf("%.2lf", (double)value/100));
|
||||
value = curAccountAmount[accountIt->id];
|
||||
_accountsGrid->item(i, ACCOUNT_CUR)->setText(v.sprintf("%.2lf", value));
|
||||
_accountsGrid->item(i, ACCOUNT_CUR)->setText(v.sprintf("%.2lf", (double)value/100));
|
||||
_accountsGrid->item(i, ACCOUNT_CUR)->setForeground((value >= 0) ? QBrush(Qt::black) : QBrush(Qt::red));
|
||||
value = finalAccountAmount[accountIt->id];
|
||||
_accountsGrid->item(i, ACCOUNT_FINAL)->setText(v.sprintf("%.2lf", value));
|
||||
_accountsGrid->item(i, ACCOUNT_FINAL)->setText(v.sprintf("%.2lf", (double)value/100));
|
||||
}
|
||||
else
|
||||
{
|
||||
value = _accountsInitValues[accountIt->id] - (*virtuals)[accountIt->id];
|
||||
value2 = (*notChecked)[accountIt->id];
|
||||
|
||||
_accountsGrid->item(i, ACCOUNT_INIT)->setText(v.sprintf("%.2lf (%.2lf)", value, value-value2));
|
||||
_accountsGrid->item(i, ACCOUNT_INIT)->setText(v.sprintf("%.2lf (%.2lf)", (double)value/100, (double)(value-value2)/100));
|
||||
value = curAccountAmount[accountIt->id];
|
||||
_accountsGrid->item(i, ACCOUNT_CUR)->setText(v.sprintf("%.2lf (%.2lf)", value, value-value2));
|
||||
_accountsGrid->item(i, ACCOUNT_CUR)->setText(v.sprintf("%.2lf (%.2lf)", (double)value/100, (double)(value-value2)/100));
|
||||
_accountsGrid->item(i, ACCOUNT_CUR)->setForeground((value >= 0) ? QBrush(Qt::black) : QBrush(Qt::red));
|
||||
value = finalAccountAmount[accountIt->id];
|
||||
_accountsGrid->item(i, ACCOUNT_FINAL)->setText(v.sprintf("%.2lf (%.2lf)", value, value-value2));
|
||||
_accountsGrid->item(i, ACCOUNT_FINAL)->setText(v.sprintf("%.2lf (%.2lf)", (double)value/100, (double)(value-value2)/100));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -846,7 +845,7 @@ void AccountPanel::OnAccountModified(int row, int column)
|
||||
|
||||
amount = _accountsGrid->item(row, column)->text().toDouble();
|
||||
|
||||
_kiss->SetAccountAmount(id, _curMonth, _curYear, amount);
|
||||
_kiss->SetAccountAmount(id, _curMonth, _curYear, amount*100);
|
||||
_accountsInitValues[id] = amount;
|
||||
|
||||
UpdateStats();
|
||||
@@ -1130,15 +1129,15 @@ void AccountPanel::OnUnGroup()
|
||||
|
||||
void AccountPanel::OnUpdateNextMonths()
|
||||
{
|
||||
double* deltas, *cur_amounts, amount;
|
||||
int* deltas, *cur_amounts, amount;
|
||||
int i, a;
|
||||
User* user = _kiss->GetUser();
|
||||
bool had_values, accounts_updated = false;
|
||||
int last_month = 0, last_year = 0, account_updated = 0;
|
||||
std::map<int, std::vector<int> > operations;
|
||||
|
||||
deltas = new double[user->_accounts.size()] ;
|
||||
cur_amounts = new double[user->_accounts.size()] ;
|
||||
deltas = new int[user->_accounts.size()] ;
|
||||
cur_amounts = new int[user->_accounts.size()] ;
|
||||
|
||||
operations = _kiss->GetAllOperations();
|
||||
|
||||
|
||||
@@ -77,12 +77,12 @@ private:
|
||||
GridAccount* _grid;
|
||||
QTableWidget* _accountsGrid, *_statsGrid;
|
||||
KDChart::Widget* _pie;
|
||||
double *_categoriesValues;
|
||||
int *_categoriesValues;
|
||||
// wxRadioBox *_radioMode;
|
||||
std::map<QString, int> _categoriesIndexes;
|
||||
std::vector<Operation>* _curOperations;
|
||||
QString* _categories, *_accounts;
|
||||
std::map<int, double> _accountsInitValues;
|
||||
std::map<int, int> _accountsInitValues;
|
||||
QStandardItemModel* _dataset;
|
||||
int _fixCosts;
|
||||
QRadioButton *_virtual, *_real, *_check;
|
||||
|
||||
@@ -352,9 +352,9 @@ void ImportPanel::OnIntegrate()
|
||||
std::map<int, int> mapid;
|
||||
int oldid, account;
|
||||
bool update;
|
||||
std::map<AccountAmount, double, AccountAmount> accountAmounts;
|
||||
std::map<AccountAmount, double, AccountAmount>::iterator it;
|
||||
double amount;
|
||||
std::map<AccountAmount, int, AccountAmount> accountAmounts;
|
||||
std::map<AccountAmount, int, AccountAmount>::iterator it;
|
||||
int amount;
|
||||
|
||||
if (!_operations->size()) return;
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ SearchBanner::~SearchBanner()
|
||||
std::vector<Operation> * SearchBanner::Search()
|
||||
{
|
||||
QString *description=0;
|
||||
double *amountFrom=0, *amountTo=0;
|
||||
int *amountFrom=0, *amountTo=0;
|
||||
std::vector<int> categories, accounts;
|
||||
QDate *dateFrom=0, *dateTo=0;
|
||||
User* user= _kiss->GetUser();
|
||||
@@ -152,8 +152,8 @@ std::vector<Operation> * SearchBanner::Search()
|
||||
|
||||
if (_amountFrom->text().length())
|
||||
{
|
||||
amountFrom = new double;
|
||||
*amountFrom = _amountFrom->text().toDouble(&ok);
|
||||
amountFrom = new int;
|
||||
*amountFrom = _amountFrom->text().toInt(&ok);
|
||||
if (!ok)
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("Invalid amount from"));
|
||||
@@ -165,8 +165,8 @@ std::vector<Operation> * SearchBanner::Search()
|
||||
|
||||
if (_amountTo->text().length())
|
||||
{
|
||||
amountTo = new double;
|
||||
*amountTo = _amountTo->text().toDouble(&ok);
|
||||
amountTo = new int;
|
||||
*amountTo = _amountTo->text().toInt(&ok);
|
||||
if (!ok)
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("Invalid amount to"));
|
||||
|
||||
+17
-17
@@ -141,7 +141,7 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
|
||||
nbCategories = user->GetCategoriesNumber();
|
||||
// nbCategories = (user->GetCategoriesNumber() <= wxUI::MAX_CATEGORY) ? user->GetCategoriesNumber() : wxUI::MAX_CATEGORY;
|
||||
|
||||
_categoriesValues = new double[user->GetCategoriesNumber()];
|
||||
_categoriesValues = new int[user->GetCategoriesNumber()];
|
||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||
_categoriesValues[i] = 0.0;
|
||||
|
||||
@@ -158,7 +158,7 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
|
||||
legend->setTitleText(_("Cost repartition"));
|
||||
QVector< double > vec;
|
||||
vec << 0.0;
|
||||
_categoriesValues = new double[nbCategories];
|
||||
_categoriesValues = new int[nbCategories];
|
||||
for(i=0; i<nbCategories; i++)
|
||||
{
|
||||
_categoriesValues[i] = 0.0;
|
||||
@@ -217,13 +217,13 @@ QString StatsPanel::GetToolTip()
|
||||
|
||||
void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearTo)
|
||||
{
|
||||
std::map<int, std::map<int, std::map<int, double> > > accountAmounts;
|
||||
std::map<int, double> categories;
|
||||
std::map<int, std::vector<double> > operations;
|
||||
std::map<int, std::map<int, std::map<int, int> > > accountAmounts;
|
||||
std::map<int, int> categories;
|
||||
std::map<int, std::vector<int> > operations;
|
||||
std::vector<Account>::iterator accountIt;
|
||||
std::map<int, double>::iterator categoriesIt;
|
||||
std::map<int, std::map<int, double> >::iterator accountYearIt;
|
||||
double total, non_fix;
|
||||
std::map<int, int>::iterator categoriesIt;
|
||||
std::map<int, std::map<int, int> >::iterator accountYearIt;
|
||||
int total, non_fix;
|
||||
int account, size, i, a, b, percents, nbDays;
|
||||
QString value, v;
|
||||
User* user = _kiss->GetUser();
|
||||
@@ -262,7 +262,7 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
||||
|
||||
vec.clear();
|
||||
for (a=0; a<nbDays; a++)
|
||||
vec << operations[accountIt->id][a];
|
||||
vec << (double) operations[accountIt->id][a] / 100;
|
||||
|
||||
_plot->setDataset(++i, vec, user->GetAccountName(accountIt->id));
|
||||
}
|
||||
@@ -314,13 +314,13 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
||||
Compute cur month value (if there are operations)
|
||||
as next month value
|
||||
*/
|
||||
vec << accountAmounts[accountIt->id][accountYearIt->first][b-1]
|
||||
+ _kiss->CalcAccountAmount(accountIt->id, b-1, accountYearIt->first, 0);
|
||||
vec << (double) (accountAmounts[accountIt->id][accountYearIt->first][b-1]
|
||||
+ _kiss->CalcAccountAmount(accountIt->id, b-1, accountYearIt->first, 0)) / 100;
|
||||
failed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
vec << accountAmounts[accountIt->id][accountYearIt->first][b];
|
||||
vec << (double) accountAmounts[accountIt->id][accountYearIt->first][b] / 100;
|
||||
failed = false;
|
||||
}
|
||||
size++;
|
||||
@@ -378,10 +378,10 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
||||
{
|
||||
_categoriesValues[_categoriesIndexes[categoriesIt->first]] = categoriesIt->second;
|
||||
if (total)
|
||||
percents = ((double) (categoriesIt->second*100))/total;
|
||||
percents = (categoriesIt->second*100)/total;
|
||||
else
|
||||
percents = 0;
|
||||
value = v.sprintf("%0.2lf (%02d%%)", categoriesIt->second, percents);
|
||||
value = v.sprintf("%0.2lf (%02d%%)", (double) categoriesIt->second/100, percents);
|
||||
if (i)
|
||||
{
|
||||
_statsGrid->setItem(_categoriesIndexes[categoriesIt->first]+1, 1, new QTableWidgetItem(value));
|
||||
@@ -393,17 +393,17 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
|
||||
_statsGrid->item(_categoriesIndexes[categoriesIt->first], 1)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
}
|
||||
QVector< double > vec;
|
||||
vec << _categoriesValues[_categoriesIndexes[categoriesIt->first]];
|
||||
vec << (double) _categoriesValues[_categoriesIndexes[categoriesIt->first]] / 100;
|
||||
_pie->setDataset(_categoriesIndexes[categoriesIt->first], vec, _categories[_categoriesIndexes[categoriesIt->first]]);
|
||||
}
|
||||
|
||||
non_fix = total - _categoriesValues[0];
|
||||
|
||||
if (total)
|
||||
percents = ((double) (non_fix*100))/total;
|
||||
percents = (non_fix*100)/total;
|
||||
else
|
||||
percents = 0;
|
||||
value = v.sprintf("%0.2lf (%02d%%)", non_fix, percents);
|
||||
value = v.sprintf("%0.2lf (%02d%%)", (double)non_fix/100, percents);
|
||||
_statsGrid->setItem(1, 1, new QTableWidgetItem(value));
|
||||
|
||||
_statsGrid->resizeColumnsToContents();
|
||||
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
QComboBox* _monthFrom, *_yearFrom, *_monthTo, *_yearTo;
|
||||
QTableWidget *_statsGrid;
|
||||
KDChart::Widget* _pie;
|
||||
double *_categoriesValues;
|
||||
int *_categoriesValues;
|
||||
//CategorySimpleDataset* _dataset;
|
||||
KDChart::Widget *_plot ;
|
||||
QString* _categories;
|
||||
|
||||
@@ -335,7 +335,7 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||
std::vector<Operation>::iterator it;
|
||||
std::vector<QString>::iterator it2;
|
||||
int r, g, b;
|
||||
double amount;
|
||||
int amount;
|
||||
QColor color;
|
||||
QDate curDate = QDate::currentDate();
|
||||
QString description, v;
|
||||
@@ -377,10 +377,10 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||
setItem(line, OP_DATE, new QTableWidgetItem(_kiss->FormatDate(op.day+1, month+1, year)));
|
||||
if (op.amount < 0)
|
||||
{
|
||||
setItem(line, DEBIT, new QTableWidgetItem(v.sprintf("%.2lf", -op.amount)));
|
||||
setItem(line, DEBIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)-op.amount/100)));
|
||||
}
|
||||
else
|
||||
setItem(line, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", op.amount)));
|
||||
setItem(line, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)op.amount/100)));
|
||||
|
||||
if (!op.meta)
|
||||
setItem(line, ACCOUNT, new QTableWidgetItem(user->GetAccountName(op.account)));
|
||||
@@ -403,8 +403,8 @@ void GridAccount::InsertOperation(User* user, Operation& op, int line, bool fix,
|
||||
{
|
||||
amount = _kiss->MetaPositiveAmount(op.id);
|
||||
|
||||
setItem(line, DEBIT, new QTableWidgetItem(v.sprintf("%.2lf", amount)));
|
||||
setItem(line, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", amount)));
|
||||
setItem(line, DEBIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)amount/100)));
|
||||
setItem(line, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)amount/100)));
|
||||
}
|
||||
|
||||
if (op.category)
|
||||
@@ -871,7 +871,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||
unsigned char r, g, b;
|
||||
std::vector<int>::iterator it;
|
||||
Operation op, op2;
|
||||
double amount;
|
||||
int amount;
|
||||
QFont font;
|
||||
Category cat ;
|
||||
bool fix_cost;
|
||||
@@ -945,11 +945,11 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||
value = item(row, DEBIT)->text();
|
||||
if (value.length())
|
||||
{
|
||||
new_op.amount = value.toDouble();
|
||||
new_op.amount = value.toDouble()*100;
|
||||
if (new_op.amount < 0)
|
||||
{
|
||||
new_op.amount *= -1.0;
|
||||
setItem(row, DEBIT, new QTableWidgetItem(value.sprintf("%.2lf", new_op.amount)));
|
||||
setItem(row, DEBIT, new QTableWidgetItem(value.sprintf("%.2lf", (double)new_op.amount/100)));
|
||||
}
|
||||
if (new_op.amount != 0.0) new_op.amount *= -1.0;
|
||||
op_complete--;
|
||||
@@ -959,11 +959,11 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||
value = item(row, CREDIT)->text();
|
||||
if (value.length())
|
||||
{
|
||||
new_op.amount = value.toDouble();
|
||||
new_op.amount = value.toDouble()*100;
|
||||
if (new_op.amount < 0)
|
||||
{
|
||||
new_op.amount *= -1.0;
|
||||
setItem(row, DEBIT, new QTableWidgetItem(value.sprintf("%.2lf", new_op.amount)));
|
||||
setItem(row, DEBIT, new QTableWidgetItem(value.sprintf("%.2lf", (double)new_op.amount/100)));
|
||||
}
|
||||
op_complete--;
|
||||
new_op.formula = _displayedOperations[row].formula;
|
||||
@@ -1131,20 +1131,20 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||
{
|
||||
amount = _kiss->MetaPositiveAmount(new_op.id);
|
||||
|
||||
setItem(row, DEBIT, new QTableWidgetItem(v.sprintf("%.2lf", amount)));
|
||||
setItem(row, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", amount)));
|
||||
setItem(row, DEBIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)amount/100)));
|
||||
setItem(row, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)amount/100)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_displayedOperations[row].amount < 0)
|
||||
{
|
||||
setItem(row, DEBIT, new QTableWidgetItem(v.sprintf("%.2lf", -new_op.amount)));
|
||||
setItem(row, DEBIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)-new_op.amount/100)));
|
||||
setItem(row, CREDIT, new QTableWidgetItem(""));
|
||||
}
|
||||
else
|
||||
{
|
||||
setItem(row, DEBIT, new QTableWidgetItem(""));
|
||||
setItem(row, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", new_op.amount)));
|
||||
setItem(row, CREDIT, new QTableWidgetItem(v.sprintf("%.2lf", (double)new_op.amount/100)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user