Show hidden accounts at the end in the list
Simplify statistics computation in AccountPanel Don't take in account simple credit on blocked accounts
This commit is contained in:
parent
aff6e14072
commit
c565c7740d
|
@ -266,7 +266,7 @@ User* Database::LoadUser(const QString& name)
|
||||||
|
|
||||||
query.clear();
|
query.clear();
|
||||||
|
|
||||||
req = QString("SELECT * FROM account WHERE user='%1' ORDER BY default_account DESC, blocked, virtual, name ASC").arg(user->_id);
|
req = QString("SELECT * FROM account WHERE user='%1' ORDER BY default_account DESC, hidden, blocked, virtual, name ASC").arg(user->_id);
|
||||||
|
|
||||||
EXECUTE_SQL_QUERY_WITH_CODE(req, 0, {delete user;}, {delete user;});
|
EXECUTE_SQL_QUERY_WITH_CODE(req, 0, {delete user;}, {delete user;});
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ User* Database::LoadUser(const QString& name)
|
||||||
|
|
||||||
query.clear();
|
query.clear();
|
||||||
|
|
||||||
req = QString("SELECT * FROM account WHERE id IN (SELECT account FROM shared_account WHERE user='%1') ORDER BY name, blocked, virtual ASC").arg(user->_id);
|
req = QString("SELECT * FROM account WHERE id IN (SELECT account FROM shared_account WHERE user='%1') ORDER BY default_account DESC, hidden, blocked, virtual, name ASC").arg(user->_id);
|
||||||
|
|
||||||
EXECUTE_SQL_QUERY_WITH_CODE(req, 0, {delete user;}, {delete user;});
|
EXECUTE_SQL_QUERY_WITH_CODE(req, 0, {delete user;}, {delete user;});
|
||||||
|
|
||||||
|
|
|
@ -619,31 +619,35 @@ void AccountPanel::UpdateStats()
|
||||||
op = *it;
|
op = *it;
|
||||||
blocked_account = false;
|
blocked_account = false;
|
||||||
|
|
||||||
// A credit on a blocked account must be considered as a debit
|
if ((mode == REAL_MODE || mode == CHECK_MODE) && op._virtual)
|
||||||
if (op.transfert && op.amount > 0)
|
continue;
|
||||||
{
|
|
||||||
|
if (mode == CHECK_MODE && !op.checked)
|
||||||
|
continue;
|
||||||
|
|
||||||
account = user->GetAccount(op.account);
|
account = user->GetAccount(op.account);
|
||||||
|
|
||||||
if (account.blocked)
|
if (account.blocked)
|
||||||
{
|
{
|
||||||
|
if (op.transfert && op.amount > 0)
|
||||||
|
{
|
||||||
|
// A Transfert on a blocked account must be considered as a debit
|
||||||
op.amount = -op.amount;
|
op.amount = -op.amount;
|
||||||
op.transfert = 0;
|
// op.transfert = 0;
|
||||||
blocked_account = true;
|
blocked_account = true;
|
||||||
}
|
}
|
||||||
|
// else
|
||||||
|
// continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch(mode)
|
|
||||||
{
|
|
||||||
case VIRTUAL_MODE:
|
|
||||||
if (op.amount >= 0)
|
if (op.amount >= 0)
|
||||||
{
|
{
|
||||||
if (!op.transfert)
|
if (!op.transfert && !account.blocked)
|
||||||
totalCredit += op.amount;
|
totalCredit += op.amount;
|
||||||
|
|
||||||
if (day >= op.day)
|
if (day >= op.day)
|
||||||
{
|
{
|
||||||
if (!op.transfert)
|
if (!op.transfert && !account.blocked)
|
||||||
curCredit += op.amount;
|
curCredit += op.amount;
|
||||||
curAccountAmount[op.account] += op.amount;
|
curAccountAmount[op.account] += op.amount;
|
||||||
}
|
}
|
||||||
|
@ -651,101 +655,25 @@ void AccountPanel::UpdateStats()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!op.transfert && user->GetCategoryName(op.category) != _("Unknown"))
|
if ((!op.transfert || account.blocked) && user->GetCategoryName(op.category) != _("Unknown"))
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
||||||
|
|
||||||
if (!op.transfert)
|
if (!op.transfert || account.blocked)
|
||||||
totalDebit += -op.amount;
|
totalDebit += -op.amount;
|
||||||
|
|
||||||
|
if (day >= op.day)
|
||||||
|
{
|
||||||
|
if (!op.transfert || account.blocked)
|
||||||
|
curDebit += -op.amount;
|
||||||
|
}
|
||||||
|
|
||||||
if (blocked_account)
|
if (blocked_account)
|
||||||
op.amount = -op.amount;
|
op.amount = -op.amount;
|
||||||
|
|
||||||
if (day >= op.day)
|
if (day >= op.day)
|
||||||
{
|
|
||||||
if (!op.transfert)
|
|
||||||
curDebit += -op.amount;
|
|
||||||
curAccountAmount[op.account] += op.amount;
|
curAccountAmount[op.account] += op.amount;
|
||||||
}
|
|
||||||
finalAccountAmount[op.account] += op.amount;
|
finalAccountAmount[op.account] += op.amount;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case REAL_MODE:
|
|
||||||
if (op.amount >= 0)
|
|
||||||
{
|
|
||||||
if (!op.transfert)
|
|
||||||
totalCredit += op.amount;
|
|
||||||
|
|
||||||
if (day >= op.day)
|
|
||||||
{
|
|
||||||
if (!op.transfert)
|
|
||||||
curCredit += op.amount;
|
|
||||||
if (!op._virtual)
|
|
||||||
curAccountAmount[op.account] += op.amount;
|
|
||||||
}
|
|
||||||
if (!op._virtual)
|
|
||||||
finalAccountAmount[op.account] += op.amount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!op.transfert && user->GetCategoryName(op.category) != _("Unknown"))
|
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
|
||||||
|
|
||||||
if (!op.transfert && !op._virtual)
|
|
||||||
totalDebit += -op.amount;
|
|
||||||
|
|
||||||
if (blocked_account)
|
|
||||||
op.amount = -op.amount;
|
|
||||||
|
|
||||||
if (day >= op.day)
|
|
||||||
{
|
|
||||||
if (!op.transfert && !op._virtual)
|
|
||||||
curDebit += -op.amount;
|
|
||||||
if (!op._virtual)
|
|
||||||
curAccountAmount[op.account] += op.amount;
|
|
||||||
}
|
|
||||||
if (!op._virtual)
|
|
||||||
finalAccountAmount[op.account] += op.amount;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CHECK_MODE:
|
|
||||||
if (op.amount >= 0)
|
|
||||||
{
|
|
||||||
if (!op.transfert && !op._virtual)
|
|
||||||
totalCredit += op.amount;
|
|
||||||
|
|
||||||
if (day >= op.day)
|
|
||||||
{
|
|
||||||
if (!op.transfert && !op._virtual)
|
|
||||||
curCredit += op.amount;
|
|
||||||
if (op.checked && !op._virtual)
|
|
||||||
curAccountAmount[op.account] += op.amount;
|
|
||||||
}
|
|
||||||
if (op.checked && !op._virtual)
|
|
||||||
finalAccountAmount[op.account] += op.amount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!op.transfert && user->GetCategoryName(op.category) != _("Unknown"))
|
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
|
||||||
|
|
||||||
if (!op.transfert && !op._virtual)
|
|
||||||
totalDebit += -op.amount;
|
|
||||||
|
|
||||||
if (blocked_account)
|
|
||||||
op.amount = -op.amount;
|
|
||||||
|
|
||||||
if (day >= op.day)
|
|
||||||
{
|
|
||||||
if (!op.transfert && !op._virtual)
|
|
||||||
curDebit += -op.amount;
|
|
||||||
if (op.checked && !op._virtual)
|
|
||||||
curAccountAmount[op.account] += op.amount;
|
|
||||||
}
|
|
||||||
if (op.checked && !op._virtual)
|
|
||||||
finalAccountAmount[op.account] += op.amount;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
balance = totalCredit - totalDebit;
|
balance = totalCredit - totalDebit;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user