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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user