Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Various code cleanup.
James Cole37250cbde38e
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.phpindex dd3f9e2719..fc047b3970 100644--- a/app/Console/Kernel.php+++ b/app/Console/Kernel.php@@ -47,8 +47,8 @@ class Kernel extends ConsoleKernel* Define the application's command schedule.** @param \Illuminate\Console\Scheduling\Schedule $schedule- * @SuppressWarnings(PHPMD.UnusedLocalVariable)* @return void+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)*/protected function schedule(Schedule $schedule){diff --git a/app/Handlers/Events/StoredJournalEventHandler.php b/app/Handlers/Events/StoredJournalEventHandler.phpindex 1f83a8ff6d..6ade7937ac 100644--- a/app/Handlers/Events/StoredJournalEventHandler.php+++ b/app/Handlers/Events/StoredJournalEventHandler.php@@ -57,11 +57,12 @@ class StoredJournalEventHandler/*** This method connects a new transfer to a piggy bank.*- *- ** @param StoredTransactionJournal $event** @return bool+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function connectToPiggyBank(StoredTransactionJournal $event): bool{diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.phpindex 62d2e1c0d6..f111e0a30a 100644--- a/app/Helpers/Attachments/AttachmentHelper.php+++ b/app/Helpers/Attachments/AttachmentHelper.php@@ -169,7 +169,6 @@ class AttachmentHelper implements AttachmentHelperInterface// store it:$this->uploadDisk->put($attachment->fileName(), $encrypted);-$attachment->uploaded = 1; // update attachment$attachment->save();$this->attachments->push($attachment);@@ -180,8 +179,6 @@ class AttachmentHelper implements AttachmentHelperInterface// return it.return $attachment;--}/**diff --git a/app/Helpers/Chart/MetaPieChart.php b/app/Helpers/Chart/MetaPieChart.phpindex c3b8297cd1..b03c2fb47b 100644--- a/app/Helpers/Chart/MetaPieChart.php+++ b/app/Helpers/Chart/MetaPieChart.php@@ -32,6 +32,8 @@ use Steam;* Class MetaPieChart** @package FireflyIII\Helpers\Chart+ *+ **/class MetaPieChart implements MetaPieChartInterface{@@ -83,12 +85,15 @@ class MetaPieChart implements MetaPieChartInterface* @param string $group** @return array+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)*/public function generate(string $direction, string $group): array{$transactions = $this->getTransactions($direction);$grouped = $this->groupByFields($transactions, $this->grouping[$group]);$chartData = $this->organizeByType($group, $grouped);+ $key = strval(trans('firefly.everything_else'));// also collect all other transactionsif ($this->collectOtherObjects && $direction === 'expense') {@@ -96,11 +101,12 @@ class MetaPieChart implements MetaPieChartInterface$collector = app(JournalCollectorInterface::class);$collector->setUser($this->user);$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]);- $journals = $collector->getJournals();- $sum = strval($journals->sum('transaction_amount'));- $sum = bcmul($sum, '-1');- $sum = bcsub($sum, $this->total);- $chartData[strval(trans('firefly.everything_else'))] = $sum;++ $journals = $collector->getJournals();+ $sum = strval($journals->sum('transaction_amount'));+ $sum = bcmul($sum, '-1');+ $sum = bcsub($sum, $this->total);+ $chartData[$key] = $sum;}if ($this->collectOtherObjects && $direction === 'income') {@@ -108,10 +114,10 @@ class MetaPieChart implements MetaPieChartInterface$collector = app(JournalCollectorInterface::class);$collector->setUser($this->user);$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]);- $journals = $collector->getJournals();- $sum = strval($journals->sum('transaction_amount'));- $sum = bcsub($sum, $this->total);- $chartData[strval(trans('firefly.everything_else'))] = $sum;+ $journals = $collector->getJournals();+ $sum = strval($journals->sum('transaction_amount'));+ $sum = bcsub($sum, $this->total);+ $chartData[$key] = $sum;}return $chartData;@@ -258,12 +264,9 @@ class MetaPieChart implements MetaPieChartInterface$collector->removeFilter(TransferFilter::class);}- if ($this->budgets->count() > 0) {- $collector->setBudgets($this->budgets);- }- if ($this->categories->count() > 0) {- $collector->setCategories($this->categories);- }+ $collector->setBudgets($this->budgets);+ $collector->setCategories($this->categories);+if ($this->tags->count() > 0) {$collector->setTags($this->tags);$collector->withCategoryInformation();@@ -278,6 +281,9 @@ class MetaPieChart implements MetaPieChartInterface* @param array $fields** @return array+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)+ **/protected function groupByFields(Collection $set, array $fields): array{diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.phpindex 939831be30..f0e84c26de 100644--- a/app/Helpers/Collector/JournalCollector.php+++ b/app/Helpers/Collector/JournalCollector.php@@ -43,6 +43,9 @@ use Steam;* Class JournalCollector** @package FireflyIII\Helpers\Collector+ *+ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)*/class JournalCollector implements JournalCollectorInterface{@@ -413,10 +416,10 @@ class JournalCollector implements JournalCollectorInterface$this->offset = $offset;$this->query->skip($offset);Log::debug(sprintf('Changed offset to %d', $offset));++ return $this;}- if (is_null($this->limit)) {- Log::debug('The limit is zero, cannot set the page.');- }+ Log::debug('The limit is zero, cannot set the page.');return $this;}diff --git a/app/Helpers/Report/BudgetReportHelper.php b/app/Helpers/Report/BudgetReportHelper.phpindex 7fecb90c89..c0469114b1 100644--- a/app/Helpers/Report/BudgetReportHelper.php+++ b/app/Helpers/Report/BudgetReportHelper.php@@ -42,6 +42,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface/*** @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // all the arrays make it long.* @param Carbon $start* @param Carbon $end* @param Collection $accountsdiff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.phpindex 70cc14ba3d..f64f72b098 100644--- a/app/Http/Controllers/AccountController.php+++ b/app/Http/Controllers/AccountController.php@@ -39,6 +39,7 @@ use View;* Class AccountController** @package FireflyIII\Http\Controllers+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)*/class AccountController extends Controller{@@ -141,9 +142,14 @@ class AccountController extends Controller}/**+ * Edit an account.+ ** @param Request $request* @param Account $account*+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ ** @return View*/public function edit(Request $request, Account $account)@@ -237,12 +243,16 @@ class AccountController extends Controller/**+ * Show an account.* @param Request $request* @param JournalRepositoryInterface $repository* @param Account $account* @param string $moment** @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = ''){@@ -389,6 +399,8 @@ class AccountController extends Controller* @param Account $account The account involved.** @return Collection+ *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/private function getPeriodOverview(Account $account): Collection{@@ -419,17 +431,13 @@ class AccountController extends Controller// try a collector for income:/** @var JournalCollectorInterface $collector */$collector = app(JournalCollectorInterface::class);- $collector->setAccounts(new Collection([$account]))->setRange($end, $currentEnd)- ->setTypes([TransactionType::DEPOSIT])- ->withOpposingAccount();+ $collector->setAccounts(new Collection([$account]))->setRange($end, $currentEnd)->setTypes([TransactionType::DEPOSIT])->withOpposingAccount();$earned = strval($collector->getJournals()->sum('transaction_amount'));// try a collector for expenses:/** @var JournalCollectorInterface $collector */$collector = app(JournalCollectorInterface::class);- $collector->setAccounts(new Collection([$account]))->setRange($end, $currentEnd)- ->setTypes([TransactionType::WITHDRAWAL])- ->withOpposingAccount();+ $collector->setAccounts(new Collection([$account]))->setRange($end, $currentEnd)->setTypes([TransactionType::WITHDRAWAL])->withOpposingAccount();$spent = strval($collector->getJournals()->sum('transaction_amount'));$dateStr = $end->format('Y-m-d');$dateName = Navigation::periodShow($end, $range);diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.phpindex f0b2b74993..ccf9e33b7f 100644--- a/app/Http/Controllers/Auth/TwoFactorController.php+++ b/app/Http/Controllers/Auth/TwoFactorController.php@@ -34,6 +34,8 @@ class TwoFactorController extends Controller** @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View* @throws FireflyException+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)*/public function index(Request $request){diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.phpindex 8b89aaf4be..6f58fc6c13 100644--- a/app/Http/Controllers/BudgetController.php+++ b/app/Http/Controllers/BudgetController.php@@ -40,6 +40,7 @@ use View;* Class BudgetController** @package FireflyIII\Http\Controllers+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)*/class BudgetController extends Controller{@@ -168,6 +169,9 @@ class BudgetController extends Controller* @param string|null $moment** @return View+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) complex because of while loop+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function index(string $moment = null){@@ -182,7 +186,6 @@ class BudgetController extends Controller$end = Navigation::endOfPeriod($start, $range);} catch (Exception $e) {// start and end are already defined.-}}$next = clone $end;@@ -190,11 +193,7 @@ class BudgetController extends Controller$prev = clone $start;$prev->subDay();$prev = Navigation::startOfPeriod($prev, $range);--$this->repository->cleanupBudgets();--$budgets = $this->repository->getActiveBudgets();$inactive = $this->repository->getInactiveBudgets();$periodStart = $start->formatLocalized($this->monthAndDayFormat);@@ -252,6 +251,9 @@ class BudgetController extends Controller* @param string $moment** @return View+ *+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)*/public function noBudget(Request $request, JournalRepositoryInterface $repository, string $moment = ''){@@ -461,6 +463,7 @@ class BudgetController extends Controller* @param Carbon $end** @return array+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)*/private function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array{diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.phpindex e29bb0d6f5..c7a992bd27 100644--- a/app/Http/Controllers/HomeController.php+++ b/app/Http/Controllers/HomeController.php@@ -129,9 +129,9 @@ class HomeController extends Controller/** @var Carbon $start */$start = session('start', Carbon::now()->startOfMonth());/** @var Carbon $end */- $end = session('end', Carbon::now()->endOfMonth());- $accounts = $repository->getAccountsById($frontPage->data);- $showDepositsFrontpage = Preferences::get('showDepositsFrontpage', false)->data;+ $end = session('end', Carbon::now()->endOfMonth());+ $accounts = $repository->getAccountsById($frontPage->data);+ $showDeps = Preferences::get('showDepositsFrontpage', false)->data;// zero bills? Hide some elements from view./** @var BillRepositoryInterface $billRepository */@@ -146,7 +146,7 @@ class HomeController extends Controller}return view(- 'index', compact('count', 'subTitle', 'transactions', 'showDepositsFrontpage', 'billCount')+ 'index', compact('count', 'subTitle', 'transactions', 'showDeps', 'billCount'));}diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.phpindex 7ef95c1307..4948c7efdd 100644--- a/app/Http/Controllers/PreferencesController.php+++ b/app/Http/Controllers/PreferencesController.php@@ -85,27 +85,27 @@ class PreferencesController extends Controller*/public function index(AccountRepositoryInterface $repository){- $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);- $viewRangePref = Preferences::get('viewRange', '1M');- $viewRange = $viewRangePref->data;- $frontPageAccounts = Preferences::get('frontPageAccounts', []);- $language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;- $transactionPageSize = Preferences::get('transactionPageSize', 50)->data;- $customFiscalYear = Preferences::get('customFiscalYear', 0)->data;- $showDepositsFrontpage = Preferences::get('showDepositsFrontpage', false)->data;- $fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;- $fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;- $tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;- $is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled- $has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); // hasTwoFactorAuthSecret- $showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true;+ $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);+ $viewRangePref = Preferences::get('viewRange', '1M');+ $viewRange = $viewRangePref->data;+ $frontPageAccounts = Preferences::get('frontPageAccounts', []);+ $language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;+ $transactionPageSize = Preferences::get('transactionPageSize', 50)->data;+ $customFiscalYear = Preferences::get('customFiscalYear', 0)->data;+ $showDeps = Preferences::get('showDepositsFrontpage', false)->data;+ $fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;+ $fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;+ $tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;+ $is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled+ $has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); // hasTwoFactorAuthSecret+ $showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true;return view('preferences.index',compact('language', 'accounts', 'frontPageAccounts', 'tjOptionalFields','viewRange', 'customFiscalYear', 'transactionPageSize', 'fiscalYearStart', 'is2faEnabled',- 'has2faSecret', 'showIncomplete', 'showDepositsFrontpage'+ 'has2faSecret', 'showIncomplete', 'showDeps'));}diff --git a/app/Models/Transaction.php b/app/Models/Transaction.phpindex 49203aa784..45462db855 100644--- a/app/Models/Transaction.php+++ b/app/Models/Transaction.php@@ -23,13 +23,15 @@ use Watson\Validating\ValidatingTrait;* Class Transaction** @property-read int $journal_id- * @property-read Carbon $date+ * @property Carbon $date* @property-read string $transaction_description- * @property-read string $transaction_amount- * @property-read string $transaction_foreign_amount- * @property-read string $transaction_type_type+ * @property string $transaction_amount+ * @property string $transaction_foreign_amount+ * @property string $transaction_type_type+ * @property string $foreign_currency_symbol+ * @property int $foreign_currency_dp*- * @property int $account_id+ * @property int $account_id* @property-read string $account_name* @property string $account_iban* @property string $account_numberdiff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex 4cf65c0519..56e8792580 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -55,11 +55,11 @@ class Amount// there are five possible positions for the "+" or "-" sign (if it is even used)// pos_a and pos_e could be the ( and ) symbol.- $pos_a = ''; // before everything- $pos_b = ''; // before currency symbol- $pos_c = ''; // after currency symbol- $pos_d = ''; // before amount- $pos_e = ''; // after everything+ $posA = ''; // before everything+ $posB = ''; // before currency symbol+ $posC = ''; // after currency symbol+ $posD = ''; // before amount+ $posE = ''; // after everything// format would be (currency before amount)// AB%sC_D%vE@@ -73,32 +73,32 @@ class Amountdefault:case 0:// ( and ) around the whole thing- $pos_a = '(';- $pos_e = ')';+ $posA = '(';+ $posE = ')';break;case 1:// The sign string precedes the quantity and currency_symbol- $pos_a = $sign;+ $posA = $sign;break;case 2:// The sign string succeeds the quantity and currency_symbol- $pos_e = $sign;+ $posE = $sign;break;case 3:// The sign string immediately precedes the currency_symbol- $pos_b = $sign;+ $posB = $sign;break;case 4:// The sign string immediately succeeds the currency_symbol- $pos_c = $sign;+ $posC = $sign;}// default is amount before currency- $format = $pos_a . $pos_d . '%v' . $space . $pos_b . '%s' . $pos_c . $pos_e;+ $format = $posA . $posD . '%v' . $space . $posB . '%s' . $posC . $posE;if ($csPrecedes) {// alternative is currency before amount- $format = $pos_a . $pos_b . '%s' . $pos_c . $space . $pos_d . '%v' . $pos_e;+ $format = $posA . $posB . '%s' . $posC . $space . $posD . '%v' . $posE;}return $format;diff --git a/app/Support/Import/Prerequisites/BunqPrerequisites.php b/app/Support/Import/Prerequisites/BunqPrerequisites.phpindex ce0150cbb3..2171b76203 100644--- a/app/Support/Import/Prerequisites/BunqPrerequisites.php+++ b/app/Support/Import/Prerequisites/BunqPrerequisites.php@@ -258,10 +258,10 @@ class BunqPrerequisites implements PrerequisitesInterfaceif ($response->status_code !== 200) {throw new FireflyException(sprintf('Could not retrieve external IP: %d %s', $response->status_code, $response->body));}- $ip = $response->body;- Preferences::setForUser($this->user, 'external_ip', $ip);+ $serverIp = $response->body;+ Preferences::setForUser($this->user, 'external_ip', $serverIp);- return $ip;+ return $serverIp;}return $preference->data;diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.phpindex 55dea965d2..cbc478007a 100644--- a/app/Support/Search/Search.php+++ b/app/Support/Search/Search.php@@ -204,8 +204,8 @@ class Search implements SearchInterface// first "modifier" is always the text of the search:// check descr of journal:if (count($this->words) > 0- && !$this->strpos_arr(strtolower(strval($transaction->description)), $this->words)- && !$this->strpos_arr(strtolower(strval($transaction->transaction_description)), $this->words)+ && !$this->strposArray(strtolower(strval($transaction->description)), $this->words)+ && !$this->strposArray(strtolower(strval($transaction->transaction_description)), $this->words)) {Log::debug('Description does not match', $this->words);@@ -230,7 +230,7 @@ class Search implements SearchInterface** @return bool*/- private function strpos_arr(string $haystack, array $needle)+ private function strposArray(string $haystack, array $needle){if (strlen($haystack) === 0) {return false;diff --git a/app/Support/Twig/Transaction.php b/app/Support/Twig/Transaction.phpindex 3774940216..3c4902972e 100644--- a/app/Support/Twig/Transaction.php+++ b/app/Support/Twig/Transaction.php@@ -119,16 +119,15 @@ class Transaction extends Twig_Extensionreturn new Twig_SimpleFunction('transactionDestinationAccount', function (TransactionModel $transaction): string {- $name = Steam::decrypt(intval($transaction->account_encrypted), $transaction->account_name);- $id = intval($transaction->account_id);- $type = $transaction->account_type;+ $name = Steam::decrypt(intval($transaction->account_encrypted), $transaction->account_name);+ $transactionId = intval($transaction->account_id);+ $type = $transaction->account_type;// name is present in object, use that one:if (bccomp($transaction->transaction_amount, '0') === -1 && !is_null($transaction->opposing_account_id)) {-- $name = $transaction->opposing_account_name;- $id = intval($transaction->opposing_account_id);- $type = $transaction->opposing_account_type;+ $name = $transaction->opposing_account_name;+ $transactionId = intval($transaction->opposing_account_id);+ $type = $transaction->opposing_account_type;}// Find the opposing account and use that one:@@ -136,21 +135,23 @@ class Transaction extends Twig_Extension// if the amount is negative, find the opposing account and use that one:$journalId = $transaction->journal_id;/** @var TransactionModel $other */- $other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)- ->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier)- ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')- ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')- ->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);- $name = Steam::decrypt(intval($other->encrypted), $other->name);- $id = $other->account_id;- $type = $other->type;+ $other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)+ ->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where(+ 'identifier', $transaction->identifier+ )+ ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')+ ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')+ ->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);+ $name = Steam::decrypt(intval($other->encrypted), $other->name);+ $transactionId = $other->account_id;+ $type = $other->type;}if ($type === AccountType::CASH) {return '<span class="text-success">(cash)</span>';}- return sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$id]));+ return sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$transactionId]));}, ['is_safe' => ['html']]);@@ -193,36 +194,37 @@ class Transaction extends Twig_Extension'transactionSourceAccount', function (TransactionModel $transaction): string {// if the amount is negative, assume that the current account (the one in $transaction) is indeed the source account.- $name = Steam::decrypt(intval($transaction->account_encrypted), $transaction->account_name);- $id = intval($transaction->account_id);- $type = $transaction->account_type;+ $name = Steam::decrypt(intval($transaction->account_encrypted), $transaction->account_name);+ $transactionId = intval($transaction->account_id);+ $type = $transaction->account_type;// name is present in object, use that one:if (bccomp($transaction->transaction_amount, '0') === 1 && !is_null($transaction->opposing_account_id)) {-- $name = $transaction->opposing_account_name;- $id = intval($transaction->opposing_account_id);- $type = $transaction->opposing_account_type;+ $name = $transaction->opposing_account_name;+ $transactionId = intval($transaction->opposing_account_id);+ $type = $transaction->opposing_account_type;}// Find the opposing account and use that one:if (bccomp($transaction->transaction_amount, '0') === 1 && is_null($transaction->opposing_account_id)) {$journalId = $transaction->journal_id;/** @var TransactionModel $other */- $other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)- ->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier)- ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')- ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')- ->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);- $name = Steam::decrypt(intval($other->encrypted), $other->name);- $id = $other->account_id;- $type = $other->type;+ $other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)+ ->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where(+ 'identifier', $transaction->identifier+ )+ ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')+ ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')+ ->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);+ $name = Steam::decrypt(intval($other->encrypted), $other->name);+ $transactionId = $other->account_id;+ $type = $other->type;}if ($type === AccountType::CASH) {return '<span class="text-success">(cash)</span>';}- return sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$id]));+ return sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$transactionId]));}, ['is_safe' => ['html']]);diff --git a/resources/views/index.twig b/resources/views/index.twigindex 7f82db5715..e3462baea5 100644--- a/resources/views/index.twig+++ b/resources/views/index.twig@@ -115,7 +115,7 @@</div></div>{# OPTIONAL REVENUE ACCOUNTS #}- {% if showDepositsFrontpage %}+ {% if showDeps %}<div class="box"><div class="box-header with-border"><h3 class="box-title">{{ 'revenue_accounts'|_ }}</h3>diff --git a/resources/views/preferences/index.twig b/resources/views/preferences/index.twigindex e2ade7cc6d..f04a9669e3 100644--- a/resources/views/preferences/index.twig+++ b/resources/views/preferences/index.twig@@ -128,7 +128,7 @@<div class="col-sm-10"><div class="checkbox"><label>- <input type="checkbox" name="showDepositsFrontpage[]" value="{{ showDepositsFrontpage }}"+ <input type="checkbox" name="showDepositsFrontpage[]" value="{{ showDeps }}"{% if showDepositsFrontpage %}checked{% endif %}