Remove category chart from report controller.

This commit is contained in:
James Cole
2016-05-15 16:13:05 +02:00
parent bd818b2dea
commit 6a750a998f
48 changed files with 30 additions and 434 deletions

View File

@@ -218,59 +218,6 @@ class CategoryController extends Controller
}
/**
* @param Category $category
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return \Illuminate\Http\JsonResponse
*/
public function period(Category $category, Carbon $start, Carbon $end, Collection $accounts)
{
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($accounts);
$cache->addProperty($category->id);
$cache->addProperty('category');
$cache->addProperty('period');
if ($cache->has()) {
return Response::json($cache->get());
}
/** @var CRI $repository */
$repository = app(CRI::class);
$categoryCollection = new Collection([$category]);
// loop over period, add by users range:
$current = clone $start;
$viewRange = Preferences::get('viewRange', '1M')->data;
$format = strval(trans('config.month'));
$set = new Collection;
while ($current < $end) {
$currentStart = clone $current;
$currentEnd = Navigation::endOfPeriod($currentStart, $viewRange);
$spent = $repository->spentInPeriod($categoryCollection, $accounts, $currentStart, $currentEnd);
$earned = $repository->earnedInPeriod($categoryCollection, $accounts, $currentStart, $currentEnd);
$entry = [
$category->name,
$currentStart->formatLocalized($format),
$spent,
$earned,
];
$set->push($entry);
$currentEnd->addDay();
$current = clone $currentEnd;
}
$data = $this->generator->period($set);
$cache->store($data);
return Response::json($data);
}
/**
* @param CRI $repository
* @param Category $category