mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-27 19:31:01 -06:00
Fix negative amounts and chart names.
This commit is contained in:
parent
15846e157b
commit
18c46df9aa
@ -83,8 +83,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
||||
if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) {
|
||||
$data['labels'][] = $entry[0];
|
||||
$left[] = round($entry[1], 2);
|
||||
$spent[] = round($entry[2], 2);
|
||||
$overspent[] = round($entry[3], 2);
|
||||
$spent[] = round($entry[2] * -1, 2); // spent is coming in negative, must be positive
|
||||
$overspent[] = round($entry[3] * -1, 2); // same
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,8 +236,8 @@ class BudgetController extends Controller
|
||||
// we already have amount, startdate and enddate.
|
||||
// if this "is" a limit repetition (as opposed to a budget without one entirely)
|
||||
// depends on whether startdate and enddate are null.
|
||||
$name = $budget->name;
|
||||
if (is_null($budget->startdate) && is_null($budget->enddate)) {
|
||||
$name = $budget->name . ' (' . $start->formatLocalized(trans('config.month')) . ')';
|
||||
$currentStart = clone $start;
|
||||
$currentEnd = clone $end;
|
||||
$expenses = $repository->balanceInPeriod($budget, $currentStart, $currentEnd, $accounts);
|
||||
@ -246,21 +246,20 @@ class BudgetController extends Controller
|
||||
$spent = $expenses;
|
||||
$overspent = 0;
|
||||
} else {
|
||||
$name = $budget->name . ' (' . $budget->startdate->formatLocalized(trans('config.month')) . ')';
|
||||
$currentStart = clone $budget->startdate;
|
||||
$currentEnd = clone $budget->enddate;
|
||||
$expenses = $repository->balanceInPeriod($budget, $currentStart, $currentEnd, $accounts);
|
||||
$amount = $budget->amount;
|
||||
// smaller than 1 means spent MORE than budget allows.
|
||||
$left = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? 0 : bcadd($budget->amount, $expenses);
|
||||
$spent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? $amount : $expenses;
|
||||
$spent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? ($amount*-1) : $expenses;
|
||||
$overspent = bccomp(bcadd($budget->amount, $expenses), '0') < 1 ? bcadd($budget->amount, $expenses) : 0;
|
||||
}
|
||||
|
||||
$allEntries->push([$name, $left, $spent, $overspent, $amount, $expenses]);
|
||||
}
|
||||
|
||||
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end) * -1;
|
||||
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
|
||||
$allEntries->push([trans('firefly.noBudget'), 0, 0, $noBudgetExpenses, 0, 0]);
|
||||
$data = $this->generator->frontpage($allEntries);
|
||||
$cache->store($data);
|
||||
|
Loading…
Reference in New Issue
Block a user