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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user