From bc0769358dd237ccdf786e1794b123971edb2378 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 5 Feb 2026 05:51:44 +0100 Subject: [PATCH] Clean up update handlers. --- .../Models/Transaction/DestroyController.php | 23 ------------------- .../Transaction/DeleteController.php | 22 ------------------ .../Internal/Update/AccountUpdateService.php | 4 +--- 3 files changed, 1 insertion(+), 48 deletions(-) diff --git a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php b/app/Api/V1/Controllers/Models/Transaction/DestroyController.php index 153bd46167..5ab715051c 100644 --- a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php +++ b/app/Api/V1/Controllers/Models/Transaction/DestroyController.php @@ -74,31 +74,8 @@ class DestroyController extends Controller public function destroy(TransactionGroup $transactionGroup): JsonResponse { Log::debug(sprintf('Now in %s', __METHOD__)); - // grab asset account(s) from group: - $accounts = []; - - /** @var TransactionJournal $journal */ - foreach ($transactionGroup->transactionJournals as $journal) { - /** @var Transaction $transaction */ - foreach ($journal->transactions as $transaction) { - $type = $transaction->account->accountType->type; - // if is valid liability, trigger event! - if (in_array($type, config('firefly.valid_liabilities'), true)) { - $accounts[] = $transaction->account; - } - } - } - $this->groupRepository->destroy($transactionGroup); - Preferences::mark(); - - /** @var Account $account */ - foreach ($accounts as $account) { - Log::debug(sprintf('Now going to trigger updated account event for account #%d', $account->id)); - event(new UpdatedAccount($account)); - } - return response()->json([], 204); } diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.php index 44a10c046d..efa6e18450 100644 --- a/app/Http/Controllers/Transaction/DeleteController.php +++ b/app/Http/Controllers/Transaction/DeleteController.php @@ -112,29 +112,7 @@ class DeleteController extends Controller } $objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type); session()->flash('success', (string) trans('firefly.deleted_'.strtolower($objectType), ['description' => $group->title ?? $journal->description])); - - // grab asset account(s) from group: - $accounts = []; - - /** @var TransactionJournal $currentJournal */ - foreach ($group->transactionJournals as $currentJournal) { - /** @var Transaction $transaction */ - foreach ($currentJournal->transactions as $transaction) { - $type = $transaction->account->accountType->type; - // if is valid liability, trigger event! - if (in_array($type, config('firefly.valid_liabilities'), true)) { - $accounts[] = $transaction->account; - } - } - } - $this->repository->destroy($group); - - /** @var Account $account */ - foreach ($accounts as $account) { - Log::debug(sprintf('Now going to trigger updated account event for account #%d', $account->id)); - event(new UpdatedAccount($account)); - } Preferences::mark(); return redirect($this->getPreviousUrl('transactions.delete.url')); diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.php index bef63353a7..fe586541be 100644 --- a/app/Services/Internal/Update/AccountUpdateService.php +++ b/app/Services/Internal/Update/AccountUpdateService.php @@ -105,7 +105,7 @@ class AccountUpdateService // update preferences if inactive: $this->updatePreferences($account); - event(new UpdatedAccount($account)); + event(new UpdatedExistingAccount($account)); return $account; } @@ -151,8 +151,6 @@ class AccountUpdateService $account->save(); - event(new UpdatedExistingAccount($account)); - return $account; }