Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Rename and clean up commands.
James Cole36457455ca56
diff --git a/app/Console/Commands/Correction/CorrectsAccountOrder.php b/app/Console/Commands/Correction/CorrectsAccountOrder.phpindex fcfa87e79e..af3d8d089f 100644--- a/app/Console/Commands/Correction/CorrectsAccountOrder.php+++ b/app/Console/Commands/Correction/CorrectsAccountOrder.php@@ -34,7 +34,7 @@ class CorrectsAccountOrder extends Commanduse ShowsFriendlyMessages;protected $description = 'Make sure account order is correct.';- protected $signature = 'firefly-iii:fix-account-order';+ protected $signature = 'correction:account-order';private AccountRepositoryInterface $repository;@@ -51,8 +51,6 @@ class CorrectsAccountOrder extends Command$this->repository->resetAccountOrder();}- $this->friendlyPositive('All accounts are ordered correctly');-return 0;}diff --git a/app/Console/Commands/Correction/CorrectsAccountTypes.php b/app/Console/Commands/Correction/CorrectsAccountTypes.phpindex 589bf76812..75be735063 100644--- a/app/Console/Commands/Correction/CorrectsAccountTypes.php+++ b/app/Console/Commands/Correction/CorrectsAccountTypes.php@@ -41,7 +41,7 @@ class CorrectsAccountTypes extends Commanduse ShowsFriendlyMessages;protected $description = 'Make sure all journals have the correct from/to account types.';- protected $signature = 'firefly-iii:fix-account-types';+ protected $signature = 'correction:account-types';private int $count;private array $expected;private AccountFactory $factory;@@ -117,9 +117,6 @@ class CorrectsAccountTypes extends Command}}}- if (0 === $this->count) {- $this->friendlyPositive('All account types are OK');- }if (0 !== $this->count) {app('log')->debug(sprintf('%d journals had to be fixed.', $this->count));$this->friendlyInfo(sprintf('Acted on %d transaction(s)', $this->count));diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.phpindex 6853254e7a..a1d29d471c 100644--- a/app/Console/Commands/Correction/CorrectsAmounts.php+++ b/app/Console/Commands/Correction/CorrectsAmounts.php@@ -41,7 +41,7 @@ class CorrectsAmounts extends Commanduse ShowsFriendlyMessages;protected $description = 'This command makes sure positive and negative amounts are recorded correctly.';- protected $signature = 'correction:fix-amount-pos-neg';+ protected $signature = 'correction:amounts';public function handle(): int{@@ -69,7 +69,6 @@ class CorrectsAmounts extends Command{$count = AutoBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);if (0 === $count) {- $this->friendlyPositive('All auto budget amounts are positive.');return;}@@ -80,7 +79,6 @@ class CorrectsAmounts extends Command{$count = AvailableBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);if (0 === $count) {- $this->friendlyPositive('All available budget amounts are positive.');return;}@@ -93,7 +91,6 @@ class CorrectsAmounts extends Command$count += Bill::where('amount_max', '<', 0)->update(['amount_max' => DB::raw('amount_max * -1')]);$count += Bill::where('amount_min', '<', 0)->update(['amount_min' => DB::raw('amount_min * -1')]);if (0 === $count) {- $this->friendlyPositive('All bill amounts are positive.');return;}@@ -104,7 +101,6 @@ class CorrectsAmounts extends Command{$count = BudgetLimit::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);if (0 === $count) {- $this->friendlyPositive('All budget limit amounts are positive.');return;}@@ -115,7 +111,6 @@ class CorrectsAmounts extends Command{$count = CurrencyExchangeRate::where('rate', '<', 0)->update(['rate' => DB::raw('rate * -1')]);if (0 === $count) {- $this->friendlyPositive('All currency exchange rates are positive.');return;}@@ -126,7 +121,6 @@ class CorrectsAmounts extends Command{$count = PiggyBank::where('target_amount', '<', 0)->update(['target_amount' => DB::raw('target_amount * -1')]);if (0 === $count) {- $this->friendlyPositive('All piggy bank amounts are positive.');return;}@@ -139,7 +133,6 @@ class CorrectsAmounts extends Command$count += RecurrenceTransaction::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);$count += RecurrenceTransaction::where('foreign_amount', '<', 0)->update(['foreign_amount' => DB::raw('foreign_amount * -1')]);if (0 === $count) {- $this->friendlyPositive('All recurring transaction amounts are positive.');return;}@@ -162,7 +155,6 @@ class CorrectsAmounts extends Command}}if (0 === $fixed) {- $this->friendlyPositive('All rule trigger amounts are positive.');return;}diff --git a/app/Console/Commands/Correction/CorrectsCurrencies.php b/app/Console/Commands/Correction/CorrectsCurrencies.phpindex 3a9d0cdc35..dc812457ea 100644--- a/app/Console/Commands/Correction/CorrectsCurrencies.php+++ b/app/Console/Commands/Correction/CorrectsCurrencies.php@@ -42,7 +42,7 @@ class CorrectsCurrencies extends Commanduse ShowsFriendlyMessages;protected $description = 'Enables all currencies in use.';- protected $signature = 'firefly-iii:enable-currencies';+ protected $signature = 'correction:currencies';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/CorrectsDatabase.php b/app/Console/Commands/Correction/CorrectsDatabase.phpindex 3762970056..3b0004d8fc 100644--- a/app/Console/Commands/Correction/CorrectsDatabase.php+++ b/app/Console/Commands/Correction/CorrectsDatabase.php@@ -46,40 +46,36 @@ class CorrectsDatabase extends Commandreturn 1;}$commands = [-- // also just in case, some integrity commands:- // 'upgrade:restore-oauth-keys',- // 'upgrade:add-timezones-to-dates',- // 'upgrade:create-group-memberships',- // 'upgrade:upgrade-group-information',- // 'upgrade:610-currency-preferences',- // 'upgrade:620-piggy-banks',- 'firefly-iii:fix-piggies',- 'firefly-iii:create-link-types',- 'firefly-iii:create-access-tokens',- 'firefly-iii:remove-bills',- 'firefly-iii:fix-amount-pos-neg',- 'firefly-iii:enable-currencies',- 'firefly-iii:fix-transfer-budgets',- 'firefly-iii:fix-uneven-amount',- 'firefly-iii:delete-zero-amount',- 'firefly-iii:delete-orphaned-transactions',- 'firefly-iii:delete-empty-journals',- 'firefly-iii:delete-empty-groups',- 'firefly-iii:fix-account-types',- 'firefly-iii:fix-ibans',- 'firefly-iii:fix-account-order',- 'firefly-iii:rename-meta-fields',- 'firefly-iii:fix-ob-currencies',- 'firefly-iii:fix-long-descriptions',- 'firefly-iii:fix-recurring-transactions',- 'firefly-iii:upgrade-group-information',- // 'firefly-iii:fix-transaction-types', // very resource heavy.- 'firefly-iii:fix-frontpage-accounts',- // new!- 'firefly-iii:unify-group-accounts',- 'firefly-iii:trigger-credit-recalculation',- 'firefly-iii:migrate-preferences',+ 'correction:restore-oauth-keys',+ 'correction:timezones',+ 'correction:create-group-memberships',+ 'correction:group-information',+ 'correction:piggy-banks',+ 'correction:link-types',+ 'correction:access-tokens',+ 'correction:bills',+ 'correction:amounts',+ 'correction:currencies',+ 'correction:transfer-budgets',+ 'correction:uneven-amounts',+ 'correction:zero-amounts',+ 'correction:orphaned-transactions',+ 'correction:empty-journals',+ 'correction:empty-groups',+ 'correction:account-types',+ 'correction:ibans',+ 'correction:account-order',+ 'correction:meta-fields',+ 'correction:opening-balance-currencies',+ 'correction:long-descriptions',+ 'correction:recurring-transactions',+ 'correction:frontpage-accounts',+ 'correction:group-accounts',+ 'correction:recalculates-liabilities',+ 'correction:preferences',+ // 'correction:transaction-types', // resource heavy, disabled.+ // 'correction:recalculate-native-amounts', // not necessary, disabled.+ 'firefly-iii:report-integrity',];foreach ($commands as $command) {$this->friendlyLine(sprintf('Now executing command "%s"', $command));diff --git a/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php b/app/Console/Commands/Correction/CorrectsFrontpageAccounts.phpindex ad275b5438..4cdaa1489a 100644--- a/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php+++ b/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php@@ -36,7 +36,7 @@ class CorrectsFrontpageAccounts extends Commanduse ShowsFriendlyMessages;protected $description = 'Fixes a preference that may include deleted accounts or accounts of another type.';- protected $signature = 'firefly-iii:fix-frontpage-accounts';+ protected $signature = 'correction:frontpage-accounts';/*** Execute the console command.@@ -52,8 +52,6 @@ class CorrectsFrontpageAccounts extends Command$this->fixPreference($preference);}}- $this->friendlyPositive('Account preferences are OK');-return 0;}diff --git a/app/Console/Commands/Correction/CorrectsGroupAccounts.php b/app/Console/Commands/Correction/CorrectsGroupAccounts.phpindex 82d6589e97..ddafa932c5 100644--- a/app/Console/Commands/Correction/CorrectsGroupAccounts.php+++ b/app/Console/Commands/Correction/CorrectsGroupAccounts.php@@ -39,7 +39,7 @@ class CorrectsGroupAccounts extends Commanduse ShowsFriendlyMessages;protected $description = 'Unify the source / destination accounts of split groups.';- protected $signature = 'firefly-iii:unify-group-accounts';+ protected $signature = 'correction:group-accounts';/*** Execute the console command.@@ -64,8 +64,6 @@ class CorrectsGroupAccounts extends Command$handler->unifyAccounts($event);}- $this->friendlyPositive('Updated possible inconsistent transaction groups.');-return 0;}}diff --git a/app/Console/Commands/Correction/CorrectsGroupInformation.php b/app/Console/Commands/Correction/CorrectsGroupInformation.phpindex add733dc24..1a187d2da5 100644--- a/app/Console/Commands/Correction/CorrectsGroupInformation.php+++ b/app/Console/Commands/Correction/CorrectsGroupInformation.php@@ -50,7 +50,7 @@ class CorrectsGroupInformation extends Commanduse ShowsFriendlyMessages;protected $description = 'Makes sure that every object is linked to a group';- protected $signature = 'firefly-iii:upgrade-group-information';+ protected $signature = 'correction:group-information';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/CorrectsIbans.php b/app/Console/Commands/Correction/CorrectsIbans.phpindex 044bc51ec9..672fce3281 100644--- a/app/Console/Commands/Correction/CorrectsIbans.php+++ b/app/Console/Commands/Correction/CorrectsIbans.php@@ -35,7 +35,7 @@ class CorrectsIbans extends Commanduse ShowsFriendlyMessages;protected $description = 'Removes spaces from IBANs';- protected $signature = 'firefly-iii:fix-ibans';+ protected $signature = 'correction:ibans';private int $count = 0;/**@@ -46,9 +46,6 @@ class CorrectsIbans extends Command$accounts = Account::whereNotNull('iban')->get();$this->filterIbans($accounts);$this->countAndCorrectIbans($accounts);- if (0 === $this->count) {- $this->friendlyPositive('All IBANs are valid.');- }return 0;}diff --git a/app/Console/Commands/Correction/CorrectsLongDescriptions.php b/app/Console/Commands/Correction/CorrectsLongDescriptions.phpindex fdb965af29..5abaa4b1d7 100644--- a/app/Console/Commands/Correction/CorrectsLongDescriptions.php+++ b/app/Console/Commands/Correction/CorrectsLongDescriptions.php@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;use FireflyIII\Models\TransactionGroup;use FireflyIII\Models\TransactionJournal;use Illuminate\Console\Command;+use Illuminate\Support\Facades\DB;class CorrectsLongDescriptions extends Command{@@ -35,14 +36,14 @@ class CorrectsLongDescriptions extends Commandprivate const int MAX_LENGTH = 1000;protected $description = 'Fixes long descriptions in journals and groups.';- protected $signature = 'firefly-iii:fix-long-descriptions';+ protected $signature = 'correction:long-descriptions';/*** Execute the console command.*/public function handle(): int{- $journals = TransactionJournal::get(['id', 'description']);+ $journals = TransactionJournal::where(DB::raw('LENGTH(description)'),'>', self::MAX_LENGTH)->get(['id', 'description']);$count = 0;/** @var TransactionJournal $journal */@@ -55,7 +56,7 @@ class CorrectsLongDescriptions extends Command}}- $groups = TransactionGroup::get(['id', 'title']);+ $groups = TransactionGroup::where(DB::raw('LENGTH(title)'),'>', self::MAX_LENGTH)->get(['id', 'title']);/** @var TransactionGroup $group */foreach ($groups as $group) {@@ -66,9 +67,6 @@ class CorrectsLongDescriptions extends Command++$count;}}- if (0 === $count) {- $this->friendlyPositive('All transaction group and journal title lengths are within bounds.');- }return 0;}diff --git a/app/Console/Commands/Correction/CorrectsMetDataFields.php b/app/Console/Commands/Correction/CorrectsMetaDataFields.phpsimilarity index 89%rename from app/Console/Commands/Correction/CorrectsMetDataFields.phprename to app/Console/Commands/Correction/CorrectsMetaDataFields.phpindex a8bf5687bb..731c5f49f7 100644--- a/app/Console/Commands/Correction/CorrectsMetDataFields.php+++ b/app/Console/Commands/Correction/CorrectsMetaDataFields.php@@ -26,13 +26,14 @@ namespace FireflyIII\Console\Commands\Correction;use FireflyIII\Console\Commands\ShowsFriendlyMessages;use Illuminate\Console\Command;+use Illuminate\Support\Facades\DB;-class CorrectsMetDataFields extends Command+class CorrectsMetaDataFields extends Command{use ShowsFriendlyMessages;protected $description = 'Rename changed meta fields.';- protected $signature = 'firefly-iii:rename-meta-fields';+ protected $signature = 'correction:meta-fields';private int $count = 0;@@ -58,9 +59,6 @@ class CorrectsMetDataFields extends Commandforeach ($changes as $original => $update) {$this->rename($original, $update);}- if (0 === $this->count) {- $this->friendlyPositive('All meta fields are correct.');- }if (0 !== $this->count) {$this->friendlyInfo(sprintf('Renamed %d meta field(s).', $this->count));}@@ -70,7 +68,7 @@ class CorrectsMetDataFields extends Commandprivate function rename(string $original, string $update): void{- $total = \DB::table('journal_meta')+ $total = DB::table('journal_meta')->where('name', '=', $original)->update(['name' => $update]);diff --git a/app/Console/Commands/Correction/CorrectsNativeAmounts.php b/app/Console/Commands/Correction/CorrectsNativeAmounts.phpindex 2564648232..3bcd2d4e85 100644--- a/app/Console/Commands/Correction/CorrectsNativeAmounts.php+++ b/app/Console/Commands/Correction/CorrectsNativeAmounts.php@@ -52,7 +52,7 @@ class CorrectsNativeAmounts extends Commandprotected $description = 'Recalculate native amounts for all objects.';- protected $signature = 'firefly-iii:recalculate-native-amounts';+ protected $signature = 'correction:recalculate-native-amounts';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.phpindex e99a7b551b..16a3d196ce 100644--- a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php+++ b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php@@ -40,7 +40,7 @@ class CorrectsOpeningBalanceCurrencies extends Commanduse ShowsFriendlyMessages;protected $description = 'Will make sure that opening balance transaction currencies match the account they\'re for.';- protected $signature = 'firefly-iii:fix-ob-currencies';+ protected $signature = 'correction:opening-balance-currencies';/*** Execute the console command.@@ -59,10 +59,6 @@ class CorrectsOpeningBalanceCurrencies extends Command$message = sprintf('Corrected %d opening balance transaction(s).', $count);$this->friendlyInfo($message);}- if (0 === $count) {- $message = 'There was nothing to fix in the opening balance transactions.';- $this->friendlyPositive($message);- }return 0;}diff --git a/app/Console/Commands/Correction/CorrectsPiggyBanks.php b/app/Console/Commands/Correction/CorrectsPiggyBanks.phpindex 4f10722688..e5928093d0 100644--- a/app/Console/Commands/Correction/CorrectsPiggyBanks.php+++ b/app/Console/Commands/Correction/CorrectsPiggyBanks.php@@ -39,7 +39,7 @@ class CorrectsPiggyBanks extends Commanduse ShowsFriendlyMessages;protected $description = 'Fixes common issues with piggy banks.';- protected $signature = 'firefly-iii:fix-piggies';+ protected $signature = 'correction:piggy-banks';/*** Execute the console command.@@ -66,9 +66,6 @@ class CorrectsPiggyBanks extends Commandcontinue;}}- if (0 === $count) {- $this->friendlyPositive('All piggy bank events are OK.');- }if (0 !== $count) {$this->friendlyInfo(sprintf('Fixed %d piggy bank event(s).', $count));}diff --git a/app/Console/Commands/Correction/CorrectsPreferences.php b/app/Console/Commands/Correction/CorrectsPreferences.phpindex 13d5ce8dc2..e8e4b04a6b 100644--- a/app/Console/Commands/Correction/CorrectsPreferences.php+++ b/app/Console/Commands/Correction/CorrectsPreferences.php@@ -32,7 +32,7 @@ class CorrectsPreferences extends Command{protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.';- protected $signature = 'firefly-iii:migrate-preferences';+ protected $signature = 'correction:preferences';/*** Execute the console command.@@ -50,7 +50,7 @@ class CorrectsPreferences extends Commandif (null === $preference) {continue;}- if (null !== $preference->user_group_id) {+ if (null === $preference->user_group_id) {$preference->user_group_id = $user->user_group_id;$preference->save();++$count;diff --git a/app/Console/Commands/Correction/CorrectsRecurringTransactions.php b/app/Console/Commands/Correction/CorrectsRecurringTransactions.phpindex f9d5f8b88b..e7d302dff2 100644--- a/app/Console/Commands/Correction/CorrectsRecurringTransactions.php+++ b/app/Console/Commands/Correction/CorrectsRecurringTransactions.php@@ -38,7 +38,7 @@ class CorrectsRecurringTransactions extends Commanduse ShowsFriendlyMessages;protected $description = 'Fixes recurring transactions with the wrong transaction type.';- protected $signature = 'firefly-iii:fix-recurring-transactions';+ protected $signature = 'correction:recurring-transactions';private int $count = 0;private RecurringRepositoryInterface $recurringRepos;private UserRepositoryInterface $userRepos;@@ -50,9 +50,6 @@ class CorrectsRecurringTransactions extends Command{$this->stupidLaravel();$this->correctTransactions();- if (0 === $this->count) {- $this->friendlyPositive('All recurring transactions are OK.');- }return 0;}diff --git a/app/Console/Commands/Correction/CorrectsTimezoneInformation.php b/app/Console/Commands/Correction/CorrectsTimezoneInformation.phpindex 94c63ada8b..c963f3844a 100644--- a/app/Console/Commands/Correction/CorrectsTimezoneInformation.php+++ b/app/Console/Commands/Correction/CorrectsTimezoneInformation.php@@ -92,7 +92,7 @@ class CorrectsTimezoneInformation extends Command** @var string*/- protected $signature = 'firefly-iii:add-timezones-to-dates';+ protected $signature = 'correction:timezones';/*** Execute the console command.@@ -126,8 +126,6 @@ class CorrectsTimezoneInformation extends CommandLog::error($e->getMessage());}if (0 === $count) {- $this->friendlyPositive(sprintf('Timezone information is present in field "%s" of model "%s".', $field, $shortModel));-return;}$this->friendlyInfo(sprintf('Adding timezone information to field "%s" of model "%s".', $field, $shortModel));diff --git a/app/Console/Commands/Correction/CorrectsTransactionTypes.php b/app/Console/Commands/Correction/CorrectsTransactionTypes.phpindex 3cecedaa9a..bb185d5d87 100644--- a/app/Console/Commands/Correction/CorrectsTransactionTypes.php+++ b/app/Console/Commands/Correction/CorrectsTransactionTypes.php@@ -39,7 +39,7 @@ class CorrectsTransactionTypes extends Commanduse ShowsFriendlyMessages;protected $description = 'Make sure all transactions are of the correct type, based on source + dest.';- protected $signature = 'firefly-iii:fix-transaction-types';+ protected $signature = 'correction:transaction-types';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/CorrectsTransferBudgets.php b/app/Console/Commands/Correction/CorrectsTransferBudgets.phpindex 58ddd9d27e..6c95fe2ab0 100644--- a/app/Console/Commands/Correction/CorrectsTransferBudgets.php+++ b/app/Console/Commands/Correction/CorrectsTransferBudgets.php@@ -37,7 +37,7 @@ class CorrectsTransferBudgets extends Commanduse ShowsFriendlyMessages;protected $description = 'Removes budgets from transfers.';- protected $signature = 'firefly-iii:fix-transfer-budgets';+ protected $signature = 'correction:transfer-budgets';/*** Execute the console command.@@ -60,10 +60,6 @@ class CorrectsTransferBudgets extends Command$entry->budgets()->sync([]);++$count;}- if (0 === $count) {- $message = 'No invalid budget/journal entries.';- $this->friendlyPositive($message);- }if (0 !== $count) {$message = sprintf('Corrected %d invalid budget/journal entries (entry).', $count);app('log')->debug($message);diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.phpindex d90742f606..791c9d5c90 100644--- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php+++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php@@ -41,7 +41,7 @@ class CorrectsUnevenAmount extends Commanduse ShowsFriendlyMessages;protected $description = 'Fix journals with uneven amounts.';- protected $signature = 'firefly-iii:fix-uneven-amount';+ protected $signature = 'correction:uneven-amounts';private int $count;/**@@ -118,11 +118,6 @@ class CorrectsUnevenAmount extends Command++$count;}}- if (0 === $count) {- $this->friendlyPositive('No "old style" foreign currency transfers.');-- return;- }}private function fixUnevenAmounts(): void@@ -164,9 +159,6 @@ class CorrectsUnevenAmount extends Command$this->fixJournal($entry->transaction_journal_id);}}- if (0 === $this->count) {- $this->friendlyPositive('Database amount integrity is OK');- }}private function fixJournal(int $param): void@@ -291,8 +283,6 @@ class CorrectsUnevenAmount extends CommandLog::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));}if (0 === $count) {- $this->friendlyPositive('Journal currency integrity is OK');-return;}diff --git a/app/Console/Commands/Correction/CreatesAccessTokens.php b/app/Console/Commands/Correction/CreatesAccessTokens.phpindex 166caed8dd..d1408446d1 100644--- a/app/Console/Commands/Correction/CreatesAccessTokens.php+++ b/app/Console/Commands/Correction/CreatesAccessTokens.php@@ -38,7 +38,7 @@ class CreatesAccessTokens extends Commandprotected $description = 'Creates user access tokens which are used for command line access to personal data.';- protected $signature = 'firefly-iii:create-access-tokens';+ protected $signature = 'correction:access-tokens';/*** Execute the console command.@@ -64,9 +64,6 @@ class CreatesAccessTokens extends Command++$count;}}- if (0 === $count) {- $this->friendlyPositive('Verified access tokens.');- }return 0;}diff --git a/app/Console/Commands/Correction/CreatesGroupMemberships.php b/app/Console/Commands/Correction/CreatesGroupMemberships.phpindex 123d370711..92709fdad0 100644--- a/app/Console/Commands/Correction/CreatesGroupMemberships.php+++ b/app/Console/Commands/Correction/CreatesGroupMemberships.php@@ -39,7 +39,7 @@ class CreatesGroupMemberships extends Commandpublic const string CONFIG_NAME = '560_create_group_memberships';protected $description = 'Update group memberships';- protected $signature = 'firefly-iii:create-group-memberships';+ protected $signature = 'correction:create-group-memberships';/*** Execute the console command.@@ -49,7 +49,6 @@ class CreatesGroupMemberships extends Commandpublic function handle(): int{$this->createGroupMemberships();- $this->friendlyPositive('Validated group memberships');return 0;}diff --git a/app/Console/Commands/Correction/CreatesLinkTypes.php b/app/Console/Commands/Correction/CreatesLinkTypes.phpindex bde4c1cab1..8b9e4f6cfe 100644--- a/app/Console/Commands/Correction/CreatesLinkTypes.php+++ b/app/Console/Commands/Correction/CreatesLinkTypes.php@@ -37,7 +37,7 @@ class CreatesLinkTypes extends Commandprotected $description = 'Creates all link types.';- protected $signature = 'firefly-iii:create-link-types';+ protected $signature = 'correction:link-types';/*** Execute the console command.@@ -66,9 +66,6 @@ class CreatesLinkTypes extends Command$link->editable = false;$link->save();}- if (0 === $count) {- $this->friendlyPositive('All link types are OK');- }return 0;}diff --git a/app/Console/Commands/Correction/RemovesBills.php b/app/Console/Commands/Correction/RemovesBills.phpindex a8708ca8f3..8588607c45 100644--- a/app/Console/Commands/Correction/RemovesBills.php+++ b/app/Console/Commands/Correction/RemovesBills.php@@ -37,7 +37,7 @@ class RemovesBills extends Commanduse ShowsFriendlyMessages;protected $description = 'Remove bills from transactions that shouldn\'t have one.';- protected $signature = 'firefly-iii:remove-bills';+ protected $signature = 'correction:bills';/*** Execute the console command.@@ -60,7 +60,6 @@ class RemovesBills extends Commandif ($journals->count() > 0) {$this->friendlyInfo('Fixed all transaction journals so they have correct bill information.');}- $this->friendlyPositive('All bills and journals are OK');return 0;}diff --git a/app/Console/Commands/Correction/RemovesEmptyGroups.php b/app/Console/Commands/Correction/RemovesEmptyGroups.phpindex 50f3800c36..5d0b86d59f 100644--- a/app/Console/Commands/Correction/RemovesEmptyGroups.php+++ b/app/Console/Commands/Correction/RemovesEmptyGroups.php@@ -37,7 +37,7 @@ class RemovesEmptyGroups extends Commanduse ShowsFriendlyMessages;protected $description = 'Delete empty transaction groups.';- protected $signature = 'firefly-iii:delete-empty-groups';+ protected $signature = 'correction:empty-groups';/*** Execute the console command.@@ -61,9 +61,6 @@ class RemovesEmptyGroups extends CommandTransactionGroup::whereNull('deleted_at')->whereIn('id', $chunk)->delete();}}- if (0 === $total) {- $this->friendlyInfo('Verified there are no empty groups.');- }return 0;}diff --git a/app/Console/Commands/Correction/RemovesEmptyJournals.php b/app/Console/Commands/Correction/RemovesEmptyJournals.phpindex e74ff91cbe..fad74548d0 100644--- a/app/Console/Commands/Correction/RemovesEmptyJournals.php+++ b/app/Console/Commands/Correction/RemovesEmptyJournals.php@@ -39,7 +39,7 @@ class RemovesEmptyJournals extends Commandprotected $description = 'Delete empty and uneven transaction journals.';- protected $signature = 'firefly-iii:delete-empty-journals';+ protected $signature = 'correction:empty-journals';/*** Execute the console command.@@ -82,9 +82,6 @@ class RemovesEmptyJournals extends Command++$total;}}- if (0 === $total) {- $this->friendlyPositive('No uneven transaction journals.');- }}private function deleteEmptyJournals(): void@@ -107,8 +104,5 @@ class RemovesEmptyJournals extends Command$this->friendlyInfo(sprintf('Deleted empty transaction journal #%d', $entry->id));++$count;}- if (0 === $count) {- $this->friendlyPositive('No empty transaction journals.');- }}}diff --git a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php b/app/Console/Commands/Correction/RemovesOrphanedTransactions.phpindex b927cdc648..33eb7ba05c 100644--- a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php+++ b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php@@ -38,7 +38,7 @@ class RemovesOrphanedTransactions extends Commandprotected $description = 'Deletes orphaned transactions.';- protected $signature = 'firefly-iii:delete-orphaned-transactions';+ protected $signature = 'correction:orphaned-transactions';/*** Execute the console command.@@ -63,7 +63,7 @@ class RemovesOrphanedTransactions extends Command;$count = $set->count();if (0 === $count) {- $this->friendlyPositive('No orphaned journals.');+ //$this->friendlyPositive('No orphaned journals.');return;}@@ -116,9 +116,6 @@ class RemovesOrphanedTransactions extends Command++$count;}}- if (0 === $count) {- $this->friendlyPositive('No orphaned transactions.');- }}private function deleteFromOrphanedAccounts(): void@@ -147,8 +144,5 @@ class RemovesOrphanedTransactions extends Command);++$count;}- if (0 === $count) {- $this->friendlyPositive('No orphaned accounts.');- }}}diff --git a/app/Console/Commands/Correction/DeletesZeroAmount.php b/app/Console/Commands/Correction/RemovesZeroAmount.phpsimilarity index 87%rename from app/Console/Commands/Correction/DeletesZeroAmount.phprename to app/Console/Commands/Correction/RemovesZeroAmount.phpindex fe998f9ae1..fd9d1c344e 100644--- a/app/Console/Commands/Correction/DeletesZeroAmount.php+++ b/app/Console/Commands/Correction/RemovesZeroAmount.php@@ -29,16 +29,13 @@ use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionJournal;use Illuminate\Console\Command;-/**- * Class DeleteZeroAmount- */-class DeletesZeroAmount extends Command+class RemovesZeroAmount extends Command{use ShowsFriendlyMessages;protected $description = 'Delete transactions with zero amount.';- protected $signature = 'firefly-iii:delete-zero-amount';+ protected $signature = 'correction:zero-amounts';/*** Execute the console command.@@ -56,9 +53,6 @@ class DeletesZeroAmount extends CommandTransaction::where('transaction_journal_id', $journal->id)->delete();}- if (0 === $journals->count()) {- $this->friendlyPositive('No zero-amount transaction journals.');- }return 0;}diff --git a/app/Console/Commands/Correction/RestoresOAuthKeys.php b/app/Console/Commands/Correction/RestoresOAuthKeys.phpindex 4b5c4440ee..b50115eabe 100644--- a/app/Console/Commands/Correction/RestoresOAuthKeys.php+++ b/app/Console/Commands/Correction/RestoresOAuthKeys.php@@ -36,7 +36,7 @@ class RestoresOAuthKeys extends Commanduse ShowsFriendlyMessages;protected $description = 'Will restore the OAuth keys generated for the system.';- protected $signature = 'firefly-iii:restore-oauth-keys';+ protected $signature = 'correction:restore-oauth-keys';/*** Execute the console command.@@ -76,7 +76,6 @@ class RestoresOAuthKeys extends Commandreturn;}- $this->friendlyPositive('OAuth keys are OK');}private function keysInDatabase(): booldiff --git a/app/Console/Commands/Correction/TriggersCreditCalculation.php b/app/Console/Commands/Correction/TriggersCreditCalculation.phpindex 0538825763..57918d9976 100644--- a/app/Console/Commands/Correction/TriggersCreditCalculation.php+++ b/app/Console/Commands/Correction/TriggersCreditCalculation.php@@ -28,13 +28,10 @@ use FireflyIII\Models\Account;use FireflyIII\Services\Internal\Support\CreditRecalculateService;use Illuminate\Console\Command;-/**- * Class CorrectionSkeleton- */class TriggersCreditCalculation extends Command{protected $description = 'Triggers the credit recalculation service for liabilities.';- protected $signature = 'firefly-iii:trigger-credit-recalculation';+ protected $signature = 'correction:recalculates-liabilities';/*** Execute the console command.diff --git a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.phpindex 0099b11e5d..f425abe9f9 100644--- a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php+++ b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php@@ -32,9 +32,6 @@ use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;use Illuminate\Console\Command;use Illuminate\Database\QueryException;-/**- * Class TransactionIdentifier- */class AddsTransactionIdentifiers extends Command{use ShowsFriendlyMessages;diff --git a/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stub b/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stubindex 5d2dba01f5..6dee8d3977 100644--- a/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stub+++ b/app/Console/Commands/Upgrade/UpgradeSkeleton.php.stub@@ -14,7 +14,7 @@ class UpgradeSkeleton extends Commandprotected $description = 'SOME DESCRIPTION';- protected $signature = 'firefly-iii:UPGRSKELETON {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:UPGRSKELETON {--F|force : Force the execution of this command.}';/*** Execute the console command.diff --git a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.phpindex b50fa0c150..d4f6495c46 100644--- a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php+++ b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php@@ -36,9 +36,6 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;use FireflyIII\User;use Illuminate\Console\Command;-/**- * Class AccountCurrencies- */class UpgradesAccountCurrencies extends Command{use ShowsFriendlyMessages;diff --git a/app/Console/Commands/Upgrade/UpgradesAttachments.php b/app/Console/Commands/Upgrade/UpgradesAttachments.phpindex aa2e310733..93f4e628b7 100644--- a/app/Console/Commands/Upgrade/UpgradesAttachments.php+++ b/app/Console/Commands/Upgrade/UpgradesAttachments.php@@ -30,9 +30,6 @@ use FireflyIII\Models\Attachment;use FireflyIII\Models\Note;use Illuminate\Console\Command;-/**- * Class MigrateAttachments- */class UpgradesAttachments extends Command{use ShowsFriendlyMessages;diff --git a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.phpindex 927b9e1845..50ed8b6ff3 100644--- a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php+++ b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php@@ -32,9 +32,6 @@ use FireflyIII\User;use Illuminate\Console\Command;use Illuminate\Support\Collection;-/**- * Class UpgradesCurrencyPreferences- */class UpgradesCurrencyPreferences extends Command{use ShowsFriendlyMessages;diff --git a/app/Console/Commands/Upgrade/UpgradesDatabase.php b/app/Console/Commands/Upgrade/UpgradesDatabase.phpindex 10fdde02ea..fb24640cbc 100644--- a/app/Console/Commands/Upgrade/UpgradesDatabase.php+++ b/app/Console/Commands/Upgrade/UpgradesDatabase.php@@ -63,6 +63,10 @@ class UpgradesDatabase extends Command'upgrade:550-budget-limit-periods','upgrade:600-rule-actions','upgrade:610-account-balance',+ 'upgrade:610-currency-preferences',+ 'upgrade:610-currency-preferences',+ 'upgrade:620-piggy-banks',+ 'upgrade:620-native-amounts','firefly-iii:correct-database',];$args = [];diff --git a/app/Console/Commands/Upgrade/UpgradesNativeAmounts.php b/app/Console/Commands/Upgrade/UpgradesNativeAmounts.phpnew file mode 100644index 0000000000..91ed5026f7--- /dev/null+++ b/app/Console/Commands/Upgrade/UpgradesNativeAmounts.php@@ -0,0 +1,79 @@+<?php+/*+ * UpgradesNativeAmounts.php+ * Copyright (c) 2024 [email protected].+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see https://www.gnu.org/licenses/.+ */++namespace FireflyIII\Console\Commands\Upgrade;++use FireflyIII\Console\Commands\ShowsFriendlyMessages;+use Illuminate\Console\Command;+use Illuminate\Support\Facades\Artisan;++class UpgradesNativeAmounts extends Command+{+ use ShowsFriendlyMessages;+ public const string CONFIG_NAME = '620_native_amounts';++ protected $description = 'Runs the native amounts calculations.';++ protected $signature = 'upgrade:620-native-amounts {--F|force : Force the execution of this command.}';++ /**+ * Execute the console command.+ *+ * @return int+ */+ public function handle(): int+ {+ if ($this->isExecuted() && true !== $this->option('force')) {+ $this->friendlyInfo('This command has already been executed.');++ return 0;+ }++ Artisan::call('correction:recalculate-native-amounts');++ $this->markAsExecuted();+++ return 0;+ }++ /**+ * @return bool+ */+ private function isExecuted(): bool+ {+ $configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);+ if (null !== $configVar) {+ return (bool)$configVar->data;+ }++ return false;+ }+++ /**+ *+ */+ private function markAsExecuted(): void+ {+ app('fireflyconfig')->set(self::CONFIG_NAME, true);+ }+}diff --git a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.phpindex e2e04cf3cd..2f64a2bdd2 100644--- a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php+++ b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php@@ -30,9 +30,6 @@ use FireflyIII\Models\RecurrenceMeta;use FireflyIII\Models\RecurrenceTransactionMeta;use Illuminate\Console\Command;-/**- * Class MigrateRecurrenceMeta- */class UpgradesRecurrenceMetaData extends Command{use ShowsFriendlyMessages;diff --git a/app/Console/Commands/Upgrade/UpgradesRecurrenceType.php b/app/Console/Commands/Upgrade/UpgradesRecurrenceType.phpindex 802e303f94..c03376af23 100644--- a/app/Console/Commands/Upgrade/UpgradesRecurrenceType.php+++ b/app/Console/Commands/Upgrade/UpgradesRecurrenceType.php@@ -27,9 +27,6 @@ namespace FireflyIII\Console\Commands\Upgrade;use FireflyIII\Console\Commands\ShowsFriendlyMessages;use Illuminate\Console\Command;-/**- * Class MigrateRecurrenceType- */class UpgradesRecurrenceType extends Command{use ShowsFriendlyMessages;diff --git a/app/Console/Commands/Upgrade/UpgradesTagLocations.php b/app/Console/Commands/Upgrade/UpgradesTagLocations.phpindex d0a297c20c..a6fe336a49 100644--- a/app/Console/Commands/Upgrade/UpgradesTagLocations.php+++ b/app/Console/Commands/Upgrade/UpgradesTagLocations.php@@ -29,9 +29,6 @@ use FireflyIII\Models\Location;use FireflyIII\Models\Tag;use Illuminate\Console\Command;-/**- * Class MigrateTagLocations- */class UpgradesTagLocations extends Command{use ShowsFriendlyMessages;diff --git a/app/Console/Commands/Upgrade/UpgradeTransferCurrencies.php b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.phpsimilarity index 99%rename from app/Console/Commands/Upgrade/UpgradeTransferCurrencies.phprename to app/Console/Commands/Upgrade/UpgradesTransferCurrencies.phpindex 4057a7f863..a51ec5a95c 100644--- a/app/Console/Commands/Upgrade/UpgradeTransferCurrencies.php+++ b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php@@ -34,10 +34,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;use Illuminate\Console\Command;-/**- * Class UpgradeTransferCurrencies- */-class UpgradeTransferCurrencies extends Command+class UpgradesTransferCurrencies extends Command{use ShowsFriendlyMessages;diff --git a/app/Models/Preference.php b/app/Models/Preference.phpindex 4aecc15d0c..555338f692 100644--- a/app/Models/Preference.php+++ b/app/Models/Preference.php@@ -39,13 +39,13 @@ class Preference extends Modeluse ReturnsIntegerUserIdTrait;protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','data' => 'array',];- protected $fillable = ['user_id', 'data', 'name'];+ protected $fillable = ['user_id', 'data', 'name', 'user_group_id'];/*** Route binder. Converts the key in the URL to the specified object (or throw 404).@@ -56,7 +56,7 @@ class Preference extends Model{if (auth()->check()) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();// some preferences do not have an administration ID.// some need it, to make sure the correct one is selected.@@ -64,8 +64,8 @@ class Preference extends Model$userGroupId = 0 === $userGroupId ? null : $userGroupId;/** @var null|Preference $preference */- $preference = null;- $items = config('firefly.admin_specific_prefs');+ $preference = null;+ $items = config('firefly.admin_specific_prefs');if (null !== $userGroupId && in_array($value, $items, true)) {// find a preference with a specific user_group_id$preference = $user->preferences()->where('user_group_id', $userGroupId)->where('name', $value)->first();@@ -82,7 +82,7 @@ class Preference extends Modelif (null !== $preference) {return $preference;}- $default = config('firefly.default_preferences');+ $default = config('firefly.default_preferences');if (array_key_exists($value, $default)) {$preference = new self();$preference->name = $value;