mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 15:39:50 +00:00
Migrate actions
This commit is contained in:
@@ -23,15 +23,16 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/**
|
||||
* Class PrependDescription.
|
||||
*/
|
||||
class PrependDescription implements ActionInterface
|
||||
{
|
||||
/** @var RuleAction The rule action */
|
||||
private $action;
|
||||
private RuleAction $action;
|
||||
|
||||
/**
|
||||
* TriggerInterface constructor.
|
||||
@@ -48,8 +49,16 @@ class PrependDescription implements ActionInterface
|
||||
*/
|
||||
public function actOnArray(array $journal): bool
|
||||
{
|
||||
$description = sprintf('%s%s', $this->action->action_value, $journal['description']);
|
||||
DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $description]);
|
||||
$before = $journal['description'];
|
||||
$after = sprintf('%s%s', $this->action->action_value, $journal['description']);
|
||||
DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $after]);
|
||||
|
||||
// journal
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
|
||||
// audit log
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', $before, $after));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user