Make sure the date is passed on when running the cron job.

This commit is contained in:
James Cole
2019-07-02 06:11:06 +02:00
parent 5bbe1eab7c
commit 54623061d8
3 changed files with 21 additions and 3 deletions

View File

@@ -24,10 +24,12 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Tools;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Cronjobs\RecurringCronjob;
use Illuminate\Console\Command;
use InvalidArgumentException;
/**
* Class Cron
@@ -58,9 +60,23 @@ class Cron extends Command
*/
public function handle(): int
{
$date = null;
try {
$date = new Carbon($this->option('date'));
} catch (InvalidArgumentException $e) {
$this->error(sprintf('"%s" is not a valid date', $this->option('date')));
$e->getMessage();
}
$recurring = new RecurringCronjob;
$recurring->setForce($this->option('force'));
// set date in cron job:
if (null !== $date) {
$recurring->setDate($date);
}
try {
$result = $recurring->fire();
} catch (FireflyException $e) {