From 4e51f0abc4817dc0d7850aa27cf620fa26f005a1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 13 Oct 2020 06:35:33 +0200 Subject: [PATCH] Clean up some code. --- .../Autocomplete/AccountController.php | 7 +-- .../V1/Controllers/Chart/BudgetController.php | 4 -- .../Commands/Correction/FixAccountTypes.php | 35 ++++-------- .../Commands/Correction/RenameMetaFields.php | 7 +-- app/Console/Commands/DecryptDatabase.php | 3 - app/Console/Commands/Tools/ApplyRules.php | 24 ++++---- .../Commands/Upgrade/MigrateAttachments.php | 6 +- .../Commands/Upgrade/MigrateToGroups.php | 29 ++++------ app/Factory/TransactionJournalFactory.php | 35 ++++-------- .../Controllers/Category/CreateController.php | 11 ++-- .../Controllers/Chart/CategoryController.php | 20 +++---- .../Recurring/CreateController.php | 16 ++---- .../Controllers/Recurring/EditController.php | 20 +++---- .../Controllers/Recurring/IndexController.php | 8 +-- .../Controllers/Report/CategoryController.php | 48 +++++----------- app/Http/Controllers/TagController.php | 21 +++---- .../Transaction/BulkController.php | 6 +- .../Transaction/ConvertController.php | 55 +++++++++---------- app/Jobs/CreateRecurringTransactions.php | 2 - .../PiggyBank/PiggyBankRepository.php | 1 - .../Update/RecurrenceUpdateService.php | 1 - app/Support/Amount.php | 2 - app/Support/Binder/BudgetList.php | 1 - app/Support/FireflyConfig.php | 5 -- .../Recurring/CalculateRangeOccurrences.php | 16 ------ app/Transformers/AccountTransformer.php | 1 - .../Account/ReconciliationValidation.php | 2 +- public/v1/js/ff/budgets/index.js | 4 +- public/v1/js/ff/firefly.js | 2 +- public/v1/js/ff/help.js | 2 +- resources/views/v1/profile/index.twig | 8 +-- routes/api.php | 12 ---- routes/web.php | 29 ++-------- 33 files changed, 149 insertions(+), 294 deletions(-) diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.php index f0ff700644..e894077fa0 100644 --- a/app/Api/V1/Controllers/Autocomplete/AccountController.php +++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php @@ -41,7 +41,6 @@ class AccountController extends Controller use AccountFilter; private array $balanceTypes; - private AccountRepositoryInterface $repository; @@ -76,16 +75,14 @@ class AccountController extends Controller $query = $data['query']; $date = $data['date'] ?? today(config('app.timezone')); - /** @var AccountRepositoryInterface $repository */ - $repository = app(AccountRepositoryInterface::class); $return = []; - $result = $repository->searchAccount((string) $query, $types, $data['limit']); + $result = $this->repository->searchAccount((string) $query, $types, $data['limit']); $defaultCurrency = app('amount')->getDefaultCurrency(); /** @var Account $account */ foreach ($result as $account) { $nameWithBalance = $account->name; - $currency = $repository->getAccountCurrency($account) ?? $defaultCurrency; + $currency = $this->repository->getAccountCurrency($account) ?? $defaultCurrency; if (in_array($account->accountType->type, $this->balanceTypes, true)) { $balance = app('steam')->balance($account, $date); diff --git a/app/Api/V1/Controllers/Chart/BudgetController.php b/app/Api/V1/Controllers/Chart/BudgetController.php index 6f68502c8d..2dd4a953f2 100644 --- a/app/Api/V1/Controllers/Chart/BudgetController.php +++ b/app/Api/V1/Controllers/Chart/BudgetController.php @@ -58,13 +58,10 @@ class BudgetController extends Controller $this->middleware( function ($request, $next) { - //$this->generator = app(GeneratorInterface::class); $this->repository = app(BudgetRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class); $this->blRepository = app(BudgetLimitRepositoryInterface::class); - //$this->nbRepository = app(NoBudgetRepositoryInterface::class); - return $next($request); } ); @@ -195,7 +192,6 @@ class BudgetController extends Controller { foreach ($sets as $set) { $label = $set['label']; - //$basic['spent']['entries'][$label] = $set['entries']['spent']; $basic['spent_capped']['entries'][$label] = $set['entries']['spent_capped']; $basic['left']['entries'][$label] = $set['entries']['left']; $basic['overspent']['entries'][$label] = $set['entries']['overspent']; diff --git a/app/Console/Commands/Correction/FixAccountTypes.php b/app/Console/Commands/Correction/FixAccountTypes.php index 969c71fea2..f4638c9f4e 100644 --- a/app/Console/Commands/Correction/FixAccountTypes.php +++ b/app/Console/Commands/Correction/FixAccountTypes.php @@ -46,14 +46,10 @@ class FixAccountTypes extends Command * The name and signature of the console command. * @var string */ - protected $signature = 'firefly-iii:fix-account-types'; - /** @var int */ - private $count; - private array $expected; - /** @var AccountFactory */ - private $factory; - /** @var array */ - private $fixable; + protected $signature = 'firefly-iii:fix-account-types'; + private int $count; + private array $expected; + private AccountFactory $factory; /** @@ -65,19 +61,8 @@ class FixAccountTypes extends Command { $this->stupidLaravel(); Log::debug('Now in fix-account-types'); - $start = microtime(true); - $this->factory = app(AccountFactory::class); - // some combinations can be fixed by this script: - $this->fixable = [// transfers from asset to liability and vice versa - sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::LOAN), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::DEBT), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::MORTGAGE), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::LOAN, AccountType::ASSET), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::DEBT, AccountType::ASSET), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::MORTGAGE, AccountType::ASSET), - - // withdrawals with a revenue account as destination instead of an expense account. - sprintf('%s%s%s', TransactionType::WITHDRAWAL, AccountType::ASSET, AccountType::REVENUE), - - // deposits with an expense account as source instead of a revenue account. - sprintf('%s%s%s', TransactionType::DEPOSIT, AccountType::EXPENSE, AccountType::ASSET),]; - - + $start = microtime(true); + $this->factory = app(AccountFactory::class); $this->expected = config('firefly.source_dests'); $journals = TransactionJournal::with(['TransactionType', 'transactions', 'transactions.account', 'transactions.account.accounttype'])->get(); Log::debug(sprintf('Found %d journals to inspect.', $journals->count())); @@ -203,10 +188,10 @@ class FixAccountTypes extends Command */ private function inspectJournal(TransactionJournal $journal): void { - $count = $journal->transactions()->count(); - if (2 !== $count) { - Log::debug(sprintf('Journal has %d transactions, so cant fix.', $count)); - $this->info(sprintf('Cannot inspect transaction journal #%d because it has %d transaction(s) instead of 2.', $journal->id, $count)); + $transactions = $journal->transactions()->count(); + if (2 !== $transactions) { + Log::debug(sprintf('Journal has %d transactions, so can\'t fix.', $transactions)); + $this->info(sprintf('Cannot inspect transaction journal #%d because it has %d transaction(s) instead of 2.', $journal->id, $transactions)); return; } diff --git a/app/Console/Commands/Correction/RenameMetaFields.php b/app/Console/Commands/Correction/RenameMetaFields.php index 30ef3ad15e..8be384f419 100644 --- a/app/Console/Commands/Correction/RenameMetaFields.php +++ b/app/Console/Commands/Correction/RenameMetaFields.php @@ -44,8 +44,7 @@ class RenameMetaFields extends Command */ protected $signature = 'firefly-iii:rename-meta-fields'; - /** @var int */ - private $count; + private int $count; /** @@ -93,9 +92,9 @@ class RenameMetaFields extends Command */ private function rename(string $original, string $update): void { - $count = DB::table('journal_meta') + $total = DB::table('journal_meta') ->where('name', '=', $original) ->update(['name' => $update]); - $this->count += $count; + $this->count += $total; } } diff --git a/app/Console/Commands/DecryptDatabase.php b/app/Console/Commands/DecryptDatabase.php index 5995e0cb99..e7fb423adb 100644 --- a/app/Console/Commands/DecryptDatabase.php +++ b/app/Console/Commands/DecryptDatabase.php @@ -98,8 +98,6 @@ class DecryptDatabase extends Command } catch(JsonException $e) { Log::error($e->getMessage()); } - //Log::debug(sprintf('Decrypted field "%s" "%s" to "%s" in table "%s" (row #%d)', $field, $original, print_r($value, true), $table, $id)); - /** @var Preference $object */ $object = Preference::find((int) $id); if (null !== $object) { @@ -110,7 +108,6 @@ class DecryptDatabase extends Command } if ($value !== $original) { - //Log::debug(sprintf('Decrypted field "%s" "%s" to "%s" in table "%s" (row #%d)', $field, $original, $value, $table, $id)); DB::table($table)->where('id', $id)->update([$field => $value]); } } diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.php index 3e5e2e7078..553358e918 100644 --- a/app/Console/Commands/Tools/ApplyRules.php +++ b/app/Console/Commands/Tools/ApplyRules.php @@ -131,11 +131,11 @@ class ApplyRules extends Command $ruleEngine->setUser($this->getUser()); // add the accounts as filter: - $accounts = []; + $filterAccountList = []; foreach($this->accounts as $account) { - $accounts[] = $account->id; + $filterAccountList[] = $account->id; } - $list = implode(',', $accounts); + $list = implode(',', $filterAccountList); $ruleEngine->addOperator(['type' => 'account_id', 'value' => $list]); // add the date as a filter: @@ -295,7 +295,7 @@ class ApplyRules extends Command private function verifyInputDates(): void { // parse start date. - $startDate = Carbon::now()->startOfMonth(); + $inputStart = Carbon::now()->startOfMonth(); $startString = $this->option('start_date'); if (null === $startString) { /** @var JournalRepositoryInterface $repository */ @@ -303,26 +303,26 @@ class ApplyRules extends Command $repository->setUser($this->getUser()); $first = $repository->firstNull(); if (null !== $first) { - $startDate = $first->date; + $inputStart = $first->date; } } if (null !== $startString && '' !== $startString) { - $startDate = Carbon::createFromFormat('Y-m-d', $startString); + $inputStart = Carbon::createFromFormat('Y-m-d', $startString); } // parse end date - $endDate = Carbon::now(); + $inputEnd = Carbon::now(); $endString = $this->option('end_date'); if (null !== $endString && '' !== $endString) { - $endDate = Carbon::createFromFormat('Y-m-d', $endString); + $inputEnd = Carbon::createFromFormat('Y-m-d', $endString); } - if ($startDate > $endDate) { - [$endDate, $startDate] = [$startDate, $endDate]; + if ($inputStart > $inputEnd) { + [$inputEnd, $inputStart] = [$inputStart, $inputEnd]; } - $this->startDate = $startDate; - $this->endDate = $endDate; + $this->startDate = $inputStart; + $this->endDate = $inputEnd; } /** diff --git a/app/Console/Commands/Upgrade/MigrateAttachments.php b/app/Console/Commands/Upgrade/MigrateAttachments.php index 6120a2a4de..e401a12045 100644 --- a/app/Console/Commands/Upgrade/MigrateAttachments.php +++ b/app/Console/Commands/Upgrade/MigrateAttachments.php @@ -72,8 +72,8 @@ class MigrateAttachments extends Command foreach ($attachments as $att) { // move description: - $description = (string) $att->description; - if ('' !== $description) { + $attDescription = (string) $att->description; + if ('' !== $attDescription) { // find or create note: $note = $att->notes()->first(); @@ -81,7 +81,7 @@ class MigrateAttachments extends Command $note = new Note; $note->noteable()->associate($att); } - $note->text = $description; + $note->text = $attDescription; $note->save(); // clear description: diff --git a/app/Console/Commands/Upgrade/MigrateToGroups.php b/app/Console/Commands/Upgrade/MigrateToGroups.php index fbcd53f001..94379c4473 100644 --- a/app/Console/Commands/Upgrade/MigrateToGroups.php +++ b/app/Console/Commands/Upgrade/MigrateToGroups.php @@ -58,23 +58,18 @@ class MigrateToGroups extends Command * * @var string */ - protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}'; - /** @var JournalCLIRepositoryInterface */ - private $cliRepository; - private $count; - /** @var TransactionGroupFactory */ - private $groupFactory; - /** @var JournalRepositoryInterface */ - private $journalRepository; - /** @var JournalDestroyService */ - private $service; - + protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}'; + private JournalCLIRepositoryInterface $cliRepository; + private int $count; + private TransactionGroupFactory $groupFactory; + private JournalRepositoryInterface $journalRepository; + private JournalDestroyService $service; /** * Execute the console command. * - * @throws Exception * @return int + * @throws Exception */ public function handle(): int { @@ -254,16 +249,16 @@ class MigrateToGroups extends Command private function makeGroupsFromAll(): void { $orphanedJournals = $this->cliRepository->getJournalsWithoutGroup(); - $count = count($orphanedJournals); - if ($count > 0) { - Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $count)); - $this->line(sprintf('Going to convert %d transaction journals. Please hold..', $count)); + $total = count($orphanedJournals); + if ($total > 0) { + Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $total)); + $this->line(sprintf('Going to convert %d transaction journals. Please hold..', $total)); /** @var array $journal */ foreach ($orphanedJournals as $array) { $this->giveGroup($array); } } - if (0 === $count) { + if (0 === $total) { $this->info('No need to convert transaction journals.'); } } diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index c16c168920..03104bb1ce 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Factory; -use Carbon\Carbon; use Exception; use FireflyIII\Exceptions\DuplicateTransactionException; use FireflyIII\Exceptions\FireflyException; @@ -56,26 +55,17 @@ class TransactionJournalFactory { use JournalServiceTrait; - private AccountRepositoryInterface $accountRepository; - private AccountValidator $accountValidator; - private BillRepositoryInterface $billRepository; - /** @var CurrencyRepositoryInterface */ - private $currencyRepository; - /** @var bool */ - private $errorOnHash; - /** @var array */ - private $fields; - /** @var PiggyBankEventFactory */ - private $piggyEventFactory; - /** @var PiggyBankRepositoryInterface */ - private $piggyRepository; - /** @var TransactionFactory */ - private $transactionFactory; - /** @var TransactionTypeRepositoryInterface */ - private $typeRepository; - /** @var User The user */ - private $user; - + private AccountRepositoryInterface $accountRepository; + private AccountValidator $accountValidator; + private BillRepositoryInterface $billRepository; + private CurrencyRepositoryInterface $currencyRepository; + private bool $errorOnHash; + private array $fields; + private PiggyBankEventFactory $piggyEventFactory; + private PiggyBankRepositoryInterface $piggyRepository; + private TransactionFactory $transactionFactory; + private TransactionTypeRepositoryInterface $typeRepository; + private User $user; /** * Constructor. @@ -112,7 +102,6 @@ class TransactionJournalFactory $this->currencyRepository = app(CurrencyRepositoryInterface::class); $this->typeRepository = app(TransactionTypeRepositoryInterface::class); - $this->transactionFactory = app(TransactionFactory::class); $this->billRepository = app(BillRepositoryInterface::class); $this->budgetRepository = app(BudgetRepositoryInterface::class); $this->categoryRepository = app(CategoryRepositoryInterface::class); @@ -196,7 +185,6 @@ class TransactionJournalFactory $this->user = $user; $this->currencyRepository->setUser($this->user); $this->tagFactory->setUser($user); - $this->transactionFactory->setUser($this->user); $this->billRepository->setUser($this->user); $this->budgetRepository->setUser($this->user); $this->categoryRepository->setUser($this->user); @@ -329,7 +317,6 @@ class TransactionJournalFactory Log::debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description)); /** Create two transactions. */ - /** @var TransactionFactory $transactionFactory */ $transactionFactory = app(TransactionFactory::class); $transactionFactory->setUser($this->user); $transactionFactory->setJournal($journal); diff --git a/app/Http/Controllers/Category/CreateController.php b/app/Http/Controllers/Category/CreateController.php index 771932ab96..cecb8c1da5 100644 --- a/app/Http/Controllers/Category/CreateController.php +++ b/app/Http/Controllers/Category/CreateController.php @@ -39,11 +39,8 @@ use Illuminate\View\View; */ class CreateController extends Controller { - /** @var CategoryRepositoryInterface The category repository */ - private $repository; - - /** @var AttachmentHelperInterface Helper for attachments. */ - private $attachments; + private CategoryRepositoryInterface $repository; + private AttachmentHelperInterface $attachments; /** * CategoryController constructor. @@ -58,7 +55,7 @@ class CreateController extends Controller function ($request, $next) { app('view')->share('title', (string) trans('firefly.categories')); app('view')->share('mainTitleIcon', 'fa-bookmark'); - $this->repository = app(CategoryRepositoryInterface::class); + $this->repository = app(CategoryRepositoryInterface::class); $this->attachments = app(AttachmentHelperInterface::class); return $next($request); @@ -107,7 +104,7 @@ class CreateController extends Controller $this->attachments->saveAttachmentsForModel($category, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { - session()->flash('info',(string)trans('firefly.no_att_demo_user')); + session()->flash('info', (string) trans('firefly.no_att_demo_user')); } if (count($this->attachments->getMessages()->get('attachments')) > 0) { diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 6fa4efcaab..5ecdb02468 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -45,6 +45,7 @@ use Illuminate\Support\Collection; class CategoryController extends Controller { use DateCalculation, AugumentData, ChartGeneration; + /** @var GeneratorInterface Chart generation methods. */ protected $generator; @@ -85,10 +86,10 @@ class CategoryController extends Controller $start = app('navigation')->startOfPeriod($start, $range); $end = $this->getDate(); - /** @var WholePeriodChartGenerator $generator */ - $generator = app(WholePeriodChartGenerator::class); - $chartData = $generator->generate($category, $start, $end); - $data = $this->generator->multiSet($chartData); + /** @var WholePeriodChartGenerator $chartGenerator */ + $chartGenerator = app(WholePeriodChartGenerator::class); + $chartData = $chartGenerator->generate($category, $start, $end); + $data = $this->generator->multiSet($chartData); $cache->store($data); return response()->json($data); @@ -111,14 +112,14 @@ class CategoryController extends Controller $cache->addProperty($end); $cache->addProperty('chart.category.frontpage'); if ($cache->has()) { - return response()->json($cache->get()); // @codeCoverageIgnore + return response()->json($cache->get()); // @codeCoverageIgnore } $frontPageGenerator = new FrontpageChartGenerator($start, $end); - $chartData = $frontPageGenerator->generate(); - $data = $this->generator->multiSet($chartData); + $chartData = $frontPageGenerator->generate(); + $data = $this->generator->multiSet($chartData); $cache->store($data); return response()->json($data); @@ -210,13 +211,10 @@ class CategoryController extends Controller return response()->json($cache->get()); // @codeCoverageIgnore } - /** @var GeneratorInterface $generator */ - $generator = app(GeneratorInterface::class); - /** @var WholePeriodChartGenerator $chartGenerator */ $chartGenerator = app(WholePeriodChartGenerator::class); $chartData = $chartGenerator->generate($category, $start, $end); - $data = $generator->multiSet($chartData); + $data = $this->generator->multiSet($chartData); $cache->store($data); diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php index f127b5f3f8..bc5a42ba09 100644 --- a/app/Http/Controllers/Recurring/CreateController.php +++ b/app/Http/Controllers/Recurring/CreateController.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Recurring; -use Carbon\Carbon; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Http\Controllers\Controller; @@ -45,12 +44,9 @@ use Illuminate\View\View; */ class CreateController extends Controller { - /** @var BudgetRepositoryInterface The budget repository */ - private $budgets; - /** @var RecurringRepositoryInterface Recurring repository */ - private $recurring; - - private AttachmentHelperInterface $attachments; + private BudgetRepositoryInterface $budgetRepos; + private RecurringRepositoryInterface $recurring; + private AttachmentHelperInterface $attachments; /** * CreateController constructor. @@ -69,7 +65,7 @@ class CreateController extends Controller app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence')); $this->recurring = app(RecurringRepositoryInterface::class); - $this->budgets = app(BudgetRepositoryInterface::class); + $this->budgetRepos = app(BudgetRepositoryInterface::class); $this->attachments = app(AttachmentHelperInterface::class); return $next($request); @@ -83,7 +79,7 @@ class CreateController extends Controller */ public function createFromJournal(Request $request, TransactionJournal $journal) { - $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets()); + $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets()); $defaultCurrency = app('amount')->getDefaultCurrency(); $tomorrow = today(config('app.timezone')); $oldRepetitionType = $request->old('repetition_type'); @@ -177,7 +173,7 @@ class CreateController extends Controller */ public function create(Request $request) { - $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets()); + $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets()); $defaultCurrency = app('amount')->getDefaultCurrency(); $tomorrow = today(config('app.timezone')); $oldRepetitionType = $request->old('repetition_type'); diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.php index 22f5b49226..2941d6ff18 100644 --- a/app/Http/Controllers/Recurring/EditController.php +++ b/app/Http/Controllers/Recurring/EditController.php @@ -46,11 +46,9 @@ use Symfony\Component\HttpFoundation\ParameterBag; */ class EditController extends Controller { - /** @var BudgetRepositoryInterface The budget repository */ - private $budgets; - /** @var RecurringRepositoryInterface Recurring repository */ - private $recurring; - private AttachmentHelperInterface $attachments; + private BudgetRepositoryInterface $budgetRepos; + private RecurringRepositoryInterface $recurring; + private AttachmentHelperInterface $attachments; /** * EditController constructor. @@ -69,7 +67,7 @@ class EditController extends Controller app('view')->share('subTitle', (string) trans('firefly.recurrences')); $this->recurring = app(RecurringRepositoryInterface::class); - $this->budgets = app(BudgetRepositoryInterface::class); + $this->budgetRepos = app(BudgetRepositoryInterface::class); $this->attachments = app(AttachmentHelperInterface::class); return $next($request); } @@ -82,9 +80,9 @@ class EditController extends Controller * @param Request $request * @param Recurrence $recurrence * + * @return Factory|View * @throws FireflyException * - * @return Factory|View */ public function edit(Request $request, Recurrence $recurrence) { @@ -93,7 +91,7 @@ class EditController extends Controller $transformer->setParameters(new ParameterBag); $array = $transformer->transform($recurrence); - $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets()); + $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets()); /** @var RecurrenceRepetition $repetition */ $repetition = $recurrence->recurrenceRepetitions()->first(); @@ -108,7 +106,7 @@ class EditController extends Controller } $request->session()->forget('recurrences.edit.fromUpdate'); - $repetitionEnd = 'forever'; + $repetitionEnd = 'forever'; $repetitionEnds = [ 'forever' => (string) trans('firefly.repeat_forever'), 'until_date' => (string) trans('firefly.repeat_until_date'), @@ -129,7 +127,7 @@ class EditController extends Controller ]; $hasOldInput = null !== $request->old('_token'); - $preFilled = [ + $preFilled = [ 'transaction_type' => strtolower($recurrence->transactionType->type), 'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active, 'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules, @@ -151,8 +149,8 @@ class EditController extends Controller * @param RecurrenceFormRequest $request * @param Recurrence $recurrence * - * @throws FireflyException * @return RedirectResponse|Redirector + * @throws FireflyException */ public function update(RecurrenceFormRequest $request, Recurrence $recurrence) { diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.php index 677ff9ce9a..e115a416a0 100644 --- a/app/Http/Controllers/Recurring/IndexController.php +++ b/app/Http/Controllers/Recurring/IndexController.php @@ -45,8 +45,7 @@ use Symfony\Component\HttpFoundation\ParameterBag; class IndexController extends Controller { use GetConfigurationData; - /** @var RecurringRepositoryInterface Recurring repository */ - private $recurring; + private RecurringRepositoryInterface $recurringRepos; /** * IndexController constructor. @@ -63,7 +62,7 @@ class IndexController extends Controller app('view')->share('mainTitleIcon', 'fa-paint-brush'); app('view')->share('title', (string) trans('firefly.recurrences')); - $this->recurring = app(RecurringRepositoryInterface::class); + $this->recurringRepos = app(RecurringRepositoryInterface::class); return $next($request); } @@ -84,13 +83,12 @@ class IndexController extends Controller { $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page'); $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; - $collection = $this->recurring->get(); + $collection = $this->recurringRepos->get(); $today = today(config('app.timezone')); $year = today(config('app.timezone')); // split collection $total = $collection->count(); - /** @var Collection $recurrences */ $recurrences = $collection->slice(($page - 1) * $pageSize, $pageSize); /** @var RecurrenceTransformer $transformer */ diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php index c3e633f188..5cfc816ae1 100644 --- a/app/Http/Controllers/Report/CategoryController.php +++ b/app/Http/Controllers/Report/CategoryController.php @@ -26,7 +26,6 @@ use Carbon\Carbon; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Account; use FireflyIII\Models\Category; -use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface; use FireflyIII\Repositories\Category\OperationsRepositoryInterface; use FireflyIII\Support\CacheProperties; @@ -44,9 +43,8 @@ class CategoryController extends Controller { use BasicDataSupport; - - /** @var OperationsRepositoryInterface */ - private $opsRepository; + private OperationsRepositoryInterface $opsRepository; + private NoCategoryRepositoryInterface $noCatRepository; /** * ExpenseReportController constructor. @@ -58,8 +56,8 @@ class CategoryController extends Controller parent::__construct(); $this->middleware( function ($request, $next) { - $this->opsRepository = app(OperationsRepositoryInterface::class); - + $this->opsRepository = app(OperationsRepositoryInterface::class); + $this->noCatRepository = app(NoCategoryRepositoryInterface::class); return $next($request); } ); @@ -505,14 +503,6 @@ class CategoryController extends Controller if ($cache->has()) { return $cache->get(); // @codeCoverageIgnore } - /** @var CategoryRepositoryInterface $repository */ - $repository = app(CategoryRepositoryInterface::class); - - /** @var OperationsRepositoryInterface $opsRepository */ - $opsRepository = app(OperationsRepositoryInterface::class); - - /** @var NoCategoryRepositoryInterface $noCatRepos */ - $noCatRepos = app(NoCategoryRepositoryInterface::class); // depending on the carbon format (a reliable way to determine the general date difference) // change the "listOfPeriods" call so the entire period gets included correctly. @@ -527,8 +517,8 @@ class CategoryController extends Controller $periods = app('navigation')->listOfPeriods($start, $end); $data = []; - $with = $opsRepository->listExpenses($start, $end, $accounts); - $without = $noCatRepos->listExpenses($start, $end, $accounts); + $with = $this->opsRepository->listExpenses($start, $end, $accounts); + $without = $this->noCatRepository->listExpenses($start, $end, $accounts); foreach ([$with, $without] as $set) { foreach ($set as $currencyId => $currencyRow) { foreach ($currencyRow['categories'] as $categoryId => $categoryRow) { @@ -594,12 +584,6 @@ class CategoryController extends Controller return $cache->get(); // @codeCoverageIgnore } - /** @var OperationsRepositoryInterface $opsRepository */ - $opsRepository = app(OperationsRepositoryInterface::class); - - /** @var NoCategoryRepositoryInterface $noCatRepos */ - $noCatRepos = app(NoCategoryRepositoryInterface::class); - // depending on the carbon format (a reliable way to determine the general date difference) // change the "listOfPeriods" call so the entire period gets included correctly. $format = app('navigation')->preferredCarbonFormat($start, $end); @@ -613,8 +597,8 @@ class CategoryController extends Controller $periods = app('navigation')->listOfPeriods($start, $end); $data = []; - $with = $opsRepository->listIncome($start, $end, $accounts); - $without = $noCatRepos->listIncome($start, $end, $accounts); + $with = $this->opsRepository->listIncome($start, $end, $accounts); + $without = $this->noCatRepository->listIncome($start, $end, $accounts); foreach ([$with, $without] as $set) { foreach ($set as $currencyId => $currencyRow) { foreach ($currencyRow['categories'] as $categoryId => $categoryRow) { @@ -677,19 +661,13 @@ class CategoryController extends Controller $cache->addProperty('category-report'); $cache->addProperty($accounts->pluck('id')->toArray()); if ($cache->has()) { - // return $cache->get(); // @codeCoverageIgnore + return $cache->get(); // @codeCoverageIgnore } - /** @var OperationsRepositoryInterface $opsRepository */ - $opsRepository = app(OperationsRepositoryInterface::class); - - /** @var NoCategoryRepositoryInterface $noCatRepository */ - $noCatRepository = app(NoCategoryRepositoryInterface::class); - - $earnedWith = $opsRepository->listIncome($start, $end, $accounts); - $spentWith = $opsRepository->listExpenses($start, $end, $accounts); - $earnedWithout = $noCatRepository->listIncome($start, $end, $accounts); - $spentWithout = $noCatRepository->listExpenses($start, $end, $accounts); + $earnedWith = $this->opsRepository->listIncome($start, $end, $accounts); + $spentWith = $this->opsRepository->listExpenses($start, $end, $accounts); + $earnedWithout = $this->noCatRepository->listIncome($start, $end, $accounts); + $spentWithout = $this->noCatRepository->listExpenses($start, $end, $accounts); $report = [ 'categories' => [], diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 2ff4259eb0..a5bdb76b63 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -43,11 +43,8 @@ class TagController extends Controller { use PeriodOverview; - /** @var TagRepositoryInterface The tag repository. */ - protected $repository; - - /** @var AttachmentHelperInterface Helper for attachments. */ - private $attachments; + protected TagRepositoryInterface $repository; + private AttachmentHelperInterface $attachmentsHelper; /** * TagController constructor. @@ -62,7 +59,7 @@ class TagController extends Controller app('view')->share('title', (string) trans('firefly.tags')); app('view')->share('mainTitleIcon', 'fa-tag'); - $this->attachments = app(AttachmentHelperInterface::class); + $this->attachmentsHelper = app(AttachmentHelperInterface::class); $this->repository = app(TagRepositoryInterface::class); return $next($request); @@ -323,14 +320,14 @@ class TagController extends Controller /** @var array $files */ $files = $request->hasFile('attachments') ? $request->file('attachments') : null; if (null !== $files && !auth()->user()->hasRole('demo')) { - $this->attachments->saveAttachmentsForModel($result, $files); + $this->attachmentsHelper->saveAttachmentsForModel($result, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { session()->flash('info',(string)trans('firefly.no_att_demo_user')); } - if (count($this->attachments->getMessages()->get('attachments')) > 0) { - $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore + if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) { + $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore } @@ -366,14 +363,14 @@ class TagController extends Controller /** @var array $files */ $files = $request->hasFile('attachments') ? $request->file('attachments') : null; if (null !== $files && !auth()->user()->hasRole('demo')) { - $this->attachments->saveAttachmentsForModel($tag, $files); + $this->attachmentsHelper->saveAttachmentsForModel($tag, $files); } if (null !== $files && auth()->user()->hasRole('demo')) { session()->flash('info',(string)trans('firefly.no_att_demo_user')); } - if (count($this->attachments->getMessages()->get('attachments')) > 0) { - $request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore + if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) { + $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore } diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.php index 75c4052111..cd33d6b5fe 100644 --- a/app/Http/Controllers/Transaction/BulkController.php +++ b/app/Http/Controllers/Transaction/BulkController.php @@ -81,9 +81,9 @@ class BulkController extends Controller // make amounts positive. // get list of budgets: - /** @var BudgetRepositoryInterface $repository */ - $repository = app(BudgetRepositoryInterface::class); - $budgetList = app('expandedform')->makeSelectListWithEmpty($repository->getActiveBudgets()); + /** @var BudgetRepositoryInterface $budgetRepos */ + $budgetRepos = app(BudgetRepositoryInterface::class); + $budgetList = app('expandedform')->makeSelectListWithEmpty($budgetRepos->getActiveBudgets()); return view('transactions.bulk.edit', compact('journals', 'subTitle', 'budgetList')); } diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php index dae64ea1ca..1a6278e5fa 100644 --- a/app/Http/Controllers/Transaction/ConvertController.php +++ b/app/Http/Controllers/Transaction/ConvertController.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Transaction; -use Carbon\Carbon; use Exception; use FireflyIII\Events\UpdatedTransactionGroup; use FireflyIII\Exceptions\FireflyException; @@ -43,7 +42,6 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Routing\Redirector; use Log; -use View; /** * Class ConvertController. @@ -55,6 +53,7 @@ class ConvertController extends Controller use ModelInformation, UserNavigation; private JournalRepositoryInterface $repository; + private AccountRepositoryInterface $accountRepository; /** * ConvertController constructor. @@ -68,8 +67,8 @@ class ConvertController extends Controller // some useful repositories: $this->middleware( function ($request, $next) { - $this->repository = app(JournalRepositoryInterface::class); - + $this->repository = app(JournalRepositoryInterface::class); + $this->accountRepository = app(AccountRepositoryInterface::class); app('view')->share('title', (string) trans('firefly.transactions')); app('view')->share('mainTitleIcon', 'fa-exchange'); @@ -85,9 +84,9 @@ class ConvertController extends Controller * @param TransactionType $destinationType * @param TransactionGroup $group * + * @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws Exception * - * @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(TransactionType $destinationType, TransactionGroup $group) { @@ -151,9 +150,9 @@ class ConvertController extends Controller * @param TransactionType $destinationType * @param TransactionGroup $group * - * @throws FireflyException * @return RedirectResponse|Redirector * + * @throws FireflyException */ public function postIndex(Request $request, TransactionType $destinationType, TransactionGroup $group) { @@ -188,8 +187,8 @@ class ConvertController extends Controller * @param TransactionType $transactionType * @param array $data * - * @throws FireflyException * @return TransactionJournal + * @throws FireflyException */ private function convertJournal(TransactionJournal $journal, TransactionType $transactionType, array $data): TransactionJournal { @@ -245,23 +244,23 @@ class ConvertController extends Controller } /** - * @throws Exception * @return array + * @throws Exception */ private function getAssetAccounts(): array { // make repositories - /** @var AccountRepositoryInterface $repository */ - $repository = app(AccountRepositoryInterface::class); - $accountList = $repository->getActiveAccountsByType([AccountType::ASSET]); - $defaultCurrency = app('amount')->getDefaultCurrency(); - $grouped = []; + /** @var AccountRepositoryInterface $accountRepository */ + $accountRepository = app(AccountRepositoryInterface::class); + $accountList = $accountRepository->getActiveAccountsByType([AccountType::ASSET]); + $defaultCurrency = app('amount')->getDefaultCurrency(); + $grouped = []; // group accounts: /** @var Account $account */ foreach ($accountList as $account) { $balance = app('steam')->balance($account, today()); - $currency = $repository->getAccountCurrency($account) ?? $defaultCurrency; - $role = (string) $repository->getMetaValue($account, 'account_role'); + $currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency; + $role = (string) $accountRepository->getMetaValue($account, 'account_role'); if ('' === $role) { $role = 'no_account_type'; // @codeCoverageIgnore } @@ -274,22 +273,22 @@ class ConvertController extends Controller } /** - * @throws Exception * @return array + * @throws Exception */ private function getLiabilities(): array { // make repositories - /** @var AccountRepositoryInterface $repository */ - $repository = app(AccountRepositoryInterface::class); - $accountList = $repository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]); - $defaultCurrency = app('amount')->getDefaultCurrency(); - $grouped = []; + /** @var AccountRepositoryInterface $accountRepository */ + $accountRepository = app(AccountRepositoryInterface::class); + $accountList = $accountRepository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]); + $defaultCurrency = app('amount')->getDefaultCurrency(); + $grouped = []; // group accounts: /** @var Account $account */ foreach ($accountList as $account) { $balance = app('steam')->balance($account, today()); - $currency = $repository->getAccountCurrency($account) ?? $defaultCurrency; + $currency = $accountRepository->getAccountCurrency($account) ?? $defaultCurrency; $role = 'l_' . $account->accountType->type; $key = (string) trans('firefly.opt_group_' . $role); $grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')'; @@ -304,16 +303,16 @@ class ConvertController extends Controller private function getValidDepositSources(): array { // make repositories - /** @var AccountRepositoryInterface $repository */ - $repository = app(AccountRepositoryInterface::class); - $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN]; - $accountList = $repository + /** @var AccountRepositoryInterface $accountRepository */ + $accountRepository = app(AccountRepositoryInterface::class); + $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN]; + $accountList = $accountRepository ->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]); - $grouped = []; + $grouped = []; // group accounts: /** @var Account $account */ foreach ($accountList as $account) { - $role = (string) $repository->getMetaValue($account, 'account_role'); + $role = (string) $accountRepository->getMetaValue($account, 'account_role'); $name = $account->name; if ('' === $role) { $role = 'no_account_type'; // @codeCoverageIgnore diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php index 374e016530..f7d8dbe1fc 100644 --- a/app/Jobs/CreateRecurringTransactions.php +++ b/app/Jobs/CreateRecurringTransactions.php @@ -282,10 +282,8 @@ class CreateRecurringTransactions implements ShouldQueue */ private function handleOccurrence(Recurrence $recurrence, RecurrenceRepetition $repetition, Carbon $date): ?TransactionGroup { - #Log::debug(sprintf('Now at date %s.', $date->format('Y-m-d'))); $date->startOfDay(); if ($date->ne($this->date)) { - #Log::debug(sprintf('%s is not today (%s)', $date->format('Y-m-d'), $this->date->format('Y-m-d'))); return null; } diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index b5313c65f9..ad042c1f53 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -196,7 +196,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface } // currency of the account + the piggy bank currency are almost the same. // which amount from the transaction matches? - // $currency->id === $piggyBankCurrency->id $amount = null; if ((int)$source->transaction_currency_id === (int)$currency->id) { Log::debug('Use normal amount'); diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.php index e510da7820..d552824695 100644 --- a/app/Services/Internal/Update/RecurrenceUpdateService.php +++ b/app/Services/Internal/Update/RecurrenceUpdateService.php @@ -89,7 +89,6 @@ class RecurrenceUpdateService $recurrence->save(); // update all meta data: - //$this->updateMetaData($recurrence, $data); if (isset($data['recurrence']['notes']) && null !== $data['recurrence']['notes']) { $this->setNoteText($recurrence, $data['recurrence']['notes']); diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 744f6d4623..7c5f99728d 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -311,7 +311,6 @@ class Amount $currencyPrefStr = $currencyPreference ? $currencyPreference->data : 'EUR'; // at this point the currency preference could be encrypted, if coming from an old version. - //Log::debug('Going to try to decrypt users currency preference.'); $currencyCode = $this->tryDecrypt((string) $currencyPrefStr); // could still be json encoded: @@ -351,7 +350,6 @@ class Amount try { $value = Crypt::decrypt($value); // verified } catch (DecryptException $e) { - //Log::debug(sprintf('Could not decrypt "%s". %s', $value, $e->getMessage())); } return $value; diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php index 518c617234..c0bb888b4f 100644 --- a/app/Support/Binder/BudgetList.php +++ b/app/Support/Binder/BudgetList.php @@ -69,7 +69,6 @@ class BudgetList implements BinderInterface // add empty budget if applicable. if (in_array(0, $list, true)) { - //Log::debug('Add empty budget because $list contains 0.'); $collection->push(new Budget); } diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php index 2ce1219d79..8711785f12 100644 --- a/app/Support/FireflyConfig.php +++ b/app/Support/FireflyConfig.php @@ -87,8 +87,6 @@ class FireflyConfig /** @var Configuration $config */ $config = Configuration::where('name', $name)->first(['id', 'name', 'data']); } catch (QueryException|Exception $e) { - //Log::error(sprintf('Query exception while polling for config var: %s', $e->getMessage())); - //Log::error($e->getTraceAsString()); throw new FireflyException(sprintf('Could not poll the database: %s', $e->getMessage())); } @@ -156,7 +154,6 @@ class FireflyConfig if ('testing' === config('app.env')) { Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); } - //Log::debug('Set new value for ', ['name' => $name]); /** @var Configuration $config */ try { $config = Configuration::whereName($name)->first(); @@ -168,7 +165,6 @@ class FireflyConfig return $item; } if (null === $config) { - //Log::debug('Does not exist yet ', ['name' => $name]); /** @var Configuration $item */ $item = new Configuration; $item->name = $name; @@ -179,7 +175,6 @@ class FireflyConfig return $item; } - //Log::debug('Exists already, overwrite value.', ['name' => $name]); $config->data = $value; $config->save(); Cache::forget('ff-config-' . $name); diff --git a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php index 39a8858e22..9bef93fbcb 100644 --- a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php +++ b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php @@ -46,11 +46,8 @@ trait CalculateRangeOccurrences { $return = []; $attempts = 0; - #Log::debug('Rep is daily. Start of loop.'); while ($start <= $end) { - #Log::debug(sprintf('Mutator is now: %s', $start->format('Y-m-d'))); if (0 === $attempts % $skipMod) { - #Log::debug(sprintf('Attempts modulo skipmod is zero, include %s', $start->format('Y-m-d'))); $return[] = clone $start; } $start->addDay(); @@ -77,27 +74,14 @@ trait CalculateRangeOccurrences $return = []; $attempts = 0; $dayOfMonth = (int)$moment; - #Log::debug(sprintf('Day of month in repetition is %d', $dayOfMonth)); - #Log::debug(sprintf('Start is %s.', $start->format('Y-m-d'))); - #Log::debug(sprintf('End is %s.', $end->format('Y-m-d'))); if ($start->day > $dayOfMonth) { - #Log::debug('Add a month.'); // day has passed already, add a month. $start->addMonth(); } - #Log::debug(sprintf('Start is now %s.', $start->format('Y-m-d'))); - #Log::debug('Start loop.'); while ($start < $end) { - #Log::debug(sprintf('Mutator is now %s.', $start->format('Y-m-d'))); $domCorrected = min($dayOfMonth, $start->daysInMonth); - #Log::debug(sprintf('DoM corrected is %d', $domCorrected)); $start->day = $domCorrected; - #Log::debug(sprintf('Mutator is now %s.', $start->format('Y-m-d'))); - #Log::debug(sprintf('$attempts %% $skipMod === 0 is %s', var_export(0 === $attempts % $skipMod, true))); - #Log::debug(sprintf('$start->lte($mutator) is %s', var_export($start->lte($start), true))); - #Log::debug(sprintf('$end->gte($mutator) is %s', var_export($end->gte($start), true))); if (0 === $attempts % $skipMod && $start->lte($start) && $end->gte($start)) { - #Log::debug(sprintf('ADD %s to return!', $start->format('Y-m-d'))); $return[] = clone $start; } $attempts++; diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php index 65b3b718a0..3a431f60d0 100644 --- a/app/Transformers/AccountTransformer.php +++ b/app/Transformers/AccountTransformer.php @@ -240,7 +240,6 @@ class AccountTransformer extends AbstractTransformer $openingBalance = null; $openingBalanceDate = null; if (in_array($accountType, ['asset', 'liabilities'], true)) { - //$journal = $this->repository->getOpeningBalance($account); $amount = $this->repository->getOpeningBalanceAmount($account); $openingBalance = $amount; $openingBalanceDate = $this->repository->getOpeningBalanceDate($account); diff --git a/app/Validation/Account/ReconciliationValidation.php b/app/Validation/Account/ReconciliationValidation.php index 6ea09a47b6..63c9a21f57 100644 --- a/app/Validation/Account/ReconciliationValidation.php +++ b/app/Validation/Account/ReconciliationValidation.php @@ -53,7 +53,7 @@ trait ReconciliationValidation return false; } - // $types depends on type of source: + // types depends on type of source: $types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]; // if source is reconciliation, destination can't be. if (null !== $this->source && AccountType::RECONCILIATION === $this->source->accountType->type) { diff --git a/public/v1/js/ff/budgets/index.js b/public/v1/js/ff/budgets/index.js index 0d7a74bf13..2b6d601cd1 100644 --- a/public/v1/js/ff/budgets/index.js +++ b/public/v1/js/ff/budgets/index.js @@ -103,7 +103,7 @@ function updateBudgetedAmount(e) { updateTotalBudgetedAmount(data.transaction_currency_id); }).fail(function () { - alert('I failed :('); + console.error('I failed :('); }); } else { $.post(updateBudgetLimitUri.replace('REPLACEME', budgetLimitId.toString()), { @@ -119,7 +119,7 @@ function updateBudgetedAmount(e) { // update budgeted amount }).fail(function () { - alert('I failed :('); + console.error('I failed :('); }); } } diff --git a/public/v1/js/ff/firefly.js b/public/v1/js/ff/firefly.js index edd31052f1..14536c6a07 100644 --- a/public/v1/js/ff/firefly.js +++ b/public/v1/js/ff/firefly.js @@ -70,7 +70,7 @@ $(function () { }).done(function () { window.location.reload(true); }).fail(function () { - alert('Could not change date range'); + console.error('Could not change date range'); }); } ); diff --git a/public/v1/js/ff/help.js b/public/v1/js/ff/help.js index f8fcf650af..2da5497886 100644 --- a/public/v1/js/ff/help.js +++ b/public/v1/js/ff/help.js @@ -53,7 +53,7 @@ function enableGuidance(route, specialPage) { $.post('json/intro/enable/' + route + '/' + specialPage, {_token: token}).done(function (data) { alert(data.message); }).fail(function () { - alert('Could not re-enable introduction.'); + console.error('Could not re-enable introduction.'); }); } diff --git a/resources/views/v1/profile/index.twig b/resources/views/v1/profile/index.twig index 4d5a8863d6..3834ca1e3e 100644 --- a/resources/views/v1/profile/index.twig +++ b/resources/views/v1/profile/index.twig @@ -18,7 +18,7 @@
  • {{ 'command_line_token'|_ }}
  • - {% if false == externalIdentity %} + {% if false == isExternalIdentity %}
  • {{ 'oauth'|_ }}
  • @@ -42,7 +42,7 @@
    - {% if false == externalIdentity %} + {% if false == isExternalIdentity %}
    diff --git a/routes/api.php b/routes/api.php index 42919ad95e..b2cd3eb29b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -240,18 +240,6 @@ Route::group( } ); -//// Bills -//Route::group( -// ['namespace' => 'FireflyIII\Api\V1\Controllers\Chart', 'prefix' => 'chart/bill', -// 'as' => 'api.v1.chart.bill.',], -// static function () { -// -// // Overview API routes: -// // Route::get('overview', ['uses' => 'BillController@overview', 'as' => 'overview']); -// } -//); - - // Configuration Route::group( ['namespace' => 'FireflyIII\Api\V1\Controllers', 'prefix' => 'configuration', diff --git a/routes/web.php b/routes/web.php index 210adf1f1c..5b18191a1f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -78,10 +78,10 @@ Route::group( } ); -///** -// * For the two factor routes, the user must be logged in, but NOT 2FA. Account confirmation does not matter here. -// * -// */ +/** + * For the two factor routes, the user must be logged in, but NOT 2FA. Account confirmation does not matter here. + * + */ Route::group( ['middleware' => 'user-logged-in-no-2fa', 'prefix' => 'two-factor', 'as' => 'two-factor.', 'namespace' => 'FireflyIII\Http\Controllers\Auth'], static function () { @@ -603,11 +603,6 @@ Route::group( ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'json', 'as' => 'json.'], static function () { - // for auto complete - // Route::get('transaction-journals/all', ['uses' => 'Json\AutoCompleteController@allJournals', 'as' => 'autocomplete.all-journals']); - // Route::get('transaction-journals/with-id', ['uses' => 'Json\AutoCompleteController@allJournalsWithID', 'as' => 'autocomplete.all-journals-with-id']); - // Route::get('currency-names', ['uses' => 'Json\AutoCompleteController@currencyNames', 'as' => 'autocomplete.currency-names']); - // budgets: Route::get( 'budget/total-budgeted/{currency}/{start_date}/{end_date}', @@ -909,8 +904,6 @@ Route::group( // index controller Route::get('', ['uses' => 'Rule\IndexController@index', 'as' => 'index']); - //Route::get('up/{rule}', ['uses' => 'Rule\IndexController@up', 'as' => 'up']); - //Route::get('down/{rule}', ['uses' => 'Rule\IndexController@down', 'as' => 'down']); Route::post('move-rule/{rule}/{ruleGroup}', ['uses' => 'Rule\IndexController@moveRule', 'as' => 'move-rule']); @@ -1044,20 +1037,6 @@ Route::group( } ); -/** - * Transaction Split Controller. - */ -//Route::group( -// ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Transaction', 'prefix' => 'transactions/split', -// 'as' => 'transactions.split.'], static function () { -// // TODO improve these routes -// Route::get('edit/{tj}', ['uses' => 'SplitController@edit', 'as' => 'edit']); -// Route::post('update/{tj}', ['uses' => 'SplitController@update', 'as' => 'update']); -// // TODO end of todo. -// -//} -//); - /** * Transaction Convert Controller. */