Fix issues where rule action would use old data.

This commit is contained in:
James Cole
2021-03-23 06:42:26 +01:00
parent ccaadd1f52
commit d1c87e1c21
21 changed files with 406 additions and 304 deletions

View File

@@ -52,19 +52,20 @@ class PrependNotes implements ActionInterface
{
$dbNote = Note
::
where('noteable_id', (int) $journal['transaction_journal_id'])
where('noteable_id', (int)$journal['transaction_journal_id'])
->where('noteable_type', TransactionJournal::class)
->first(['notes.*']);
if (null === $dbNote) {
$dbNote = new Note;
$dbNote->noteable_id = (int) $journal['transaction_journal_id'];
$dbNote->noteable_id = (int)$journal['transaction_journal_id'];
$dbNote->noteable_type = TransactionJournal::class;
$dbNote->text = '';
}
Log::debug(sprintf('RuleAction PrependNotes prepended "%s" to "%s".', $this->action->action_value, $dbNote->text));
$text = sprintf('%s%s', $this->action->action_value, $dbNote->text);
$text = sprintf('%s%s', $this->action->action_value, $dbNote->text);
$dbNote->text = $text;
$dbNote->save();
return true;
}
}