mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-28 00:57:11 +00:00
Redirect user to original account refactor.
This commit is contained in:
@@ -36,6 +36,7 @@ use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\UserRedirection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -45,6 +46,7 @@ use Log;
|
||||
*/
|
||||
class ReconcileController extends Controller
|
||||
{
|
||||
use UserRedirection;
|
||||
/** @var AccountRepositoryInterface The account repository */
|
||||
private $accountRepos;
|
||||
/** @var CurrencyRepositoryInterface The currency repository */
|
||||
@@ -370,32 +372,4 @@ class ReconcileController extends Controller
|
||||
// redirect to previous URL.
|
||||
return redirect($this->getPreviousUri('reconcile.edit.uri'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect user to the original asset account.
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
protected function redirectToOriginalAccount(Account $account) // user redirection + nav
|
||||
{
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $account->transactions()->first();
|
||||
if (null === $transaction) {
|
||||
throw new FireflyException(sprintf('Expected a transaction. Account #%d has none. BEEP, error.', $account->id)); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$journal = $transaction->transactionJournal;
|
||||
/** @var Transaction $opposingTransaction */
|
||||
$opposingTransaction = $journal->transactions()->where('transactions.id', '!=', $transaction->id)->first();
|
||||
|
||||
if (null === $opposingTransaction) {
|
||||
throw new FireflyException('Expected an opposing transaction. This account has none. BEEP, error.'); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return redirect(route('accounts.show', [$opposingTransaction->account_id]));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user