mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-16 02:13:34 -06:00
Catch 0 start balance.
This commit is contained in:
parent
05fa1b40d1
commit
bbc7b54a38
@ -144,13 +144,17 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
// diff (negative when lost, positive when gained)
|
||||
$diff = $account->endBalance - $account->startBalance;
|
||||
|
||||
if ($diff < 0) {
|
||||
if ($diff < 0 && $account->startBalance > 0) {
|
||||
// percentage lost compared to start.
|
||||
$pct = (($diff * -1) / $account->startBalance) * 100;
|
||||
} else {
|
||||
$pct = ($diff / $account->startBalance) * 100;
|
||||
if ($diff >= 0 && $account->startBalance > 0) {
|
||||
$pct = ($diff / $account->startBalance) * 100;
|
||||
} else {
|
||||
$pct = 0;
|
||||
}
|
||||
}
|
||||
$pct = $pct > 100 ? 100 : $pct;
|
||||
$pct = $pct > 100 ? 100 : $pct;
|
||||
$account->difference = $diff;
|
||||
$account->percentage = round($pct);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user