Skip to content

Commit

Permalink
Fix cron controller. firefly-iii#3318
Browse files Browse the repository at this point in the history
  • Loading branch information
JC5 committed May 1, 2020
1 parent 6a25b41 commit 49b1435
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/System/CronController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function cron(string $token): string
{
$results = [];
$results[] = $this->runRecurring();
$results[] = $this->runAutoBudget();

return implode("<br>\n", $results);
}
Expand Down
20 changes: 20 additions & 0 deletions app/Support/Http/Controllers/CronRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
namespace FireflyIII\Support\Http\Controllers;

use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Cronjobs\AutoBudgetCronjob;
use FireflyIII\Support\Cronjobs\RecurringCronjob;

/**
Expand All @@ -50,4 +51,23 @@ protected function runRecurring(): string
return 'The recurring transaction cron job fired successfully.';
}

/**
* @return string
*/
protected function runAutoBudget(): string
{
/** @var AutoBudgetCronjob $autoBudget */
$autoBudget = app(AutoBudgetCronjob::class);
try {
$result = $autoBudget->fire();
} catch (FireflyException $e) {
return $e->getMessage();
}
if (false === $result) {
return 'The auto budget cron job did not fire.';
}

return 'The auto budget cron job fired successfully.';
}

}

0 comments on commit 49b1435

Please sign in to comment.