mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup.
This commit is contained in:
@@ -47,7 +47,6 @@ class ApplyRules extends Command
|
||||
use ShowsFriendlyMessages;
|
||||
use VerifiesAccessToken;
|
||||
|
||||
|
||||
protected $description = 'This command will apply your rules and rule groups on a selection of your transactions.';
|
||||
|
||||
protected $signature
|
||||
@@ -74,7 +73,6 @@ class ApplyRules extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function handle(): int
|
||||
@@ -149,8 +147,6 @@ class ApplyRules extends Command
|
||||
* Laravel will execute ALL __construct() methods for ALL commands whenever a SINGLE command is
|
||||
* executed. This leads to noticeable slow-downs and class calls. To prevent this, this method should
|
||||
* be called from the handle method instead of using the constructor to initialize the command.
|
||||
*
|
||||
|
||||
*/
|
||||
private function stupidLaravel(): void
|
||||
{
|
||||
@@ -165,7 +161,6 @@ class ApplyRules extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function verifyInput(): bool
|
||||
@@ -188,7 +183,6 @@ class ApplyRules extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function verifyInputAccounts(): bool
|
||||
@@ -223,9 +217,6 @@ class ApplyRules extends Command
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function verifyInputRuleGroups(): bool
|
||||
{
|
||||
$ruleGroupString = $this->option('rule_groups');
|
||||
@@ -248,9 +239,6 @@ class ApplyRules extends Command
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function verifyInputRules(): bool
|
||||
{
|
||||
$ruleString = $this->option('rules');
|
||||
@@ -299,6 +287,7 @@ class ApplyRules extends Command
|
||||
}
|
||||
if (false === $inputEnd || false === $inputStart) {
|
||||
Log::error('Could not parse start or end date in verifyInputDate().');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -310,22 +299,19 @@ class ApplyRules extends Command
|
||||
$this->endDate = $inputEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
private function grabAllRules(): void
|
||||
{
|
||||
$this->groups = $this->ruleGroupRepository->getActiveGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
private function getRulesToApply(): Collection
|
||||
{
|
||||
$rulesToApply = new Collection();
|
||||
|
||||
/** @var RuleGroup $group */
|
||||
foreach ($this->groups as $group) {
|
||||
$rules = $this->ruleGroupRepository->getActiveStoreRules($group);
|
||||
|
||||
/** @var Rule $rule */
|
||||
foreach ($rules as $rule) {
|
||||
// if in rule selection, or group in selection or all rules, it's included.
|
||||
@@ -340,12 +326,6 @@ class ApplyRules extends Command
|
||||
return $rulesToApply;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param RuleGroup $group
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function includeRule(Rule $rule, RuleGroup $group): bool
|
||||
{
|
||||
return in_array($group->id, $this->ruleGroupSelection, true)
|
||||
|
@@ -32,20 +32,16 @@ use FireflyIII\Support\Cronjobs\BillWarningCronjob;
|
||||
use FireflyIII\Support\Cronjobs\ExchangeRatesCronjob;
|
||||
use FireflyIII\Support\Cronjobs\RecurringCronjob;
|
||||
use Illuminate\Console\Command;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class Cron
|
||||
*
|
||||
|
||||
*/
|
||||
class Cron extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
|
||||
protected $description = 'Runs all Firefly III cron-job related commands. Configure a cron job according to the official Firefly III documentation.';
|
||||
|
||||
protected $signature = 'firefly-iii:cron
|
||||
@@ -54,23 +50,21 @@ class Cron extends Command
|
||||
';
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$date = null;
|
||||
|
||||
try {
|
||||
$date = new Carbon($this->option('date'));
|
||||
} catch (InvalidArgumentException $e) {
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date')));
|
||||
}
|
||||
$force = (bool)$this->option('force'); // @phpstan-ignore-line
|
||||
|
||||
/*
|
||||
* Fire exchange rates cron job.
|
||||
*/
|
||||
// Fire exchange rates cron job.
|
||||
if (true === config('cer.download_enabled')) {
|
||||
try {
|
||||
$this->exchangeRatesCronJob($force, $date);
|
||||
@@ -81,9 +75,7 @@ class Cron extends Command
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fire recurring transaction cron job.
|
||||
*/
|
||||
// Fire recurring transaction cron job.
|
||||
try {
|
||||
$this->recurringCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
@@ -92,9 +84,7 @@ class Cron extends Command
|
||||
$this->friendlyError($e->getMessage());
|
||||
}
|
||||
|
||||
/*
|
||||
* Fire auto-budget cron job:
|
||||
*/
|
||||
// Fire auto-budget cron job:
|
||||
try {
|
||||
$this->autoBudgetCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
@@ -103,9 +93,7 @@ class Cron extends Command
|
||||
$this->friendlyError($e->getMessage());
|
||||
}
|
||||
|
||||
/*
|
||||
* Fire bill warning cron job
|
||||
*/
|
||||
// Fire bill warning cron job
|
||||
try {
|
||||
$this->billWarningCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
@@ -119,10 +107,6 @@ class Cron extends Command
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon|null $date
|
||||
*/
|
||||
private function exchangeRatesCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$exchangeRates = new ExchangeRatesCronjob();
|
||||
@@ -146,9 +130,6 @@ class Cron extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon|null $date
|
||||
*
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws FireflyException
|
||||
* @throws NotFoundExceptionInterface
|
||||
@@ -175,11 +156,6 @@ class Cron extends Command
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon|null $date
|
||||
*
|
||||
*/
|
||||
private function autoBudgetCronJob(bool $force, ?Carbon $date): void
|
||||
{
|
||||
$autoBudget = new AutoBudgetCronjob();
|
||||
@@ -203,9 +179,6 @@ class Cron extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon|null $date
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
|
Reference in New Issue
Block a user