Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Various code cleanup.
James Colec98706fac069
diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.phpindex a4a96a7067..547b225125 100644--- a/app/Console/Commands/Export/ExportData.php+++ b/app/Console/Commands/Export/ExportData.php@@ -132,11 +132,9 @@ class ExportData extends Commandif (!empty($data)) {try {$this->exportData($options, $data);- app('telemetry')->feature('system.command.executed', 'firefly-iii:export-data');} catch (FireflyException $e) {$this->error(sprintf('Could not store data: %s', $e->getMessage()));- app('telemetry')->feature('system.command.errored', 'firefly-iii:export-data');$returnCode = 1;}}diff --git a/app/Console/Commands/ScanAttachments.php b/app/Console/Commands/ScanAttachments.phpindex 25852b1561..c094309b54 100644--- a/app/Console/Commands/ScanAttachments.php+++ b/app/Console/Commands/ScanAttachments.php@@ -84,8 +84,6 @@ class ScanAttachments extends Command$this->line(sprintf('Fixed attachment #%d', $attachment->id));}- app('telemetry')->feature('system.command.executed', $this->signature);-return 0;}}diff --git a/app/Console/Commands/SetLatestVersion.php b/app/Console/Commands/SetLatestVersion.phpindex a5b065a8af..f5bbdad5d5 100644--- a/app/Console/Commands/SetLatestVersion.php+++ b/app/Console/Commands/SetLatestVersion.php@@ -60,8 +60,6 @@ class SetLatestVersion extends Commandapp('fireflyconfig')->set('ff3_version', config('firefly.version'));$this->line('Updated version.');- app('telemetry')->feature('system.command.executed', 'firefly-iii:set-latest-version');-return 0;}}diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.phpindex 6197a76d1c..4a990ae8ee 100644--- a/app/Console/Commands/Tools/ApplyRules.php+++ b/app/Console/Commands/Tools/ApplyRules.php@@ -99,8 +99,6 @@ class ApplyRules extends Command$result = $this->verifyInput();if (false === $result) {- app('telemetry')->feature('system.command.errored', 'firefly-iii:apply-rules');-return 1;}@@ -119,8 +117,6 @@ class ApplyRules extends Command$this->warn(' --rule_groups=1,2,...');$this->warn(' --all_rules');- app('telemetry')->feature('system.command.errored', 'firefly-iii:apply-rules');-return 1;}@@ -148,8 +144,6 @@ class ApplyRules extends Command// file the rule(s)$ruleEngine->fire();- app('telemetry')->feature('system.command.executed', 'firefly-iii:apply-rules');-$this->line('');$end = round(microtime(true) - $start, 2);$this->line(sprintf('Done in %s seconds!', $end));diff --git a/app/Console/Commands/Tools/Cron.php b/app/Console/Commands/Tools/Cron.phpindex c5920dd66b..720ac0e43c 100644--- a/app/Console/Commands/Tools/Cron.php+++ b/app/Console/Commands/Tools/Cron.php@@ -92,8 +92,6 @@ class Cron extends Command$this->info('More feedback on the cron jobs can be found in the log files.');- app('telemetry')->feature('system.command.executed', 'firefly-iii:cron');-return 0;}diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.phpindex 8c624d0bf9..98cb37688d 100644--- a/app/Console/Commands/UpgradeFireflyInstructions.php+++ b/app/Console/Commands/UpgradeFireflyInstructions.php@@ -63,18 +63,6 @@ class UpgradeFireflyInstructions extends Command$this->installInstructions();}- // collect system telemetry- $isDocker = true === env('IS_DOCKER', false) ? 'true' : 'false';- app('telemetry')->feature('system.php.version', PHP_VERSION);- app('telemetry')->feature('system.os.version', PHP_OS);- app('telemetry')->feature('system.database.driver', env('DB_CONNECTION', '(unknown)'));- app('telemetry')->feature('system.os.is_docker', $isDocker);- try {- app('telemetry')->feature('system.users.count', (string)User::count());- } catch (QueryException $e) {- // @ignoreException- }-return 0;}diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex f8db606acf..f506f96233 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -149,7 +149,7 @@ class AccountFactory// try with type:if (null === $result) {$types = config(sprintf('firefly.accountTypeByIdentifier.%s', $accountTypeName)) ?? [];- if (count($types) > 0) {+ if (!empty($types)) {$result = AccountType::whereIn('type', $types)->first();}}diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.phpindex fc33d3cf4c..55ac3508a1 100644--- a/app/Generator/Report/Audit/MonthReportGenerator.php+++ b/app/Generator/Report/Audit/MonthReportGenerator.php@@ -253,7 +253,7 @@ class MonthReportGenerator implements ReportGeneratorInterfacereturn ['journals' => $journals,'currency' => $currency,- 'exists' => 0!==count($journals),+ 'exists' => !empty($journals),'end' => $this->end->formatLocalized((string)trans('config.month_and_day', [], $locale)),'endBalance' => app('steam')->balance($account, $this->end),'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day', [], $locale)),diff --git a/app/Generator/Report/Budget/MonthReportGenerator.php b/app/Generator/Report/Budget/MonthReportGenerator.phpindex e30d4632db..3b3b64d64a 100644--- a/app/Generator/Report/Budget/MonthReportGenerator.php+++ b/app/Generator/Report/Budget/MonthReportGenerator.php@@ -179,7 +179,7 @@ class MonthReportGenerator implements ReportGeneratorInterface*/protected function getExpenses(): array{- if (count($this->expenses) > 0) {+ if (!empty($this->expenses)) {Log::debug('Return previous set of expenses.');return $this->expenses;diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.phpindex 804b376447..ac717e2dcb 100644--- a/app/Generator/Report/Category/MonthReportGenerator.php+++ b/app/Generator/Report/Category/MonthReportGenerator.php@@ -188,7 +188,7 @@ class MonthReportGenerator implements ReportGeneratorInterface*/protected function getExpenses(): array{- if (count($this->expenses) > 0) {+ if (!empty($this->expenses)) {Log::debug('Return previous set of expenses.');return $this->expenses;@@ -213,7 +213,7 @@ class MonthReportGenerator implements ReportGeneratorInterface*/protected function getIncome(): array{- if (count($this->income) > 0) {+ if (!empty($this->income)) {return $this->income;}diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.phpindex 1ef75943e1..13a21a6988 100644--- a/app/Http/Controllers/Admin/UpdateController.php+++ b/app/Http/Controllers/Admin/UpdateController.php@@ -100,10 +100,6 @@ class UpdateController extends Controller$channel = $request->get('update_channel');$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';- // store as telemetry- app('telemetry')->feature('admin.update.channel', $channel);- app('telemetry')->feature('admin.update.permission', (string)$checkForUpdates);-app('fireflyconfig')->set('permission_update_check', $checkForUpdates);app('fireflyconfig')->set('last_update_check', time());app('fireflyconfig')->set('update_channel', $channel);diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.phpindex b8e3e916c7..aac62aa510 100644--- a/app/Http/Controllers/Auth/RegisterController.php+++ b/app/Http/Controllers/Auth/RegisterController.php@@ -112,9 +112,6 @@ class RegisterController extends Controller$this->registered($request, $user);- // telemetry- app('telemetry')->feature('system.users.count', (string)User::count());-return redirect($this->redirectPath());}diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.phpindex 3236f9b1be..12e450d3c0 100644--- a/app/Http/Controllers/Chart/ExpenseReportController.php+++ b/app/Http/Controllers/Chart/ExpenseReportController.php@@ -187,7 +187,7 @@ class ExpenseReportController extends Controller$newSet[$key] = $entry;}}- if (0===count($newSet)) {+ if (empty($newSet)) {$newSet = $chartData;}$data = $this->generator->multiSet($newSet);diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.phpindex 31bfea6235..46d8ffc918 100644--- a/app/Http/Controllers/Json/BoxController.php+++ b/app/Http/Controllers/Json/BoxController.php@@ -189,7 +189,7 @@ class BoxController extends Controller$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);}- if (0===count($sums)) {+ if (empty($sums)) {$currency = app('amount')->getDefaultCurrency();$sums[$currency->id] = app('amount')->formatAnything($currency, '0', false);$incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false);diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.phpindex 110c5ec743..f0326ebc99 100644--- a/app/Http/Controllers/Json/FrontpageController.php+++ b/app/Http/Controllers/Json/FrontpageController.php@@ -64,7 +64,7 @@ class FrontpageController extends Controller}}$html = '';- if (0!==count($info)) {+ if (!empty($info)) {try {$html = prefixView('json.piggy-banks', compact('info'))->render();diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.phpindex ab85cf8c29..9bda7c5d82 100644--- a/app/Http/Controllers/NewUserController.php+++ b/app/Http/Controllers/NewUserController.php@@ -125,11 +125,6 @@ class NewUserController extends Controller'invoice_date' => false, 'internal_reference' => false, 'notes' => true, 'attachments' => true,];app('preferences')->set('transaction_journal_optional_fields', $visibleFields);- // telemetry: user language preference + default language.- app('telemetry')->feature('config.firefly.default_language', config('firefly.default_language', 'en_US'));- app('telemetry')->feature('user.preferences.language', app('steam')->getLanguage());- app('telemetry')->feature('user.preferences.locale', app('steam')->getLocale());-session()->flash('success', (string) trans('firefly.stored_new_accounts_new_user'));app('preferences')->mark();diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.phpindex f700a900c7..30fbc5ea6b 100644--- a/app/Http/Controllers/PreferencesController.php+++ b/app/Http/Controllers/PreferencesController.php@@ -217,11 +217,6 @@ class PreferencesController extends Controllersession()->flash('success', (string)trans('firefly.saved_preferences'));app('preferences')->mark();- // telemetry: user language preference + default language.- app('telemetry')->feature('config.firefly.default_language', config('firefly.default_language', 'en_US'));- app('telemetry')->feature('user.preferences.language', app('steam')->getLanguage());- app('telemetry')->feature('user.preferences.locale', app('steam')->getLocale());-return redirect(route('preferences.index'));}}diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex aa34bdb7d4..d1e7648663 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -247,7 +247,7 @@ class AccountRepository implements AccountRepositoryInterface}// add sort parameters. At this point they're filtered to allowed fields to sort by:- if (count($sort) > 0) {+ if (!empty($sort)) {foreach ($sort as $param) {$query->orderBy($param[0], $param[1]);}diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.phpindex 7a2968b19e..abc71b4cfe 100644--- a/app/Repositories/Rule/RuleRepository.php+++ b/app/Repositories/Rule/RuleRepository.php@@ -542,8 +542,6 @@ class RuleRepository implements RuleRepositoryInterface'order' => $order,'active' => $active,];- app('telemetry')->feature('rules.triggers.uses_trigger', $trigger['type']);-$this->storeTrigger($rule, $triggerValues);++$order;}@@ -571,8 +569,6 @@ class RuleRepository implements RuleRepositoryInterface'order' => $order,'active' => $active,];- app('telemetry')->feature('rules.actions.uses_action', $action['type']);-$this->storeAction($rule, $actionValues);++$order;}diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.phpindex 1f588c20b4..4ea0bf4f30 100644--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php@@ -380,7 +380,6 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface{/** @var GroupUpdateService $service */$service = app(GroupUpdateService::class);-return $service->update($transactionGroup, $data);}diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.phpindex d51bdb895d..46108986fd 100644--- a/app/Services/Internal/Support/RecurringTransactionTrait.php+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php@@ -313,7 +313,7 @@ trait RecurringTransactionTrait*/protected function updateTags(RecurrenceTransaction $transaction, array $tags): void{- if (count($tags) > 0) {+ if (!empty($tags)) {/** @var RecurrenceMeta|null $entry */$entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first();if (null === $entry) {diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.phpindex d276b112fe..b5a44a7d84 100644--- a/app/Services/Internal/Update/GroupUpdateService.php+++ b/app/Services/Internal/Update/GroupUpdateService.php@@ -32,7 +32,7 @@ use Log;/*** Class GroupUpdateService-* See reference nr. 91+ * See reference nr. 91*/class GroupUpdateService{@@ -57,6 +57,7 @@ class GroupUpdateService$transactionGroup->save();}+if (empty($transactions)) {Log::debug('No transactions submitted, do nothing.');@@ -105,6 +106,9 @@ class GroupUpdateService*/private function updateTransactionJournal(TransactionGroup $transactionGroup, TransactionJournal $journal, array $data): void{+ if (empty($data)) {+ return;+ }/** @var JournalUpdateService $updateService */$updateService = app(JournalUpdateService::class);$updateService->setTransactionGroup($transactionGroup);diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.phpindex d13ea0d83d..77c533e098 100644--- a/app/Services/Internal/Update/JournalUpdateService.php+++ b/app/Services/Internal/Update/JournalUpdateService.php@@ -48,7 +48,7 @@ use Log;* Class to centralise code that updates a journal given the input by system.** Class JournalUpdateService-* See reference nr. 93+ * See reference nr. 93*/class JournalUpdateService{@@ -128,6 +128,11 @@ class JournalUpdateServicepublic function update(): void{Log::debug(sprintf('Now in JournalUpdateService for journal #%d.', $this->transactionJournal->id));++ if ($this->removeReconciliation()) {+ $this->data['reconciled'] = false;+ }+// can we update account data using the new type?if ($this->hasValidAccounts()) {Log::info('Account info is valid, now update.');@@ -158,7 +163,7 @@ class JournalUpdateService$this->updateAmount();$this->updateForeignAmount();-// See reference nr. 94+ // See reference nr. 94app('preferences')->mark();@@ -201,7 +206,7 @@ class JournalUpdateService$result = $validator->validateSource($sourceId, $sourceName, null);Log::debug(sprintf('hasValidSourceAccount(%d, "%s") will return %s', $sourceId, $sourceName, var_export($result, true)));-// See reference nr. 95+ // See reference nr. 95// validate submitted info:return $result;@@ -295,7 +300,7 @@ class JournalUpdateService$result = $validator->validateDestination($destId, $destName, null);Log::debug(sprintf('hasValidDestinationAccount(%d, "%s") will return %s', $destId, $destName, var_export($result, true)));-// See reference nr. 96+ // See reference nr. 96// validate submitted info:return $result;@@ -758,4 +763,19 @@ class JournalUpdateService$this->sourceTransaction->refresh();$this->destinationTransaction->refresh();}++ /**+ * @return bool+ */+ private function removeReconciliation(): bool+ {+ if (count($this->data) > 1) {+ return true;+ }+ if (1 === count($this->data) && true === array_key_exists('transaction_journal_id', $this->data)) {+ return true;+ }++ return false;+ }}diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex 6c66154d80..dc81594895 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -297,8 +297,6 @@ class OperatorQuerySearch implements SearchInterface// check if alias, replace if necessary:$operator = self::getRootOperator($operator);- //app('telemetry')->feature('search.operators.uses_operator', $operator);-switch ($operator) {default:Log::error(sprintf('No such operator: %s', $operator));