Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix #10990
James Cole87d3d1450492
diff --git a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.phpindex 94a6d2e022..ba53793505 100644--- a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php+++ b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php@@ -68,10 +68,6 @@ class UpdateController extends Controller$data = $request->getAll();$piggyBank = $this->repository->update($piggyBank, $data);- if (array_key_exists('current_amount', $data) && '' !== $data['current_amount']) {- $this->repository->setCurrentAmount($piggyBank, $data['current_amount']);- }-// enrich/** @var User $admin */$admin = auth()->user();diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.phpindex 7a2d0a7be4..023a48169e 100644--- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php@@ -64,7 +64,7 @@ class UpdateRequest extends FormRequest*/public function getAll(): array{- app('log')->debug(sprintf('Now in %s', __METHOD__));+ Log::debug(sprintf('Now in %s', __METHOD__));$this->integerFields = ['order', 'currency_id', 'foreign_currency_id', 'transaction_journal_id', 'source_id', 'destination_id', 'budget_id', 'category_id', 'bill_id', 'recurrence_id'];$this->dateFields = ['date', 'interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];$this->textareaFields = ['notes'];@@ -97,7 +97,7 @@ class UpdateRequest extends FormRequest*/private function getTransactionData(): array{- app('log')->debug(sprintf('Now in %s', __METHOD__));+ Log::debug(sprintf('Now in %s', __METHOD__));$return = [];/** @var null|array $transactions */@@ -181,7 +181,7 @@ class UpdateRequest extends FormRequestprivate function getDateData(array $current, array $transaction): array{foreach ($this->dateFields as $fieldName) {- app('log')->debug(sprintf('Now at date field %s', $fieldName));+ Log::debug(sprintf('Now at date field %s', $fieldName));if (array_key_exists($fieldName, $transaction)) {Log::debug(sprintf('New value: "%s"', $transaction[$fieldName]));$current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]);@@ -247,7 +247,7 @@ class UpdateRequest extends FormRequest*/public function rules(): array{- app('log')->debug(sprintf('Now in %s', __METHOD__));+ Log::debug(sprintf('Now in %s', __METHOD__));$validProtocols = config('firefly.valid_url_protocols');return [@@ -330,7 +330,7 @@ class UpdateRequest extends FormRequest*/public function withValidator(Validator $validator): void{- app('log')->debug('Now in withValidator');+ Log::debug('Now in withValidator');/** @var TransactionGroup $transactionGroup */$transactionGroup = $this->route()->parameter('transactionGroup');diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.phpindex 40455001d3..bc6b9f9f8a 100644--- a/app/Factory/PiggyBankFactory.php+++ b/app/Factory/PiggyBankFactory.php@@ -242,7 +242,7 @@ class PiggyBankFactory}}}-+ Log::debug('Looping all accounts.');/** @var array $info */foreach ($accounts as $info) {$account = $this->accountRepository->find((int)($info['account_id'] ?? 0));@@ -251,6 +251,7 @@ class PiggyBankFactorycontinue;}+ Log::debug(sprintf('Working on account #%d', $account->id));if (array_key_exists('current_amount', $info) && null !== $info['current_amount']) {// an amount is set, first check out if there is a difference with the previous amount.$previous = $toBeLinked[$account->id]['current_amount'] ?? '0';@@ -258,22 +259,24 @@ class PiggyBankFactory// create event for difference.if (0 !== bccomp($diff, '0')) {+ // 2025-10-01 for issue #10990 disable this event.Log::debug(sprintf('[a] Will save event for difference %s (previous value was %s)', $diff, $previous));- event(new ChangedAmount($piggyBank, $diff, null, null));+ // event(new ChangedAmount($piggyBank, $diff, null, null));}$toBeLinked[$account->id] = ['current_amount' => $info['current_amount']];Log::debug(sprintf('[a] Will link account #%d with amount %s', $account->id, $info['current_amount']));}if (array_key_exists('current_amount', $info) && null === $info['current_amount']) {- // an amount is set, first check out if there is a difference with the previous amount.+ // no amount is set, first check out if there is a difference with the previous amount.$previous = $toBeLinked[$account->id]['current_amount'] ?? '0';$diff = bcsub('0', $previous);// create event for difference.if (0 !== bccomp($diff, '0')) {+ // 2025-10-01 for issue #10990 disable this event.Log::debug(sprintf('[b] Will save event for difference %s (previous value was %s)', $diff, $previous));- event(new ChangedAmount($piggyBank, $diff, null, null));+ // event(new ChangedAmount($piggyBank, $diff, null, null));}// no amount set, use previous amount or go to ZERO.@@ -282,7 +285,8 @@ class PiggyBankFactory// create event:Log::debug('linkToAccountIds: Trigger change for positive amount [b].');- event(new ChangedAmount($piggyBank, $toBeLinked[$account->id]['current_amount'] ?? '0', null, null));+ // 2025-10-01 for issue #10990 disable this event.+ // event(new ChangedAmount($piggyBank, $toBeLinked[$account->id]['current_amount'] ?? '0', null, null));}if (!array_key_exists('current_amount', $info)) {$toBeLinked[$account->id] ??= [];diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.phpindex e63da28927..734cfe8b0f 100644--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php@@ -36,6 +36,7 @@ use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionJournal;use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups;use FireflyIII\Support\Facades\Amount;+use FireflyIII\Support\Facades\Steam;use FireflyIII\Support\Http\Api\ExchangeRateConverter;use Illuminate\Support\Facades\Log;@@ -227,7 +228,6 @@ trait ModifiesPiggyBanks$factory->user = $this->user;// the piggy bank currency is set or updated FIRST, if it exists.-$factory->linkToAccountIds($piggyBank, $data['accounts'] ?? []);@@ -244,7 +244,7 @@ trait ModifiesPiggyBanks// question is, from which account(s) to remove the difference?// solution: just start from the top until there is no more money left to remove.- $this->removeAmountFromAll($piggyBank, app('steam')->positive($difference));+ $this->removeAmountFromAll($piggyBank, Steam::positive($difference));}// update using name: