mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
First calculations for multi-year budget chart.
This commit is contained in:
parent
36d7a02994
commit
69553b138b
@ -47,14 +47,25 @@ class BudgetController extends Controller
|
||||
public 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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user