mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
Code cleanup
This commit is contained in:
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use Artisan;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Schema;
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Integrity;
|
||||
|
||||
use Artisan;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Schema;
|
||||
|
@@ -34,7 +34,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
|
@@ -45,8 +45,8 @@ class OtherCurrenciesCorrections extends Command
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const CONFIG_NAME = '480_other_currencies';
|
||||
protected $description = 'Update all journal currency information.';
|
||||
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
|
||||
protected $description = 'Update all journal currency information.';
|
||||
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
|
||||
private array $accountCurrencies;
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private JournalCLIRepositoryInterface $cliRepos;
|
||||
|
@@ -68,30 +68,6 @@ class UpgradeCurrencyPreferences extends Command
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getPreference(User $user): string
|
||||
{
|
||||
$preference = Preference::where('user_id', $user->id)->where('name', 'currencyPreference')->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);
|
||||
|
||||
if (null !== $preference) {
|
||||
return (string)$preference->data;
|
||||
}
|
||||
return 'EUR';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function markAsExecuted(): void
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
|
||||
private function runUpgrade(): void
|
||||
{
|
||||
$groups = UserGroup::get();
|
||||
@@ -107,6 +83,24 @@ class UpgradeCurrencyPreferences extends Command
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserGroup $group
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function upgradeGroupPreferences(UserGroup $group)
|
||||
{
|
||||
$currencies = TransactionCurrency::get();
|
||||
$enabled = new Collection();
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
if ($currency->enabled) {
|
||||
$enabled->push($currency);
|
||||
}
|
||||
}
|
||||
$group->currencies()->sync($enabled->pluck('id')->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
@@ -136,20 +130,25 @@ class UpgradeCurrencyPreferences extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserGroup $group
|
||||
* @param User $user
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*/
|
||||
private function upgradeGroupPreferences(UserGroup $group)
|
||||
private function getPreference(User $user): string
|
||||
{
|
||||
$currencies = TransactionCurrency::get();
|
||||
$enabled = new Collection();
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
if ($currency->enabled) {
|
||||
$enabled->push($currency);
|
||||
}
|
||||
$preference = Preference::where('user_id', $user->id)->where('name', 'currencyPreference')->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);
|
||||
|
||||
if (null !== $preference) {
|
||||
return (string)$preference->data;
|
||||
}
|
||||
$group->currencies()->sync($enabled->pluck('id')->toArray());
|
||||
return 'EUR';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function markAsExecuted(): void
|
||||
{
|
||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
use Artisan;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -72,7 +71,7 @@ class UpgradeDatabase extends Command
|
||||
// also just in case, some integrity commands:
|
||||
'firefly-iii:create-group-memberships',
|
||||
'firefly-iii:upgrade-group-information',
|
||||
'firefly-iii:upgrade-currency-preferences'
|
||||
'firefly-iii:upgrade-currency-preferences',
|
||||
];
|
||||
$args = [];
|
||||
if ($this->option('force')) {
|
||||
|
Reference in New Issue
Block a user