mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
More chart cleanup.
This commit is contained in:
@@ -333,70 +333,5 @@ class BudgetController extends Controller
|
|||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
|
|
||||||
return Response::json($data);
|
return Response::json($data);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param BudgetRepositoryInterface $repository
|
|
||||||
* @param $reportType
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*/
|
|
||||||
public function year(BudgetRepositoryInterface $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* // chart properties for cache:
|
|
||||||
* $cache = new CacheProperties();
|
|
||||||
* $cache->addProperty($start);
|
|
||||||
* $cache->addProperty($end);
|
|
||||||
* $cache->addProperty($reportType);
|
|
||||||
* $cache->addProperty($accounts);
|
|
||||||
* $cache->addProperty('budget');
|
|
||||||
* $cache->addProperty('year');
|
|
||||||
* if ($cache->has()) {
|
|
||||||
* return Response::json($cache->get());
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* $budgetInformation = $repository->getBudgetsAndExpensesPerMonth($accounts, $start, $end);
|
|
||||||
* $budgets = new Collection;
|
|
||||||
* $entries = new Collection;
|
|
||||||
*
|
|
||||||
* // @var array $row
|
|
||||||
* foreach ($budgetInformation as $row) {
|
|
||||||
* $budgets->push($row['budget']);
|
|
||||||
* }
|
|
||||||
* while ($start < $end) {
|
|
||||||
* // month is the current end of the period:
|
|
||||||
* $month = clone $start;
|
|
||||||
* $month->endOfMonth();
|
|
||||||
* $row = [clone $start];
|
|
||||||
* $dateFormatted = $start->format('Y-m');
|
|
||||||
*
|
|
||||||
* // each budget, check if there is an entry for this month:
|
|
||||||
* // @var array $row
|
|
||||||
* foreach ($budgetInformation as $budgetRow) {
|
|
||||||
* $spent = 0; // nothing spent.
|
|
||||||
* if (isset($budgetRow['entries'][$dateFormatted])) {
|
|
||||||
* $spent = $budgetRow['entries'][$dateFormatted] * -1; // to fit array
|
|
||||||
* }
|
|
||||||
* $row[] = $spent;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // add "no budget" thing.
|
|
||||||
* $row[] = round(bcmul($repository->getWithoutBudgetSum($accounts, $start, $month), '-1'), 4);
|
|
||||||
*
|
|
||||||
* $entries->push($row);
|
|
||||||
* $start->endOfMonth()->addDay();
|
|
||||||
* }
|
|
||||||
* $data = $this->generator->year($budgets, $entries);
|
|
||||||
* $cache->store($data);
|
|
||||||
*
|
|
||||||
* return Response::json($data);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user