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

@@ -34,7 +34,6 @@ use Illuminate\Routing\Redirector;
/**
* Trait UserNavigation
*
*/
trait UserNavigation
{
@@ -45,10 +44,6 @@ trait UserNavigation
* returned but instead the index (/) will be returned.
* - If the remembered url contains "jscript/" the remembered url will not be returned but instead the index (/)
* will be returned.
*
* @param string $identifier
*
* @return string
*/
final protected function getPreviousUrl(string $identifier): string
{
@@ -61,10 +56,6 @@ trait UserNavigation
/**
* Will return false if you cant edit this account type.
*
* @param Account $account
*
* @return bool
*/
final protected function isEditableAccount(Account $account): bool
{
@@ -74,14 +65,9 @@ trait UserNavigation
return in_array($type, $editable, true);
}
/**
* @param TransactionGroup $group
*
* @return bool
*/
final protected function isEditableGroup(TransactionGroup $group): bool
{
/** @var TransactionJournal|null $journal */
/** @var null|TransactionJournal $journal */
$journal = $group->transactionJournals()->first();
if (null === $journal) {
return false;
@@ -93,9 +79,7 @@ trait UserNavigation
}
/**
* @param Account $account
*
* @return RedirectResponse|Redirector
* @return Redirector|RedirectResponse
*/
final protected function redirectAccountToAccount(Account $account)
{
@@ -103,7 +87,7 @@ trait UserNavigation
if (AccountType::RECONCILIATION === $type || AccountType::INITIAL_BALANCE === $type || AccountType::LIABILITY_CREDIT === $type) {
// reconciliation must be stored somewhere in this account's transactions.
/** @var Transaction|null $transaction */
/** @var null|Transaction $transaction */
$transaction = $account->transactions()->first();
if (null === $transaction) {
app('log')->error(sprintf('Account #%d has no transactions. Dont know where it belongs.', $account->id));
@@ -112,7 +96,8 @@ trait UserNavigation
return redirect(route('index'));
}
$journal = $transaction->transactionJournal;
/** @var Transaction|null $other */
/** @var null|Transaction $other */
$other = $journal->transactions()->where('id', '!=', $transaction->id)->first();
if (null === $other) {
app('log')->error(sprintf('Account #%d has no valid journals. Dont know where it belongs.', $account->id));
@@ -128,13 +113,11 @@ trait UserNavigation
}
/**
* @param TransactionGroup $group
*
* @return RedirectResponse|Redirector
* @return Redirector|RedirectResponse
*/
final protected function redirectGroupToAccount(TransactionGroup $group)
{
/** @var TransactionJournal|null $journal */
/** @var null|TransactionJournal $journal */
$journal = $group->transactionJournals()->first();
if (null === $journal) {
app('log')->error(sprintf('No journals in group #%d', $group->id));
@@ -144,6 +127,7 @@ trait UserNavigation
// prefer redirect to everything but expense and revenue:
$transactions = $journal->transactions;
$ignore = [AccountType::REVENUE, AccountType::EXPENSE, AccountType::RECONCILIATION, AccountType::INITIAL_BALANCE];
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
$type = $transaction->account->accountType->type;
@@ -155,11 +139,6 @@ trait UserNavigation
return redirect(route('index'));
}
/**
* @param string $identifier
*
* @return string|null
*/
final protected function rememberPreviousUrl(string $identifier): ?string
{
$return = app('steam')->getSafePreviousUrl();