mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix some rule things.
This commit is contained in:
@@ -248,7 +248,7 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
|
|
||||||
/** @var Collection $transactions */
|
/** @var Collection $transactions */
|
||||||
$transactions = $journal->transactions()
|
$transactions = $journal->transactions()
|
||||||
->groupBy('transactions.id')
|
->groupBy($groupBy)
|
||||||
->orderBy('transactions.id')->get($fields);
|
->orderBy('transactions.id')->get($fields);
|
||||||
break;
|
break;
|
||||||
case TransactionType::WITHDRAWAL:
|
case TransactionType::WITHDRAWAL:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace FireflyIII\Rules\Actions;
|
|||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\RuleAction;
|
use FireflyIII\Models\RuleAction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@@ -55,13 +56,22 @@ class SetBudget implements ActionInterface
|
|||||||
return $current->name == $search;
|
return $current->name == $search;
|
||||||
}
|
}
|
||||||
)->first();
|
)->first();
|
||||||
if (!is_null($budget)) {
|
if (is_null($budget)) {
|
||||||
Log::debug(sprintf('RuleAction SetBudget set the budget of journal #%d to budget #%d ("%s").', $journal->id, $budget->id, $budget->name));
|
Log::debug(sprintf('RuleAction SetBudget could not set budget of journal #%d to "%s" because no such budget exists.', $journal->id, $search));
|
||||||
|
|
||||||
$journal->budgets()->sync([$budget->id]);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug(sprintf('RuleAction SetBudget could not set budget of journal #%d to "%s" because no such budget exists.', $journal->id, $search));
|
if ($journal->transactionType->type == TransactionType::TRANSFER) {
|
||||||
|
Log::debug(sprintf('RuleAction SetBudget could not set budget of journal #%d to "%s" because journal is a transfer.', $journal->id, $search));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::debug(sprintf('RuleAction SetBudget set the budget of journal #%d to budget #%d ("%s").', $journal->id, $budget->id, $budget->name));
|
||||||
|
|
||||||
|
$journal->budgets()->sync([$budget->id]);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,14 +63,6 @@ final class Processor
|
|||||||
Log::debug(sprintf('Making new rule from Rule %d', $rule->id));
|
Log::debug(sprintf('Making new rule from Rule %d', $rule->id));
|
||||||
$self = new self;
|
$self = new self;
|
||||||
$self->rule = $rule;
|
$self->rule = $rule;
|
||||||
|
|
||||||
/*
|
|
||||||
* The number of "found triggers" must start at -1, because the first
|
|
||||||
* trigger is "create-journal" or "update-journal" when this Processor
|
|
||||||
* is called from a Rule.
|
|
||||||
*/
|
|
||||||
$self->setFoundTriggers(-1);
|
|
||||||
|
|
||||||
$triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();
|
$triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();
|
||||||
/** @var RuleTrigger $trigger */
|
/** @var RuleTrigger $trigger */
|
||||||
foreach ($triggerSet as $trigger) {
|
foreach ($triggerSet as $trigger) {
|
||||||
@@ -189,7 +181,7 @@ final class Processor
|
|||||||
foreach ($this->actions as $action) {
|
foreach ($this->actions as $action) {
|
||||||
/** @var ActionInterface $actionClass */
|
/** @var ActionInterface $actionClass */
|
||||||
$actionClass = ActionFactory::getAction($action);
|
$actionClass = ActionFactory::getAction($action);
|
||||||
Log::debug(sprintf('Fire action %s on journal #%d', $actionClass, $this->journal->id));
|
Log::debug(sprintf('Fire action %s on journal #%d', get_class($actionClass), $this->journal->id));
|
||||||
$actionClass->act($this->journal);
|
$actionClass->act($this->journal);
|
||||||
if ($action->stop_processing) {
|
if ($action->stop_processing) {
|
||||||
Log::debug('Stop processing now and break.');
|
Log::debug('Stop processing now and break.');
|
||||||
@@ -212,6 +204,7 @@ final class Processor
|
|||||||
Log::debug('start of Processor::triggered()');
|
Log::debug('start of Processor::triggered()');
|
||||||
$foundTriggers = $this->getFoundTriggers();
|
$foundTriggers = $this->getFoundTriggers();
|
||||||
$hitTriggers = 0;
|
$hitTriggers = 0;
|
||||||
|
Log::debug(sprintf('Found triggers starts at %d', $foundTriggers));
|
||||||
/** @var AbstractTrigger $trigger */
|
/** @var AbstractTrigger $trigger */
|
||||||
foreach ($this->triggers as $trigger) {
|
foreach ($this->triggers as $trigger) {
|
||||||
$foundTriggers++;
|
$foundTriggers++;
|
||||||
|
|||||||
Reference in New Issue
Block a user