mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
chore: reformat code.
This commit is contained in:
@@ -70,7 +70,7 @@ class CategoryController extends Controller
|
||||
* Show an overview for a category for all time, per month/week/year.
|
||||
* TODO test method, for category refactor.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Category $category
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -102,6 +102,14 @@ class CategoryController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
private function getDate(): Carbon
|
||||
{
|
||||
return today(config('app.timezone'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the category chart on the front page.
|
||||
* TODO test method for category refactor.
|
||||
@@ -133,10 +141,10 @@ class CategoryController extends Controller
|
||||
* Chart report.
|
||||
* TODO test method for category refactor.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Category $category
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -158,88 +166,13 @@ class CategoryController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Chart for period for transactions without a category.
|
||||
* TODO test me.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function reportPeriodNoCategory(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('chart.category.period.no-cat');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$data = $this->reportPeriodChart($accounts, $start, $end, null);
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Chart for a specific period.
|
||||
* TODO test me, for category refactor.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function specificPeriod(Category $category, Carbon $date): JsonResponse
|
||||
{
|
||||
$range = app('navigation')->getViewRange(false);
|
||||
$start = app('navigation')->startOfPeriod($date, $range);
|
||||
$end = session()->get('end');
|
||||
if ($end < $start) {
|
||||
[$end, $start] = [$start, $end];
|
||||
}
|
||||
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($category->id);
|
||||
$cache->addProperty('chart.category.period-chart');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
|
||||
/** @var WholePeriodChartGenerator $chartGenerator */
|
||||
$chartGenerator = app(WholePeriodChartGenerator::class);
|
||||
$chartData = $chartGenerator->generate($category, $start, $end);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
private function getDate(): Carbon
|
||||
{
|
||||
return today(config('app.timezone'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate report chart for either with or without category.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Category|null $category
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Category|null $category
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -318,4 +251,71 @@ class CategoryController extends Controller
|
||||
|
||||
return $this->generator->multiSet($chartData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Chart for period for transactions without a category.
|
||||
* TODO test me.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function reportPeriodNoCategory(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('chart.category.period.no-cat');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$data = $this->reportPeriodChart($accounts, $start, $end, null);
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Chart for a specific period.
|
||||
* TODO test me, for category refactor.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function specificPeriod(Category $category, Carbon $date): JsonResponse
|
||||
{
|
||||
$range = app('navigation')->getViewRange(false);
|
||||
$start = app('navigation')->startOfPeriod($date, $range);
|
||||
$end = session()->get('end');
|
||||
if ($end < $start) {
|
||||
[$end, $start] = [$start, $end];
|
||||
}
|
||||
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($category->id);
|
||||
$cache->addProperty('chart.category.period-chart');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
|
||||
/** @var WholePeriodChartGenerator $chartGenerator */
|
||||
$chartGenerator = app(WholePeriodChartGenerator::class);
|
||||
$chartData = $chartGenerator->generate($category, $start, $end);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user