Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Transaction events for #11544
James Cole76b8ff18b06d
diff --git a/app/Api/V1/Controllers/Models/Transaction/StoreController.php b/app/Api/V1/Controllers/Models/Transaction/StoreController.phpindex bfecbcd58e..42665dae50 100644--- a/app/Api/V1/Controllers/Models/Transaction/StoreController.php+++ b/app/Api/V1/Controllers/Models/Transaction/StoreController.php@@ -27,7 +27,8 @@ namespace FireflyIII\Api\V1\Controllers\Models\Transaction;use FireflyIII\Api\V1\Controllers\Controller;use FireflyIII\Api\V1\Requests\Models\Transaction\StoreRequest;use FireflyIII\Enums\UserRoleEnum;-use FireflyIII\Events\StoredTransactionGroup;+use FireflyIII\Events\Model\TransactionGroup\CreatedSingleTransactionGroup;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupEventFlags;use FireflyIII\Exceptions\DuplicateTransactionException;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;@@ -109,9 +110,12 @@ class StoreController extends Controllerthrow new ValidationException($validator);}Preferences::mark();- $applyRules = $data['apply_rules'] ?? true;- $fireWebhooks = $data['fire_webhooks'] ?? true;- event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));+ $flags = new TransactionGroupEventFlags();+ $flags->applyRules = $data['apply_rules'] ?? true;+ $flags->fireWebhooks = $data['fire_webhooks'] ?? true;+ $flags->batchSubmission = $data['batch_submission'] ?? false;+ Log::debug('dingflofbips');+ event(new CreatedSingleTransactionGroup($transactionGroup, $flags));$manager = $this->getManager();diff --git a/app/Events/Model/TransactionGroup/CreatedSingleTransactionGroup.php b/app/Events/Model/TransactionGroup/CreatedSingleTransactionGroup.phpnew file mode 100644index 0000000000..7c08c2090f--- /dev/null+++ b/app/Events/Model/TransactionGroup/CreatedSingleTransactionGroup.php@@ -0,0 +1,40 @@+<?php+/*+ * CreatedSingleTransactionGroup.php+ * Copyright (c) 2026 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Events\Model\TransactionGroup;++use FireflyIII\Events\Event;+use FireflyIII\Models\TransactionGroup;+use Illuminate\Queue\SerializesModels;+use Illuminate\Support\Facades\Log;++class CreatedSingleTransactionGroup extends Event+{+ use SerializesModels;++ /**+ * Create a new event instance.+ */+ public function __construct(public TransactionGroup $transactionGroup, public TransactionGroupEventFlags $flags) {+ Log::debug(__METHOD__);+ }+}+diff --git a/app/Events/Model/TransactionGroup/CreatedTransactionGroupBatch.php b/app/Events/Model/TransactionGroup/CreatedTransactionGroupInBatch.phpsimilarity index 95%rename from app/Events/Model/TransactionGroup/CreatedTransactionGroupBatch.phprename to app/Events/Model/TransactionGroup/CreatedTransactionGroupInBatch.phpindex bbbca184d5..c9ac4f9b06 100644--- a/app/Events/Model/TransactionGroup/CreatedTransactionGroupBatch.php+++ b/app/Events/Model/TransactionGroup/CreatedTransactionGroupInBatch.php@@ -25,7 +25,7 @@ use FireflyIII\Events\Event;use Illuminate\Queue\SerializesModels;use Illuminate\Support\Collection;-class CreatedTransactionGroupBatch extends Event+class CreatedTransactionGroupInBatch extends Event{use SerializesModels;diff --git a/app/Events/Model/TransactionGroup/TransactionGroupEventFlags.php b/app/Events/Model/TransactionGroup/TransactionGroupEventFlags.phpnew file mode 100644index 0000000000..f68e2f83a5--- /dev/null+++ b/app/Events/Model/TransactionGroup/TransactionGroupEventFlags.php@@ -0,0 +1,30 @@+<?php+/*+ * TransactionGroupEventFlags.php+ * Copyright (c) 2026 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Events\Model\TransactionGroup;++class TransactionGroupEventFlags+{+ public bool $applyRules = true;+ public bool $fireWebhooks = true;+ public bool $batchSubmission = false;++}diff --git a/app/Events/StoredTransactionGroup.php b/app/Events/StoredTransactionGroup.phpindex 743018ea2f..15c0d42b7b 100644--- a/app/Events/StoredTransactionGroup.php+++ b/app/Events/StoredTransactionGroup.php@@ -37,9 +37,5 @@ class StoredTransactionGroup extends Event/*** Create a new event instance.*/- public function __construct(- public TransactionGroup $transactionGroup,- public bool $applyRules,- public bool $fireWebhooks- ) {}+ public function __construct(public TransactionGroup $transactionGroup, public bool $applyRules, public bool $fireWebhooks) {}}diff --git a/app/Handlers/Events/StoredGroupEventHandler.php b/app/Handlers/Events/StoredGroupEventHandler.phpindex f1101731ca..dddf285924 100644--- a/app/Handlers/Events/StoredGroupEventHandler.php+++ b/app/Handlers/Events/StoredGroupEventHandler.php@@ -55,8 +55,8 @@ class StoredGroupEventHandlerpublic function triggerRulesManually(TriggeredStoredTransactionGroup $event): void{- $newEvent = new StoredTransactionGroup($event->transactionGroup, true, false);- $this->processRules($newEvent, $event->ruleGroup);+// $newEvent = new StoredTransactionGroup($event->transactionGroup, true, false);+// $this->processRules($newEvent, $event->ruleGroup);}/**diff --git a/app/Handlers/Observer/TransactionObserver.php b/app/Handlers/Observer/TransactionObserver.phpindex 97f81bf08b..2509a73f39 100644--- a/app/Handlers/Observer/TransactionObserver.php+++ b/app/Handlers/Observer/TransactionObserver.php@@ -40,13 +40,10 @@ class TransactionObserverpublic function created(Transaction $transaction): void{+ return;+Log::debug('Observe "created" of a transaction.');- if (- true === FireflyConfig::get('use_running_balance', config('firefly.feature_flags.running_balance_column'))->data && (- 1 === bccomp($transaction->amount, '0')- && self::$recalculate- )- ) {+ if (true === FireflyConfig::get('use_running_balance', config('firefly.feature_flags.running_balance_column'))->data && (1 === bccomp($transaction->amount, '0') && self::$recalculate)) {Log::debug('Trigger recalculateForJournal');$journal = $transaction->transactionJournal;if ($journal instanceof TransactionJournal) {diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.phpindex bf9fcacb31..a96a010d30 100644--- a/app/Helpers/Collector/GroupCollector.php+++ b/app/Helpers/Collector/GroupCollector.php@@ -442,7 +442,7 @@ class GroupCollector implements GroupCollectorInterface}$result = $this->query->get($this->fields);// $this->dumpQueryInLogs();- Log::debug(sprintf('Count of result is %d', $result->count()));+ // Log::debug(sprintf('Count of result is %d', $result->count()));// now to parse this into an array.$collection = $this->parseArray($result);diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.phpindex d4afadafbe..6a43da707d 100644--- a/app/Http/Controllers/Transaction/CreateController.php+++ b/app/Http/Controllers/Transaction/CreateController.php@@ -24,7 +24,8 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;-use FireflyIII\Events\StoredTransactionGroup;+use FireflyIII\Events\Model\TransactionGroup\CreatedSingleTransactionGroup;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupEventFlags;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\TransactionGroup;use FireflyIII\Repositories\Account\AccountRepositoryInterface;@@ -76,7 +77,9 @@ class CreateController extends Controller$newGroup = $service->cloneGroup($group);// event!- event(new StoredTransactionGroup($newGroup, true, true));+ $flags = new TransactionGroupEventFlags();+ event(new CreatedSingleTransactionGroup($group, $flags));+ // event(new StoredTransactionGroup($newGroup, true, true));Preferences::mark();diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.phpindex c9282f00c2..cf912bf643 100644--- a/app/Jobs/CreateRecurringTransactions.php+++ b/app/Jobs/CreateRecurringTransactions.php@@ -25,8 +25,9 @@ declare(strict_types=1);namespace FireflyIII\Jobs;use Carbon\Carbon;+use FireflyIII\Events\Model\TransactionGroup\CreatedSingleTransactionGroup;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupEventFlags;use FireflyIII\Events\Model\TransactionGroup\TransactionGroupsRequestedReporting;-use FireflyIII\Events\StoredTransactionGroup;use FireflyIII\Exceptions\DuplicateTransactionException;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Recurrence;@@ -383,7 +384,10 @@ class CreateRecurringTransactions implements ShouldQueueLog::info(sprintf('Created new transaction group #%d', $group->id));// trigger event:- event(new StoredTransactionGroup($group, $recurrence->apply_rules, true));+ $flags = new TransactionGroupEventFlags();+ $flags->applyRules = $recurrence->apply_rules;+ event(new CreatedSingleTransactionGroup($group, $flags));+ // event(new StoredTransactionGroup($group, $recurrence->apply_rules, true));$this->groups->push($group);// update recurring thing:diff --git a/app/Listeners/Model/TransactionGroup/ProcessesNewTransactionGroup.php b/app/Listeners/Model/TransactionGroup/ProcessesNewTransactionGroup.phpnew file mode 100644index 0000000000..98ac2ba3f8--- /dev/null+++ b/app/Listeners/Model/TransactionGroup/ProcessesNewTransactionGroup.php@@ -0,0 +1,39 @@+<?php+/*+ * ProcessesNewTransactionGroup.php+ * Copyright (c) 2026 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++namespace FireflyIII\Listeners\Model\TransactionGroup;++use FireflyIII\Events\Model\TransactionGroup\CreatedSingleTransactionGroup;+use Illuminate\Support\Facades\Log;++class ProcessesNewTransactionGroup+{+ public function handle(CreatedSingleTransactionGroup $event): void+ {+ Log::debug(sprintf('In ProcessesNewTransactionGroup::handle(#%d)', $event->transactionGroup->id));+ if (true === $event->flags->batchSubmission) {+ Log::debug(sprintf('Will do nothing for group #%d because it is part of a batch.', $event->transactionGroup->id));+ return;+ }+ Log::debug(sprintf('Will join group #%d with all other open transaction groups and process them.', $event->transactionGroup->id));+ }++}diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.phpindex aa21d6caa1..0fe1df6603 100644--- a/app/Providers/EventServiceProvider.php+++ b/app/Providers/EventServiceProvider.php@@ -27,7 +27,6 @@ use FireflyIII\Events\DestroyedTransactionGroup;use FireflyIII\Events\Model\TransactionGroup\TriggeredStoredTransactionGroup;use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;use FireflyIII\Events\StoredAccount;-use FireflyIII\Events\StoredTransactionGroup;use FireflyIII\Events\UpdatedAccount;use FireflyIII\Events\UpdatedTransactionGroup;use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;@@ -44,7 +43,7 @@ class EventServiceProvider extends ServiceProviderprotected $listen= [// is a Transaction Journal related event.- StoredTransactionGroup::class => ['FireflyIII\Handlers\Events\StoredGroupEventHandler@runAllHandlers'],+ // StoredTransactionGroup::class => ['FireflyIII\Handlers\Events\StoredGroupEventHandler@runAllHandlers'],TriggeredStoredTransactionGroup::class => ['FireflyIII\Handlers\Events\StoredGroupEventHandler@triggerRulesManually'],// is a Transaction Journal related event.UpdatedTransactionGroup::class => ['FireflyIII\Handlers\Events\UpdatedGroupEventHandler@runAllHandlers'],diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.phpindex a44823e2e9..2cec606a89 100644--- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php+++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php@@ -223,10 +223,7 @@ class AccountEnrichment implements EnrichmentInterface// $finalBalance = Steam::finalAccountBalance($item, $date, $this->primaryCurrency, $this->convertToPrimary);$finalBalance = $this->balances[$id];$balanceDifference = $this->getBalanceDifference($id, $currency);- Log::debug(- sprintf('Call finalAccountBalance(%s) with date/time "%s"', var_export($this->convertToPrimary, true), $date->toIso8601String()),- $finalBalance- );+ // Log::debug(sprintf('Call finalAccountBalance(%s) with date/time "%s"', var_export($this->convertToPrimary, true), $date->toIso8601String()), $finalBalance);// collect current balances:$currentBalance = Steam::bcround($finalBalance[$currency->code] ?? '0', $currency->decimal_places);@@ -329,7 +326,7 @@ class AccountEnrichment implements EnrichmentInterface'zoom_level' => (int) $location['zoom_level'],];}- Log::debug(sprintf('Enrich with %d locations(s)', count($this->locations)));+// Log::debug(sprintf('Enrich with %d locations(s)', count($this->locations)));}private function collectMetaData(): void@@ -385,7 +382,7 @@ class AccountEnrichment implements EnrichmentInterfaceforeach ($notes as $note) {$this->notes[(int) $note['noteable_id']] = (string) $note['text'];}- Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));+// Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));}private function collectObjectGroups(): voiddiff --git a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetEnrichment.phpindex 12386b34b0..4daf51c0d8 100644--- a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php+++ b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php@@ -183,7 +183,7 @@ class BudgetEnrichment implements EnrichmentInterfaceforeach ($notes as $note) {$this->notes[(int) $note['noteable_id']] = (string) $note['text'];}- Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));+// Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));}private function collectObjectGroups(): voiddiff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.phpindex 7834c19f67..237522af10 100644--- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php+++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php@@ -191,7 +191,7 @@ class BudgetLimitEnrichment implements EnrichmentInterfaceforeach ($notes as $note) {$this->notes[(int) $note['noteable_id']] = (string) $note['text'];}- Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));+// Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));}private function filterToBudget(array $expenses, int $budget): arraydiff --git a/app/Support/JsonApi/Enrichments/CategoryEnrichment.php b/app/Support/JsonApi/Enrichments/CategoryEnrichment.phpindex 04f334946d..07ab2ce2c1 100644--- a/app/Support/JsonApi/Enrichments/CategoryEnrichment.php+++ b/app/Support/JsonApi/Enrichments/CategoryEnrichment.php@@ -132,7 +132,7 @@ class CategoryEnrichment implements EnrichmentInterfaceforeach ($notes as $note) {$this->notes[(int) $note['noteable_id']] = (string) $note['text'];}- Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));+// Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));}private function collectTransactions(): voiddiff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.phpindex 8cb9e0cebc..66c5e8ad8e 100644--- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php+++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php@@ -262,7 +262,7 @@ class PiggyBankEnrichment implements EnrichmentInterfaceforeach ($notes as $note) {$this->notes[(int) $note['noteable_id']] = (string) $note['text'];}- Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));+// Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));}private function collectObjectGroups(): voiddiff --git a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php b/app/Support/JsonApi/Enrichments/RecurringEnrichment.phpindex 47efd78c75..6b89bf5665 100644--- a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php+++ b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php@@ -327,7 +327,7 @@ class RecurringEnrichment implements EnrichmentInterface$this->notes[$notableId] = (string) $note['text'];Log::debug(sprintf('Collected note #%d for recurrence #%d', $note['id'], $notableId));}- Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));+// Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));}private function collectPiggyBankInfo(array $piggyBankIds): voiddiff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.phpindex d66f0cd2cd..7fb7defd72 100644--- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php+++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php@@ -205,7 +205,7 @@ class SubscriptionEnrichment implements EnrichmentInterfaceforeach ($notes as $note) {$this->notes[(int) $note['noteable_id']] = (string) $note['text'];}- Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));+// Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));}private function collectObjectGroups(): voiddiff --git a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.phpindex 54ed349c65..bdc1474b6a 100644--- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php+++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php@@ -206,7 +206,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface'zoom_level' => (int) $location['zoom_level'],];}- Log::debug(sprintf('Enrich with %d locations(s)', count($this->locations)));+// Log::debug(sprintf('Enrich with %d locations(s)', count($this->locations)));}private function collectMetaData(): void@@ -242,7 +242,7 @@ class TransactionGroupEnrichment implements EnrichmentInterfaceforeach ($notes as $note) {$this->notes[(int) $note['noteable_id']] = (string) $note['text'];}- Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));+// Log::debug(sprintf('Enrich with %d note(s)', count($this->notes)));}private function collectTags(): voiddiff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.phpindex 901ea52926..5b711b5052 100644--- a/app/Support/Request/ConvertsDataTypes.php+++ b/app/Support/Request/ConvertsDataTypes.php@@ -398,7 +398,7 @@ trait ConvertsDataTypesprotected function getCarbonDate(string $field): ?Carbon{$data = (string) $this->get($field);- Log::debug(sprintf('Date string is "%s"', $data));+ //Log::debug(sprintf('Date string is "%s"', $data));if ('' === $data) {return null;diff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex 5e05ebcde1..3fe8d426a4 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -59,12 +59,7 @@ class Steam?bool $convertToPrimary = null,bool $inclusive = true): array {- Log::debug(sprintf(- 'accountsBalancesOptimized: Called for %d account(s) with date/time "%s" (inclusive: %s)',- $accounts->count(),- $date->toIso8601String(),- var_export($inclusive, true)- ));+ // Log::debug(sprintf('accountsBalancesOptimized: Called for %d account(s) with date/time "%s" (inclusive: %s)', $accounts->count(), $date->toIso8601String(), var_export($inclusive, true)));$result = [];$convertToPrimary ??= Amount::convertToPrimary();$primary ??= Amount::getPrimaryCurrency();@@ -80,7 +75,7 @@ class Steam->toArray();- Log::debug('Array of sums: ', $arrayOfSums);+ // Log::debug('Array of sums: ', $arrayOfSums);/** @var Account $account */foreach ($accounts as $account) {@@ -136,7 +131,7 @@ class Steam}$final = array_merge($return, $sumsByCode);$result[$account->id] = $final;- Log::debug(sprintf('Final balance for account #%d is', $account->id), $final);+ // Log::debug(sprintf('Final balance for account #%d is', $account->id), $final);}return $result;