Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix negative amounts and chart names.
James Cole18c46df9aa1f
diff --git a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.phpindex 42608e027d..6af66916ff 100644--- a/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php+++ b/app/Generator/Chart/Budget/ChartJsBudgetChartGenerator.php@@ -83,8 +83,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorif ($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}}diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.phpindex d178dc3724..2e595f74e2 100644--- a/app/Http/Controllers/Chart/BudgetController.php+++ b/app/Http/Controllers/Chart/BudgetController.php@@ -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);