Code cleanup.

This commit is contained in:
James Cole
2021-03-28 11:46:23 +02:00
parent 2c575f3ca5
commit b5eeacc128
124 changed files with 1568 additions and 1384 deletions

View File

@@ -42,6 +42,7 @@ use Illuminate\Support\Collection;
class BudgetReportController extends Controller
{
use AugumentData, TransactionCalculation;
/** @var GeneratorInterface Chart generation methods. */
private $generator;
@@ -199,7 +200,7 @@ class BudgetReportController extends Controller
$chartData[$spentKey] = $chartData[$spentKey] ?? [
'label' => sprintf(
'%s (%s)',
(string) trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
(string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
$currency['currency_name']
),
'type' => 'bar',
@@ -224,6 +225,29 @@ class BudgetReportController extends Controller
return response()->json($data);
}
/**
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
private function makeEntries(Carbon $start, Carbon $end): array
{
$return = [];
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
$currentStart = clone $start;
while ($currentStart <= $end) {
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
$key = $currentStart->formatLocalized($format);
$return[$key] = '0';
$currentStart = clone $currentEnd;
$currentStart->addDay()->startOfDay();
}
return $return;
}
/**
* Chart that groups expenses by the account.
*
@@ -260,27 +284,4 @@ class BudgetReportController extends Controller
return response()->json($data);
}
/**
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
private function makeEntries(Carbon $start, Carbon $end): array
{
$return = [];
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
$currentStart = clone $start;
while ($currentStart <= $end) {
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
$key = $currentStart->formatLocalized($format);
$return[$key] = '0';
$currentStart = clone $currentEnd;
$currentStart->addDay()->startOfDay();
}
return $return;
}
}