From 1b56765da32604da56b7955be0faba49ce030503 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 4 Dec 2017 20:57:33 +0100 Subject: [PATCH] Touch journals so issue #1036 is fixed. --- app/TransactionRules/Actions/AddTag.php | 1 + app/TransactionRules/Actions/ClearBudget.php | 1 + app/TransactionRules/Actions/ClearCategory.php | 1 + app/TransactionRules/Actions/ClearNotes.php | 1 + app/TransactionRules/Actions/RemoveAllTags.php | 1 + app/TransactionRules/Actions/RemoveTag.php | 2 +- app/TransactionRules/Actions/SetBudget.php | 2 +- app/TransactionRules/Actions/SetCategory.php | 2 +- app/TransactionRules/Actions/SetDescription.php | 1 + app/TransactionRules/Actions/SetDestinationAccount.php | 1 + app/TransactionRules/Actions/SetSourceAccount.php | 1 + 11 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/TransactionRules/Actions/AddTag.php b/app/TransactionRules/Actions/AddTag.php index 79514af3a4..d4d3e4a486 100644 --- a/app/TransactionRules/Actions/AddTag.php +++ b/app/TransactionRules/Actions/AddTag.php @@ -60,6 +60,7 @@ class AddTag implements ActionInterface $count = $journal->tags()->where('tag_id', $tag->id)->count(); if (0 === $count) { $journal->tags()->save($tag); + $journal->touch(); Log::debug(sprintf('RuleAction AddTag. Added tag #%d ("%s") to journal %d.', $tag->id, $tag->tag, $journal->id)); return true; diff --git a/app/TransactionRules/Actions/ClearBudget.php b/app/TransactionRules/Actions/ClearBudget.php index c824651be1..fdbe53c0cf 100644 --- a/app/TransactionRules/Actions/ClearBudget.php +++ b/app/TransactionRules/Actions/ClearBudget.php @@ -54,6 +54,7 @@ class ClearBudget implements ActionInterface public function act(TransactionJournal $journal): bool { $journal->budgets()->detach(); + $journal->touch(); Log::debug(sprintf('RuleAction ClearBudget removed all budgets from journal %d.', $journal->id)); return true; diff --git a/app/TransactionRules/Actions/ClearCategory.php b/app/TransactionRules/Actions/ClearCategory.php index 76456d06fd..933b034b73 100644 --- a/app/TransactionRules/Actions/ClearCategory.php +++ b/app/TransactionRules/Actions/ClearCategory.php @@ -54,6 +54,7 @@ class ClearCategory implements ActionInterface public function act(TransactionJournal $journal): bool { $journal->categories()->detach(); + $journal->touch(); Log::debug(sprintf('RuleAction ClearCategory removed all categories from journal %d.', $journal->id)); return true; diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.php index 0c132687cf..b9b1d34e5d 100644 --- a/app/TransactionRules/Actions/ClearNotes.php +++ b/app/TransactionRules/Actions/ClearNotes.php @@ -60,6 +60,7 @@ class ClearNotes implements ActionInterface foreach ($notes as $note) { $note->delete(); } + $journal->touch(); return true; } diff --git a/app/TransactionRules/Actions/RemoveAllTags.php b/app/TransactionRules/Actions/RemoveAllTags.php index f1b506b865..e270faa8cd 100644 --- a/app/TransactionRules/Actions/RemoveAllTags.php +++ b/app/TransactionRules/Actions/RemoveAllTags.php @@ -55,6 +55,7 @@ class RemoveAllTags implements ActionInterface { Log::debug(sprintf('RuleAction ClearCategory removed all tags from journal %d.', $journal->id)); $journal->tags()->detach(); + $journal->touch(); return true; } diff --git a/app/TransactionRules/Actions/RemoveTag.php b/app/TransactionRules/Actions/RemoveTag.php index a5a2f4d616..3b6e10a42f 100644 --- a/app/TransactionRules/Actions/RemoveTag.php +++ b/app/TransactionRules/Actions/RemoveTag.php @@ -66,7 +66,7 @@ class RemoveTag implements ActionInterface if (null !== $tag) { Log::debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal->id)); $journal->tags()->detach([$tag->id]); - + $journal->touch(); return true; } Log::debug(sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag exists.', $name, $journal->id)); diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.php index 40e93a73d3..98609f8c33 100644 --- a/app/TransactionRules/Actions/SetBudget.php +++ b/app/TransactionRules/Actions/SetBudget.php @@ -88,7 +88,7 @@ class SetBudget implements ActionInterface Log::debug(sprintf('RuleAction SetBudget set the budget of journal #%d to budget #%d ("%s").', $journal->id, $budget->id, $budget->name)); $journal->budgets()->sync([$budget->id]); - + $journal->touch(); return true; } } diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.php index 09e1bcd3d8..9052ef5baf 100644 --- a/app/TransactionRules/Actions/SetCategory.php +++ b/app/TransactionRules/Actions/SetCategory.php @@ -57,7 +57,7 @@ class SetCategory implements ActionInterface $name = $this->action->action_value; $category = Category::firstOrCreateEncrypted(['name' => $name, 'user_id' => $journal->user->id]); $journal->categories()->sync([$category->id]); - + $journal->touch(); Log::debug(sprintf('RuleAction SetCategory set the category of journal #%d to budget #%d ("%s").', $journal->id, $category->id, $category->name)); return true; diff --git a/app/TransactionRules/Actions/SetDescription.php b/app/TransactionRules/Actions/SetDescription.php index 1a72105aff..cd56b164f4 100644 --- a/app/TransactionRules/Actions/SetDescription.php +++ b/app/TransactionRules/Actions/SetDescription.php @@ -66,6 +66,7 @@ class SetDescription implements ActionInterface $this->action->action_value ) ); + $journal->touch(); return true; } diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php index 933d46b1b4..e1008e6c0c 100644 --- a/app/TransactionRules/Actions/SetDestinationAccount.php +++ b/app/TransactionRules/Actions/SetDestinationAccount.php @@ -103,6 +103,7 @@ class SetDestinationAccount implements ActionInterface $transaction = $journal->transactions()->where('amount', '>', 0)->first(); $transaction->account_id = $this->newDestinationAccount->id; $transaction->save(); + $journal->touch(); Log::debug(sprintf('Updated transaction #%d and gave it new account ID.', $transaction->id)); return true; diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.php index 4bdb6be100..06ec739a62 100644 --- a/app/TransactionRules/Actions/SetSourceAccount.php +++ b/app/TransactionRules/Actions/SetSourceAccount.php @@ -104,6 +104,7 @@ class SetSourceAccount implements ActionInterface $transaction = $journal->transactions()->where('amount', '<', 0)->first(); $transaction->account_id = $this->newSourceAccount->id; $transaction->save(); + $journal->touch(); Log::debug(sprintf('Updated transaction #%d and gave it new account ID.', $transaction->id)); return true;