mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Better validation, can now also use notes in expression.
This commit is contained in:
@@ -26,13 +26,16 @@ namespace FireflyIII\TransactionRules\Actions;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Traits\RefreshNotesTrait;
|
||||
|
||||
/**
|
||||
* Class AppendDescription.
|
||||
* TODO Can be replaced (and migrated) to action "set description" with a prefilled expression
|
||||
*/
|
||||
class AppendDescription implements ActionInterface
|
||||
{
|
||||
private RuleAction $action;
|
||||
use RefreshNotesTrait;
|
||||
|
||||
/**
|
||||
* TriggerInterface constructor.
|
||||
@@ -44,6 +47,7 @@ class AppendDescription implements ActionInterface
|
||||
|
||||
public function actOnArray(array $journal): bool
|
||||
{
|
||||
$this->refreshNotes($journal);
|
||||
$append = $this->action->getValue($journal);
|
||||
$description = sprintf('%s %s', $journal['description'], $append);
|
||||
\DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $description]);
|
||||
|
@@ -29,12 +29,15 @@ use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Traits\RefreshNotesTrait;
|
||||
|
||||
/**
|
||||
* Class AppendDescriptionToNotes
|
||||
* TODO Can be replaced (and migrated) to action "set notes" with a prefilled expression
|
||||
*/
|
||||
class AppendDescriptionToNotes implements ActionInterface
|
||||
{
|
||||
use RefreshNotesTrait;
|
||||
private RuleAction $action;
|
||||
|
||||
/**
|
||||
@@ -47,6 +50,7 @@ class AppendDescriptionToNotes implements ActionInterface
|
||||
|
||||
public function actOnArray(array $journal): bool
|
||||
{
|
||||
$this->refreshNotes($journal);
|
||||
/** @var null|TransactionJournal $object */
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
|
@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/**
|
||||
* Class AppendNotes.
|
||||
* TODO Can be replaced (and migrated) to action "set notes" with a prefilled expression
|
||||
*/
|
||||
class AppendNotes implements ActionInterface
|
||||
{
|
||||
|
@@ -33,6 +33,7 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
||||
/**
|
||||
* Class AppendNotesToDescription
|
||||
* TODO Can be replaced (and migrated) to action "set description" with a prefilled expression
|
||||
*/
|
||||
class AppendNotesToDescription implements ActionInterface
|
||||
{
|
||||
|
@@ -32,6 +32,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/**
|
||||
* Class MoveDescriptionToNotes
|
||||
* TODO Can be replaced (and migrated) to action "set notes" with a prefilled expression
|
||||
*/
|
||||
class MoveDescriptionToNotes implements ActionInterface
|
||||
{
|
||||
|
@@ -36,6 +36,7 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
|
||||
/**
|
||||
* Class MoveNotesToDescription
|
||||
* TODO Can be replaced (and migrated) to action "set notes" with a prefilled expression
|
||||
*/
|
||||
class MoveNotesToDescription implements ActionInterface
|
||||
{
|
||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/**
|
||||
* Class PrependDescription.
|
||||
* TODO Can be replaced (and migrated) to action "set description" with a prefilled expression
|
||||
*/
|
||||
class PrependDescription implements ActionInterface
|
||||
{
|
||||
|
@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/**
|
||||
* Class PrependNotes.
|
||||
* TODO Can be replaced (and migrated) to action "set notes" with a prefilled expression
|
||||
*/
|
||||
class PrependNotes implements ActionInterface
|
||||
{
|
||||
|
Reference in New Issue
Block a user