mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 01:06:46 +00:00
cleanup: Commands are a lot less verbal and report better on success / failue
This commit is contained in:
@@ -43,18 +43,8 @@ use Psr\Container\NotFoundExceptionInterface;
|
||||
class UpgradeLiabilities extends Command
|
||||
{
|
||||
public const CONFIG_NAME = '560_upgrade_liabilities';
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Upgrade liabilities to new 5.6.0 structure.';
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:upgrade-liabilities {--F|force : Force the execution of this command.}';
|
||||
protected $signature = 'firefly-iii:upgrade-liabilities {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -66,7 +56,6 @@ class UpgradeLiabilities extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$start = microtime(true);
|
||||
if ($this->isExecuted() && true !== $this->option('force')) {
|
||||
$this->warn('This command has already been executed.');
|
||||
|
||||
@@ -75,10 +64,6 @@ class UpgradeLiabilities extends Command
|
||||
$this->upgradeLiabilities();
|
||||
|
||||
$this->markAsExecuted();
|
||||
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Upgraded liabilities in %s seconds.', $end));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,15 +80,12 @@ class UpgradeLiabilities extends Command
|
||||
}
|
||||
// source MUST be the liability.
|
||||
if ((int)$destination->account_id === (int)$account->id) {
|
||||
Log::debug(sprintf('Must switch around, because account #%d is the destination.', $destination->account_id));
|
||||
// so if not, switch things around:
|
||||
$sourceAccountId = (int)$source->account_id;
|
||||
$source->account_id = $destination->account_id;
|
||||
$destination->account_id = $sourceAccountId;
|
||||
$source->save();
|
||||
$destination->save();
|
||||
Log::debug(sprintf('Source transaction #%d now has account #%d', $source->id, $source->account_id));
|
||||
Log::debug(sprintf('Dest transaction #%d now has account #%d', $destination->id, $destination->account_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +137,6 @@ class UpgradeLiabilities extends Command
|
||||
*/
|
||||
private function upgradeForUser(User $user): void
|
||||
{
|
||||
Log::debug(sprintf('Upgrading liabilities for user #%d', $user->id));
|
||||
$accounts = $user->accounts()
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->whereIn('account_types.type', config('firefly.valid_liabilities'))
|
||||
@@ -174,7 +155,6 @@ class UpgradeLiabilities extends Command
|
||||
*/
|
||||
private function upgradeLiabilities(): void
|
||||
{
|
||||
Log::debug('Upgrading liabilities.');
|
||||
$users = User::get();
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
@@ -190,7 +170,6 @@ class UpgradeLiabilities extends Command
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser($account->user);
|
||||
Log::debug(sprintf('Upgrade liability #%d', $account->id));
|
||||
|
||||
// get opening balance, and correct if necessary.
|
||||
$openingBalance = $repository->getOpeningBalance($account);
|
||||
|
Reference in New Issue
Block a user