mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Refactor rule processor so it's testable.
This commit is contained in:
@@ -157,7 +157,9 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
$this->rules[$userId]->each(
|
||||
function (Rule $rule) use ($journal) {
|
||||
Log::debug(sprintf('Going to apply rule #%d to journal %d.', $rule->id, $journal->id));
|
||||
$processor = Processor::make($rule);
|
||||
/** @var Processor $processor */
|
||||
$processor = app(Processor::class);
|
||||
$processor->make($rule);
|
||||
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
|
||||
$processor->handleTransactionJournal($journal);
|
||||
if ($rule->stop_processing) {
|
||||
|
||||
@@ -200,7 +200,10 @@ class ExecuteRuleGroupOnExistingTransactions extends Job implements ShouldQueue
|
||||
// Create a list of processors for these rules
|
||||
return array_map(
|
||||
function ($rule) {
|
||||
return Processor::make($rule);
|
||||
/** @var Processor $processor */
|
||||
$processor = app(Processor::class);
|
||||
$processor->make($rule);
|
||||
return $processor;
|
||||
},
|
||||
$rules->all()
|
||||
);
|
||||
|
||||
@@ -162,7 +162,9 @@ class ExecuteRuleOnExistingTransactions extends Job implements ShouldQueue
|
||||
{
|
||||
// Lookup all journals that match the parameters specified
|
||||
$transactions = $this->collectJournals();
|
||||
$processor = Processor::make($this->rule, true);
|
||||
/** @var Processor $processor */
|
||||
$processor = app(Processor::class);
|
||||
$processor->make($this->rule, true);
|
||||
$hits = 0;
|
||||
$misses = 0;
|
||||
$total = 0;
|
||||
|
||||
Reference in New Issue
Block a user