mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Code cleanup.
This commit is contained in:
@@ -40,7 +40,6 @@ use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class CreateController
|
||||
*/
|
||||
class CreateController extends Controller
|
||||
@@ -52,8 +51,6 @@ class CreateController extends Controller
|
||||
|
||||
/**
|
||||
* CreateController constructor.
|
||||
*
|
||||
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -76,9 +73,6 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Create a new account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function create(Request $request, string $objectType)
|
||||
@@ -134,9 +128,8 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Store the new account.
|
||||
*
|
||||
* @param AccountFormRequest $request
|
||||
* @return Redirector|RedirectResponse
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
@@ -161,7 +154,7 @@ class CreateController extends Controller
|
||||
}
|
||||
|
||||
// store attachment(s):
|
||||
/** @var array|null $files */
|
||||
/** @var null|array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||
|
@@ -42,8 +42,6 @@ class DeleteController extends Controller
|
||||
|
||||
/**
|
||||
* DeleteController constructor.
|
||||
*
|
||||
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -65,9 +63,7 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Delete account screen.
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
* @return Factory|Redirector|RedirectResponse|View
|
||||
*/
|
||||
public function delete(Account $account)
|
||||
{
|
||||
@@ -90,10 +86,7 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Delete the account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @return Redirector|RedirectResponse
|
||||
*/
|
||||
public function destroy(Request $request, Account $account)
|
||||
{
|
||||
|
@@ -36,7 +36,6 @@ use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class EditController
|
||||
*/
|
||||
class EditController extends Controller
|
||||
@@ -70,11 +69,7 @@ class EditController extends Controller
|
||||
/**
|
||||
* Edit account overview.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
* @return Factory|Redirector|RedirectResponse|View
|
||||
*/
|
||||
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -178,10 +173,7 @@ class EditController extends Controller
|
||||
/**
|
||||
* Update the account.
|
||||
*
|
||||
* @param AccountFormRequest $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
* @return $this|Redirector|RedirectResponse
|
||||
*/
|
||||
public function update(AccountFormRequest $request, Account $account)
|
||||
{
|
||||
@@ -195,7 +187,7 @@ class EditController extends Controller
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));
|
||||
|
||||
// store new attachment(s):
|
||||
/** @var array|null $files */
|
||||
/** @var null|array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||
|
@@ -33,12 +33,10 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class IndexController
|
||||
*/
|
||||
class IndexController extends Controller
|
||||
@@ -49,8 +47,6 @@ class IndexController extends Controller
|
||||
|
||||
/**
|
||||
* IndexController constructor.
|
||||
*
|
||||
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -70,12 +66,10 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
*
|
||||
* @return Factory|View
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
* @throws \JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
@@ -91,8 +85,10 @@ class IndexController extends Controller
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
unset($collection);
|
||||
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$start->subDay();
|
||||
@@ -126,12 +122,10 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Show list of accounts.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
*
|
||||
* @return Factory|View
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
* @throws \JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
@@ -154,8 +148,10 @@ class IndexController extends Controller
|
||||
app('log')->debug(sprintf('Count of collection: %d, count of accounts: %d', $total, $accounts->count()));
|
||||
|
||||
unset($collection);
|
||||
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$start->subDay();
|
||||
@@ -165,7 +161,6 @@ class IndexController extends Controller
|
||||
$endBalances = app('steam')->balancesByAccounts($accounts, $end);
|
||||
$activities = app('steam')->getLastActivities($ids);
|
||||
|
||||
|
||||
$accounts->each(
|
||||
function (Account $account) use ($activities, $startBalances, $endBalances) {
|
||||
$interest = (string)$this->repository->getMetaValue($account, 'interest');
|
||||
@@ -189,6 +184,7 @@ class IndexController extends Controller
|
||||
);
|
||||
// make paginator:
|
||||
app('log')->debug(sprintf('Count of accounts before LAP: %d', $accounts->count()));
|
||||
|
||||
/** @var LengthAwarePaginator $accounts */
|
||||
$accounts = new LengthAwarePaginator($accounts, $total, $pageSize, $page);
|
||||
$accounts->setPath(route('accounts.index', [$objectType]));
|
||||
|
@@ -39,7 +39,6 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
@@ -53,8 +52,6 @@ class ReconcileController extends Controller
|
||||
|
||||
/**
|
||||
* ReconcileController constructor.
|
||||
*
|
||||
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -76,13 +73,10 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* Reconciliation overview.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return Factory|Redirector|RedirectResponse|View
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
* @throws \JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
@@ -106,6 +100,7 @@ class ReconcileController extends Controller
|
||||
if (null === $start && null === $end) {
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon(), $range));
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', app('navigation')->endOfPeriod(new Carbon(), $range));
|
||||
}
|
||||
@@ -153,14 +148,10 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* Submit a new reconciliation.
|
||||
*
|
||||
* @param ReconciliationStoreRequest $request
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @return Redirector|RedirectResponse
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws DuplicateTransactionException
|
||||
* @throws JsonException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end)
|
||||
{
|
||||
@@ -202,14 +193,8 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* Creates a reconciliation group.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $difference
|
||||
*
|
||||
* @return string
|
||||
* @throws DuplicateTransactionException
|
||||
* @throws JsonException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference): string
|
||||
{
|
||||
@@ -258,11 +243,14 @@ class ReconcileController extends Controller
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/** @var TransactionGroupFactory $factory */
|
||||
$factory = app(TransactionGroupFactory::class);
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$factory->setUser($user);
|
||||
|
||||
try {
|
||||
$factory->create($submission);
|
||||
} catch (FireflyException $e) {
|
||||
|
@@ -36,13 +36,11 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class ShowController
|
||||
*
|
||||
*/
|
||||
class ShowController extends Controller
|
||||
{
|
||||
@@ -52,8 +50,6 @@ class ShowController extends Controller
|
||||
|
||||
/**
|
||||
* ShowController constructor.
|
||||
*
|
||||
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -77,14 +73,10 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show an account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @return Factory|Redirector|RedirectResponse|View
|
||||
*
|
||||
* @return RedirectResponse|Redirector|Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
* @throws \JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
@@ -96,9 +88,9 @@ class ShowController extends Controller
|
||||
return $this->redirectAccountToAccount($account);
|
||||
}
|
||||
|
||||
/** @var Carbon $start */
|
||||
// @var Carbon $start
|
||||
$start ??= session('start');
|
||||
/** @var Carbon $end */
|
||||
// @var Carbon $end
|
||||
$end ??= session('end');
|
||||
|
||||
if ($end < $start) {
|
||||
@@ -123,20 +115,19 @@ class ShowController extends Controller
|
||||
$subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
}
|
||||
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector
|
||||
->setAccounts(new Collection([$account]))
|
||||
->setLimit($pageSize)
|
||||
->setPage($page)->withAccountInformation()->withCategoryInformation()
|
||||
->setRange($start, $end);
|
||||
->setRange($start, $end)
|
||||
;
|
||||
|
||||
// this search will not include transaction groups where this asset account (or liability)
|
||||
// is just part of ONE of the journals. To force this:
|
||||
$collector->setExpandGroupSearch(true);
|
||||
|
||||
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
|
||||
$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
@@ -168,12 +159,10 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show an account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @return Factory|Redirector|RedirectResponse|View
|
||||
*
|
||||
* @return RedirectResponse|Redirector|Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
* @throws \JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
@@ -189,12 +178,13 @@ class ShowController extends Controller
|
||||
$end = today(config('app.timezone'));
|
||||
$today = today(config('app.timezone'));
|
||||
$start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||
$subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$periods = new Collection();
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation();
|
||||
|
Reference in New Issue
Block a user