Fix a bug: current account value is badly computed if operations are not in date order

This commit is contained in:
Grégory Soutadé 2018-08-26 18:10:46 +02:00
parent 38770639be
commit f1de45d08a

View File

@ -623,11 +623,9 @@ void AccountPanel::UpdateStats()
if (op.amount >= 0) if (op.amount >= 0)
{ {
if (!op.transfert && !account.blocked) if (!op.transfert && !account.blocked)
totalCredit += op.amount;
if (day >= op.day)
{ {
if (!op.transfert && !account.blocked) totalCredit += op.amount;
if (day >= op.day)
curCredit += op.amount; curCredit += op.amount;
} }
} }
@ -637,11 +635,9 @@ void AccountPanel::UpdateStats()
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ; _categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
if (!op.transfert || force_debit) if (!op.transfert || force_debit)
totalDebit += -op.amount;
if (day >= op.day)
{ {
if (!op.transfert || force_debit) totalDebit += -op.amount;
if (day >= op.day)
curDebit += -op.amount; curDebit += -op.amount;
} }
@ -649,9 +645,8 @@ void AccountPanel::UpdateStats()
op.amount = -op.amount; op.amount = -op.amount;
} }
finalAccountAmount[op.account] += op.amount; finalAccountAmount[op.account] += op.amount;
curAccountAmounts[op.day][op.account] += op.amount; for(i=op.day; i<nbDays; i++)
for(i=op.day+1; i<nbDays; i++) curAccountAmounts[i][op.account] += op.amount;
curAccountAmounts[i][op.account] = curAccountAmounts[op.day][op.account];
} }
if (mode != CHECK_MODE) if (mode != CHECK_MODE)