Add rule error reporting to all rules.

This commit is contained in:
James Cole
2023-08-13 15:01:12 +02:00
parent 965acd6d45
commit b0ab06b7eb
19 changed files with 199 additions and 66 deletions

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions;
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
use FireflyIII\Events\TriggeredAuditLog;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
@@ -63,19 +64,19 @@ class MoveNotesToDescription implements ActionInterface
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
if (null === $object) {
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
// TODO introduce error
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user')));
return false;
}
$note = $object->notes()->first();
if (null === $note) {
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_notes_to_move')));
// nothing to move, return null
// TODO introduce error
return false;
}
if ('' === $note->text) {
// nothing to move, return null
$note->delete();
// TODO introduce error
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_notes_to_move')));
return false;
}
$before = $object->description;