Fix bugs :
* QString::number use scientific format, si it's invalid for numbers > 1 000 000. We need to use v.sprintf("%d"); * Accounts and categories where badly mapped during import * Fix cost not taken in account during import * Forbid empty account name and empty category name
|
@ -1,4 +1,4 @@
|
|||
v0.3 (05/05/2012)
|
||||
v0.3 (12/05/2012)
|
||||
** User **
|
||||
New interface in Qt4
|
||||
Use BDD file from .local/share/kisscount
|
||||
|
@ -21,6 +21,8 @@ v0.3 (05/05/2012)
|
|||
Last account/category wasn't taken in account during search
|
||||
New users have system language set instead of English
|
||||
Account/Category modification are immediatly reported in other panels
|
||||
Accounts and categories where badly mapped during import
|
||||
Fix cost not taken in account during import
|
||||
|
||||
v0.2 (04/07/2011)
|
||||
Remove dependancies of libsqlite and libxml
|
||||
|
|
BIN
ressources/icons/about.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ressources/icons/charts.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
ressources/icons/check.png
Normal file
After Width: | Height: | Size: 597 B |
BIN
ressources/icons/delete.png
Normal file
After Width: | Height: | Size: 813 B |
BIN
ressources/icons/exit.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ressources/icons/export.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
ressources/icons/import.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
ressources/icons/preferences.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
ressources/icons/search.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
ressources/icons/switch_user.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
ressources/icons/user.png
Normal file
After Width: | Height: | Size: 10 KiB |
|
@ -477,7 +477,7 @@ bool Database::GetOperation(int id, Operation* op)
|
|||
void Database::LinkOrUnlinkOperation(User* user, Operation& op)
|
||||
{
|
||||
Operation linked;
|
||||
QString req;
|
||||
QString req, v;
|
||||
QSqlRecord set;
|
||||
Account account, account2;
|
||||
bool _virtual;
|
||||
|
@ -513,7 +513,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), QString::number(-op.amount), QString::number(op.account));
|
||||
.arg(op.description, QString::number(op.month), QString::number(op.year), v.sprintf("%d", -op.amount), QString::number(op.account));
|
||||
|
||||
EXECUTE_SQL_QUERY(req, );
|
||||
|
||||
|
@ -555,7 +555,7 @@ void Database::LinkOrUnlinkOperation(User* user, Operation& op)
|
|||
|
||||
void Database::UpdateOperation(User* user, Operation& op, bool checkTransfert)
|
||||
{
|
||||
QString req;
|
||||
QString req, v;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
if (checkTransfert)
|
||||
|
@ -565,7 +565,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), QString::number(op.amount), op.description, QString::number(op.category));
|
||||
QString::number(op.day), v.sprintf("%d", 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));
|
||||
|
@ -578,7 +578,7 @@ void Database::UpdateOperation(User* user, Operation& op, bool checkTransfert)
|
|||
|
||||
int Database::AddOperation(User* user, Operation& op, bool checkTransfert)
|
||||
{
|
||||
QString req;
|
||||
QString req, v;
|
||||
QSqlRecord set;
|
||||
QSqlQuery query(_db);
|
||||
|
||||
|
@ -587,7 +587,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), QString::number(op.amount), op.description);
|
||||
QString::number(op.month), QString::number(op.day), v.sprintf("%d", 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));
|
||||
|
@ -750,11 +750,11 @@ int Database::MetaPositiveAmount(int id)
|
|||
|
||||
void Database::SetAccountAmount(int accountId, int month, int year, int amount)
|
||||
{
|
||||
QString req;
|
||||
QString req, v;
|
||||
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), QString::number(amount));
|
||||
req = req.arg(QString::number(accountId), QString::number(year), QString::number(month), v.sprintf("%d", amount));
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
}
|
||||
|
||||
|
@ -1099,7 +1099,7 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
|||
void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
QString req;
|
||||
QString req, v;
|
||||
QSqlRecord set;
|
||||
int amount;
|
||||
QSqlQuery query(_db);
|
||||
|
@ -1135,7 +1135,7 @@ void Database::GenerateMonth(User* user, int monthFrom, int yearFrom, int monthT
|
|||
|
||||
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), QString::number(amount));
|
||||
req = req.arg(QString::number(it->id), QString::number(yearTo), QString::number(monthTo), v.sprintf("%d", amount));
|
||||
|
||||
EXECUTE_SQL_UPDATE(req, );
|
||||
}
|
||||
|
@ -1246,7 +1246,7 @@ std::vector<Operation>* Database::Search(User* user, QString* description, QDate
|
|||
{
|
||||
QSqlRecord set;
|
||||
QSqlQuery query(_db);
|
||||
QString req;
|
||||
QString req, v;
|
||||
bool firstCond = false;
|
||||
std::vector<int>::iterator it;
|
||||
std::vector<Account>::iterator accountIt;
|
||||
|
@ -1309,13 +1309,13 @@ std::vector<Operation>* Database::Search(User* user, QString* description, QDate
|
|||
if (amountFrom)
|
||||
{
|
||||
if (firstCond) req += " AND " ; else firstCond = true;
|
||||
req += "ABS(amount) >= " + QString::number(*amountFrom);
|
||||
req += "ABS(amount) >= " + v.sprintf("%d", *amountFrom);
|
||||
}
|
||||
|
||||
if (amountTo)
|
||||
{
|
||||
if (firstCond) req += " AND " ; else firstCond = true;
|
||||
req += "ABS(amount) <= " + QString::number(*amountTo);
|
||||
req += "ABS(amount) <= " + v.sprintf("%d", *amountTo);
|
||||
}
|
||||
|
||||
if (categories.size())
|
||||
|
|
|
@ -55,7 +55,7 @@ protected:
|
|||
|
||||
std::map<int, int> _accounts;
|
||||
std::map<int, int> _categories;
|
||||
std::map<AccountAmount, double, AccountAmount> _accountAmounts;
|
||||
std::map<AccountAmount, int, AccountAmount> _accountAmounts;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -84,7 +84,7 @@ bool XMLExportEngine::SaveAccounts()
|
|||
|
||||
bool XMLExportEngine::SaveAccountAmounts()
|
||||
{
|
||||
std::map<AccountAmount, double, AccountAmount>::iterator it;
|
||||
std::map<AccountAmount, int, AccountAmount>::iterator it;
|
||||
QString v;
|
||||
|
||||
for(it=_accountAmounts.begin(); it!=_accountAmounts.end(); it++)
|
||||
|
@ -93,7 +93,7 @@ bool XMLExportEngine::SaveAccountAmounts()
|
|||
_writer->writeAttribute("account", QString::number(it->first.account));
|
||||
_writer->writeAttribute("month", QString::number(it->first.month));
|
||||
_writer->writeAttribute("year", QString::number(it->first.year));
|
||||
_writer->writeAttribute("amount", v.sprintf("%.2lf", it->second));
|
||||
_writer->writeAttribute("amount", v.sprintf("%d", it->second));
|
||||
_writer->writeEndElement();
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,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", QString::number(it->amount));
|
||||
_writer->writeAttribute("amount", v.sprintf("%d", it->amount));
|
||||
_writer->writeAttribute("description", it->description);
|
||||
_writer->writeAttribute("category", QString::number(it->category));
|
||||
_writer->writeAttribute("fix_cost", (it->fix_cost ? "1" : "0"));
|
||||
|
|
|
@ -302,15 +302,40 @@ void ImportEngine::ParseFile(std::vector<Account>& accounts, std::vector<Categor
|
|||
std::vector<Operation>* ImportEngine::GetOperations(std::map<int, int>& accounts, std::map<int, int>& categories)
|
||||
{
|
||||
int i;
|
||||
|
||||
std::map<AccountAmount, int, AccountAmount>::iterator it;
|
||||
std::map<AccountAmount, int, AccountAmount> newAccountAmount;
|
||||
AccountAmount account;
|
||||
|
||||
for(i=0; i<(int)_operations.size(); i++)
|
||||
{
|
||||
if (_operations[i].account < 0)
|
||||
if (_accounts[_operations[i].account] < 0)
|
||||
// Unresolved account, get new account id from User
|
||||
_operations[i].account = accounts[_operations[i].account];
|
||||
if (_operations[i].category < 0)
|
||||
else
|
||||
// Apply local mapping
|
||||
_operations[i].account = _accounts[_operations[i].account];
|
||||
|
||||
if (_categories[_operations[i].category] < 0)
|
||||
_operations[i].category = categories[_operations[i].category];
|
||||
else
|
||||
_operations[i].category = _categories[_operations[i].category];
|
||||
|
||||
}
|
||||
|
||||
for(it=_accountAmounts.begin(); it!=_accountAmounts.end(); it++)
|
||||
{
|
||||
account = it->first;
|
||||
|
||||
if (_accounts[account.account] < 0)
|
||||
account.account = accounts[account.account];
|
||||
else
|
||||
account.account = _accounts[account.account];
|
||||
newAccountAmount[account] = it->second;
|
||||
}
|
||||
|
||||
_accountAmounts.clear();
|
||||
_accountAmounts = newAccountAmount;
|
||||
|
||||
if (_kiss->GetOperationOrder() == "ASC")
|
||||
std::sort(_operations.begin(), _operations.end(), sortOperations);
|
||||
else
|
||||
|
|
|
@ -213,14 +213,14 @@ void XMLImportEngine::LoadOperation(const QXmlAttributes& attrs)
|
|||
op.amount = attrs.value("amount").toInt();
|
||||
op.description = attrs.value("description");
|
||||
op.category = attrs.value("category").toInt();
|
||||
op.category = (attrs.value("fix_cost") == "1");
|
||||
op.fix_cost = (attrs.value("fix_cost") == "1");
|
||||
op.account = attrs.value("account").toInt();
|
||||
op.checked = (attrs.value("checked") == "1");
|
||||
op.transfert = attrs.value("transfert").toInt();
|
||||
op.formula = attrs.value("formula");
|
||||
op.meta = (attrs.value("meta") == "1");
|
||||
op._virtual = (attrs.value("virtual") == "1");
|
||||
|
||||
|
||||
UNESCAPE_CHARS(op.description);
|
||||
|
||||
_operations.push_back(op);
|
||||
|
|
|
@ -255,8 +255,10 @@ void ImportPanel::OnLoadOperations()
|
|||
if (_accountsGrid->item(i, 2)->text() == _("Create one"))
|
||||
nbAccounts++;
|
||||
else
|
||||
accounts[_accountsGrid->item(i, 0)->text().toInt()] =
|
||||
user->GetAccountId(_accountsGrid->item(i, 1)->text());
|
||||
{
|
||||
oldid = _unresolvedAccounts[i].id;
|
||||
accounts[oldid] = user->GetAccountId(_accountsGrid->item(i, 2)->text());
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<_categoriesGrid->rowCount(); i++)
|
||||
|
@ -264,8 +266,10 @@ void ImportPanel::OnLoadOperations()
|
|||
if (_categoriesGrid->item(i, 2)->text() == _("Create one"))
|
||||
nbCategories++;
|
||||
else
|
||||
categories[_categoriesGrid->item(i, 0)->text().toInt()] =
|
||||
user->GetAccountId(_categoriesGrid->item(i, 1)->text());
|
||||
{
|
||||
oldid = _unresolvedCategories[i].id;
|
||||
categories[oldid] = user->GetCategoryId(_categoriesGrid->item(i, 2)->text());;
|
||||
}
|
||||
}
|
||||
|
||||
if (nbAccounts || nbCategories)
|
||||
|
@ -295,10 +299,15 @@ void ImportPanel::OnLoadOperations()
|
|||
account.name = _accountsGrid->item(i, 1)->text();
|
||||
else
|
||||
account.name = _accountsGrid->item(i, 0)->text();
|
||||
if (account.name.length() == 0)
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("Account ") + QString::number(i) + _(" must have a name"));
|
||||
return;
|
||||
}
|
||||
account.number = _accountsGrid->item(i, 0)->text();
|
||||
|
||||
oldid = account.id;
|
||||
_resolvedAccounts[oldid] = accounts[_accountsGrid->item(i, 0)->text().toInt()] = _kiss->AddAccount(account);
|
||||
accounts[oldid] = account.id = _kiss->AddAccount(account);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,9 +322,15 @@ void ImportPanel::OnLoadOperations()
|
|||
category.name = _categoriesGrid->item(i, 1)->text();
|
||||
else
|
||||
category.name = _categoriesGrid->item(i, 0)->text();
|
||||
|
||||
if (category.name.length() == 0)
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("Category ") + QString::number(i) + _(" must have a name"));
|
||||
return;
|
||||
}
|
||||
|
||||
oldid = category.id;
|
||||
_resolvedCategories[oldid] = categories[_categoriesGrid->item(i, 0)->text().toInt()] = category.id = _kiss->AddCategory(category);
|
||||
categories[oldid] = category.id = _kiss->AddCategory(category);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,9 +411,6 @@ void ImportPanel::OnIntegrate()
|
|||
{
|
||||
account = it->first.account;
|
||||
|
||||
if (_resolvedAccounts.count(account))
|
||||
account = _resolvedAccounts[account];
|
||||
|
||||
amount = _kiss->GetAccountAmount(account, it->first.month, it->first.year);
|
||||
|
||||
if (!amount)
|
||||
|
|
|
@ -847,7 +847,7 @@ void PreferencesPanel::OnAccountModified(int row, int col)
|
|||
if (value.size())
|
||||
{
|
||||
new_account.number = value;
|
||||
op_complete--;
|
||||
//op_complete--;
|
||||
}
|
||||
|
||||
// Account modification
|
||||
|
@ -863,6 +863,14 @@ void PreferencesPanel::OnAccountModified(int row, int col)
|
|||
|
||||
if (col == ACCOUNT_NAME)
|
||||
{
|
||||
if (new_account.name.length() == 0)
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("Account must have a name")+new_account.name+_(" already exists"));
|
||||
_accountsGrid->setItem(row, ACCOUNT_NAME, new QTableWidgetItem(user->_accounts[row].name));
|
||||
_inModification = false;
|
||||
return ;
|
||||
}
|
||||
|
||||
try {
|
||||
new_id = user->GetAccountId(new_account.name);
|
||||
if (new_id != new_account.id)
|
||||
|
@ -882,7 +890,7 @@ void PreferencesPanel::OnAccountModified(int row, int col)
|
|||
// New account
|
||||
else
|
||||
{
|
||||
if (op_complete)
|
||||
if (op_complete || new_account.name.length() == 0)
|
||||
{
|
||||
_inModification = false;
|
||||
return ;
|
||||
|
@ -1020,6 +1028,14 @@ void PreferencesPanel::OnCategoryModified(int row, int col)
|
|||
new_cat.font = old_cat.font;
|
||||
new_cat.parent = old_cat.parent;
|
||||
|
||||
if (new_cat.name.length() == 0)
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("Category must have a name"));
|
||||
_categoriesGrid->setItem(row, CATEGORY_NAME, new QTableWidgetItem(_(user->_categories[row].name.toStdString().c_str())));
|
||||
_inModification = false;
|
||||
return ;
|
||||
}
|
||||
|
||||
try {
|
||||
new_id = user->GetCategoryId(new_cat.name);
|
||||
if (new_id != new_cat.id)
|
||||
|
|