mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-21 09:00:07 +00:00
Various code cleanup and fixed alignments.
This commit is contained in:
@@ -64,7 +64,7 @@ class ReportController extends Controller
|
||||
public function netWorth(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty('chart.report.net-worth');
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));
|
||||
@@ -72,12 +72,12 @@ class ReportController extends Controller
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
$current = clone $start;
|
||||
$chartData = [];
|
||||
$locale = app('steam')->getLocale();
|
||||
$current = clone $start;
|
||||
$chartData = [];
|
||||
|
||||
/** @var NetWorthInterface $helper */
|
||||
$helper = app(NetWorthInterface::class);
|
||||
$helper = app(NetWorthInterface::class);
|
||||
$helper->setUser(auth()->user());
|
||||
|
||||
// filter accounts on having the preference for being included.
|
||||
@@ -107,8 +107,8 @@ class ReportController extends Controller
|
||||
if ('native' === $key) {
|
||||
continue;
|
||||
}
|
||||
$currencyId = $netWorthItem['currency_id'];
|
||||
$label = $current->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
$currencyId = $netWorthItem['currency_id'];
|
||||
$label = $current->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
if (!array_key_exists($currencyId, $chartData)) {
|
||||
$chartData[$currencyId] = [
|
||||
'label' => 'Net worth in '.$netWorthItem['currency_name'],
|
||||
@@ -123,7 +123,7 @@ class ReportController extends Controller
|
||||
$current->addDays(7);
|
||||
}
|
||||
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
@@ -137,7 +137,7 @@ class ReportController extends Controller
|
||||
public function operations(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty('chart.report.operations');
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($accounts);
|
||||
@@ -154,17 +154,17 @@ class ReportController extends Controller
|
||||
$chartData = [];
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->withAccountInformation();
|
||||
$collector->setXorAccounts($accounts);
|
||||
$collector->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::RECONCILIATION, TransactionType::TRANSFER]);
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$journals = $collector->getExtractedJournals();
|
||||
|
||||
// loop. group by currency and by period.
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$period = $journal['date']->format($format);
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$period = $journal['date']->format($format);
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$data[$currencyId] ??= [
|
||||
'currency_id' => $currencyId,
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
@@ -178,8 +178,8 @@ class ReportController extends Controller
|
||||
'earned' => '0',
|
||||
];
|
||||
// in our outgoing?
|
||||
$key = 'spent';
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$key = 'spent';
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
|
||||
// deposit = incoming
|
||||
// transfer or reconcile or opening balance, and these accounts are the destination.
|
||||
@@ -192,7 +192,7 @@ class ReportController extends Controller
|
||||
// loop this data, make chart bars for each currency:
|
||||
/** @var array $currency */
|
||||
foreach ($data as $currency) {
|
||||
$income = [
|
||||
$income = [
|
||||
'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]),
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
||||
@@ -201,7 +201,7 @@ class ReportController extends Controller
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'entries' => [],
|
||||
];
|
||||
$expense = [
|
||||
$expense = [
|
||||
'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
||||
@@ -220,11 +220,11 @@ class ReportController extends Controller
|
||||
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
|
||||
}
|
||||
|
||||
$chartData[] = $income;
|
||||
$chartData[] = $expense;
|
||||
$chartData[] = $income;
|
||||
$chartData[] = $expense;
|
||||
}
|
||||
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
|
||||
Reference in New Issue
Block a user