Commit 93afc106 authored by Cristian Oneț's avatar Cristian Oneț
Browse files

Fix the cleared balance of liability accounts.

The problem was caused by the fact that when refactored, the code
didn't consider the fact that previously the balance was also being
multiplied by factor. Instead of using factor at each step use it
only at the end when the result is returned since it's faster this

BUG: 338684
(cherry picked from commit 850b95c1)
parent 7c416fbf
......@@ -1487,8 +1487,7 @@ const MyMoneyMoney MyMoneyFile::clearedBalance(const QString &id, const QDate& d
MyMoneyAccount account = this->account(id);
MyMoneyMoney factor(1, 1);
if (account.accountGroup() == MyMoneyAccount::Liability
|| account.accountGroup() == MyMoneyAccount::Equity)
if (account.accountGroup() == MyMoneyAccount::Liability || account.accountGroup() == MyMoneyAccount::Equity)
factor = -factor;
MyMoneyTransactionFilter filter;
......@@ -1504,10 +1503,10 @@ const MyMoneyMoney MyMoneyFile::clearedBalance(const QString &id, const QDate& d
const MyMoneySplit &split = (*it_s);
if (split.accountId() != id)
cleared -= split.shares() * factor;
cleared -= split.shares();
return cleared;
return cleared * factor;
const MyMoneyMoney MyMoneyFile::totalBalance(const QString& id, const QDate& date) const
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment