Clean up commands.

This commit is contained in:
James Cole
2024-12-28 07:35:20 +01:00
parent 89ab360391
commit 0a089efcac
40 changed files with 105 additions and 162 deletions

View File

@@ -76,9 +76,6 @@ class AddsTransactionIdentifiers extends Command
$this->updateJournalIdentifiers($journal);
}
if (0 === $this->count) {
$this->friendlyPositive('All split journal transaction identifiers are OK.');
}
if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Fixed %d split journal transaction identifier(s).', $this->count));
}

View File

@@ -70,7 +70,6 @@ class RemovesDatabaseDecryption extends Command
private function decryptTable(string $table, array $fields): void
{
if ($this->isDecrypted($table)) {
$this->friendlyInfo(sprintf('No decryption required for table "%s".', $table));
return;
}

View File

@@ -62,9 +62,6 @@ class UpgradesAccountCurrencies extends Command
}
$this->updateAccountCurrencies();
if (0 === $this->count) {
$this->friendlyPositive('All account currencies are OK.');
}
if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Corrected %d account(s).', $this->count));
}

View File

@@ -73,9 +73,6 @@ class UpgradesAccountMetaData extends Command
$this->markAsExecuted();
if (0 === $count) {
$this->friendlyPositive('All account meta is OK.');
}
if (0 !== $count) {
$this->friendlyInfo(sprintf('Renamed %d account meta entries (entry).', $count));
}

View File

@@ -79,9 +79,6 @@ class UpgradesAttachments extends Command
++$count;
}
}
if (0 === $count) {
$this->friendlyPositive('All attachments are OK.');
}
if (0 !== $count) {
$this->friendlyInfo(sprintf('Updated %d attachment(s).', $count));
}

View File

@@ -73,9 +73,6 @@ class UpgradesBillsToRules extends Command
$this->migrateUser($user);
}
if (0 === $this->count) {
$this->friendlyPositive('All bills are OK.');
}
if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Verified and fixed %d bill(s).', $this->count));
}

View File

@@ -77,9 +77,6 @@ class UpgradesBudgetLimits extends Command
}
}
}
if (0 === $count) {
$this->friendlyPositive('All budget limits are OK.');
}
$this->markAsExecuted();
return 0;

View File

@@ -55,7 +55,6 @@ class UpgradesCreditCardLiabilities extends Command
$ccType = AccountType::where('type', AccountType::CREDITCARD)->first();
$debtType = AccountType::where('type', AccountType::DEBT)->first();
if (null === $ccType || null === $debtType) {
$this->friendlyPositive('No incorrectly stored credit card liabilities.');
$this->markAsExecuted();
return 0;
@@ -73,9 +72,6 @@ class UpgradesCreditCardLiabilities extends Command
'Credit card liability types are no longer supported and have been converted to generic debts. See: https://bit.ly/FF3-credit-cards'
);
}
if (0 === $accounts->count()) {
$this->friendlyPositive('No incorrectly stored credit card liabilities.');
}
$this->markAsExecuted();
return 0;

View File

@@ -57,7 +57,6 @@ class UpgradesDatabase extends Command
'upgrade:480-account-meta',
'upgrade:481-recurrence-meta',
'upgrade:500-tag-locations',
'upgrade:550-recurrence-type',
'upgrade:560-liabilities',
'upgrade:600-liabilities',
'upgrade:550-budget-limit-periods',

View File

@@ -68,7 +68,7 @@ class UpgradesJournalMetaData extends Command
private function isMigrated(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = app('fireflyconfig')->get(UpgradesToGroups::CONFIG_NAME, false);
return (bool) $configVar->data;
}

View File

@@ -72,9 +72,6 @@ class UpgradesJournalNotes extends Command
++$count;
}
if (0 === $count) {
$this->friendlyPositive('No notes to migrate.');
}
if (0 !== $count) {
$this->friendlyInfo(sprintf('Migrated %d note(s).', $count));
}

View File

@@ -52,9 +52,6 @@ class UpgradesRecurrenceMetaData extends Command
}
$count = $this->migrateMetaData();
if (0 === $count) {
$this->friendlyPositive('No recurrence meta data migrated.');
}
if ($count > 0) {
$this->friendlyInfo(sprintf('Migrated %d meta data entries', $count));
}

View File

@@ -1,67 +0,0 @@
<?php
/*
* MigrateRecurrenceType.php
* Copyright (c) 2021 james@firefly-iii.org
*
* 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/>.
*/
declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
class UpgradesRecurrenceType extends Command
{
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '550_migrate_recurrence_type';
protected $description = 'Migrate transaction type of recurring transaction.';
protected $signature = 'upgrade:550-recurrence-type {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
*/
public function handle(): int
{
if ($this->isExecuted() && true !== $this->option('force')) {
$this->friendlyInfo('This command has already been executed.');
return 0;
}
$this->friendlyWarning('This command has been disabled.');
$this->markAsExecuted();
return 0;
}
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
return (bool) $configVar?->data;
}
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
}
}

View File

@@ -72,9 +72,6 @@ class UpgradesToGroups extends Command
if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Migrated %d transaction journal(s).', $this->count));
}
if (0 === $this->count) {
$this->friendlyPositive('No journals to migrate to groups.');
}
$this->markAsMigrated();
return 0;
@@ -363,9 +360,6 @@ class UpgradesToGroups extends Command
$this->giveGroup($array);
}
}
if (0 === $total) {
$this->friendlyPositive('No need to convert transaction journals.');
}
}
private function giveGroup(array $array): void

View File

@@ -69,12 +69,6 @@ class UpgradesTransferCurrencies extends Command
$this->startUpdateRoutine();
$this->markAsExecuted();
if (0 === $this->count) {
$this->friendlyPositive('All transfers have correct currency information.');
return 0;
}
$this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
return 0;