Clean up autocomplete controller (accounts)

This commit is contained in:
James Cole
2024-10-20 10:16:54 +02:00
parent 7f3e3fc3bf
commit 6ff84b8e90
9 changed files with 298 additions and 255 deletions

View File

@@ -33,9 +33,10 @@ use Illuminate\Console\Command;
class CorrectAccountBalance extends Command
{
use ShowsFriendlyMessages;
public const string CONFIG_NAME = '610_correct_balances';
protected $description = 'Recalculate all account balance amounts';
protected $signature = 'firefly-iii:correct-account-balance {--F|force : Force the execution of this command.}';
protected $description = 'Recalculate all account balance amounts';
protected $signature = 'firefly-iii:correct-account-balance {--F|force : Force the execution of this command.}';
public function handle(): int
{
@@ -44,23 +45,29 @@ class CorrectAccountBalance extends Command
return 0;
}
if(config('firefly.feature_flags.running_balance_column')) {
$this->friendlyInfo('Will recalculate account balances. This may take a LONG time. Please be patient.');
$this->markAsExecuted();
$this->correctBalanceAmounts();
$this->friendlyInfo('Done recalculating account balances.');
return 0;
}
$this->friendlyWarning('This command has been disabled.');
$this->markAsExecuted();
// $this->correctBalanceAmounts();
return 0;
}
private function correctBalanceAmounts(): void
{
AccountBalanceCalculator::recalculateAll();
return;
AccountBalanceCalculator::recalculateAll(true);
}
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
return (bool) $configVar?->data;
}
private function markAsExecuted(): void