mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Restore cron options.
This commit is contained in:
@@ -77,7 +77,7 @@ class Cron extends Command
|
||||
*/
|
||||
if (true === config('cer.enabled')) {
|
||||
try {
|
||||
//$this->exchangeRatesCronJob($force, $date);
|
||||
$this->exchangeRatesCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
@@ -89,7 +89,7 @@ class Cron extends Command
|
||||
* Fire recurring transaction cron job.
|
||||
*/
|
||||
try {
|
||||
//$this->recurringCronJob($force, $date);
|
||||
$this->recurringCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
@@ -111,7 +111,7 @@ class Cron extends Command
|
||||
* Fire bill warning cron job
|
||||
*/
|
||||
try {
|
||||
//$this->billWarningCronJob($force, $date);
|
||||
$this->billWarningCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
@@ -132,16 +132,21 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
||||
$totalAmount = $autoBudget->amount;
|
||||
Log::debug(sprintf('Total amount available for current budget period is %s', $budgetAvailable));
|
||||
|
||||
if (-1 !== bccomp( $budgetAvailable, $totalAmount)) {
|
||||
if (-1 !== bccomp($budgetAvailable, $totalAmount)) {
|
||||
Log::info(sprintf('There is no overspending, no need to adjust. Budget limit amount will be %s.', $totalAmount));
|
||||
// create budget limit:
|
||||
$this->createBudgetLimit($autoBudget, $start, $end, $totalAmount);
|
||||
}
|
||||
if (1 !== bccomp($budgetAvailable, $totalAmount)) {
|
||||
if (1 !== bccomp($budgetAvailable, $totalAmount) && 1 === bccomp($budgetAvailable, '0')) {
|
||||
Log::info(sprintf('There was overspending, so the new amount will be %s.', $budgetAvailable));
|
||||
// create budget limit:
|
||||
$this->createBudgetLimit($autoBudget, $start, $end, $budgetAvailable);
|
||||
}
|
||||
if (1 !== bccomp($budgetAvailable, $totalAmount) && -1 === bccomp($budgetAvailable, '0')) {
|
||||
Log::info('There was overspending, but so much even this period cant fix that. Reset it to 1.');
|
||||
// create budget limit:
|
||||
$this->createBudgetLimit($autoBudget, $start, $end, '1');
|
||||
}
|
||||
Log::debug(sprintf('Done with auto budget #%d', $autoBudget->id));
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,8 @@ namespace FireflyIII\Support\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Support\Cronjobs\AutoBudgetCronjob;
|
||||
use FireflyIII\Support\Cronjobs\BillWarningCronjob;
|
||||
use FireflyIII\Support\Cronjobs\ExchangeRatesCronjob;
|
||||
use FireflyIII\Support\Cronjobs\RecurringCronjob;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
@@ -98,4 +100,70 @@ trait CronRunner
|
||||
'message' => $recurring->message,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function exchangeRatesCronJob(bool $force, Carbon $date): array
|
||||
{
|
||||
/** @var ExchangeRatesCronjob $exchangeRates */
|
||||
$exchangeRates = app(ExchangeRatesCronjob::class);
|
||||
$exchangeRates->setForce($force);
|
||||
$exchangeRates->setDate($date);
|
||||
try {
|
||||
$exchangeRates->fire();
|
||||
} catch (FireflyException $e) {
|
||||
return [
|
||||
'job_fired' => false,
|
||||
'job_succeeded' => false,
|
||||
'job_errored' => true,
|
||||
'message' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'job_fired' => $exchangeRates->jobFired,
|
||||
'job_succeeded' => $exchangeRates->jobSucceeded,
|
||||
'job_errored' => $exchangeRates->jobErrored,
|
||||
'message' => $exchangeRates->message,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function billWarningCronJob(bool $force, Carbon $date): array
|
||||
{
|
||||
/** @var BillWarningCronjob $billWarning */
|
||||
$billWarning = app(BillWarningCronjob::class);
|
||||
$billWarning->setForce($force);
|
||||
$billWarning->setDate($date);
|
||||
try {
|
||||
$billWarning->fire();
|
||||
} catch (FireflyException $e) {
|
||||
return [
|
||||
'job_fired' => false,
|
||||
'job_succeeded' => false,
|
||||
'job_errored' => true,
|
||||
'message' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'job_fired' => $billWarning->jobFired,
|
||||
'job_succeeded' => $billWarning->jobSucceeded,
|
||||
'job_errored' => $billWarning->jobErrored,
|
||||
'message' => $billWarning->message,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user