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();
|
||||
|
||||
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;});
|
||||
|
||||
|
@ -279,7 +279,7 @@ User* Database::LoadUser(const QString& name)
|
|||
|
||||
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;});
|
||||
|
||||
|
|
|
@ -619,133 +619,61 @@ void AccountPanel::UpdateStats()
|
|||
op = *it;
|
||||
blocked_account = false;
|
||||
|
||||
// A credit on a blocked account must be considered as a debit
|
||||
if (op.transfert && op.amount > 0)
|
||||
{
|
||||
account = user->GetAccount(op.account);
|
||||
if ((mode == REAL_MODE || mode == CHECK_MODE) && op._virtual)
|
||||
continue;
|
||||
|
||||
if (account.blocked)
|
||||
{
|
||||
op.amount = -op.amount;
|
||||
op.transfert = 0;
|
||||
blocked_account = true;
|
||||
}
|
||||
if (mode == CHECK_MODE && !op.checked)
|
||||
continue;
|
||||
|
||||
account = user->GetAccount(op.account);
|
||||
|
||||
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.transfert = 0;
|
||||
blocked_account = true;
|
||||
}
|
||||
// else
|
||||
// continue;
|
||||
}
|
||||
|
||||
if (op.amount >= 0)
|
||||
{
|
||||
if (!op.transfert && !account.blocked)
|
||||
totalCredit += op.amount;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case VIRTUAL_MODE:
|
||||
if (op.amount >= 0)
|
||||
{
|
||||
if (!op.transfert)
|
||||
totalCredit += op.amount;
|
||||
if (day >= op.day)
|
||||
{
|
||||
if (!op.transfert && !account.blocked)
|
||||
curCredit += op.amount;
|
||||
curAccountAmount[op.account] += op.amount;
|
||||
}
|
||||
finalAccountAmount[op.account] += op.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((!op.transfert || account.blocked) && user->GetCategoryName(op.category) != _("Unknown"))
|
||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
||||
|
||||
if (day >= op.day)
|
||||
{
|
||||
if (!op.transfert)
|
||||
curCredit += op.amount;
|
||||
curAccountAmount[op.account] += op.amount;
|
||||
}
|
||||
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 || account.blocked)
|
||||
totalDebit += -op.amount;
|
||||
|
||||
if (!op.transfert)
|
||||
totalDebit += -op.amount;
|
||||
if (day >= op.day)
|
||||
{
|
||||
if (!op.transfert || account.blocked)
|
||||
curDebit += -op.amount;
|
||||
}
|
||||
|
||||
if (blocked_account)
|
||||
op.amount = -op.amount;
|
||||
if (blocked_account)
|
||||
op.amount = -op.amount;
|
||||
|
||||
if (day >= op.day)
|
||||
{
|
||||
if (!op.transfert)
|
||||
curDebit += -op.amount;
|
||||
curAccountAmount[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;
|
||||
}
|
||||
if (day >= op.day)
|
||||
curAccountAmount[op.account] += op.amount;
|
||||
finalAccountAmount[op.account] += op.amount;
|
||||
}
|
||||
}
|
||||
|
||||
balance = totalCredit - totalDebit;
|
||||
|
|
Loading…
Reference in New Issue
Block a user