mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 03:53:37 +00:00
Code cleanup.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user