Merge remote-tracking branch 'upstream/main' into feat/expression-engine

This commit is contained in:
Michael Thomas
2024-03-06 21:38:40 -05:00
2225 changed files with 111169 additions and 148980 deletions

View File

@@ -29,7 +29,6 @@ use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use Illuminate\Support\Facades\Log;
/**
* Class AppendNotes.
@@ -41,8 +40,6 @@ class AppendNotes implements ActionInterface
/**
* TriggerInterface constructor.
*
* @param RuleAction $action
*/
public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
@@ -50,13 +47,10 @@ class AppendNotes implements ActionInterface
$this->evaluator = $evaluator;
}
/**
* @inheritDoc
*/
public function actOnArray(array $journal): bool
{
$actionValue = $this->evaluator->evaluate($journal);
$dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])
$dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])
->where('noteable_type', TransactionJournal::class)
->first(['notes.*']);
if (null === $dbNote) {
@@ -65,14 +59,14 @@ class AppendNotes implements ActionInterface
$dbNote->noteable_type = TransactionJournal::class;
$dbNote->text = '';
}
Log::debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $actionValue, $dbNote->text));
app('log')->debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $actionValue, $dbNote->text));
$before = $dbNote->text;
$text = sprintf('%s%s', $dbNote->text, $actionValue);
$dbNote->text = $text;
$dbNote->save();
/** @var TransactionJournal $object */
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $text));