Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -32,7 +32,6 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Support\Collection;
use Throwable;
/**
* Class BalanceController.
@@ -61,11 +60,8 @@ class BalanceController extends Controller
/**
* Show overview of budget balances.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*
* @throws FireflyException
*/
public function general(Collection $accounts, Carbon $start, Carbon $end)
@@ -74,6 +70,7 @@ class BalanceController extends Controller
'budgets' => [],
'accounts' => [],
];
/** @var Account $account */
foreach ($accounts as $account) {
$report['accounts'][$account->id] = [
@@ -96,10 +93,13 @@ class BalanceController extends Controller
'sums' => [], // per currency
];
$spent = [];
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$journals = $collector->setRange($start, $end)->setSourceAccounts($accounts)->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)
->getExtractedJournals();
->getExtractedJournals()
;
/** @var array $journal */
foreach ($journals as $journal) {
$sourceAccount = $journal['source_account_id'];
@@ -137,12 +137,14 @@ class BalanceController extends Controller
$report['budgets'][$budgetId]['spent'] = $spent;
// get transactions in budget
}
try {
$result = view('reports.partials.balance', compact('report'))->render();
} catch (Throwable $e) {
} catch (\Throwable $e) {
app('log')->error(sprintf('Could not render reports.partials.balance: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
$result = 'Could not render view.';
throw new FireflyException($result, 0, $e);
}