Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
First calculations for multi-year budget chart.
James Cole69553b138b00
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.phpindex 864e910cc4..2cdba30b4e 100644--- a/app/Http/Controllers/Chart/BudgetController.php+++ b/app/Http/Controllers/Chart/BudgetController.php@@ -47,14 +47,25 @@ class BudgetController extends Controllerpublic function multiYear(BudgetRepositoryInterface $repository, $report_type, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets){$currentStart = clone $start;+ $collection = new Collection;while ($currentStart < $end) {$currentEnd = clone $currentStart;$currentEnd->endOfYear();- //echo 'now for '.$currentStart->format('Ymd').' to '.$currentEnd->format('Ymd').'<br>';- //epository->balanceInPeriod()+ echo 'now for ' . $currentStart->format('Ymd') . ' to ' . $currentEnd->format('Ymd') . '<br>';+ /** @var Budget $budget */+ foreach ($budgets as $budget) {+ if (is_null($budget->id)) {+ $name = trans('firefly.noBudget');+ $sum = $repository->getWithoutBudgetSum($currentStart, $currentEnd);+ } else {+ $name = $budget->name;+ $sum = $repository->balanceInPeriodForList($budget, $currentStart, $currentEnd, $accounts);+ }+ echo $name.': '.$sum.'<br>';+ }// do something for all budgets.// jump to next year.diff --git a/app/Http/routes.php b/app/Http/routes.phpindex 4599887047..1e3f4c109a 100644--- a/app/Http/routes.php+++ b/app/Http/routes.php@@ -60,6 +60,12 @@ Route::bind(->whereIn('budgets.id', $ids)->where('budgets.user_id', Auth::user()->id)->get(['budgets.*']);++ // add empty budget if applicable.+ if(in_array('0', $ids)) {+ $object->push(new Budget);+ }+if ($object->count() > 0) {return $object;}