Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Move more events #11544
James Cole844470bf08be
diff --git a/app/Events/Model/TransactionGroup/TransactionGroupRequestsAuditLogEntry.php b/app/Events/Model/TransactionGroup/TransactionGroupRequestsAuditLogEntry.phpnew file mode 100644index 0000000000..4c2f327f9f--- /dev/null+++ b/app/Events/Model/TransactionGroup/TransactionGroupRequestsAuditLogEntry.php@@ -0,0 +1,33 @@+<?php+/*+ * TransactionGroupRequestsAuditLogEntry.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 Illuminate\Database\Eloquent\Model;+use Illuminate\Queue\SerializesModels;++class TransactionGroupRequestsAuditLogEntry extends Event+{+ use SerializesModels;++ public function __construct(public Model $changer, public Model $auditable, public string $field, public mixed $before, public mixed $after) {}+}diff --git a/app/Handlers/Events/AuditEventHandler.php b/app/Listeners/Model/TransactionGroup/StoresAuditLogEntry.phpsimilarity index 86%rename from app/Handlers/Events/AuditEventHandler.phprename to app/Listeners/Model/TransactionGroup/StoresAuditLogEntry.phpindex 21e8ac56ed..c43f63ff72 100644--- a/app/Handlers/Events/AuditEventHandler.php+++ b/app/Listeners/Model/TransactionGroup/StoresAuditLogEntry.php@@ -1,8 +1,7 @@<?php-/*- * AuditEventHandler.php- * Copyright (c) 2022 [email protected]+ * StoresAuditLogEntry.php+ * Copyright (c) 2026 [email protected]** This file is part of Firefly III (https://github.com/firefly-iii).*@@ -20,22 +19,16 @@* along with this program. If not, see <https://www.gnu.org/licenses/>.*/-declare(strict_types=1);--namespace FireflyIII\Handlers\Events;+namespace FireflyIII\Listeners\Model\TransactionGroup;use Carbon\Carbon;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Repositories\AuditLogEntry\ALERepositoryInterface;use Illuminate\Support\Facades\Log;-/**- * Class AuditEventHandler- */-class AuditEventHandler+class StoresAuditLogEntry{- public function storeAuditEvent(TriggeredAuditLog $event): void- {+ public function handle(TransactionGroupRequestsAuditLogEntry $event): void {$array = ['auditable' => $event->auditable,'changer' => $event->changer,diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.phpindex 54fd5c3740..4ea57c76ce 100644--- a/app/Providers/EventServiceProvider.php+++ b/app/Providers/EventServiceProvider.php@@ -29,7 +29,6 @@ use FireflyIII\Events\Model\TransactionGroup\TriggeredStoredTransactionGroup;use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;use FireflyIII\Events\StoredAccount;use FireflyIII\Events\StoredTransactionGroup;-use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Events\UpdatedAccount;use FireflyIII\Events\UpdatedTransactionGroup;use Illuminate\Auth\Events\Login;@@ -50,7 +49,7 @@ class EventServiceProvider extends ServiceProvider'FireflyIII\Handlers\Events\UserEventHandler@checkSingleUserIsAdmin','FireflyIII\Handlers\Events\UserEventHandler@demoUserBackToEnglish',],- // is a User related event.+ // is a User related event.InvitationCreated::class => ['FireflyIII\Handlers\Events\AdminEventHandler@sendInvitationNotification','FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationInvite',@@ -69,8 +68,6 @@ class EventServiceProvider extends ServiceProviderStoredAccount::class => ['FireflyIII\Handlers\Events\StoredAccountEventHandler@recalculateCredit'],UpdatedAccount::class => ['FireflyIII\Handlers\Events\UpdatedAccountEventHandler@recalculateCredit'],- // audit log events:- TriggeredAuditLog::class => ['FireflyIII\Handlers\Events\AuditEventHandler@storeAuditEvent'],// preferencesUserGroupChangedPrimaryCurrency::class => ['FireflyIII\Handlers\Events\PreferencesEventHandler@resetPrimaryCurrencyAmounts'],diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.phpindex d677f73a6f..140fe4ac65 100644--- a/app/Services/Internal/Update/GroupUpdateService.php+++ b/app/Services/Internal/Update/GroupUpdateService.php@@ -24,7 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Services\Internal\Update;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Exceptions\DuplicateTransactionException;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\TransactionJournalFactory;@@ -58,7 +58,7 @@ class GroupUpdateService$oldTitle = $transactionGroup->title;$transactionGroup->title = $data['group_title'];$transactionGroup->save();- event(new TriggeredAuditLog($transactionGroup->user, $transactionGroup, 'update_group_title', $oldTitle, $data['group_title']));+ event(new TransactionGroupRequestsAuditLogEntry($transactionGroup->user, $transactionGroup, 'update_group_title', $oldTitle, $data['group_title']));}if (0 === count($transactions)) {@@ -81,8 +81,8 @@ class GroupUpdateServiceLog::debug('Going to update split group.');- $existing = $transactionGroup->transactionJournals->pluck('id')->toArray();- $updated = $this->updateTransactions($transactionGroup, $transactions);+ $existing = $transactionGroup->transactionJournals->pluck('id')->toArray();+ $updated = $this->updateTransactions($transactionGroup, $transactions);Log::debug('Array of updated IDs: ', $updated);if (0 === count($updated)) {@@ -94,13 +94,13 @@ class GroupUpdateServicereturn $transactionGroup;}- $result = array_diff($existing, $updated);+ $result = array_diff($existing, $updated);Log::debug('Result of DIFF: ', $result);/** @var string $deletedId */foreach ($result as $deletedId) {/** @var TransactionJournal $journal */- $journal = $transactionGroup->transactionJournals()->find((int) $deletedId);+ $journal = $transactionGroup->transactionJournals()->find((int)$deletedId);/** @var JournalDestroyService $service */$service = app(JournalDestroyService::class);@@ -151,10 +151,10 @@ class GroupUpdateService*/foreach ($transactions as $index => $transaction) {Log::debug(sprintf('Now at #%d of %d', $index + 1, count($transactions)), $transaction);- $journalId = (int) ($transaction['transaction_journal_id'] ?? 0);+ $journalId = (int)($transaction['transaction_journal_id'] ?? 0);/** @var null|TransactionJournal $journal */- $journal = $transactionGroup->transactionJournals()->find($journalId);+ $journal = $transactionGroup->transactionJournals()->find($journalId);if (null === $journal) {Log::debug('This entry has no existing journal: make a new split.');// force the transaction type on the transaction data.@@ -199,7 +199,7 @@ class GroupUpdateService$submission = ['transactions' => [$data]];/** @var TransactionJournalFactory $factory */- $factory = app(TransactionJournalFactory::class);+ $factory = app(TransactionJournalFactory::class);$factory->setUser($transactionGroup->user);try {diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.phpindex 1234e24859..d9cd00f631 100644--- a/app/Services/Internal/Update/JournalUpdateService.php+++ b/app/Services/Internal/Update/JournalUpdateService.php@@ -29,7 +29,7 @@ use Carbon\Exceptions\InvalidDateException;use Carbon\Exceptions\InvalidFormatException;use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\TagFactory;use FireflyIII\Factory\TransactionJournalMetaFactory;@@ -61,41 +61,43 @@ class JournalUpdateService{use JournalServiceTrait;- private BillRepositoryInterface $billRepository;- private CurrencyRepositoryInterface $currencyRepository;+ private BillRepositoryInterface $billRepository;+ private CurrencyRepositoryInterface $currencyRepository;private TransactionGroupRepositoryInterface $transactionGroupRepository;- private array $data;- private ?Account $destinationAccount = null;- private ?Transaction $destinationTransaction = null;- private array $metaDate = [- 'interest_date',- 'book_date',- 'process_date',- 'due_date',- 'payment_date',- 'invoice_date',- '_internal_previous_date',- ];- private array $metaString = [- 'sepa_cc',- 'sepa_ct_op',- 'sepa_ct_id',- 'sepa_db',- 'sepa_country',- 'sepa_ep',- 'sepa_ci',- 'sepa_batch_id',- 'recurrence_id',- 'internal_reference',- 'bunq_payment_id',- 'external_id',- 'external_url',- ];- private ?Account $sourceAccount = null;- private ?Transaction $sourceTransaction = null;- private ?TransactionGroup $transactionGroup = null;- private ?TransactionJournal $transactionJournal = null;- private string $startCompareHash = '';+ private array $data;+ private ?Account $destinationAccount = null;+ private ?Transaction $destinationTransaction = null;+ private array $metaDate+ = [+ 'interest_date',+ 'book_date',+ 'process_date',+ 'due_date',+ 'payment_date',+ 'invoice_date',+ '_internal_previous_date',+ ];+ private array $metaString+ = [+ 'sepa_cc',+ 'sepa_ct_op',+ 'sepa_ct_id',+ 'sepa_db',+ 'sepa_country',+ 'sepa_ep',+ 'sepa_ci',+ 'sepa_batch_id',+ 'recurrence_id',+ 'internal_reference',+ 'bunq_payment_id',+ 'external_id',+ 'external_url',+ ];+ private ?Account $sourceAccount = null;+ private ?Transaction $sourceTransaction = null;+ private ?TransactionGroup $transactionGroup = null;+ private ?TransactionJournal $transactionJournal = null;+ private string $startCompareHash = '';/*** JournalUpdateService constructor.@@ -118,7 +120,7 @@ class JournalUpdateServicepublic function setTransactionGroup(TransactionGroup $transactionGroup): void{- $this->transactionGroup = $transactionGroup;+ $this->transactionGroup = $transactionGroup;$this->billRepository->setUser($transactionGroup->user);$this->categoryRepository->setUser($transactionGroup->user);$this->budgetRepository->setUser($transactionGroup->user);@@ -189,8 +191,8 @@ class JournalUpdateServiceprivate function hasValidSourceAccount(): bool{- $sourceId = $this->data['source_id'] ?? null;- $sourceName = $this->data['source_name'] ?? null;+ $sourceId = $this->data['source_id'] ?? null;+ $sourceName = $this->data['source_name'] ?? null;Log::debug(sprintf('Now in hasValidSourceAccount("%s","%s").', $sourceId, $sourceName));if (!$this->hasFields(['source_id', 'source_name'])) {@@ -205,11 +207,11 @@ class JournalUpdateService// make a new validator./** @var AccountValidator $validator */- $validator = app(AccountValidator::class);+ $validator = app(AccountValidator::class);$validator->setTransactionType($expectedType);$validator->setUser($this->transactionJournal->user);- $result = $validator->validateSource(['id' => $sourceId, 'name' => $sourceName]);+ $result = $validator->validateSource(['id' => $sourceId, 'name' => $sourceName]);Log::debug(sprintf('hasValidSourceAccount(%d, "%s") will return %s', $sourceId, $sourceName, var_export($result, true)));// TODO type overrule the account validator may have a different opinion on the transaction type.@@ -220,7 +222,7 @@ class JournalUpdateServiceprivate function hasFields(array $fields): bool{- return array_any($fields, fn ($field): bool => array_key_exists($field, $this->data));+ return array_any($fields, fn($field): bool => array_key_exists($field, $this->data));}private function getOriginalSourceAccount(): Account@@ -241,8 +243,7 @@ class JournalUpdateService->transactions()->with(['account'])->where('amount', '<', 0)- ->first()- ;+ ->first();$this->sourceTransaction = $result;}Log::debug(sprintf('getSourceTransaction: %s', $this->sourceTransaction->amount));@@ -270,8 +271,8 @@ class JournalUpdateServiceprivate function hasValidDestinationAccount(): bool{Log::debug('Now in hasValidDestinationAccount().');- $destId = $this->data['destination_id'] ?? null;- $destName = $this->data['destination_name'] ?? null;+ $destId = $this->data['destination_id'] ?? null;+ $destName = $this->data['destination_name'] ?? null;if (!$this->hasFields(['destination_id', 'destination_name'])) {Log::debug('No destination info submitted, grab the original data.');@@ -281,16 +282,16 @@ class JournalUpdateService}// make new account validator.- $expectedType = $this->getExpectedType();+ $expectedType = $this->getExpectedType();Log::debug(sprintf('(b) Expected type (new or unchanged) is %s', $expectedType));// make a new validator./** @var AccountValidator $validator */- $validator = app(AccountValidator::class);+ $validator = app(AccountValidator::class);$validator->setTransactionType($expectedType);$validator->setUser($this->transactionJournal->user);$validator->source = $this->getValidSourceAccount();- $result = $validator->validateDestination(['id' => $destId, 'name' => $destName]);+ $result = $validator->validateDestination(['id' => $destId, 'name' => $destName]);Log::debug(sprintf('hasValidDestinationAccount(%d, "%s") will return %s', $destId, $destName, var_export($result, true)));// TODO typeOverrule: the account validator may have another opinion on the transaction type.@@ -319,8 +320,7 @@ class JournalUpdateService$result = $this->transactionJournal->transactions()->where('amount', '>', 0)- ->first()- ;+ ->first();$this->destinationTransaction = $result;}@@ -338,8 +338,8 @@ class JournalUpdateServicereturn $this->getOriginalSourceAccount();}- $sourceInfo = [- 'id' => (int) ($this->data['source_id'] ?? null),+ $sourceInfo = [+ 'id' => (int)($this->data['source_id'] ?? null),'name' => $this->data['source_name'] ?? null,'iban' => $this->data['source_iban'] ?? null,'number' => $this->data['source_number'] ?? null,@@ -366,8 +366,8 @@ class JournalUpdateService*/private function updateAccounts(): void{- $source = $this->getValidSourceAccount();- $destination = $this->getValidDestinationAccount();+ $source = $this->getValidSourceAccount();+ $destination = $this->getValidDestinationAccount();// cowardly refuse to update if both accounts are the same.if ($source->id === $destination->id) {@@ -380,7 +380,7 @@ class JournalUpdateService$origSourceTransaction->account()->associate($source);$origSourceTransaction->save();- $destTransaction = $this->getDestinationTransaction();+ $destTransaction = $this->getDestinationTransaction();$destTransaction->account()->associate($destination);$destTransaction->save();@@ -402,8 +402,8 @@ class JournalUpdateServicereturn $this->getOriginalDestinationAccount();}- $destInfo = [- 'id' => (int) ($this->data['destination_id'] ?? null),+ $destInfo = [+ 'id' => (int)($this->data['destination_id'] ?? null),'name' => $this->data['destination_name'] ?? null,'iban' => $this->data['destination_iban'] ?? null,'number' => $this->data['destination_number'] ?? null,@@ -431,13 +431,13 @@ class JournalUpdateService{Log::debug('Now in updateType()');if ($this->hasFields(['type'])) {- $type = 'opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type'];+ $type = 'opening-balance' === $this->data['type'] ? 'opening balance' : $this->data['type'];Log::debug(sprintf(- 'Trying to change journal #%d from a %s to a %s.',- $this->transactionJournal->id,- $this->transactionJournal->transactionType->type,- $type- ));+ 'Trying to change journal #%d from a %s to a %s.',+ $this->transactionJournal->id,+ $this->transactionJournal->transactionType->type,+ $type+ ));/** @var TransactionTypeFactory $typeFactory */$typeFactory = app(TransactionTypeFactory::class);@@ -462,8 +462,8 @@ class JournalUpdateService{$type = $this->transactionJournal->transactionType->type;if ((array_key_exists('bill_id', $this->data) || array_key_exists('bill_name', $this->data)) && TransactionTypeEnum::WITHDRAWAL->value === $type) {- $billId = (int) ($this->data['bill_id'] ?? 0);- $billName = (string) ($this->data['bill_name'] ?? '');+ $billId = (int)($this->data['bill_id'] ?? 0);+ $billName = (string)($this->data['bill_name'] ?? '');$bill = $this->billRepository->findBill($billId, $billName);$this->transactionJournal->bill_id = $bill?->id;Log::debug('Updated bill ID');@@ -475,8 +475,8 @@ class JournalUpdateService*/private function updateField(string $fieldName): void{- if (array_key_exists($fieldName, $this->data) && '' !== (string) $this->data[$fieldName]) {- $value = $this->data[$fieldName];+ if (array_key_exists($fieldName, $this->data) && '' !== (string)$this->data[$fieldName]) {+ $value = $this->data[$fieldName];if ('date' === $fieldName) {if (!$value instanceof Carbon) {@@ -496,8 +496,8 @@ class JournalUpdateServiceLog::debug(sprintf('Old date: %s, new date: %s', $this->transactionJournal->date->toW3cString(), $value->toW3cString()));/** @var TransactionJournalMetaFactory $factory */- $factory = app(TransactionJournalMetaFactory::class);- $set = ['journal' => $this->transactionJournal, 'name' => '_internal_previous_date', 'data' => null];+ $factory = app(TransactionJournalMetaFactory::class);+ $set = ['journal' => $this->transactionJournal, 'name' => '_internal_previous_date', 'data' => null];if ($res) {Log::debug('Transaction is set to be AFTER its current date. Save also the "_internal_previous_date"-field.');$set['data'] = clone $this->transactionJournal->date;@@ -508,7 +508,7 @@ class JournalUpdateService$factory->updateOrCreate($set);}event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($this->transactionJournal->user,$this->transactionJournal,sprintf('update_%s', $fieldName),@@ -565,7 +565,7 @@ class JournalUpdateService{// update notes.if ($this->hasFields(['notes'])) {- $notes = '' === (string) $this->data['notes'] ? null : $this->data['notes'];+ $notes = '' === (string)$this->data['notes'] ? null : $this->data['notes'];$this->storeNotes($this->transactionJournal, $notes);}}@@ -595,7 +595,7 @@ class JournalUpdateServiceif ($this->hasFields([$field])) {$value = '' === $this->data[$field] ? null : $this->data[$field];Log::debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));- $set = ['journal' => $this->transactionJournal, 'name' => $field, 'data' => $value];+ $set = ['journal' => $this->transactionJournal, 'name' => $field, 'data' => $value];$factory->updateOrCreate($set);}}@@ -609,17 +609,17 @@ class JournalUpdateServiceforeach ($this->metaDate as $field) {if ($this->hasFields([$field])) {try {- $value = '' === (string) $this->data[$field] ? null : new Carbon($this->data[$field]);- } catch (InvalidDateException|InvalidFormatException $e) { // @phpstan-ignore-line+ $value = '' === (string)$this->data[$field] ? null : new Carbon($this->data[$field]);+ } catch (InvalidDateException | InvalidFormatException $e) { // @phpstan-ignore-lineLog::debug(sprintf('%s is not a valid date value: %s', $this->data[$field], $e->getMessage()));return;}Log::debug(sprintf('Field "%s" is present ("%s"), try to update it.', $field, $value));- $set = ['journal' => $this->transactionJournal, 'name' => $field, 'data' => $value];+ $set = ['journal' => $this->transactionJournal, 'name' => $field, 'data' => $value];$factory->updateOrCreate($set);// also set date with timezone.- $set = ['journal' => $this->transactionJournal, 'name' => sprintf('%s_tz', $field), 'data' => $value?->format('e')];+ $set = ['journal' => $this->transactionJournal, 'name' => sprintf('%s_tz', $field), 'data' => $value?->format('e')];$factory->updateOrCreate($set);}}@@ -631,19 +631,19 @@ class JournalUpdateServiceif (!$this->hasFields(['currency_id', 'currency_code'])) {return;}- $currencyId = $this->data['currency_id'] ?? null;- $currencyCode = $this->data['currency_code'] ?? null;- $currency = $this->currencyRepository->findCurrency($currencyId, $currencyCode);+ $currencyId = $this->data['currency_id'] ?? null;+ $currencyCode = $this->data['currency_code'] ?? null;+ $currency = $this->currencyRepository->findCurrency($currencyId, $currencyCode);// update currency everywhere.$this->transactionJournal->transaction_currency_id = $currency->id;$this->transactionJournal->save();- $source = $this->getSourceTransaction();- $source->transaction_currency_id = $currency->id;+ $source = $this->getSourceTransaction();+ $source->transaction_currency_id = $currency->id;$source->save();- $dest = $this->getDestinationTransaction();- $dest->transaction_currency_id = $currency->id;+ $dest = $this->getDestinationTransaction();+ $dest->transaction_currency_id = $currency->id;$dest->save();// refresh transactions.@@ -659,7 +659,7 @@ class JournalUpdateServicereturn;}- $value = $this->data['amount'] ?? '';+ $value = $this->data['amount'] ?? '';Log::debug(sprintf('[a] Amount is now "%s"', $value));try {@@ -670,9 +670,9 @@ class JournalUpdateServicereturn;}Log::debug(sprintf('[b] Amount is now "%s"', $value));- $origSourceTransaction = $this->getSourceTransaction();- $destTransaction = $this->getDestinationTransaction();- $originalSourceAmount = $origSourceTransaction->amount;+ $origSourceTransaction = $this->getSourceTransaction();+ $destTransaction = $this->getDestinationTransaction();+ $originalSourceAmount = $origSourceTransaction->amount;// $originalDestAmount = $destTransaction->amount;$origSourceTransaction->amount = Steam::negative($amount);$origSourceTransaction->balance_dirty = true;@@ -686,7 +686,7 @@ class JournalUpdateService$this->destinationTransaction->refresh();Log::debug(sprintf('Updated amount to "%s"', $amount));- $group = $this->transactionGroup;+ $group = $this->transactionGroup;if (null === $group) {$group = $this->transactionJournal?->transactionGroup;}@@ -699,17 +699,17 @@ class JournalUpdateServicereturn;}Log::debug('Amount was changed, needs audit log entry.');- $transfer = TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type;+ $transfer = TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type;// $withdrawal = TransactionTypeEnum::WITHDRAWAL->value === $this->transactionJournal->transactionType->type;- $deposit = TransactionTypeEnum::DEPOSIT->value === $this->transactionJournal->transactionType->type;- $makePositive = $transfer || $deposit ? true : false;- $recordCurrency = $origSourceTransaction->transactionCurrency;- $originalSourceAmount = $makePositive ? Steam::positive($originalSourceAmount) : Steam::negative($originalSourceAmount);- $value = $makePositive ? Steam::positive($value) : Steam::negative($value);+ $deposit = TransactionTypeEnum::DEPOSIT->value === $this->transactionJournal->transactionType->type;+ $makePositive = $transfer || $deposit ? true : false;+ $recordCurrency = $origSourceTransaction->transactionCurrency;+ $originalSourceAmount = $makePositive ? Steam::positive($originalSourceAmount) : Steam::negative($originalSourceAmount);+ $value = $makePositive ? Steam::positive($value) : Steam::negative($value);// should not return in NULL but seems to do.event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($group->user,$group,'update_amount',@@ -718,7 +718,7 @@ class JournalUpdateService'decimal_places' => $recordCurrency->decimal_places,'amount' => $originalSourceAmount,],- ['currency_symbol' => $recordCurrency->symbol, 'decimal_places' => $recordCurrency->decimal_places, 'amount' => $value]+ ['currency_symbol' => $recordCurrency->symbol, 'decimal_places' => $recordCurrency->decimal_places, 'amount' => $value]));}@@ -738,9 +738,9 @@ class JournalUpdateService$originalSourceAmount = $source->foreign_amount;// find currency in data array- $newForeignId = $this->data['foreign_currency_id'] ?? null;- $newForeignCode = $this->data['foreign_currency_code'] ?? null;- $foreignCurrency = $this->currencyRepository->findCurrencyNull($newForeignId, $newForeignCode) ?? $foreignCurrency;+ $newForeignId = $this->data['foreign_currency_id'] ?? null;+ $newForeignCode = $this->data['foreign_currency_code'] ?? null;+ $foreignCurrency = $this->currencyRepository->findCurrencyNull($newForeignId, $newForeignCode) ?? $foreignCurrency;// not the same as normal currencyif (null !== $foreignCurrency && $foreignCurrency->id === $this->transactionJournal->transaction_currency_id) {@@ -758,9 +758,9 @@ class JournalUpdateService// if the transaction is a TRANSFER, and the foreign amount and currency are set (like they seem to be)// the correct fields to update in the destination transaction are NOT the foreign amount and currency// but rather the normal amount and currency. This is new behavior.- $isTransfer = TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type;+ $isTransfer = TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type;// also check if it is not between an asset account and a liability, because then the same rule applies.- $isBetween = $this->isBetweenAssetAndLiability();+ $isBetween = $this->isBetweenAssetAndLiability();if ($isTransfer || $isBetween) {Log::debug('Switch amounts, store in amount and not foreign_amount');@@ -785,7 +785,7 @@ class JournalUpdateService// add audit log entry.Log::debug(sprintf('Updated foreign amount to "%s"', $foreignAmount));- $group = $this->transactionGroup;+ $group = $this->transactionGroup;if (null === $group) {$group = $this->transactionJournal?->transactionGroup;}@@ -798,17 +798,17 @@ class JournalUpdateServicereturn;}Log::debug('Amount was changed, needs audit log entry.');- $transfer = TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type;+ $transfer = TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type;// $withdrawal = TransactionTypeEnum::WITHDRAWAL->value === $this->transactionJournal->transactionType->type;- $deposit = TransactionTypeEnum::DEPOSIT->value === $this->transactionJournal->transactionType->type;- $makePositive = $transfer || $deposit ? true : false;- $recordCurrency = $source->foreignCurrency;- $originalSourceAmount = $makePositive ? Steam::positive($originalSourceAmount) : Steam::negative($originalSourceAmount);- $value = $makePositive ? Steam::positive($foreignAmount) : Steam::negative($foreignAmount);+ $deposit = TransactionTypeEnum::DEPOSIT->value === $this->transactionJournal->transactionType->type;+ $makePositive = $transfer || $deposit ? true : false;+ $recordCurrency = $source->foreignCurrency;+ $originalSourceAmount = $makePositive ? Steam::positive($originalSourceAmount) : Steam::negative($originalSourceAmount);+ $value = $makePositive ? Steam::positive($foreignAmount) : Steam::negative($foreignAmount);// should not return in NULL but seems to do.event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($group->user,$group,'update_foreign_amount',@@ -817,7 +817,7 @@ class JournalUpdateService'decimal_places' => $recordCurrency->decimal_places,'amount' => $originalSourceAmount,],- ['currency_symbol' => $recordCurrency->symbol, 'decimal_places' => $recordCurrency->decimal_places, 'amount' => $value]+ ['currency_symbol' => $recordCurrency->symbol, 'decimal_places' => $recordCurrency->decimal_places, 'amount' => $value]));}@@ -826,8 +826,8 @@ class JournalUpdateService$source->foreign_amount = null;$source->save();- $dest->foreign_currency_id = null;- $dest->foreign_amount = null;+ $dest->foreign_currency_id = null;+ $dest->foreign_amount = null;$dest->save();Log::debug(sprintf('Foreign amount is "%s" so remove foreign amount info.', $amount));@@ -843,18 +843,16 @@ class JournalUpdateServiceprivate function isBetweenAssetAndLiability(): bool{/** @var null|Transaction $sourceTransaction */- $sourceTransaction = $this->transactionJournal+ $sourceTransaction = $this->transactionJournal->transactions()->where('amount', '<', 0)- ->first()- ;+ ->first();/** @var null|Transaction $destinationTransaction */$destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)- ->first()- ;+ ->first();if (null === $sourceTransaction || null === $destinationTransaction) {Log::warning('Either transaction is false, stop.');@@ -866,15 +864,15 @@ class JournalUpdateServicereturn false;}- $source = $sourceTransaction->account;- $destination = $destinationTransaction->account;+ $source = $sourceTransaction->account;+ $destination = $destinationTransaction->account;if (null === $source || null === $destination) {Log::warning('Either is false, stop.');return false;}- $sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];+ $sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];// source is liability, destination is assetif (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) {diff --git a/app/TransactionRules/Actions/AddTag.php b/app/TransactionRules/Actions/AddTag.phpindex d0de2e9370..acd4b49085 100644--- a/app/TransactionRules/Actions/AddTag.php+++ b/app/TransactionRules/Actions/AddTag.php@@ -25,7 +25,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Factory\TagFactory;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -52,12 +52,12 @@ class AddTag implements ActionInterface$factory = app(TagFactory::class);/** @var User $user */- $user = User::find($journal['user_id']);+ $user = User::find($journal['user_id']);$factory->setUser($user);$tagName = $this->action->getValue($journal);$tag = $factory->findOrCreate($tagName);- $type = $journal['transaction_type_type'];+ $type = $journal['transaction_type_type'];if (TransactionTypeEnum::OPENING_BALANCE->value === $type|| TransactionTypeEnum::LIABILITY_CREDIT->value === $type@@ -75,33 +75,32 @@ class AddTag implements ActionInterfacereturn false;}- $count = DB::table('tag_transaction_journal')- ->where('tag_id', $tag->id)- ->where('transaction_journal_id', $journal['transaction_journal_id'])- ->count()- ;+ $count = DB::table('tag_transaction_journal')+ ->where('tag_id', $tag->id)+ ->where('transaction_journal_id', $journal['transaction_journal_id'])+ ->count();if (0 === $count) {// add to journal:DB::table('tag_transaction_journal')->insert([- 'tag_id' => $tag->id,- 'transaction_journal_id' => $journal['transaction_journal_id'],- ]);+ 'tag_id' => $tag->id,+ 'transaction_journal_id' => $journal['transaction_journal_id'],+ ]);Log::debug(sprintf('RuleAction AddTag. Added tag #%d ("%s") to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id']));/** @var TransactionJournal $object */$object = TransactionJournal::find($journal['transaction_journal_id']);// event for audit log entry- event(new TriggeredAuditLog($this->action->rule, $object, 'add_tag', null, $tag->tag));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'add_tag', null, $tag->tag));return true;}Log::debug(sprintf(- 'RuleAction AddTag fired but tag %d ("%s") was already added to journal %d.',- $tag->id,- $tag->tag,- $journal['transaction_journal_id']- ));+ 'RuleAction AddTag fired but tag %d ("%s") was already added to journal %d.',+ $tag->id,+ $tag->tag,+ $journal['transaction_journal_id']+ ));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.tag_already_added', ['tag' => $tagName])));return false;diff --git a/app/TransactionRules/Actions/AppendDescription.php b/app/TransactionRules/Actions/AppendDescription.phpindex ea7327e6f2..883f197a51 100644--- a/app/TransactionRules/Actions/AppendDescription.php+++ b/app/TransactionRules/Actions/AppendDescription.php@@ -23,7 +23,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;use FireflyIII\TransactionRules\Traits\RefreshNotesTrait;@@ -50,15 +50,14 @@ class AppendDescription implements ActionInterface$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])- ;+ ->where('id', $journal['transaction_journal_id'])+ ->limit(1)+ ->update(['description' => $description]);// event for audit log entry/** @var TransactionJournal $object */- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $journal['description'], $description));+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_description', $journal['description'], $description));return true;}diff --git a/app/TransactionRules/Actions/AppendDescriptionToNotes.php b/app/TransactionRules/Actions/AppendDescriptionToNotes.phpindex 4108dbefef..5bec1b245f 100644--- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php+++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php@@ -25,7 +25,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\Note;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -55,13 +55,13 @@ class AppendDescriptionToNotes implements ActionInterface$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);if (null === $object) {Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));- event(new RuleActionFailedOnArray($this->action, $journal, (string) trans('rules.journal_other_user')));+ event(new RuleActionFailedOnArray($this->action, $journal, (string)trans('rules.journal_other_user')));return false;}- $note = $object->notes()->first();+ $note = $object->notes()->first();if (null === $note) {- $note = new Note();+ $note = new Note();$note->noteable()->associate($object);$note->text = '';}@@ -70,12 +70,12 @@ class AppendDescriptionToNotes implements ActionInterface$note->text = trim(sprintf("%s \n%s", $note->text, $object->description));}if ('' === $note->text) {- $note->text = (string) $object->description;+ $note->text = (string)$object->description;}- $after = $note->text;+ $after = $note->text;// event for audit log entry- event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $after));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_notes', $before, $after));$note->save();diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.phpindex 32cdb3f385..1b8285c482 100644--- a/app/TransactionRules/Actions/AppendNotes.php+++ b/app/TransactionRules/Actions/AppendNotes.php@@ -23,7 +23,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\Note;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -48,10 +48,10 @@ class AppendNotes implements ActionInterfacepublic function actOnArray(array $journal): bool{$this->refreshNotes($journal);- $dbNote = Note::where('noteable_id', (int) $journal['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);+ $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);if (null === $dbNote) {$dbNote = new Note();- $dbNote->noteable_id = (int) $journal['transaction_journal_id'];+ $dbNote->noteable_id = (int)$journal['transaction_journal_id'];$dbNote->noteable_type = TransactionJournal::class;$dbNote->text = '';}@@ -62,10 +62,10 @@ class AppendNotes implements ActionInterface$dbNote->save();/** @var TransactionJournal $object */- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);Log::debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $append, $before));- event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $text));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_notes', $before, $text));return true;}diff --git a/app/TransactionRules/Actions/AppendNotesToDescription.php b/app/TransactionRules/Actions/AppendNotesToDescription.phpindex a3d1a211e0..1b4b29fb55 100644--- a/app/TransactionRules/Actions/AppendNotesToDescription.php+++ b/app/TransactionRules/Actions/AppendNotesToDescription.php@@ -25,7 +25,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\Note;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -62,21 +62,21 @@ class AppendNotesToDescription implements ActionInterfacereturn false;}- $note = $object->notes()->first();+ $note = $object->notes()->first();if (null === $note) {Log::debug('Journal has no notes.');- $note = new Note();+ $note = new Note();$note->noteable()->associate($object);$note->text = '';}// only append if there is something to appendif ('' !== $note->text) {$before = $object->description;- $object->description = trim(sprintf('%s %s', $object->description, (string) $this->clearString($note->text)));+ $object->description = trim(sprintf('%s %s', $object->description, (string)$this->clearString($note->text)));$object->save();Log::debug(sprintf('Journal description is updated to "%s".', $object->description));- event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $before, $object->description));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_description', $before, $object->description));return true;}diff --git a/app/TransactionRules/Actions/ClearBudget.php b/app/TransactionRules/Actions/ClearBudget.phpindex 6f69e68c52..56ea7093a6 100644--- a/app/TransactionRules/Actions/ClearBudget.php+++ b/app/TransactionRules/Actions/ClearBudget.php@@ -24,7 +24,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;use Illuminate\Support\Facades\DB;@@ -56,7 +56,7 @@ class ClearBudget implements ActionInterfaceDB::table('budget_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();- event(new TriggeredAuditLog($this->action->rule, $object, 'clear_budget', $budget->name, null));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'clear_budget', $budget->name, null));Log::debug(sprintf('RuleAction ClearBudget removed all budgets from journal #%d.', $journal['transaction_journal_id']));diff --git a/app/TransactionRules/Actions/ClearCategory.php b/app/TransactionRules/Actions/ClearCategory.phpindex 89801cbca4..72ca9b16ad 100644--- a/app/TransactionRules/Actions/ClearCategory.php+++ b/app/TransactionRules/Actions/ClearCategory.php@@ -24,7 +24,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;use Illuminate\Support\Facades\DB;@@ -56,7 +56,7 @@ class ClearCategory implements ActionInterfaceDB::table('category_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();- event(new TriggeredAuditLog($this->action->rule, $object, 'clear_category', $category->name, null));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'clear_category', $category->name, null));Log::debug(sprintf('RuleAction ClearCategory removed all categories from journal #%d.', $journal['transaction_journal_id']));diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.phpindex 7a68a74f50..744495642f 100644--- a/app/TransactionRules/Actions/ClearNotes.php+++ b/app/TransactionRules/Actions/ClearNotes.php@@ -24,7 +24,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\Note;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -49,7 +49,7 @@ class ClearNotes implements ActionInterface$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);/** @var null|Note $notes */- $notes = $object->notes()->first();+ $notes = $object->notes()->first();if (null === $notes) {Log::debug(sprintf('RuleAction ClearNotes, journal #%d has no notes.', $journal['transaction_journal_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_already_no_notes')));@@ -59,13 +59,12 @@ class ClearNotes implements ActionInterface$before = $notes->text;DB::table('notes')- ->where('noteable_id', $journal['transaction_journal_id'])- ->where('noteable_type', TransactionJournal::class)- ->delete()- ;+ ->where('noteable_id', $journal['transaction_journal_id'])+ ->where('noteable_type', TransactionJournal::class)+ ->delete();Log::debug(sprintf('RuleAction ClearNotes removed all notes from journal #%d.', $journal['transaction_journal_id']));- event(new TriggeredAuditLog($this->action->rule, $object, 'clear_notes', $before, null));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'clear_notes', $before, null));return true;}diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.phpindex 0c8103bb75..86b709a1d1 100644--- a/app/TransactionRules/Actions/ConvertToDeposit.php+++ b/app/TransactionRules/Actions/ConvertToDeposit.php@@ -27,7 +27,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\AccountFactory;use FireflyIII\Models\Account;@@ -57,14 +57,14 @@ class ConvertToDeposit implements ActionInterface// make object from array (so the data is fresh)./** @var null|TransactionJournal $object */- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);if (null === $object) {Log::error(sprintf('Cannot find journal #%d, cannot convert to deposit.', $journal['transaction_journal_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));return false;}- $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();+ $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();if ($groupCount > 1) {Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to deposit.', $journal['transaction_group_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group')));@@ -73,7 +73,7 @@ class ConvertToDeposit implements ActionInterface}Log::debug(sprintf('Convert journal #%d to deposit.', $journal['transaction_journal_id']));- $type = $object->transactionType->type;+ $type = $object->transactionType->type;if (TransactionTypeEnum::DEPOSIT->value === $type) {Log::error(sprintf('Journal #%d is already a deposit (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_deposit')));@@ -95,7 +95,7 @@ class ConvertToDeposit implements ActionInterface}event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($this->action->rule,$object,'update_transaction_type',@@ -119,7 +119,7 @@ class ConvertToDeposit implements ActionInterfacereturn false;}event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($this->action->rule,$object,'update_transaction_type',@@ -143,22 +143,22 @@ class ConvertToDeposit implements ActionInterface*/private function convertWithdrawalArray(TransactionJournal $journal, string $actionValue = ''): bool{- $user = $journal->user;+ $user = $journal->user;// find or create revenue account./** @var AccountFactory $factory */- $factory = app(AccountFactory::class);+ $factory = app(AccountFactory::class);$factory->setUser($user);- $repository = app(AccountRepositoryInterface::class);+ $repository = app(AccountRepositoryInterface::class);$repository->setUser($user);- $destAccount = $this->getDestinationAccount($journal);- $sourceAccount = $this->getSourceAccount($journal);+ $destAccount = $this->getDestinationAccount($journal);+ $sourceAccount = $this->getSourceAccount($journal);// get the action value, or use the original destination name in case the action value is empty:// this becomes a new or existing (revenue) account, which is the source of the new deposit.- $opposingName = '' === $actionValue ? $destAccount->name : $actionValue;+ $opposingName = '' === $actionValue ? $destAccount->name : $actionValue;// we check all possible source account types if one exists:$validTypes = config('firefly.expected_source_types.source.Deposit');$opposingAccount = $repository->findByName($opposingName, $validTypes);@@ -170,22 +170,20 @@ class ConvertToDeposit implements ActionInterface// update the source transaction and put in the new revenue ID.DB::table('transactions')- ->where('transaction_journal_id', '=', $journal->id)- ->where('amount', '<', 0)- ->update(['account_id' => $opposingAccount->id])- ;+ ->where('transaction_journal_id', '=', $journal->id)+ ->where('amount', '<', 0)+ ->update(['account_id' => $opposingAccount->id]);// update the destination transaction and put in the original source account ID.DB::table('transactions')- ->where('transaction_journal_id', '=', $journal->id)- ->where('amount', '>', 0)- ->update(['account_id' => $sourceAccount->id])- ;+ ->where('transaction_journal_id', '=', $journal->id)+ ->where('amount', '>', 0)+ ->update(['account_id' => $sourceAccount->id]);// change transaction type of journal:- $newType = TransactionType::whereType(TransactionTypeEnum::DEPOSIT->value)->first();+ $newType = TransactionType::whereType(TransactionTypeEnum::DEPOSIT->value)->first();- DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);+ DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);Log::debug('Converted withdrawal to deposit.');@@ -229,21 +227,21 @@ class ConvertToDeposit implements ActionInterface*/private function convertTransferArray(TransactionJournal $journal, string $actionValue = ''): bool{- $user = $journal->user;+ $user = $journal->user;// find or create revenue account./** @var AccountFactory $factory */- $factory = app(AccountFactory::class);+ $factory = app(AccountFactory::class);$factory->setUser($user);- $repository = app(AccountRepositoryInterface::class);+ $repository = app(AccountRepositoryInterface::class);$repository->setUser($user);- $sourceAccount = $this->getSourceAccount($journal);+ $sourceAccount = $this->getSourceAccount($journal);// get the action value, or use the original source name in case the action value is empty:// this becomes a new or existing (revenue) account, which is the source of the new deposit.- $opposingName = '' === $actionValue ? $sourceAccount->name : $actionValue;+ $opposingName = '' === $actionValue ? $sourceAccount->name : $actionValue;// we check all possible source account types if one exists:$validTypes = config('firefly.expected_source_types.source.Deposit');$opposingAccount = $repository->findByName($opposingName, $validTypes);@@ -255,15 +253,14 @@ class ConvertToDeposit implements ActionInterface// update source transaction(s) to be revenue accountDB::table('transactions')- ->where('transaction_journal_id', '=', $journal->id)- ->where('amount', '<', 0)- ->update(['account_id' => $opposingAccount->id])- ;+ ->where('transaction_journal_id', '=', $journal->id)+ ->where('amount', '<', 0)+ ->update(['account_id' => $opposingAccount->id]);// change transaction type of journal:- $newType = TransactionType::whereType(TransactionTypeEnum::DEPOSIT->value)->first();+ $newType = TransactionType::whereType(TransactionTypeEnum::DEPOSIT->value)->first();- DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);+ DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);Log::debug('Converted transfer to deposit.');diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.phpindex f73936cc95..ff02b694a3 100644--- a/app/TransactionRules/Actions/ConvertToTransfer.php+++ b/app/TransactionRules/Actions/ConvertToTransfer.php@@ -27,7 +27,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;use FireflyIII\Events\Model\Rule\RuleActionFailedOnObject;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\RuleAction;@@ -58,18 +58,18 @@ class ConvertToTransfer implements ActionInterface*/public function actOnArray(array $journal): bool{- $accountName = $this->action->getValue($journal);+ $accountName = $this->action->getValue($journal);// make object from array (so the data is fresh)./** @var null|TransactionJournal $object */- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);if (null === $object) {Log::error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));return false;}- $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();+ $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();if ($groupCount > 1) {Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group')));@@ -77,9 +77,9 @@ class ConvertToTransfer implements ActionInterfacereturn false;}- $type = $object->transactionType->type;- $user = $object->user;- $journalId = $object->id;+ $type = $object->transactionType->type;+ $user = $object->user;+ $journalId = $object->id;if (TransactionTypeEnum::TRANSFER->value === $type) {Log::error(sprintf('Journal #%d is already a transfer so cannot be converted (rule #%d).', $object->id, $this->action->rule_id));// event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_transfer')));@@ -94,7 +94,7 @@ class ConvertToTransfer implements ActionInterface// find the asset account in the action value./** @var AccountRepositoryInterface $repository */- $repository = app(AccountRepositoryInterface::class);+ $repository = app(AccountRepositoryInterface::class);$repository->setUser($user);$expectedType = null;if (TransactionTypeEnum::WITHDRAWAL->value === $type) {@@ -107,16 +107,16 @@ class ConvertToTransfer implements ActionInterface// Deposit? Replace source with account with same type as destination.}- $opposing = $repository->findByName($accountName, [$expectedType]);+ $opposing = $repository->findByName($accountName, [$expectedType]);if (null === $opposing) {Log::error(sprintf(- 'Journal #%d cannot be converted because no valid %s account with name "%s" exists (rule #%d).',- $expectedType,- $journalId,- $accountName,- $this->action->rule_id- ));+ 'Journal #%d cannot be converted because no valid %s account with name "%s" exists (rule #%d).',+ $expectedType,+ $journalId,+ $accountName,+ $this->action->rule_id+ ));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_valid_opposing', ['name' => $accountName])));return false;@@ -136,7 +136,7 @@ class ConvertToTransfer implements ActionInterface}if ($res) {event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($this->action->rule,$object,'update_transaction_type',@@ -162,7 +162,7 @@ class ConvertToTransfer implements ActionInterface}if ($res) {event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($this->action->rule,$object,'update_transaction_type',@@ -185,7 +185,7 @@ class ConvertToTransfer implements ActionInterfacereturn '';}- return (string) $journal->transactions()->where('amount', '<', 0)->first()?->account?->accountType?->type;+ return (string)$journal->transactions()->where('amount', '<', 0)->first()?->account?->accountType?->type;}private function getDestinationType(int $journalId): string@@ -198,7 +198,7 @@ class ConvertToTransfer implements ActionInterfacereturn '';}- return (string) $journal->transactions()->where('amount', '>', 0)->first()?->account?->accountType?->type;+ return (string)$journal->transactions()->where('amount', '>', 0)->first()?->account?->accountType?->type;}/**@@ -210,8 +210,8 @@ class ConvertToTransfer implements ActionInterface*/private function convertWithdrawalArray(TransactionJournal $journal, Account $opposing): bool{- $repository = app(AccountRepositoryInterface::class);- $sourceAccount = $this->getSourceAccount($journal);+ $repository = app(AccountRepositoryInterface::class);+ $sourceAccount = $this->getSourceAccount($journal);$repository->setUser($sourceAccount->user);if ($sourceAccount->id === $opposing->id) {Log::error(vsprintf('Journal #%d has already has "%s" as a source asset. ConvertToTransfer failed. (rule #%d).', [@@ -225,37 +225,37 @@ class ConvertToTransfer implements ActionInterface}/** @var Transaction $sourceTransaction */- $sourceTransaction = Transaction::where('transaction_journal_id', '=', $journal->id)->where('amount', '<', 0)->first();+ $sourceTransaction = Transaction::where('transaction_journal_id', '=', $journal->id)->where('amount', '<', 0)->first();/** @var Transaction $destTransaction */- $destTransaction = Transaction::where('transaction_journal_id', '=', $journal->id)->where('amount', '>', 0)->first();+ $destTransaction = Transaction::where('transaction_journal_id', '=', $journal->id)->where('amount', '>', 0)->first();// update destination transaction:$destTransaction->account_id = $opposing->id;$destTransaction->save();// check if the currencies are a match./** @var TransactionCurrency $sourceCurrency */- $sourceCurrency = $repository->getAccountCurrency($sourceAccount);+ $sourceCurrency = $repository->getAccountCurrency($sourceAccount);/** @var TransactionCurrency $destCurrency */- $destCurrency = $repository->getAccountCurrency($opposing);+ $destCurrency = $repository->getAccountCurrency($opposing);// if the currencies do not match, need to be smart about the involved amounts:if ($sourceCurrency->id !== $destCurrency->id) {Log::debug(sprintf('Accounts have different currencies. Source has %s, dest has %s', $sourceCurrency->code, $destCurrency->code));- $foreignAmount = '' === (string) $sourceTransaction->foreign_amount ? $sourceTransaction->amount : $sourceTransaction->foreign_amount;+ $foreignAmount = '' === (string)$sourceTransaction->foreign_amount ? $sourceTransaction->amount : $sourceTransaction->foreign_amount;Log::debug(sprintf('Foreign amount: %s', $foreignAmount));// source transaction: set the foreign currency ID and leave as is.- $sourceTransaction->foreign_currency_id = $destCurrency->id;- $sourceTransaction->foreign_amount = Steam::negative($foreignAmount);+ $sourceTransaction->foreign_currency_id = $destCurrency->id;+ $sourceTransaction->foreign_amount = Steam::negative($foreignAmount);$sourceTransaction->save();Log::debug(sprintf(- 'Set source transaction #%d foreign currency ID to #%d (amount: %s)',- $sourceTransaction->id,- $destCurrency->id,- $foreignAmount- ));+ 'Set source transaction #%d foreign currency ID to #%d (amount: %s)',+ $sourceTransaction->id,+ $destCurrency->id,+ $foreignAmount+ ));// dest transaction: set reverse amounts and currency IDs from source transaction.$destTransaction->foreign_currency_id = $sourceCurrency->transaction_currency_id;@@ -264,19 +264,19 @@ class ConvertToTransfer implements ActionInterface$destTransaction->foreign_amount = Steam::positive($sourceTransaction->amount);$destTransaction->save();Log::debug(sprintf(- 'Set dest transaction #%d to #%d %s and foreign #%d %s',- $destTransaction->id,- $destTransaction->transaction_currency_id,- $destTransaction->amount,- $destTransaction->foreign_currency_id,- $destTransaction->foreign_amount- ));+ 'Set dest transaction #%d to #%d %s and foreign #%d %s',+ $destTransaction->id,+ $destTransaction->transaction_currency_id,+ $destTransaction->amount,+ $destTransaction->foreign_currency_id,+ $destTransaction->foreign_amount+ ));}// change transaction type of journal:- $newType = TransactionType::whereType(TransactionTypeEnum::TRANSFER->value)->first();+ $newType = TransactionType::whereType(TransactionTypeEnum::TRANSFER->value)->first();- DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);+ DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);Log::debug('Converted withdrawal to transfer.');@@ -319,15 +319,14 @@ class ConvertToTransfer implements ActionInterface// update source transaction:DB::table('transactions')- ->where('transaction_journal_id', '=', $journal->id)- ->where('amount', '<', 0)- ->update(['account_id' => $opposing->id])- ;+ ->where('transaction_journal_id', '=', $journal->id)+ ->where('amount', '<', 0)+ ->update(['account_id' => $opposing->id]);// change transaction type of journal:- $newType = TransactionType::whereType(TransactionTypeEnum::TRANSFER->value)->first();+ $newType = TransactionType::whereType(TransactionTypeEnum::TRANSFER->value)->first();- DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);+ DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);Log::debug('Converted deposit to transfer.');diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.phpindex 76dafbafe5..fe7fbe6242 100644--- a/app/TransactionRules/Actions/ConvertToWithdrawal.php+++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php@@ -27,6 +27,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\AccountFactory;@@ -57,14 +58,14 @@ class ConvertToWithdrawal implements ActionInterface// make object from array (so the data is fresh)./** @var null|TransactionJournal $object */- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);if (null === $object) {Log::error(sprintf('Cannot find journal #%d, cannot convert to withdrawal.', $journal['transaction_journal_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));return false;}- $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();+ $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();if ($groupCount > 1) {Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to withdrawal.', $journal['transaction_group_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group')));@@ -72,7 +73,7 @@ class ConvertToWithdrawal implements ActionInterfacereturn false;}- $type = $object->transactionType->type;+ $type = $object->transactionType->type;if (TransactionTypeEnum::WITHDRAWAL->value === $type) {Log::error(sprintf('Journal #%d is already a withdrawal (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_withdrawal')));@@ -97,7 +98,7 @@ class ConvertToWithdrawal implements ActionInterfacereturn false;}event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($this->action->rule,$object,'update_transaction_type',@@ -121,7 +122,7 @@ class ConvertToWithdrawal implements ActionInterfacereturn false;}event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($this->action->rule,$object,'update_transaction_type',@@ -138,21 +139,21 @@ class ConvertToWithdrawal implements ActionInterface*/private function convertDepositArray(TransactionJournal $journal, string $actionValue = ''): bool{- $user = $journal->user;+ $user = $journal->user;/** @var AccountFactory $factory */- $factory = app(AccountFactory::class);+ $factory = app(AccountFactory::class);$factory->setUser($user);- $repository = app(AccountRepositoryInterface::class);+ $repository = app(AccountRepositoryInterface::class);$repository->setUser($user);- $sourceAccount = $this->getSourceAccount($journal);- $destAccount = $this->getDestinationAccount($journal);+ $sourceAccount = $this->getSourceAccount($journal);+ $destAccount = $this->getDestinationAccount($journal);// get the action value, or use the original source name in case the action value is empty:// this becomes a new or existing (expense) account, which is the destination of the new withdrawal.- $opposingName = '' === $actionValue ? $sourceAccount->name : $actionValue;+ $opposingName = '' === $actionValue ? $sourceAccount->name : $actionValue;// we check all possible source account types if one exists:$validTypes = config('firefly.expected_source_types.destination.Withdrawal');$opposingAccount = $repository->findByName($opposingName, $validTypes);@@ -164,20 +165,18 @@ class ConvertToWithdrawal implements ActionInterface// update source transaction(s) to be the original destination accountDB::table('transactions')- ->where('transaction_journal_id', '=', $journal->id)- ->where('amount', '<', 0)- ->update(['account_id' => $destAccount->id])- ;+ ->where('transaction_journal_id', '=', $journal->id)+ ->where('amount', '<', 0)+ ->update(['account_id' => $destAccount->id]);// update destination transaction(s) to be new expense account.DB::table('transactions')- ->where('transaction_journal_id', '=', $journal->id)- ->where('amount', '>', 0)- ->update(['account_id' => $opposingAccount->id])- ;+ ->where('transaction_journal_id', '=', $journal->id)+ ->where('amount', '>', 0)+ ->update(['account_id' => $opposingAccount->id]);// change transaction type of journal:- $newType = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL->value)->first();+ $newType = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL->value)->first();DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id]);Log::debug('Converted deposit to withdrawal.');@@ -222,20 +221,20 @@ class ConvertToWithdrawal implements ActionInterfaceprivate function convertTransferArray(TransactionJournal $journal, string $actionValue = ''): bool{// find or create expense account.- $user = $journal->user;+ $user = $journal->user;/** @var AccountFactory $factory */- $factory = app(AccountFactory::class);+ $factory = app(AccountFactory::class);$factory->setUser($user);- $repository = app(AccountRepositoryInterface::class);+ $repository = app(AccountRepositoryInterface::class);$repository->setUser($user);- $destAccount = $this->getDestinationAccount($journal);+ $destAccount = $this->getDestinationAccount($journal);// get the action value, or use the original source name in case the action value is empty:// this becomes a new or existing (expense) account, which is the destination of the new withdrawal.- $opposingName = '' === $actionValue ? $destAccount->name : $actionValue;+ $opposingName = '' === $actionValue ? $destAccount->name : $actionValue;// we check all possible source account types if one exists:$validTypes = config('firefly.expected_source_types.destination.Withdrawal');$opposingAccount = $repository->findByName($opposingName, $validTypes);@@ -247,13 +246,12 @@ class ConvertToWithdrawal implements ActionInterface// update destination transaction(s) to be new expense account.DB::table('transactions')- ->where('transaction_journal_id', '=', $journal->id)- ->where('amount', '>', 0)- ->update(['account_id' => $opposingAccount->id])- ;+ ->where('transaction_journal_id', '=', $journal->id)+ ->where('amount', '>', 0)+ ->update(['account_id' => $opposingAccount->id]);// change transaction type of journal:- $newType = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL->value)->first();+ $newType = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL->value)->first();DB::table('transaction_journals')->where('id', '=', $journal->id)->update(['transaction_type_id' => $newType->id]);Log::debug('Converted transfer to withdrawal.');diff --git a/app/TransactionRules/Actions/DeleteTransaction.php b/app/TransactionRules/Actions/DeleteTransaction.phpindex b2ea5ef6c3..23069a831a 100644--- a/app/TransactionRules/Actions/DeleteTransaction.php+++ b/app/TransactionRules/Actions/DeleteTransaction.php@@ -23,7 +23,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionGroup;use FireflyIII\Models\TransactionJournal;@@ -45,30 +45,30 @@ class DeleteTransaction implements ActionInterfacepublic function actOnArray(array $journal): bool{- $count = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();+ $count = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();// destroy entire group.if (1 === $count) {Log::debug(sprintf(- 'RuleAction DeleteTransaction DELETED the entire transaction group of journal #%d ("%s").',- $journal['transaction_journal_id'],- $journal['description']- ));+ 'RuleAction DeleteTransaction DELETED the entire transaction group of journal #%d ("%s").',+ $journal['transaction_journal_id'],+ $journal['description']+ ));/** @var TransactionGroup $group */$group = TransactionGroup::find($journal['transaction_group_id']);$service = app(TransactionGroupDestroyService::class);$service->destroy($group);- event(new TriggeredAuditLog($this->action->rule, $group, 'delete_group', null, null));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $group, 'delete_group', null, null));return true;}Log::debug(sprintf(- 'RuleAction DeleteTransaction DELETED transaction journal #%d ("%s").',- $journal['transaction_journal_id'],- $journal['description']- ));+ 'RuleAction DeleteTransaction DELETED transaction journal #%d ("%s").',+ $journal['transaction_journal_id'],+ $journal['description']+ ));// trigger delete factory:/** @var null|TransactionJournal $object */@@ -77,7 +77,7 @@ class DeleteTransaction implements ActionInterface/** @var JournalDestroyService $service */$service = app(JournalDestroyService::class);$service->destroy($object);- event(new TriggeredAuditLog($this->action->rule, $object, 'delete_journal', null, null));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'delete_journal', null, null));}return true;diff --git a/app/TransactionRules/Actions/LinkToBill.php b/app/TransactionRules/Actions/LinkToBill.phpindex 81fa51fe95..04a8df5f70 100644--- a/app/TransactionRules/Actions/LinkToBill.php+++ b/app/TransactionRules/Actions/LinkToBill.php@@ -25,6 +25,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -87,7 +88,7 @@ class LinkToBill implements ActionInterface/** @var TransactionJournal $object */$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- event(new TriggeredAuditLog($this->action->rule, $object, 'set_bill', null, $bill->name));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_bill', null, $bill->name));return true;}diff --git a/app/TransactionRules/Actions/MoveDescriptionToNotes.php b/app/TransactionRules/Actions/MoveDescriptionToNotes.phpindex 07fa960342..e212a50c24 100644--- a/app/TransactionRules/Actions/MoveDescriptionToNotes.php+++ b/app/TransactionRules/Actions/MoveDescriptionToNotes.php@@ -25,7 +25,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\Note;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -47,7 +47,7 @@ class MoveDescriptionToNotes implements ActionInterfacepublic function actOnArray(array $journal): bool{/** @var null|TransactionJournal $object */- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);if (null === $object) {Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user')));@@ -56,9 +56,9 @@ class MoveDescriptionToNotes implements ActionInterface}/** @var null|Note $note */- $note = $object->notes()->first();+ $note = $object->notes()->first();if (null === $note) {- $note = new Note();+ $note = new Note();$note->noteable()->associate($object);$note->text = '';}@@ -69,13 +69,13 @@ class MoveDescriptionToNotes implements ActionInterface$object->description = '(no description)';}if ('' === $note->text) {- $note->text = (string) $object->description;+ $note->text = (string)$object->description;$object->description = '(no description)';}- $after = $note->text;+ $after = $note->text;- event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $beforeDescription, $object->description));- event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $after));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_description', $beforeDescription, $object->description));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_notes', $before, $after));$note->save();$object->save();diff --git a/app/TransactionRules/Actions/MoveNotesToDescription.php b/app/TransactionRules/Actions/MoveNotesToDescription.phpindex 5ecbbec54b..3da34352b0 100644--- a/app/TransactionRules/Actions/MoveNotesToDescription.php+++ b/app/TransactionRules/Actions/MoveNotesToDescription.php@@ -25,7 +25,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;use FireflyIII\Support\Request\ConvertsDataTypes;@@ -53,14 +53,14 @@ class MoveNotesToDescription implements ActionInterfacepublic function actOnArray(array $journal): bool{/** @var null|TransactionJournal $object */- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);if (null === $object) {Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user')));return false;}- $note = $object->notes()->first();+ $note = $object->notes()->first();if (null === $note) {event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_notes_to_move')));@@ -76,12 +76,12 @@ class MoveNotesToDescription implements ActionInterface}$before = $object->description;$beforeNote = $note->text;- $object->description = (string) $this->clearString($note->text);+ $object->description = (string)$this->clearString($note->text);$object->save();$note->delete();- event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $before, $object->description));- event(new TriggeredAuditLog($this->action->rule, $object, 'clear_notes', $beforeNote, null));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_description', $before, $object->description));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'clear_notes', $beforeNote, null));return true;}diff --git a/app/TransactionRules/Actions/PrependDescription.php b/app/TransactionRules/Actions/PrependDescription.phpindex 92f2492838..0f7daf5b8f 100644--- a/app/TransactionRules/Actions/PrependDescription.php+++ b/app/TransactionRules/Actions/PrependDescription.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -56,7 +57,7 @@ class PrependDescription implements ActionInterface$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);// audit log- event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $before, $after));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_description', $before, $after));return true;}diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.phpindex 00605ba954..674c975998 100644--- a/app/TransactionRules/Actions/PrependNotes.php+++ b/app/TransactionRules/Actions/PrependNotes.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\Note;use FireflyIII\Models\RuleAction;@@ -63,7 +64,7 @@ class PrependNotes implements ActionInterface$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);// audit log- event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $before, $text));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_notes', $before, $text));return true;}diff --git a/app/TransactionRules/Actions/RemoveAllTags.php b/app/TransactionRules/Actions/RemoveAllTags.phpindex d71ed16877..a00eaa3b62 100644--- a/app/TransactionRules/Actions/RemoveAllTags.php+++ b/app/TransactionRules/Actions/RemoveAllTags.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -58,7 +59,7 @@ class RemoveAllTags implements ActionInterface$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);// audit log- event(new TriggeredAuditLog($this->action->rule, $object, 'clear_all_tags', null, null));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'clear_all_tags', null, null));return true;}diff --git a/app/TransactionRules/Actions/RemoveTag.php b/app/TransactionRules/Actions/RemoveTag.phpindex f88e68cded..111ca91ecd 100644--- a/app/TransactionRules/Actions/RemoveTag.php+++ b/app/TransactionRules/Actions/RemoveTag.php@@ -24,7 +24,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;use FireflyIII\User;@@ -45,34 +45,33 @@ class RemoveTag implements ActionInterfacepublic function actOnArray(array $journal): bool{- $name = $this->action->getValue($journal);+ $name = $this->action->getValue($journal);/** @var User $user */- $user = User::find($journal['user_id']);- $tag = $user->tags()->where('tag', $name)->first();+ $user = User::find($journal['user_id']);+ $tag = $user->tags()->where('tag', $name)->first();// if tag does not exist, no need to continue:if (null === $tag) {Log::debug(sprintf(- 'RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag exists.',- $name,- $journal['transaction_journal_id']- ));+ 'RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag exists.',+ $name,+ $journal['transaction_journal_id']+ ));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_tag', ['tag' => $name])));return false;}- $count = DB::table('tag_transaction_journal')- ->where('transaction_journal_id', $journal['transaction_journal_id'])- ->where('tag_id', $tag->id)- ->count()- ;+ $count = DB::table('tag_transaction_journal')+ ->where('transaction_journal_id', $journal['transaction_journal_id'])+ ->where('tag_id', $tag->id)+ ->count();if (0 === $count) {Log::debug(sprintf(- 'RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag is linked.',- $name,- $journal['transaction_journal_id']- ));+ 'RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag is linked.',+ $name,+ $journal['transaction_journal_id']+ ));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_unlink_tag', ['tag' => $name])));return false;@@ -80,14 +79,13 @@ class RemoveTag implements ActionInterfaceLog::debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal['transaction_journal_id']));DB::table('tag_transaction_journal')- ->where('transaction_journal_id', $journal['transaction_journal_id'])- ->where('tag_id', $tag->id)- ->delete()- ;+ ->where('transaction_journal_id', $journal['transaction_journal_id'])+ ->where('tag_id', $tag->id)+ ->delete();/** @var TransactionJournal $object */$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- event(new TriggeredAuditLog($this->action->rule, $object, 'clear_tag', $tag->tag, null));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'clear_tag', $tag->tag, null));return true;}diff --git a/app/TransactionRules/Actions/SetAmount.php b/app/TransactionRules/Actions/SetAmount.phpindex 26ba8c4443..90bee390fd 100644--- a/app/TransactionRules/Actions/SetAmount.php+++ b/app/TransactionRules/Actions/SetAmount.php@@ -25,6 +25,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\Transaction;@@ -79,7 +80,7 @@ class SetAmount implements ActionInterface// event for audit log entryif (0 !== bccomp($journal['amount'], $value)) {event(- new TriggeredAuditLog(+ new TransactionGroupRequestsAuditLogEntry($this->action->rule,$object,'update_amount',diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.phpindex e040619d6d..12d7a32070 100644--- a/app/TransactionRules/Actions/SetBudget.php+++ b/app/TransactionRules/Actions/SetBudget.php@@ -25,6 +25,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -103,7 +104,7 @@ class SetBudget implements ActionInterface/** @var TransactionJournal $object */$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- event(new TriggeredAuditLog($this->action->rule, $object, 'set_budget', $oldBudgetName, $budget->name));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_budget', $oldBudgetName, $budget->name));return true;}diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.phpindex 3673bc962b..d91f539638 100644--- a/app/TransactionRules/Actions/SetCategory.php+++ b/app/TransactionRules/Actions/SetCategory.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Factory\CategoryFactory;use FireflyIII\Models\RuleAction;@@ -97,7 +98,7 @@ class SetCategory implements ActionInterface/** @var TransactionJournal $object */$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- event(new TriggeredAuditLog($this->action->rule, $object, 'set_category', $oldCategoryName, $category->name));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_category', $oldCategoryName, $category->name));return true;}diff --git a/app/TransactionRules/Actions/SetDescription.php b/app/TransactionRules/Actions/SetDescription.phpindex 9c2f5f2124..939f133ea6 100644--- a/app/TransactionRules/Actions/SetDescription.php+++ b/app/TransactionRules/Actions/SetDescription.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\TransactionJournal;@@ -70,7 +71,7 @@ class SetDescription implements ActionInterface$after));$object->refresh();- event(new TriggeredAuditLog($this->action->rule, $object, 'update_description', $before, $after));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_description', $before, $after));return true;}diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.phpindex 14704cdf67..a46695e756 100644--- a/app/TransactionRules/Actions/SetDestinationAccount.php+++ b/app/TransactionRules/Actions/SetDestinationAccount.php@@ -25,6 +25,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\Account;use FireflyIII\Models\RuleAction;@@ -121,7 +122,7 @@ class SetDestinationAccount implements ActionInterfaceLog::debug(sprintf('New destination account is #%d ("%s").', $newAccount->id, $newAccount->name));- event(new TriggeredAuditLog($this->action->rule, $object, 'set_destination', null, $newAccount->name));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_destination', null, $newAccount->name));// update destination transaction with new destination account:DB::table('transactions')diff --git a/app/TransactionRules/Actions/SetDestinationToCashAccount.php b/app/TransactionRules/Actions/SetDestinationToCashAccount.phpindex 2c69b6f52a..822481c429 100644--- a/app/TransactionRules/Actions/SetDestinationToCashAccount.php+++ b/app/TransactionRules/Actions/SetDestinationToCashAccount.php@@ -26,6 +26,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\Transaction;@@ -102,7 +103,7 @@ class SetDestinationToCashAccount implements ActionInterfacereturn false;}- event(new TriggeredAuditLog($this->action->rule, $object, 'set_destination', null, $cashAccount->name));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_destination', null, $cashAccount->name));// update destination transaction with new destination account:DB::table('transactions')diff --git a/app/TransactionRules/Actions/SetNotes.php b/app/TransactionRules/Actions/SetNotes.phpindex f6501c3a3b..d3702e72fd 100644--- a/app/TransactionRules/Actions/SetNotes.php+++ b/app/TransactionRules/Actions/SetNotes.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\Note;use FireflyIII\Models\RuleAction;@@ -65,7 +66,7 @@ class SetNotes implements ActionInterface/** @var TransactionJournal $object */$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);- event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $oldNotes, $newNotes));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_notes', $oldNotes, $newNotes));return true;}diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.phpindex 570978b8aa..92a5e372a8 100644--- a/app/TransactionRules/Actions/SetSourceAccount.php+++ b/app/TransactionRules/Actions/SetSourceAccount.php@@ -25,6 +25,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\Account;use FireflyIII\Models\RuleAction;@@ -119,7 +120,7 @@ class SetSourceAccount implements ActionInterface->update(['account_id' => $newAccount->id]);- event(new TriggeredAuditLog($this->action->rule, $object, 'set_source', null, $newAccount->name));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_source', null, $newAccount->name));Log::debug(sprintf('Updated journal #%d (group #%d) and gave it new source account ID.', $object->id, $object->transaction_group_id));diff --git a/app/TransactionRules/Actions/SetSourceToCashAccount.php b/app/TransactionRules/Actions/SetSourceToCashAccount.phpindex 3387560d42..412fcabd36 100644--- a/app/TransactionRules/Actions/SetSourceToCashAccount.php+++ b/app/TransactionRules/Actions/SetSourceToCashAccount.php@@ -26,6 +26,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\Transaction;@@ -102,7 +103,7 @@ class SetSourceToCashAccount implements ActionInterfacereturn false;}- event(new TriggeredAuditLog($this->action->rule, $object, 'set_source', null, $cashAccount->name));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_source', null, $cashAccount->name));// update destination transaction with new destination account:DB::table('transactions')diff --git a/app/TransactionRules/Actions/SwitchAccounts.php b/app/TransactionRules/Actions/SwitchAccounts.phpindex df2c84bc47..9e3f1e0a28 100644--- a/app/TransactionRules/Actions/SwitchAccounts.php+++ b/app/TransactionRules/Actions/SwitchAccounts.php@@ -26,6 +26,7 @@ namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Events\TriggeredAuditLog;use FireflyIII\Models\RuleAction;use FireflyIII\Models\Transaction;@@ -97,7 +98,7 @@ class SwitchAccounts implements ActionInterface$sourceTransaction->save();$destTransaction->save();- event(new TriggeredAuditLog($this->action->rule, $object, 'switch_accounts', $sourceAccountId, $destinationAccountId));+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'switch_accounts', $sourceAccountId, $destinationAccountId));return true;}diff --git a/app/TransactionRules/Actions/UpdatePiggyBank.php b/app/TransactionRules/Actions/UpdatePiggyBank.phpindex a13d30ded4..eb05867445 100644--- a/app/TransactionRules/Actions/UpdatePiggyBank.php+++ b/app/TransactionRules/Actions/UpdatePiggyBank.php@@ -25,7 +25,7 @@ declare(strict_types=1);namespace FireflyIII\TransactionRules\Actions;use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;-use FireflyIII\Events\TriggeredAuditLog;+use FireflyIII\Events\Model\TransactionGroup\TransactionGroupRequestsAuditLogEntry;use FireflyIII\Models\Account;use FireflyIII\Models\PiggyBank;use FireflyIII\Models\RuleAction;@@ -54,12 +54,12 @@ class UpdatePiggyBank implements ActionInterface// refresh the transaction type./** @var User $user */- $user = User::find($journal['user_id']);+ $user = User::find($journal['user_id']);/** @var TransactionJournal $journalObj */- $journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']);+ $journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']);- $piggyBank = $this->findPiggyBank($user, $actionValue);+ $piggyBank = $this->findPiggyBank($user, $actionValue);if (!$piggyBank instanceof PiggyBank) {Log::info(sprintf('No piggy bank named "%s", cant execute action #%d of rule #%d', $actionValue, $this->action->id, $this->action->rule_id));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_piggy', ['name' => $actionValue])));@@ -72,11 +72,11 @@ class UpdatePiggyBank implements ActionInterface// piggy bank already has an event for this transaction journal?if ($this->alreadyEventPresent($piggyBank, $journal)) {Log::info(sprintf(- 'Piggy bank #%d ("%s") already has an event for transaction journal #%d, so no action will be taken.',- $piggyBank->id,- $piggyBank->name,- $journalObj->id- ));+ 'Piggy bank #%d ("%s") already has an event for transaction journal #%d, so no action will be taken.',+ $piggyBank->id,+ $piggyBank->name,+ $journalObj->id+ ));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_piggy', ['name' => $actionValue])));@@ -86,7 +86,7 @@ class UpdatePiggyBank implements ActionInterface/** @var Transaction $destination */$destination = $journalObj->transactions()->where('amount', '>', 0)->first();- $accounts = $this->getAccounts($journalObj);+ $accounts = $this->getAccounts($journalObj);Log::debug(sprintf('Source account is #%d: "%s"', $accounts['source']->id, $accounts['source']->name));Log::debug(sprintf('Destination account is #%d: "%s"', $accounts['destination']->id, $accounts['source']->name));@@ -94,7 +94,7 @@ class UpdatePiggyBank implements ActionInterfaceif ($this->isConnected($piggyBank, $accounts['source']) && !$this->isConnected($piggyBank, $accounts['destination'])) {Log::debug('Piggy bank account is linked to source, so remove amount from piggy bank.');$this->removeAmount($piggyBank, $journal, $journalObj, $accounts['source'], $destination->amount);- event(new TriggeredAuditLog($this->action->rule, $journalObj, 'remove_from_piggy', null, [+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $journalObj, 'remove_from_piggy', null, ['currency_symbol' => $journalObj->transactionCurrency->symbol,'decimal_places' => $journalObj->transactionCurrency->decimal_places,'amount' => $destination->amount,@@ -109,7 +109,7 @@ class UpdatePiggyBank implements ActionInterfaceLog::debug('Piggy bank account is linked to source, so add amount to piggy bank.');$this->addAmount($piggyBank, $journal, $journalObj, $accounts['destination'], $destination->amount);- event(new TriggeredAuditLog($this->action->rule, $journalObj, 'add_to_piggy', null, [+ event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $journalObj, 'add_to_piggy', null, ['currency_symbol' => $journalObj->transactionCurrency->symbol,'decimal_places' => $journalObj->transactionCurrency->decimal_places,'amount' => $destination->amount,@@ -121,19 +121,19 @@ class UpdatePiggyBank implements ActionInterface}if ($this->isConnected($piggyBank, $accounts['source']) && $this->isConnected($piggyBank, $accounts['destination'])) {Log::info(sprintf(- 'Piggy bank is linked to BOTH source ("#%d") and destination ("#%d"), so no action will be taken.',- $accounts['source']->id,- $accounts['destination']->id- ));+ 'Piggy bank is linked to BOTH source ("#%d") and destination ("#%d"), so no action will be taken.',+ $accounts['source']->id,+ $accounts['destination']->id+ ));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_link_piggy', ['name' => $actionValue])));return false;}Log::info(sprintf(- 'Piggy bank is not linked to source ("#%d") or destination ("#%d"), so no action will be taken.',- $accounts['source']->id,- $accounts['destination']->id- ));+ 'Piggy bank is not linked to source ("#%d") or destination ("#%d"), so no action will be taken.',+ $accounts['source']->id,+ $accounts['destination']->id+ ));event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_link_piggy', ['name' => $actionValue])));return false;@@ -179,11 +179,11 @@ class UpdatePiggyBank implements ActionInterface$accountRepository->setUser($account->user);// how much can we remove from this piggy bank?- $toRemove = $repository->getCurrentAmount($piggyBank, $account);+ $toRemove = $repository->getCurrentAmount($piggyBank, $account);Log::debug(sprintf('Amount is %s, max to remove is %s', $amount, $toRemove));// if $amount is bigger than $toRemove, shrink it.- $amount = -1 === bccomp($amount, $toRemove) ? $amount : $toRemove;+ $amount = -1 === bccomp($amount, $toRemove) ? $amount : $toRemove;Log::debug(sprintf('Amount is now %s', $amount));// if amount is zero, stop.@@ -218,7 +218,7 @@ class UpdatePiggyBank implements ActionInterface// how much can we add to the piggy bank?if (0 !== bccomp($piggyBank->target_amount, '0')) {- $toAdd = bcsub($piggyBank->target_amount, $repository->getCurrentAmount($piggyBank, $account));+ $toAdd = bcsub($piggyBank->target_amount, $repository->getCurrentAmount($piggyBank, $account));Log::debug(sprintf('Max amount to add to piggy bank is %s, amount is %s', $toAdd, $amount));// update amount to fit: