diff --git a/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php b/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php index b273a4e5b8..94028f001f 100644 --- a/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php +++ b/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php @@ -63,28 +63,28 @@ class TriggerController extends Controller { // find recurrence occurrence for this date and trigger it. // grab the date from the last time the recurrence fired: - $backupDate = $recurrence->latest_date; - $date = $request->getDate(); + $backupDate = $recurrence->latest_date; + $date = $request->getDate(); // fire the recurring cron job on the given date, then post-date the created transaction. Log::info(sprintf('Trigger: will now fire recurring cron job task for date "%s".', $date->format('Y-m-d H:i:s'))); /** @var CreateRecurringTransactions $job */ - $job = app(CreateRecurringTransactions::class); + $job = app(CreateRecurringTransactions::class); $job->setRecurrences(new Collection()->push($recurrence)); $job->setDate($date); $job->setForce(false); $job->handle(); Log::debug('Done with recurrence.'); - $groups = $job->getGroups(); + $groups = $job->getGroups(); $this->repository->markGroupsAsNow($groups); - $recurrence = $this->repository->setLatestDate($recurrence, $backupDate); + $recurrence = $this->repository->setLatestDate($recurrence, $backupDate); Preferences::mark(); // enrich groups and return them: - $paginator = new LengthAwarePaginator(new Collection(), 0, 1); + $paginator = new LengthAwarePaginator(new Collection(), 0, 1); if ($groups->count() > 0) { /** @var User $admin */ $admin = auth()->user(); @@ -96,20 +96,20 @@ class TriggerController extends Controller $paginator = $collector->getPaginatedGroups(); } - $manager = $this->getManager(); + $manager = $this->getManager(); $paginator->setPath(route('api.v1.recurrences.trigger', [$recurrence->id]).$this->buildParams()); // enrich - $admin = auth()->user(); - $enrichment = new TransactionGroupEnrichment(); + $admin = auth()->user(); + $enrichment = new TransactionGroupEnrichment(); $enrichment->setUser($admin); - $transactions = $enrichment->enrich($paginator->getCollection()); + $transactions = $enrichment->enrich($paginator->getCollection()); /** @var TransactionGroupTransformer $transformer */ - $transformer = app(TransactionGroupTransformer::class); + $transformer = app(TransactionGroupTransformer::class); $transformer->setParameters($this->parameters); - $resource = new FractalCollection($transactions, $transformer, 'transactions'); + $resource = new FractalCollection($transactions, $transformer, 'transactions'); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); diff --git a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php index fba49b20bc..6e79d27c5a 100644 --- a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php +++ b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php @@ -55,7 +55,7 @@ class UpdateController extends Controller parent::__construct(); $this->middleware(function ($request, $next) { /** @var User $admin */ - $admin = auth()->user(); + $admin = auth()->user(); $this->groupRepository = app(TransactionGroupRepositoryInterface::class); $this->groupRepository->setUser($admin); @@ -73,16 +73,16 @@ class UpdateController extends Controller public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse { Log::debug('Now in update routine for transaction group'); - $data = $request->getAll(); - $oldHash = $this->groupRepository->getCompareHash($transactionGroup); - $transactionGroup = $this->groupRepository->update($transactionGroup, $data); - $newHash = $this->groupRepository->getCompareHash($transactionGroup); - $manager = $this->getManager(); + $data = $request->getAll(); + $oldHash = $this->groupRepository->getCompareHash($transactionGroup); + $transactionGroup = $this->groupRepository->update($transactionGroup, $data); + $newHash = $this->groupRepository->getCompareHash($transactionGroup); + $manager = $this->getManager(); Preferences::mark(); - $applyRules = $data['apply_rules'] ?? true; - $fireWebhooks = $data['fire_webhooks'] ?? true; - $runRecalculations = $oldHash !== $newHash; + $applyRules = $data['apply_rules'] ?? true; + $fireWebhooks = $data['fire_webhooks'] ?? true; + $runRecalculations = $oldHash !== $newHash; $flags = new TransactionGroupEventFlags(); $flags->applyRules = $applyRules; @@ -91,32 +91,33 @@ class UpdateController extends Controller event(new UpdatedSingleTransactionGroup($transactionGroup, $flags)); /** @var User $admin */ - $admin = auth()->user(); + $admin = auth()->user(); // use new group collector: /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector ->setUser($admin) // filter on transaction group. ->setTransactionGroup($transactionGroup) // all info needed for the API: - ->withAPIInformation(); + ->withAPIInformation() + ; - $selectedGroup = $collector->getGroups()->first(); + $selectedGroup = $collector->getGroups()->first(); if (null === $selectedGroup) { throw new NotFoundHttpException(); } // enrich - $enrichment = new TransactionGroupEnrichment(); + $enrichment = new TransactionGroupEnrichment(); $enrichment->setUser($admin); - $selectedGroup = $enrichment->enrichSingle($selectedGroup); + $selectedGroup = $enrichment->enrichSingle($selectedGroup); /** @var TransactionGroupTransformer $transformer */ - $transformer = app(TransactionGroupTransformer::class); + $transformer = app(TransactionGroupTransformer::class); $transformer->setParameters($this->parameters); - $resource = new Item($selectedGroup, $transformer, 'transactions'); + $resource = new Item($selectedGroup, $transformer, 'transactions'); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); } diff --git a/app/Api/V1/Controllers/System/BatchController.php b/app/Api/V1/Controllers/System/BatchController.php index e0a693e726..1eb48d4b6a 100644 --- a/app/Api/V1/Controllers/System/BatchController.php +++ b/app/Api/V1/Controllers/System/BatchController.php @@ -52,14 +52,14 @@ class BatchController extends Controller public function finishBatch(Request $request): JsonResponse { - $journals = $this->repository->getUncompletedJournals(); + $journals = $this->repository->getUncompletedJournals(); if (0 === count($journals)) { return response()->json([], 204); } /** @var TransactionJournal $first */ - $first = $journals->first(); - $group = $first?->transactionGroup; + $first = $journals->first(); + $group = $first?->transactionGroup; if (null === $group) { return response()->json([], 204); } diff --git a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php index 3b9437a18a..14362aaef2 100644 --- a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php +++ b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php @@ -90,12 +90,12 @@ class StoreRequest extends FormRequest if (0 !== count($validator->failed())) { return; } - $data = $validator->getData(); + $data = $validator->getData(); // if no currency has been provided, use the user's default currency: /** @var TransactionCurrencyFactory $factory */ - $factory = app(TransactionCurrencyFactory::class); - $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null); + $factory = app(TransactionCurrencyFactory::class); + $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null); if (null === $currency) { $currency = Amount::getPrimaryCurrency(); } @@ -103,11 +103,11 @@ class StoreRequest extends FormRequest $repository->enable($currency); // validator already concluded start and end are valid dates: - $start = Carbon::parse($data['start'], config('app.timezone')); - $end = Carbon::parse($data['end'], config('app.timezone')); + $start = Carbon::parse($data['start'], config('app.timezone')); + $end = Carbon::parse($data['end'], config('app.timezone')); // find limit with same date range and currency. - $limit = $budget + $limit = $budget ->budgetlimits() ->where('budget_limits.start_date', $start->format('Y-m-d')) ->where('budget_limits.end_date', $end->format('Y-m-d')) diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.php index 021a466cbe..9f8dfdd441 100644 --- a/app/Console/Commands/Correction/CorrectsAmounts.php +++ b/app/Console/Commands/Correction/CorrectsAmounts.php @@ -58,7 +58,7 @@ class CorrectsAmounts extends Command public function handle(): int { - $this->service = new JournalDestroyService(); + $this->service = new JournalDestroyService(); $this->genericService = new GenericDestroyService(); // transfers must not have foreign currency info if both accounts have the same currency. $this->correctTransfers(); diff --git a/app/Console/Commands/Correction/CorrectsCurrencies.php b/app/Console/Commands/Correction/CorrectsCurrencies.php index 3c15075b55..ba2fcf776e 100644 --- a/app/Console/Commands/Correction/CorrectsCurrencies.php +++ b/app/Console/Commands/Correction/CorrectsCurrencies.php @@ -74,7 +74,8 @@ class CorrectsCurrencies extends Command ->where('accounts.user_group_id', $userGroup->id) ->where('account_meta.name', 'currency_id') ->groupBy('data') - ->get(['data']); + ->get(['data']) + ; foreach ($meta as $entry) { $found[] = (int) $entry->data; } diff --git a/app/Console/Commands/Correction/CorrectsGroupAccounts.php b/app/Console/Commands/Correction/CorrectsGroupAccounts.php index 57d078ac3a..6db8df460a 100644 --- a/app/Console/Commands/Correction/CorrectsGroupAccounts.php +++ b/app/Console/Commands/Correction/CorrectsGroupAccounts.php @@ -49,8 +49,8 @@ class CorrectsGroupAccounts extends Command /** @var TransactionJournal $journal */ foreach ($res as $journal) { - if ((int)$journal->the_count > 1) { - $groups[] = (int)$journal->transaction_group_id; + if ((int) $journal->the_count > 1) { + $groups[] = (int) $journal->transaction_group_id; } } foreach ($groups as $groupId) { diff --git a/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php b/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php index 28f7a700c0..21466c9cda 100644 --- a/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php +++ b/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php @@ -25,29 +25,9 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Correction; use FireflyIII\Console\Commands\ShowsFriendlyMessages; -use FireflyIII\Handlers\Observer\TransactionObserver; -use FireflyIII\Models\Account; -use FireflyIII\Models\AutoBudget; -use FireflyIII\Models\AvailableBudget; -use FireflyIII\Models\Bill; -use FireflyIII\Models\Budget; -use FireflyIII\Models\BudgetLimit; -use FireflyIII\Models\PiggyBank; -use FireflyIII\Models\PiggyBankEvent; -use FireflyIII\Models\Transaction; -use FireflyIII\Models\TransactionCurrency; -use FireflyIII\Models\UserGroup; -use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; -use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface; use FireflyIII\Services\Internal\Recalculate\PrimaryAmountRecalculationService; -use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Facades\FireflyConfig; -use FireflyIII\Support\Facades\Preferences; -use FireflyIII\Support\Http\Api\ExchangeRateConverter; use Illuminate\Console\Command; -use Illuminate\Database\Eloquent\Builder as EloquentBuilder; -use Illuminate\Database\Query\Builder as DatabaseBuilder; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class CorrectsPrimaryCurrencyAmounts extends Command @@ -78,6 +58,4 @@ class CorrectsPrimaryCurrencyAmounts extends Command return 0; } - - } diff --git a/app/Events/Model/TransactionGroup/DestroyedSingleTransactionGroup.php b/app/Events/Model/TransactionGroup/DestroyedSingleTransactionGroup.php index 6ee5c7143d..936ea39a18 100644 --- a/app/Events/Model/TransactionGroup/DestroyedSingleTransactionGroup.php +++ b/app/Events/Model/TransactionGroup/DestroyedSingleTransactionGroup.php @@ -1,4 +1,7 @@ $row) { $row['batch_submission'] = $batchSubmission; Log::debug(sprintf('Now creating journal %d/%d', $index + 1, count($transactions))); - $journal = $this->createJournal(new NullArrayObject($row)); + $journal = $this->createJournal(new NullArrayObject($row)); if ($journal instanceof TransactionJournal) { $collection->push($journal); } @@ -166,18 +167,18 @@ class TransactionJournalFactory $this->errorIfDuplicate($row['import_hash_v2']); // Some basic fields - $type = $this->typeRepository->findTransactionType(null, $row['type']); - $carbon = $row['date'] ?? today(config('app.timezone')); - $order = $row['order'] ?? 0; + $type = $this->typeRepository->findTransactionType(null, $row['type']); + $carbon = $row['date'] ?? today(config('app.timezone')); + $order = $row['order'] ?? 0; Log::debug('Find currency or return default.'); - $currency = $this->currencyRepository->findCurrency((int)$row['currency_id'], $row['currency_code']); + $currency = $this->currencyRepository->findCurrency((int) $row['currency_id'], $row['currency_code']); Log::debug('Find foreign currency or return NULL.'); - $foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']); - $bill = $this->billRepository->findBill((int)$row['bill_id'], $row['bill_name']); - $billId = TransactionTypeEnum::WITHDRAWAL->value === $type->type && $bill instanceof Bill ? $bill->id : null; - $description = (string)$row['description']; + $foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']); + $bill = $this->billRepository->findBill((int) $row['bill_id'], $row['bill_name']); + $billId = TransactionTypeEnum::WITHDRAWAL->value === $type->type && $bill instanceof Bill ? $bill->id : null; + $description = (string) $row['description']; // Manipulate basic fields $carbon->setTimezone(config('app.timezone')); @@ -198,7 +199,7 @@ class TransactionJournalFactory } /** create or get source and destination accounts */ - $sourceInfo = [ + $sourceInfo = [ 'id' => $row['source_id'], 'name' => $row['source_name'], 'iban' => $row['source_iban'], @@ -207,7 +208,7 @@ class TransactionJournalFactory 'currency_id' => $currency->id, ]; - $destInfo = [ + $destInfo = [ 'id' => $row['destination_id'], 'name' => $row['destination_name'], 'iban' => $row['destination_iban'], @@ -217,8 +218,8 @@ class TransactionJournalFactory ]; Log::debug('Source info:', $sourceInfo); Log::debug('Destination info:', $destInfo); - $destinationAccount = null; - $sourceAccount = null; + $destinationAccount = null; + $sourceAccount = null; if (TransactionTypeEnum::DEPOSIT->value === $type->type) { Log::debug('Transaction type is deposit, start with destination first.'); $destinationAccount = $this->getAccount($type->type, 'destination', $destInfo); @@ -243,38 +244,38 @@ class TransactionJournalFactory [$sourceAccount, $destinationAccount] = $this->reconciliationSanityCheck($sourceAccount, $destinationAccount); } - $currency = $this->getCurrencyByAccount($type->type, $currency, $sourceAccount, $destinationAccount); - $foreignCurrency = $this->compareCurrencies($currency, $foreignCurrency); - $foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount); - $description = $this->getDescription($description); + $currency = $this->getCurrencyByAccount($type->type, $currency, $sourceAccount, $destinationAccount); + $foreignCurrency = $this->compareCurrencies($currency, $foreignCurrency); + $foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount); + $description = $this->getDescription($description); Log::debug(sprintf( - 'Currency is #%d "%s", foreign currency is #%d "%s"', - $currency->id, - $currency->code, - $foreignCurrency?->id, - $foreignCurrency?->code - )); + 'Currency is #%d "%s", foreign currency is #%d "%s"', + $currency->id, + $currency->code, + $foreignCurrency?->id, + $foreignCurrency?->code + )); Log::debug(sprintf('Date: %s (%s)', $carbon->toW3cString(), $carbon->getTimezone()->getName())); /** Create a basic journal. */ - $journal = TransactionJournal::create([ - 'user_id' => $this->user->id, - 'user_group_id' => $this->userGroup->id, - 'transaction_type_id' => $type->id, - 'bill_id' => $billId, - 'transaction_currency_id' => $currency->id, - 'description' => substr($description, 0, 1000), - 'date' => $carbon, - 'date_tz' => $carbon->format('e'), - 'order' => $order, - 'tag_count' => 0, - 'completed' => !$row['batch_submission'], - ]); + $journal = TransactionJournal::create([ + 'user_id' => $this->user->id, + 'user_group_id' => $this->userGroup->id, + 'transaction_type_id' => $type->id, + 'bill_id' => $billId, + 'transaction_currency_id' => $currency->id, + 'description' => substr($description, 0, 1000), + 'date' => $carbon, + 'date_tz' => $carbon->format('e'), + 'order' => $order, + 'tag_count' => 0, + 'completed' => !$row['batch_submission'], + ]); Log::debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description)); /** Create two transactions. */ - $transactionFactory = app(TransactionFactory::class); + $transactionFactory = app(TransactionFactory::class); $transactionFactory->setJournal($journal); $transactionFactory->setAccount($sourceAccount); $transactionFactory->setCurrency($currency); @@ -283,7 +284,7 @@ class TransactionJournalFactory $transactionFactory->setReconciled($row['reconciled'] ?? false); try { - $negative = $transactionFactory->createNegative((string)$row['amount'], (string)$row['foreign_amount']); + $negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']); } catch (FireflyException $e) { Log::error(sprintf('Exception creating negative transaction: %s', $e->getMessage())); $this->forceDeleteOnError(new Collection()->push($journal)); @@ -292,7 +293,7 @@ class TransactionJournalFactory } /** @var TransactionFactory $transactionFactory */ - $transactionFactory = app(TransactionFactory::class); + $transactionFactory = app(TransactionFactory::class); $transactionFactory->setJournal($journal); $transactionFactory->setAccount($destinationAccount); $transactionFactory->setAccountInformation($destInfo); @@ -304,8 +305,8 @@ class TransactionJournalFactory // Firefly III will save the foreign currency information in such a way that both // asset accounts can look at the "amount" and "transaction_currency_id" column and // see the currency they expect to see. - $amount = (string)$row['amount']; - $foreignAmount = (string)$row['foreign_amount']; + $amount = (string) $row['amount']; + $foreignAmount = (string) $row['foreign_amount']; if ( $foreignCurrency instanceof TransactionCurrency && $foreignCurrency->id !== $currency->id @@ -313,8 +314,8 @@ class TransactionJournalFactory ) { $transactionFactory->setCurrency($foreignCurrency); $transactionFactory->setForeignCurrency($currency); - $amount = (string)$row['foreign_amount']; - $foreignAmount = (string)$row['amount']; + $amount = (string) $row['foreign_amount']; + $foreignAmount = (string) $row['amount']; Log::debug('Swap primary/foreign amounts in transfer for new save method.'); } @@ -373,17 +374,18 @@ class TransactionJournalFactory /** @var null|TransactionJournalMeta $result */ $result = TransactionJournalMeta::withTrashed() - ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') - ->whereNotNull('transaction_journals.id') - ->where('transaction_journals.user_id', $this->user->id) - ->where('data', json_encode($hash, JSON_THROW_ON_ERROR)) - ->with(['transactionJournal', 'transactionJournal.transactionGroup']) - ->first(['journal_meta.*']); + ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') + ->whereNotNull('transaction_journals.id') + ->where('transaction_journals.user_id', $this->user->id) + ->where('data', json_encode($hash, JSON_THROW_ON_ERROR)) + ->with(['transactionJournal', 'transactionJournal.transactionGroup']) + ->first(['journal_meta.*']) + ; if (null !== $result) { Log::warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash)); $journal = $result->transactionJournal()->withTrashed()->first(); $group = $journal?->transactionGroup()->withTrashed()->first(); - $groupId = (int)$group?->id; + $groupId = (int) $group?->id; throw new DuplicateTransactionException(sprintf('Duplicate of transaction #%d.', $groupId)); } @@ -395,18 +397,18 @@ class TransactionJournalFactory private function validateAccounts(NullArrayObject $data): void { Log::debug(sprintf('Now in %s', __METHOD__)); - $transactionType = $data['type'] ?? 'invalid'; + $transactionType = $data['type'] ?? 'invalid'; $this->accountValidator->setUser($this->user); $this->accountValidator->setTransactionType($transactionType); // validate source account. - $array = [ - 'id' => null !== $data['source_id'] ? (int)$data['source_id'] : null, - 'name' => null !== $data['source_name'] ? (string)$data['source_name'] : null, - 'iban' => null !== $data['source_iban'] ? (string)$data['source_iban'] : null, - 'number' => null !== $data['source_number'] ? (string)$data['source_number'] : null, + $array = [ + 'id' => null !== $data['source_id'] ? (int) $data['source_id'] : null, + 'name' => null !== $data['source_name'] ? (string) $data['source_name'] : null, + 'iban' => null !== $data['source_iban'] ? (string) $data['source_iban'] : null, + 'number' => null !== $data['source_number'] ? (string) $data['source_number'] : null, ]; - $validSource = $this->accountValidator->validateSource($array); + $validSource = $this->accountValidator->validateSource($array); // do something with result: if (false === $validSource) { @@ -415,11 +417,11 @@ class TransactionJournalFactory Log::debug('Source seems valid.'); // validate destination account - $array = [ - 'id' => null !== $data['destination_id'] ? (int)$data['destination_id'] : null, - 'name' => null !== $data['destination_name'] ? (string)$data['destination_name'] : null, - 'iban' => null !== $data['destination_iban'] ? (string)$data['destination_iban'] : null, - 'number' => null !== $data['destination_number'] ? (string)$data['destination_number'] : null, + $array = [ + 'id' => null !== $data['destination_id'] ? (int) $data['destination_id'] : null, + 'name' => null !== $data['destination_name'] ? (string) $data['destination_name'] : null, + 'iban' => null !== $data['destination_iban'] ? (string) $data['destination_iban'] : null, + 'number' => null !== $data['destination_number'] ? (string) $data['destination_number'] : null, ]; $validDestination = $this->accountValidator->validateDestination($array); @@ -504,7 +506,7 @@ class TransactionJournalFactory // return user's default: return Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup); } - $result = $preference ?? $currency; + $result = $preference ?? $currency; Log::debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name)); return $result; @@ -574,7 +576,7 @@ class TransactionJournalFactory { Log::debug('Will now store piggy event.'); - $piggyBank = $this->piggyRepository->findPiggyBank((int)$data['piggy_bank_id'], $data['piggy_bank_name']); + $piggyBank = $this->piggyRepository->findPiggyBank((int) $data['piggy_bank_id'], $data['piggy_bank_name']); if ($piggyBank instanceof PiggyBank) { $this->piggyEventFactory->create($journal, $piggyBank); @@ -594,7 +596,7 @@ class TransactionJournalFactory protected function storeMeta(TransactionJournal $journal, array $data, string $field): void { - $set = ['journal' => $journal, 'name' => $field, 'data' => (string)($data[$field] ?? '')]; + $set = ['journal' => $journal, 'name' => $field, 'data' => (string) ($data[$field] ?? '')]; if (array_key_exists($field, $data) && $data[$field] instanceof Carbon) { $data[$field]->setTimezone(config('app.timezone')); Log::debug(sprintf('%s Date: %s (%s)', $field, $data[$field], $data[$field]->timezone->getName())); diff --git a/app/Factory/WebhookMessageFactory.php b/app/Factory/WebhookMessageFactory.php index cfc0313e92..29e352efb8 100644 --- a/app/Factory/WebhookMessageFactory.php +++ b/app/Factory/WebhookMessageFactory.php @@ -1,4 +1,7 @@ webhook()->associate($webhook); $webhookMessage->sent = false; @@ -36,7 +40,7 @@ class WebhookMessageFactory $webhookMessage->message = $data; $webhookMessage->save(); Log::debug(sprintf('Stored new webhook message #%d', $webhookMessage->id)); + return $webhookMessage; } - } diff --git a/app/Generator/Webhook/StandardMessageGenerator.php b/app/Generator/Webhook/StandardMessageGenerator.php index 2e29705ec5..9737d20b57 100644 --- a/app/Generator/Webhook/StandardMessageGenerator.php +++ b/app/Generator/Webhook/StandardMessageGenerator.php @@ -55,11 +55,11 @@ use Symfony\Component\HttpFoundation\ParameterBag; */ class StandardMessageGenerator implements MessageGeneratorInterface { - private Collection $objects; + private Collection $objects; private WebhookTrigger $trigger; - private User $user; - private int $version = 0; - private Collection $webhooks; + private User $user; + private int $version = 0; + private Collection $webhooks; public function __construct() { @@ -77,10 +77,10 @@ class StandardMessageGenerator implements MessageGeneratorInterface // do some debugging Log::debug(sprintf( - 'StandardMessageGenerator will generate messages for %d object(s) and %d webhook(s).', - $this->objects->count(), - $this->webhooks->count() - )); + 'StandardMessageGenerator will generate messages for %d object(s) and %d webhook(s).', + $this->objects->count(), + $this->webhooks->count() + )); $this->run(); } @@ -92,7 +92,8 @@ class StandardMessageGenerator implements MessageGeneratorInterface ->leftJoin('webhook_triggers', 'webhook_webhook_trigger.webhook_trigger_id', 'webhook_triggers.id') ->where('active', true) ->whereIn('webhook_triggers.title', [$this->trigger->name, WebhookTrigger::ANY->name]) - ->get(['webhooks.*']); + ->get(['webhooks.*']) + ; } /** @@ -127,15 +128,15 @@ class StandardMessageGenerator implements MessageGeneratorInterface */ private function generateMessage(Webhook $webhook, Model $model): void { - $class = $model::class; + $class = $model::class; // Line is ignored because all of Firefly III's Models have an id property. Log::debug(sprintf('Now in generateMessage(#%d, %s#%d)', $webhook->id, $class, $model->id)); - $uuid = Uuid::uuid4(); + $uuid = Uuid::uuid4(); /** @var WebhookResponseModel $response */ - $response = $webhook->webhookResponses()->first(); + $response = $webhook->webhookResponses()->first(); $this->getTriggerTitles($webhook->webhookTriggers()->get()); - $basicMessage = [ + $basicMessage = [ 'uuid' => $uuid->toString(), 'user_id' => 0, 'user_group_id' => 0, @@ -180,17 +181,17 @@ class StandardMessageGenerator implements MessageGeneratorInterface switch ($responseTitle) { default: Log::error(sprintf( - 'The response code for webhook #%d is "%s" and the message generator cant handle it. Soft fail.', - $webhook->id, - $webhook->response - )); + 'The response code for webhook #%d is "%s" and the message generator cant handle it. Soft fail.', + $webhook->id, + $webhook->response + )); return; case WebhookResponse::BUDGET->name: $basicMessage['content'] = []; if ($model instanceof Budget) { - $enrichment = new BudgetEnrichment(); + $enrichment = new BudgetEnrichment(); $enrichment->setUser($model->user); /** @var Budget $model */ @@ -199,17 +200,17 @@ class StandardMessageGenerator implements MessageGeneratorInterface $basicMessage['content'] = $transformer->transform($model); } if ($model instanceof BudgetLimit) { - $user = $model->budget->user; - $enrichment = new BudgetLimitEnrichment(); + $user = $model->budget->user; + $enrichment = new BudgetLimitEnrichment(); $enrichment->setUser($user); - $parameters = new ParameterBag(); + $parameters = new ParameterBag(); $parameters->set('start', $model->start_date); $parameters->set('end', $model->end_date); /** @var BudgetLimit $model */ - $model = $enrichment->enrichSingle($model); - $transformer = new BudgetLimitTransformer(); + $model = $enrichment->enrichSingle($model); + $transformer = new BudgetLimitTransformer(); $transformer->setParameters($parameters); $basicMessage['content'] = $transformer->transform($model); } @@ -223,16 +224,16 @@ class StandardMessageGenerator implements MessageGeneratorInterface case WebhookResponse::TRANSACTIONS->name: /** @var TransactionGroup $model */ - $transformer = new TransactionGroupTransformer(); + $transformer = new TransactionGroupTransformer(); try { $basicMessage['content'] = $transformer->transformObject($model); } catch (FireflyException $e) { Log::error(sprintf( - 'The transformer could not include the requested transaction group for webhook #%d: %s', - $webhook->id, - $e->getMessage() - )); + 'The transformer could not include the requested transaction group for webhook #%d: %s', + $webhook->id, + $e->getMessage() + )); Log::error($e->getTraceAsString()); return; @@ -242,18 +243,18 @@ class StandardMessageGenerator implements MessageGeneratorInterface case WebhookResponse::ACCOUNTS->name: /** @var TransactionGroup $model */ - $accounts = $this->collectAccounts($model); - $enrichment = new AccountEnrichment(); + $accounts = $this->collectAccounts($model); + $enrichment = new AccountEnrichment(); $enrichment->setDate(null); $enrichment->setUser($model->user); - $accounts = $enrichment->enrich($accounts); + $accounts = $enrichment->enrich($accounts); foreach ($accounts as $account) { - $transformer = new AccountTransformer(); + $transformer = new AccountTransformer(); $transformer->setParameters(new ParameterBag()); $basicMessage['content'][] = $transformer->transform($account); } } - $factory = new WebhookMessageFactory(); + $factory = new WebhookMessageFactory(); $factory->create($webhook, $basicMessage); } diff --git a/app/Handlers/ExchangeRate/ConversionParameters.php b/app/Handlers/ExchangeRate/ConversionParameters.php index a1ab87282d..8c981b4e4f 100644 --- a/app/Handlers/ExchangeRate/ConversionParameters.php +++ b/app/Handlers/ExchangeRate/ConversionParameters.php @@ -1,4 +1,7 @@ date = now(); } - } diff --git a/app/Handlers/ExchangeRate/ConvertsAmountToPrimaryAmount.php b/app/Handlers/ExchangeRate/ConvertsAmountToPrimaryAmount.php index ddfcee79e5..cc3702e5ad 100644 --- a/app/Handlers/ExchangeRate/ConvertsAmountToPrimaryAmount.php +++ b/app/Handlers/ExchangeRate/ConvertsAmountToPrimaryAmount.php @@ -1,4 +1,7 @@ amountField; - $primaryAmountField = $params->primaryAmountField; + $amountField = $params->amountField; + $primaryAmountField = $params->primaryAmountField; if (!Amount::convertToPrimary($params->user)) { - Log::debug(sprintf('User does not want to do conversion, no need to convert %s and store it in field %s for %s #%d.', $params->amountField, $params->primaryAmountField, get_class($params->model), $params->model->id)); - $params->model->$primaryAmountField = null; + Log::debug(sprintf( + 'User does not want to do conversion, no need to convert %s and store it in field %s for %s #%d.', + $params->amountField, + $params->primaryAmountField, + get_class($params->model), + $params->model->id + )); + $params->model->{$primaryAmountField} = null; $params->model->saveQuietly(); + return; } - if(null === $params->originalCurrency) { - Log::debug(sprintf('Original currency field is empty, no need to convert %s and store it in field %s for %s #%d.', $params->amountField, $params->primaryAmountField, get_class($params->model), $params->model->id)); + if (null === $params->originalCurrency) { + Log::debug(sprintf( + 'Original currency field is empty, no need to convert %s and store it in field %s for %s #%d.', + $params->amountField, + $params->primaryAmountField, + get_class($params->model), + $params->model->id + )); + return; } - $primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($params->user->userGroup); - Log::debug(sprintf('Will convert amount in field %s from %s to %s and store it in %s', $params->originalCurrency->code, $primaryCurrency->code, $params->amountField, $params->primaryAmountField)); + $primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($params->user->userGroup); + Log::debug(sprintf( + 'Will convert amount in field %s from %s to %s and store it in %s', + $params->originalCurrency->code, + $primaryCurrency->code, + $params->amountField, + $params->primaryAmountField + )); if ($params->originalCurrency->id === $primaryCurrency->id) { Log::debug('Both currencies are the same, do nothing.'); + return; } - // field is empty or zero, do nothing. - $amount = (string)$params->model->$amountField; + $amount = (string) $params->model->{$amountField}; if ('' === $amount || 0 === bccomp($amount, '0')) { Log::debug(sprintf('Amount "%s" in field "%s" cannot be used, do nothing.', $amount, $amountField)); - $params->model->$amountField = null; - $params->model->$primaryAmountField = null; + $params->model->{$amountField} = null; + $params->model->{$primaryAmountField} = null; $params->model->saveQuietly(); + return; } - $converter = new ExchangeRateConverter(); - $newAmount = $converter->convert($params->originalCurrency, $primaryCurrency, now(), $amount); + $converter = new ExchangeRateConverter(); + $newAmount = $converter->convert($params->originalCurrency, $primaryCurrency, now(), $amount); $converter->setUserGroup($params->user->userGroup); $converter->setIgnoreSettings(true); - $params->model->$primaryAmountField = $newAmount; + $params->model->{$primaryAmountField} = $newAmount; $params->model->saveQuietly(); - Log::debug(sprintf('Converted field "%s" of %s #%d from %s %s to %s %s (in field "%s")', $amountField, get_class($params->model), $params->model->id, $params->originalCurrency->code, $amount, $primaryCurrency->code, $newAmount, $primaryAmountField)); + Log::debug(sprintf( + 'Converted field "%s" of %s #%d from %s %s to %s %s (in field "%s")', + $amountField, + get_class($params->model), + $params->model->id, + $params->originalCurrency->code, + $amount, + $primaryCurrency->code, + $newAmount, + $primaryAmountField + )); } - } diff --git a/app/Handlers/Observer/AutoBudgetObserver.php b/app/Handlers/Observer/AutoBudgetObserver.php index 08b176540b..798c6bbd7d 100644 --- a/app/Handlers/Observer/AutoBudgetObserver.php +++ b/app/Handlers/Observer/AutoBudgetObserver.php @@ -53,6 +53,4 @@ class AutoBudgetObserver $params->primaryAmountField = 'native_amount'; ConvertsAmountToPrimaryAmount::convert($params); } - - } diff --git a/app/Handlers/Observer/AvailableBudgetObserver.php b/app/Handlers/Observer/AvailableBudgetObserver.php index 3edf2e3859..4f18f0779f 100644 --- a/app/Handlers/Observer/AvailableBudgetObserver.php +++ b/app/Handlers/Observer/AvailableBudgetObserver.php @@ -40,7 +40,6 @@ class AvailableBudgetObserver $this->updatePrimaryCurrencyAmount($availableBudget); } - private function updatePrimaryCurrencyAmount(AvailableBudget $availableBudget): void { $params = new ConversionParameters(); @@ -51,6 +50,4 @@ class AvailableBudgetObserver $params->primaryAmountField = 'native_amount'; ConvertsAmountToPrimaryAmount::convert($params); } - - } diff --git a/app/Handlers/Observer/BudgetLimitObserver.php b/app/Handlers/Observer/BudgetLimitObserver.php index 404408b256..a1c7754995 100644 --- a/app/Handlers/Observer/BudgetLimitObserver.php +++ b/app/Handlers/Observer/BudgetLimitObserver.php @@ -61,7 +61,7 @@ class BudgetLimitObserver $singleton = PreferencesSingleton::getInstance(); if (true === $singleton->getPreference($key)) { - $user = $budgetLimit->budget->user; + $user = $budgetLimit->budget->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); diff --git a/app/Handlers/Observer/BudgetObserver.php b/app/Handlers/Observer/BudgetObserver.php index 5ec313217d..8d15495d23 100644 --- a/app/Handlers/Observer/BudgetObserver.php +++ b/app/Handlers/Observer/BudgetObserver.php @@ -51,7 +51,7 @@ class BudgetObserver if (true === $singleton->getPreference('fire_webhooks_budget_create')) { // fire event. - $user = $budget->user; + $user = $budget->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); @@ -68,10 +68,10 @@ class BudgetObserver { Log::debug('Observe "deleting" of a budget.'); - $user = $budget->user; + $user = $budget->user; /** @var MessageGeneratorInterface $engine */ - $engine = app(MessageGeneratorInterface::class); + $engine = app(MessageGeneratorInterface::class); $engine->setUser($user); $engine->setObjects(new Collection()->push($budget)); $engine->setTrigger(WebhookTrigger::DESTROY_BUDGET); @@ -79,7 +79,7 @@ class BudgetObserver Log::debug(sprintf('send event WebhookMessagesRequestSending from %s', __METHOD__)); event(new WebhookMessagesRequestSending()); - $repository = app(AttachmentRepositoryInterface::class); + $repository = app(AttachmentRepositoryInterface::class); $repository->setUser($budget->user); /** @var Attachment $attachment */ @@ -111,7 +111,7 @@ class BudgetObserver $singleton = PreferencesSingleton::getInstance(); if (true === $singleton->getPreference('fire_webhooks_budget_update')) { - $user = $budget->user; + $user = $budget->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); diff --git a/app/Handlers/Observer/DeletedAccountObserver.php b/app/Handlers/Observer/DeletedAccountObserver.php index e78074527c..aa96cedc73 100644 --- a/app/Handlers/Observer/DeletedAccountObserver.php +++ b/app/Handlers/Observer/DeletedAccountObserver.php @@ -33,7 +33,6 @@ use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; - class DeletedAccountObserver { public function deleting(Account $account): void @@ -51,13 +50,14 @@ class DeletedAccountObserver } $journalIds = Transaction::where('account_id', $account->id) - ->get(['transactions.transaction_journal_id']) - ->pluck('transaction_journal_id') - ->toArray(); + ->get(['transactions.transaction_journal_id']) + ->pluck('transaction_journal_id') + ->toArray() + ; $groupIds = TransactionJournal::whereIn('id', $journalIds) - ->get(['transaction_journals.transaction_group_id']) - ->pluck('transaction_group_id') - ->toArray() // @phpstan-ignore-line + ->get(['transaction_journals.transaction_group_id']) + ->pluck('transaction_group_id') + ->toArray() // @phpstan-ignore-line ; if (count($journalIds) > 0) { diff --git a/app/Handlers/Observer/PiggyBankEventObserver.php b/app/Handlers/Observer/PiggyBankEventObserver.php index 9def67b9f7..565ce5901b 100644 --- a/app/Handlers/Observer/PiggyBankEventObserver.php +++ b/app/Handlers/Observer/PiggyBankEventObserver.php @@ -45,7 +45,7 @@ class PiggyBankEventObserver private function updatePrimaryCurrencyAmount(PiggyBankEvent $event): void { - $user = $event->piggyBank->accounts()->first()?->user; + $user = $event->piggyBank->accounts()->first()?->user; if (null === $user) { Log::warning('Piggy bank seems to have no accounts. Break.'); diff --git a/app/Handlers/Observer/PiggyBankObserver.php b/app/Handlers/Observer/PiggyBankObserver.php index 4f6dc3e214..7b79e7f7ab 100644 --- a/app/Handlers/Observer/PiggyBankObserver.php +++ b/app/Handlers/Observer/PiggyBankObserver.php @@ -71,7 +71,7 @@ class PiggyBankObserver private function updatePrimaryCurrencyAmount(PiggyBank $piggyBank): void { - $group = $piggyBank->accounts()->first()?->user->userGroup; + $group = $piggyBank->accounts()->first()?->user->userGroup; if (null === $group) { Log::debug(sprintf('No account(s) yet for piggy bank #%d.', $piggyBank->id)); diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.php index 5c440b7e1e..4f2fa115d1 100644 --- a/app/Http/Controllers/Transaction/BulkController.php +++ b/app/Http/Controllers/Transaction/BulkController.php @@ -57,7 +57,7 @@ class BulkController extends Controller $this->middleware(function ($request, $next) { $this->repository = app(JournalRepositoryInterface::class); - app('view')->share('title', (string)trans('firefly.transactions')); + app('view')->share('title', (string) trans('firefly.transactions')); app('view')->share('mainTitleIcon', 'fa-exchange'); return $next($request); @@ -71,9 +71,9 @@ class BulkController extends Controller * * @return Factory|View */ - public function edit(array $journals): Factory | \Illuminate\Contracts\View\View + public function edit(array $journals): Factory|\Illuminate\Contracts\View\View { - $subTitle = (string)trans('firefly.mass_bulk_journals'); + $subTitle = (string) trans('firefly.mass_bulk_journals'); $this->rememberPreviousUrl('transactions.bulk-edit.url'); @@ -84,7 +84,7 @@ class BulkController extends Controller $budgetRepos = app(BudgetRepositoryInterface::class); $budgetList = app('expandedform')->makeSelectListWithEmpty($budgetRepos->getActiveBudgets()); - return view('transactions.bulk.edit', ['journals' => $journals, 'subTitle' => $subTitle, 'budgetList' => $budgetList]); + return view('transactions.bulk.edit', ['journals' => $journals, 'subTitle' => $subTitle, 'budgetList' => $budgetList]); } /** @@ -92,18 +92,18 @@ class BulkController extends Controller * * @return Application|Redirector|RedirectResponse */ - public function update(BulkEditJournalRequest $request): Redirector | RedirectResponse + public function update(BulkEditJournalRequest $request): Redirector|RedirectResponse { $journalIds = $request->get('journals'); $journalIds = is_array($journalIds) ? $journalIds : []; - $ignoreCategory = 1 === (int)$request->get('ignore_category'); - $ignoreBudget = 1 === (int)$request->get('ignore_budget'); + $ignoreCategory = 1 === (int) $request->get('ignore_category'); + $ignoreBudget = 1 === (int) $request->get('ignore_budget'); $tagsAction = $request->get('tags_action'); $collection = new Collection(); $count = 0; foreach ($journalIds as $journalId) { - $journalId = (int)$journalId; + $journalId = (int) $journalId; $journal = $this->repository->find($journalId); if (null !== $journal) { $resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id')); @@ -116,7 +116,8 @@ class BulkController extends Controller } } - $flags = new TransactionGroupEventFlags(); + $flags = new TransactionGroupEventFlags(); + // run rules on changed journals: /** @var TransactionJournal $journal */ foreach ($collection as $journal) { diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php index 7d2ca297cb..beb6de1b75 100644 --- a/app/Http/Controllers/Transaction/ConvertController.php +++ b/app/Http/Controllers/Transaction/ConvertController.php @@ -72,7 +72,7 @@ class ConvertController extends Controller // some useful repositories: $this->middleware(function ($request, $next) { $this->accountRepository = app(AccountRepositoryInterface::class); - app('view')->share('title', (string)trans('firefly.transactions')); + app('view')->share('title', (string) trans('firefly.transactions')); app('view')->share('mainTitleIcon', 'fa-exchange'); return $next($request); @@ -86,23 +86,23 @@ class ConvertController extends Controller * * @throws Exception */ - public function index(TransactionType $destinationType, TransactionGroup $group): Factory | \Illuminate\Contracts\View\View | Redirector | RedirectResponse + public function index(TransactionType $destinationType, TransactionGroup $group): Factory|\Illuminate\Contracts\View\View|Redirector|RedirectResponse { if (!$this->isEditableGroup($group)) { return $this->redirectGroupToAccount($group); } /** @var TransactionGroupTransformer $transformer */ - $transformer = app(TransactionGroupTransformer::class); + $transformer = app(TransactionGroupTransformer::class); /** @var TransactionJournal $first */ - $first = $group->transactionJournals()->first(); - $sourceType = $first->transactionType; + $first = $group->transactionJournals()->first(); + $sourceType = $first->transactionType; - $groupTitle = $group->title ?? $first->description; - $groupArray = $transformer->transformObject($group); - $subTitle = (string)trans('firefly.convert_to_' . $destinationType->type, ['description' => $groupTitle]); - $subTitleIcon = 'fa-exchange'; + $groupTitle = $group->title ?? $first->description; + $groupArray = $transformer->transformObject($group); + $subTitle = (string) trans('firefly.convert_to_'.$destinationType->type, ['description' => $groupTitle]); + $subTitleIcon = 'fa-exchange'; // get a list of asset accounts and liabilities and stuff, in various combinations: $validDepositSources = $this->getValidDepositSources(); @@ -111,11 +111,11 @@ class ConvertController extends Controller $assets = $this->getAssetAccounts(); // old input variables: - $preFilled = ['source_name' => old('source_name')]; + $preFilled = ['source_name' => old('source_name')]; if ($sourceType->type === $destinationType->type) { // cannot convert to its own type. Log::debug('This is already a transaction of the expected type..'); - session()->flash('info', (string)trans('firefly.convert_is_already_type_' . $destinationType->type)); + session()->flash('info', (string) trans('firefly.convert_is_already_type_'.$destinationType->type)); return redirect(route('transactions.show', [$group->id])); } @@ -141,26 +141,26 @@ class ConvertController extends Controller // make repositories $liabilityTypes = [AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::LOAN->value]; $accountList = $this->accountRepository->getActiveAccountsByType([ - AccountTypeEnum::REVENUE->value, - AccountTypeEnum::CASH->value, - AccountTypeEnum::LOAN->value, - AccountTypeEnum::DEBT->value, - AccountTypeEnum::MORTGAGE->value, - ]); + AccountTypeEnum::REVENUE->value, + AccountTypeEnum::CASH->value, + AccountTypeEnum::LOAN->value, + AccountTypeEnum::DEBT->value, + AccountTypeEnum::MORTGAGE->value, + ]); $grouped = []; // group accounts: /** @var Account $account */ foreach ($accountList as $account) { - $role = (string)$this->accountRepository->getMetaValue($account, 'account_role'); - $name = $account->name; + $role = (string) $this->accountRepository->getMetaValue($account, 'account_role'); + $name = $account->name; if ('' === $role) { $role = 'no_account_type'; } // maybe it's a liability thing: if (in_array($account->accountType->type, $liabilityTypes, true)) { - $role = 'l_' . $account->accountType->type; + $role = 'l_'.$account->accountType->type; } if (AccountTypeEnum::CASH->value === $account->accountType->type) { $role = 'cash_account'; @@ -170,7 +170,7 @@ class ConvertController extends Controller $role = 'revenue_account'; } - $key = (string)trans('firefly.opt_group_' . $role); + $key = (string) trans('firefly.opt_group_'.$role); $grouped[$key][$account->id] = $name; } @@ -182,26 +182,26 @@ class ConvertController extends Controller // make repositories $liabilityTypes = [AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::LOAN->value]; $accountList = $this->accountRepository->getActiveAccountsByType([ - AccountTypeEnum::EXPENSE->value, - AccountTypeEnum::CASH->value, - AccountTypeEnum::LOAN->value, - AccountTypeEnum::DEBT->value, - AccountTypeEnum::MORTGAGE->value, - ]); + AccountTypeEnum::EXPENSE->value, + AccountTypeEnum::CASH->value, + AccountTypeEnum::LOAN->value, + AccountTypeEnum::DEBT->value, + AccountTypeEnum::MORTGAGE->value, + ]); $grouped = []; // group accounts: /** @var Account $account */ foreach ($accountList as $account) { - $role = (string)$this->accountRepository->getMetaValue($account, 'account_role'); - $name = $account->name; + $role = (string) $this->accountRepository->getMetaValue($account, 'account_role'); + $name = $account->name; if ('' === $role) { $role = 'no_account_type'; } // maybe it's a liability thing: if (in_array($account->accountType->type, $liabilityTypes, true)) { - $role = 'l_' . $account->accountType->type; + $role = 'l_'.$account->accountType->type; } if (AccountTypeEnum::CASH->value === $account->accountType->type) { $role = 'cash_account'; @@ -211,7 +211,7 @@ class ConvertController extends Controller $role = 'expense_account'; } - $key = (string)trans('firefly.opt_group_' . $role); + $key = (string) trans('firefly.opt_group_'.$role); $grouped[$key][$account->id] = $name; } @@ -225,23 +225,23 @@ class ConvertController extends Controller { // make repositories $accountList = $this->accountRepository->getActiveAccountsByType([ - AccountTypeEnum::LOAN->value, - AccountTypeEnum::DEBT->value, - AccountTypeEnum::MORTGAGE->value, - ]); + AccountTypeEnum::LOAN->value, + AccountTypeEnum::DEBT->value, + AccountTypeEnum::MORTGAGE->value, + ]); $grouped = []; // group accounts: /** @var Account $account */ foreach ($accountList as $account) { - $date = today()->endOfDay(); + $date = today()->endOfDay(); Log::debug(sprintf('getLiabilities: Call finalAccountBalance with date/time "%s"', $date->toIso8601String())); // 2025-10-08 replace finalAccountBalance with accountsBalancesOptimized. // $balance = Steam::finalAccountBalance($account, $date)['balance']; $balance = Steam::accountsBalancesOptimized(new Collection()->push($account), $date)[$account->id]['balance'] ?? '0'; $currency = $this->accountRepository->getAccountCurrency($account) ?? $this->primaryCurrency; $role = sprintf('l_%s', $account->accountType->type); - $key = (string)trans(sprintf('firefly.opt_group_%s', $role)); + $key = (string) trans(sprintf('firefly.opt_group_%s', $role)); $grouped[$key][$account->id] = sprintf('%s (%s)', $account->name, Amount::formatAnything($currency, $balance, false)); } @@ -260,19 +260,19 @@ class ConvertController extends Controller // group accounts: /** @var Account $account */ foreach ($accountList as $account) { - $date = today()->endOfDay(); + $date = today()->endOfDay(); Log::debug(sprintf('getAssetAccounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String())); // 2025-10-08 replace finalAccountBalance with accountsBalancesOptimized. // $balance = Steam::finalAccountBalance($account, $date)['balance']; - $balance = Steam::accountsBalancesOptimized(new Collection()->push($account), $date)[$account->id]['balance'] ?? '0'; + $balance = Steam::accountsBalancesOptimized(new Collection()->push($account), $date)[$account->id]['balance'] ?? '0'; - $currency = $this->accountRepository->getAccountCurrency($account) ?? $this->primaryCurrency; - $role = (string)$this->accountRepository->getMetaValue($account, 'account_role'); + $currency = $this->accountRepository->getAccountCurrency($account) ?? $this->primaryCurrency; + $role = (string) $this->accountRepository->getMetaValue($account, 'account_role'); if ('' === $role) { $role = 'no_account_type'; } - $key = (string)trans(sprintf('firefly.opt_group_%s', $role)); + $key = (string) trans(sprintf('firefly.opt_group_%s', $role)); $grouped[$key][$account->id] = sprintf('%s (%s)', $account->name, Amount::formatAnything($currency, $balance, false)); } @@ -305,7 +305,7 @@ class ConvertController extends Controller // correct transfers: $group->refresh(); - session()->flash('success', (string)trans('firefly.converted_to_' . $destinationType->type)); + session()->flash('success', (string) trans('firefly.converted_to_'.$destinationType->type)); $flags = new TransactionGroupEventFlags(); event(new UpdatedSingleTransactionGroup($group, $flags)); @@ -318,22 +318,22 @@ class ConvertController extends Controller private function convertJournal(TransactionJournal $journal, TransactionType $transactionType, array $data): TransactionJournal { /** @var AccountValidator $validator */ - $validator = app(AccountValidator::class); + $validator = app(AccountValidator::class); $validator->setUser(auth()->user()); $validator->setTransactionType($transactionType->type); - $sourceId = $data['source_id'][$journal->id] ?? null; - $sourceName = $data['source_name'][$journal->id] ?? null; - $destinationId = $data['destination_id'][$journal->id] ?? null; - $destinationName = $data['destination_name'][$journal->id] ?? null; + $sourceId = $data['source_id'][$journal->id] ?? null; + $sourceName = $data['source_name'][$journal->id] ?? null; + $destinationId = $data['destination_id'][$journal->id] ?? null; + $destinationName = $data['destination_name'][$journal->id] ?? null; // double check it's not an empty string. - $sourceId = '' === $sourceId || null === $sourceId ? null : (int)$sourceId; - $sourceName = '' === $sourceName ? null : (string)$sourceName; - $destinationId = '' === $destinationId || null === $destinationId ? null : (int)$destinationId; - $destinationName = '' === $destinationName ? null : (string)$destinationName; - $validSource = $validator->validateSource(['id' => $sourceId, 'name' => $sourceName]); - $validDestination = $validator->validateDestination(['id' => $destinationId, 'name' => $destinationName]); + $sourceId = '' === $sourceId || null === $sourceId ? null : (int) $sourceId; + $sourceName = '' === $sourceName ? null : (string) $sourceName; + $destinationId = '' === $destinationId || null === $destinationId ? null : (int) $destinationId; + $destinationName = '' === $destinationName ? null : (string) $destinationName; + $validSource = $validator->validateSource(['id' => $sourceId, 'name' => $sourceName]); + $validDestination = $validator->validateDestination(['id' => $destinationId, 'name' => $destinationName]); if (false === $validSource) { throw new FireflyException(sprintf(trans('firefly.convert_invalid_source'), $journal->id)); @@ -344,7 +344,7 @@ class ConvertController extends Controller // TODO typeOverrule: the account validator may have another opinion on the transaction type. - $update = [ + $update = [ 'source_id' => $sourceId, 'source_name' => $sourceName, 'destination_id' => $destinationId, @@ -358,9 +358,9 @@ class ConvertController extends Controller // also set the currency to the currency of the source account, in case you're converting a deposit into a transfer. if (TransactionTypeEnum::TRANSFER->value === $transactionType->type && TransactionTypeEnum::DEPOSIT->value === $journal->transactionType->type) { - $source = $this->accountRepository->find((int)$sourceId); + $source = $this->accountRepository->find((int) $sourceId); $sourceCurrency = $this->accountRepository->getAccountCurrency($source); - $dest = $this->accountRepository->find((int)$destinationId); + $dest = $this->accountRepository->find((int) $destinationId); $destCurrency = $this->accountRepository->getAccountCurrency($dest); if ( $sourceCurrency instanceof TransactionCurrency @@ -375,9 +375,9 @@ class ConvertController extends Controller // same thing for converting a withdrawal into a transfer, but with the currency of the destination account. if (TransactionTypeEnum::TRANSFER->value === $transactionType->type && TransactionTypeEnum::WITHDRAWAL->value === $journal->transactionType->type) { - $source = $this->accountRepository->find((int)$sourceId); + $source = $this->accountRepository->find((int) $sourceId); $sourceCurrency = $this->accountRepository->getAccountCurrency($source); - $dest = $this->accountRepository->find((int)$destinationId); + $dest = $this->accountRepository->find((int) $destinationId); $destCurrency = $this->accountRepository->getAccountCurrency($dest); if ( $sourceCurrency instanceof TransactionCurrency @@ -391,7 +391,7 @@ class ConvertController extends Controller } /** @var JournalUpdateService $service */ - $service = app(JournalUpdateService::class); + $service = app(JournalUpdateService::class); $service->setTransactionJournal($journal); $service->setData($update); $service->update(); diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index 67bed09edf..ee318e7b6e 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -61,7 +61,7 @@ class MassController extends Controller parent::__construct(); $this->middleware(function ($request, $next) { - app('view')->share('title', (string)trans('firefly.transactions')); + app('view')->share('title', (string) trans('firefly.transactions')); app('view')->share('mainTitleIcon', 'fa-exchange'); $this->repository = app(JournalRepositoryInterface::class); @@ -74,7 +74,7 @@ class MassController extends Controller */ public function delete(array $journals): IlluminateView { - $subTitle = (string)trans('firefly.mass_delete_journals'); + $subTitle = (string) trans('firefly.mass_delete_journals'); // put previous url in session $this->rememberPreviousUrl('transactions.mass-delete.url'); @@ -87,7 +87,7 @@ class MassController extends Controller * * @return Application|Redirector|RedirectResponse */ - public function destroy(MassDeleteJournalRequest $request): Redirector | RedirectResponse + public function destroy(MassDeleteJournalRequest $request): Redirector|RedirectResponse { Log::debug(sprintf('Now in %s', __METHOD__)); $ids = $request->get('confirm_mass_delete'); @@ -100,8 +100,8 @@ class MassController extends Controller Log::debug(sprintf('Searching for ID #%d', $journalId)); /** @var null|TransactionJournal $journal */ - $journal = $this->repository->find((int)$journalId); - if (null !== $journal && (int)$journalId === $journal->id) { + $journal = $this->repository->find((int) $journalId); + if (null !== $journal && (int) $journalId === $journal->id) { $this->repository->destroyJournal($journal); ++$count; Log::debug(sprintf('Deleted transaction journal #%d', $journalId)); @@ -123,22 +123,22 @@ class MassController extends Controller */ public function edit(array $journals): IlluminateView { - $subTitle = (string)trans('firefly.mass_edit_journals'); + $subTitle = (string) trans('firefly.mass_edit_journals'); /** @var AccountRepositoryInterface $accountRepository */ - $accountRepository = app(AccountRepositoryInterface::class); + $accountRepository = app(AccountRepositoryInterface::class); // valid withdrawal sources: - $array = array_keys(config(sprintf('firefly.source_dests.%s', TransactionTypeEnum::WITHDRAWAL->value))); - $withdrawalSources = $accountRepository->getAccountsByType($array); + $array = array_keys(config(sprintf('firefly.source_dests.%s', TransactionTypeEnum::WITHDRAWAL->value))); + $withdrawalSources = $accountRepository->getAccountsByType($array); // valid deposit destinations: $array = config(sprintf('firefly.source_dests.%s.%s', TransactionTypeEnum::DEPOSIT->value, AccountTypeEnum::REVENUE->value)); $depositDestinations = $accountRepository->getAccountsByType($array); /** @var BudgetRepositoryInterface $budgetRepository */ - $budgetRepository = app(BudgetRepositoryInterface::class); - $budgets = $budgetRepository->getBudgets(); + $budgetRepository = app(BudgetRepositoryInterface::class); + $budgets = $budgetRepository->getBudgets(); // reverse amounts foreach ($journals as $index => $journal) { @@ -162,18 +162,18 @@ class MassController extends Controller * * @throws FireflyException */ - public function update(MassEditJournalRequest $request): Redirector | RedirectResponse + public function update(MassEditJournalRequest $request): Redirector|RedirectResponse { $journalIds = $request->get('journals'); if (!is_array($journalIds)) { // TODO this is a weird error, should be caught. throw new FireflyException('This is not an array.'); } - $count = 0; + $count = 0; /** @var string $journalId */ foreach ($journalIds as $journalId) { - $integer = (int)$journalId; + $integer = (int) $journalId; try { $this->updateJournal($integer, $request); @@ -195,15 +195,15 @@ class MassController extends Controller */ private function updateJournal(int $journalId, MassEditJournalRequest $request): void { - $journal = $this->repository->find($journalId); + $journal = $this->repository->find($journalId); if (!$journal instanceof TransactionJournal) { throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId)); } - $service = app(JournalUpdateService::class); + $service = app(JournalUpdateService::class); // for each field, call the update service. $service->setTransactionJournal($journal); - $data = [ + $data = [ 'date' => $this->getDateFromRequest($request, $journal->id, 'date'), 'description' => $this->getStringFromRequest($request, $journal->id, 'description'), 'source_id' => $this->getIntFromRequest($request, $journal->id, 'source_id'), @@ -259,7 +259,7 @@ class MassController extends Controller return null; } - return (string)$value[$journalId]; + return (string) $value[$journalId]; } private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?int @@ -272,6 +272,6 @@ class MassController extends Controller return null; } - return (int)$value[$journalId]; + return (int) $value[$journalId]; } } diff --git a/app/Listeners/Model/Account/UpdatesAccountInformation.php b/app/Listeners/Model/Account/UpdatesAccountInformation.php index b75bdf2505..e4efe8baf3 100644 --- a/app/Listeners/Model/Account/UpdatesAccountInformation.php +++ b/app/Listeners/Model/Account/UpdatesAccountInformation.php @@ -36,7 +36,7 @@ use Illuminate\Support\Facades\Log; class UpdatesAccountInformation implements ShouldQueue { - public function handle(CreatedNewAccount | UpdatedExistingAccount $event): void + public function handle(CreatedNewAccount|UpdatedExistingAccount $event): void { $this->recalculateCredit($event->account); $this->updateVirtualBalance($event->account); diff --git a/app/Listeners/Model/Rule/NotifiesUserAboutFailedRuleAction.php b/app/Listeners/Model/Rule/NotifiesUserAboutFailedRuleAction.php index 18d1c42f5a..5989c6a3d7 100644 --- a/app/Listeners/Model/Rule/NotifiesUserAboutFailedRuleAction.php +++ b/app/Listeners/Model/Rule/NotifiesUserAboutFailedRuleAction.php @@ -34,25 +34,25 @@ use Illuminate\Support\Facades\Log; class NotifiesUserAboutFailedRuleAction implements ShouldQueue { - public function handle(RuleActionFailedOnArray | RuleActionFailedOnObject $event): void + public function handle(RuleActionFailedOnArray|RuleActionFailedOnObject $event): void { - $ruleAction = $event->ruleAction; - $rule = $ruleAction->rule; + $ruleAction = $event->ruleAction; + $rule = $ruleAction->rule; /** @var bool $preference */ - $preference = Preferences::getForUser($rule->user, 'notification_rule_action_failures', true)->data; + $preference = Preferences::getForUser($rule->user, 'notification_rule_action_failures', true)->data; if (false === $preference) { return; } Log::debug('Now in ruleActionFailedOnArray'); - $journal = $event->journal; - $error = $event->error; - $user = $ruleAction->rule->user; + $journal = $event->journal; + $error = $event->error; + $user = $ruleAction->rule->user; - $groupId = is_array($journal) ? $journal['transaction_group_id'] : $journal->transaction_group_id; - $groupTitle = is_array($journal) ? $journal['description'] ?? '' : $journal->description ?? ''; + $groupId = is_array($journal) ? $journal['transaction_group_id'] : $journal->transaction_group_id; + $groupTitle = is_array($journal) ? $journal['description'] ?? '' : $journal->description ?? ''; - $mainMessage = trans('rules.main_message', ['rule' => $rule->title, 'action' => $ruleAction->action_type, 'group' => $groupId, 'error' => $error]); + $mainMessage = trans('rules.main_message', ['rule' => $rule->title, 'action' => $ruleAction->action_type, 'group' => $groupId, 'error' => $error]); $groupLink = route('transactions.show', [$groupId]); $ruleTitle = $rule->title; $ruleLink = route('rules.edit', [$rule->id]); diff --git a/app/Listeners/Model/Subscription/NotifiesAboutExtensionOrRenewal.php b/app/Listeners/Model/Subscription/NotifiesAboutExtensionOrRenewal.php index 48cbcf20a4..a2e8a4a2c8 100644 --- a/app/Listeners/Model/Subscription/NotifiesAboutExtensionOrRenewal.php +++ b/app/Listeners/Model/Subscription/NotifiesAboutExtensionOrRenewal.php @@ -39,11 +39,12 @@ class NotifiesAboutExtensionOrRenewal implements ShouldQueue $subscription = $event->subscription; /** @var bool $preference */ - $preference = Preferences::getForUser($subscription->user, 'notification_bill_reminder', true)->data; + $preference = Preferences::getForUser($subscription->user, 'notification_bill_reminder', true)->data; if (true === $preference) { Log::debug('Subscription reminder is true!'); NotificationSender::send($subscription->user, new BillReminder($subscription, $event->field, $event->diff)); + return; } Log::debug('User has disabled subscription reminders.'); diff --git a/app/Listeners/Model/Subscription/NotifiesAboutOverdueSubscriptions.php b/app/Listeners/Model/Subscription/NotifiesAboutOverdueSubscriptions.php index f58c35b43b..c3a4239f50 100644 --- a/app/Listeners/Model/Subscription/NotifiesAboutOverdueSubscriptions.php +++ b/app/Listeners/Model/Subscription/NotifiesAboutOverdueSubscriptions.php @@ -38,15 +38,15 @@ class NotifiesAboutOverdueSubscriptions implements ShouldQueue { Log::debug(sprintf('Now in %s', __METHOD__)); // make sure user does not get the warning twice. - $overdue = $event->overdue; - $user = $event->user; - $toBeWarned = []; + $overdue = $event->overdue; + $user = $event->user; + $toBeWarned = []; Log::debug(sprintf('%d subscriptions to warn about.', count($overdue))); foreach ($overdue as $item) { /** @var Bill $bill */ - $bill = $item['bill']; - $key = sprintf('bill_overdue_%s_%s', $bill->id, substr(hash('sha256', json_encode($item['dates']['pay_dates'], JSON_THROW_ON_ERROR)), 0, 10)); - $pref = Preferences::getForUser($bill->user, $key, false); + $bill = $item['bill']; + $key = sprintf('bill_overdue_%s_%s', $bill->id, substr(hash('sha256', json_encode($item['dates']['pay_dates'], JSON_THROW_ON_ERROR)), 0, 10)); + $pref = Preferences::getForUser($bill->user, $key, false); if (true === $pref->data) { Log::debug(sprintf('User #%d has already been warned about overdue subscription #%d.', $bill->user->id, $bill->id)); diff --git a/app/Listeners/Model/TransactionGroup/MailsNewTransactionsReport.php b/app/Listeners/Model/TransactionGroup/MailsNewTransactionsReport.php index 711b0ebc08..50a0ece0f7 100644 --- a/app/Listeners/Model/TransactionGroup/MailsNewTransactionsReport.php +++ b/app/Listeners/Model/TransactionGroup/MailsNewTransactionsReport.php @@ -41,11 +41,11 @@ class MailsNewTransactionsReport implements ShouldQueue Log::debug('In MailsNewTransactionsReport.'); /** @var UserRepositoryInterface $repository */ - $repository = app(UserRepositoryInterface::class); - $user = $repository->find($event->userId); + $repository = app(UserRepositoryInterface::class); + $user = $repository->find($event->userId); /** @var bool $sendReport */ - $sendReport = Preferences::getForUser($user, 'notification_transaction_creation', false)->data; + $sendReport = Preferences::getForUser($user, 'notification_transaction_creation', false)->data; if (false === $sendReport) { Log::debug('Not sending report, because config says so.'); diff --git a/app/Listeners/Model/TransactionGroup/ProcessesDestroyedTransactionGroup.php b/app/Listeners/Model/TransactionGroup/ProcessesDestroyedTransactionGroup.php index 7dd11431b8..e500592ba2 100644 --- a/app/Listeners/Model/TransactionGroup/ProcessesDestroyedTransactionGroup.php +++ b/app/Listeners/Model/TransactionGroup/ProcessesDestroyedTransactionGroup.php @@ -1,4 +1,7 @@ transactionGroup; - $user = $group->user; + $group = $destroyedGroupEvent->transactionGroup; + $user = $group->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); diff --git a/app/Listeners/Model/TransactionGroup/ProcessesNewTransactionGroup.php b/app/Listeners/Model/TransactionGroup/ProcessesNewTransactionGroup.php index 28dabd8ae7..b663de8be3 100644 --- a/app/Listeners/Model/TransactionGroup/ProcessesNewTransactionGroup.php +++ b/app/Listeners/Model/TransactionGroup/ProcessesNewTransactionGroup.php @@ -47,7 +47,7 @@ use Illuminate\Support\Facades\Log; class ProcessesNewTransactionGroup implements ShouldQueue { - public function handle(CreatedSingleTransactionGroup | UserRequestedBatchProcessing $event): void + public function handle(CreatedSingleTransactionGroup|UserRequestedBatchProcessing $event): void { $groupId = 0; $collection = new Collection(); @@ -60,7 +60,7 @@ class ProcessesNewTransactionGroup implements ShouldQueue Log::debug('User called UserRequestedBatchProcessing'); } - $setting = FireflyConfig::get('enable_batch_processing', false)->data; + $setting = FireflyConfig::get('enable_batch_processing', false)->data; if (true === $event->flags->batchSubmission && true === $setting) { Log::debug(sprintf('Will do nothing for group #%d because it is part of a batch.', $groupId)); @@ -106,7 +106,7 @@ class ProcessesNewTransactionGroup implements ShouldQueue private function getFromInternalDate(array $ids): Carbon { - $entries = TransactionJournalMeta::whereIn('transaction_journal_id', $ids)->where('name', '_internal_previous_date')->get(['journal_meta.*',]); + $entries = TransactionJournalMeta::whereIn('transaction_journal_id', $ids)->where('name', '_internal_previous_date')->get(['journal_meta.*']); $array = $entries->toArray(); $return = today()->subDay(); if (count($array) > 0) { @@ -117,6 +117,7 @@ class ProcessesNewTransactionGroup implements ShouldQueue $date = Carbon::parse($array[0]['data']); $return = $date->lt($return) ? $date : $return; } + return $return; } @@ -130,11 +131,12 @@ class ProcessesNewTransactionGroup implements ShouldQueue Log::debug(sprintf('Found earliest date: %s', $earliest->toW3cString())); // get accounts - $accounts = Account::leftJoin('transactions', 'transactions.account_id', 'accounts.id') - ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id') - ->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id') - ->whereIn('transaction_journals.id', $set->pluck('id')->toArray()) - ->get(['accounts.*']); + $accounts = Account::leftJoin('transactions', 'transactions.account_id', 'accounts.id') + ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id') + ->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id') + ->whereIn('transaction_journals.id', $set->pluck('id')->toArray()) + ->get(['accounts.*']) + ; Log::debug('Found accounts to process', $accounts->pluck('id')->toArray()); @@ -160,8 +162,8 @@ class ProcessesNewTransactionGroup implements ShouldQueue Log::debug(__METHOD__); /** @var TransactionJournal $first */ - $first = $set->first(); - $user = $first->user; + $first = $set->first(); + $user = $first->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); @@ -192,12 +194,12 @@ class ProcessesNewTransactionGroup implements ShouldQueue private function processRules(Collection $set): void { Log::debug(sprintf('Will now processRules for %d journal(s)', $set->count())); - $array = $set->pluck('id')->toArray(); + $array = $set->pluck('id')->toArray(); /** @var TransactionJournal $first */ - $first = $set->first(); - $journalIds = implode(',', $array); - $user = $first->user; + $first = $set->first(); + $journalIds = implode(',', $array); + $user = $first->user; Log::debug(sprintf('Add local operator for journal(s): %s', $journalIds)); // collect rules: @@ -207,12 +209,12 @@ class ProcessesNewTransactionGroup implements ShouldQueue // add the groups to the rule engine. // it should run the rules in the group and cancel the group if necessary. Log::debug('Fire processRules with ALL store-journal rule groups.'); - $groups = $ruleGroupRepository->getRuleGroupsWithRules('store-journal'); + $groups = $ruleGroupRepository->getRuleGroupsWithRules('store-journal'); // create and fire rule engine. - $newRuleEngine = app(RuleEngineInterface::class); + $newRuleEngine = app(RuleEngineInterface::class); $newRuleEngine->setUser($user); - $newRuleEngine->addOperator(['type' => 'journal_id', 'value' => $journalIds]); + $newRuleEngine->addOperator(['type' => 'journal_id', 'value' => $journalIds]); $newRuleEngine->setRuleGroups($groups); $newRuleEngine->fire(); } diff --git a/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php b/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php index 30b671e550..62abdf941f 100644 --- a/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php +++ b/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php @@ -1,4 +1,7 @@ transactionGroup; + $group = $updatedGroupEvent->transactionGroup; if (1 === $group->transactionJournals->count()) { Log::debug('Nothing to do in unifyAccounts()'); + return; } // first journal: /** @var null|TransactionJournal $first */ - $first = $group + $first = $group ->transactionJournals() ->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.order', 'ASC') ->orderBy('transaction_journals.id', 'DESC') ->orderBy('transaction_journals.description', 'DESC') - ->first(); + ->first() + ; if (null === $first) { Log::warning(sprintf('Group #%d has no transaction journals.', $group->id)); @@ -81,15 +85,15 @@ class ProcessesUpdatedTransactionGroup return; } - $all = $group->transactionJournals()->get()->pluck('id')->toArray(); + $all = $group->transactionJournals()->get()->pluck('id')->toArray(); /** @var Account $sourceAccount */ $sourceAccount = $first->transactions()->where('amount', '<', '0')->first()->account; /** @var Account $destAccount */ - $destAccount = $first->transactions()->where('amount', '>', '0')->first()->account; + $destAccount = $first->transactions()->where('amount', '>', '0')->first()->account; - $type = $first->transactionType->type; + $type = $first->transactionType->type; if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::WITHDRAWAL->value === $type) { // set all source transactions to source account: Transaction::whereIn('transaction_journal_id', $all)->where('amount', '<', 0)->update(['account_id' => $sourceAccount->id]); @@ -101,7 +105,6 @@ class ProcessesUpdatedTransactionGroup Log::debug('Done with unifyAccounts()'); } - /** * This method will check all the rules when a journal is updated. */ @@ -114,36 +117,35 @@ class ProcessesUpdatedTransactionGroup return; } - $journals = $updatedGroupEvent->transactionGroup->transactionJournals; - $array = []; + $journals = $updatedGroupEvent->transactionGroup->transactionJournals; + $array = []; /** @var TransactionJournal $journal */ foreach ($journals as $journal) { $array[] = $journal->id; } - $journalIds = implode(',', $array); + $journalIds = implode(',', $array); Log::debug(sprintf('Add local operator for journal(s): %s', $journalIds)); // collect rules: $ruleGroupRepository = app(RuleGroupRepositoryInterface::class); $ruleGroupRepository->setUser($updatedGroupEvent->transactionGroup->user); - $groups = $ruleGroupRepository->getRuleGroupsWithRules('update-journal'); + $groups = $ruleGroupRepository->getRuleGroupsWithRules('update-journal'); // file rule engine. - $newRuleEngine = app(RuleEngineInterface::class); + $newRuleEngine = app(RuleEngineInterface::class); $newRuleEngine->setUser($updatedGroupEvent->transactionGroup->user); - $newRuleEngine->addOperator(['type' => 'journal_id', 'value' => $journalIds]); + $newRuleEngine->addOperator(['type' => 'journal_id', 'value' => $journalIds]); $newRuleEngine->setRuleGroups($groups); $newRuleEngine->fire(); Log::debug('Done with processRules()'); } - private function recalculateCredit(UpdatedSingleTransactionGroup $event): void { Log::debug('Now in recalculateCredit()'); - $group = $event->transactionGroup; + $group = $event->transactionGroup; /** @var CreditRecalculateService $object */ $object = app(CreditRecalculateService::class); @@ -152,17 +154,16 @@ class ProcessesUpdatedTransactionGroup Log::debug('Done with recalculateCredit()'); } - private function triggerWebhooks(UpdatedSingleTransactionGroup $updatedGroupEvent): void { Log::debug('Now in triggerWebhooks()'); - $group = $updatedGroupEvent->transactionGroup; + $group = $updatedGroupEvent->transactionGroup; if (false === $updatedGroupEvent->fireWebhooks) { Log::info(sprintf('Will not fire webhooks for transaction group #%d', $group->id)); return; } - $user = $group->user; + $user = $group->user; /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); diff --git a/app/Listeners/Security/System/HandlesNewUserRegistration.php b/app/Listeners/Security/System/HandlesNewUserRegistration.php index 12196df639..ff06b3a786 100644 --- a/app/Listeners/Security/System/HandlesNewUserRegistration.php +++ b/app/Listeners/Security/System/HandlesNewUserRegistration.php @@ -40,7 +40,6 @@ use FireflyIII\Support\Facades\FireflyConfig; use FireflyIII\User; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\Notification; class HandlesNewUserRegistration implements ShouldQueue { @@ -70,12 +69,12 @@ class HandlesNewUserRegistration implements ShouldQueue */ private function createGroupMembership(User $user): void { - $groupExists = true; - $groupTitle = $user->email; - $index = 1; + $groupExists = true; + $groupTitle = $user->email; + $index = 1; /** @var null|UserGroup $group */ - $group = null; + $group = null; // create a new group. while ($groupExists) { // @phpstan-ignore-line @@ -85,7 +84,7 @@ class HandlesNewUserRegistration implements ShouldQueue break; } - $groupTitle = sprintf('%s-%d', $user->email, $index); + $groupTitle = sprintf('%s-%d', $user->email, $index); ++$index; if ($index > 99) { throw new FireflyException('Email address can no longer be used for registrations.'); @@ -93,11 +92,11 @@ class HandlesNewUserRegistration implements ShouldQueue } /** @var null|UserRole $role */ - $role = UserRole::where('title', UserRoleEnum::OWNER->value)->first(); + $role = UserRole::where('title', UserRoleEnum::OWNER->value)->first(); if (null === $role) { throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?'); } - GroupMembership::create(['user_id' => $user->id, 'user_group_id' => $group->id, 'user_role_id' => $role->id]); + GroupMembership::create(['user_id' => $user->id, 'user_group_id' => $group->id, 'user_role_id' => $role->id]); $user->user_group_id = $group->id; $user->save(); } @@ -113,7 +112,7 @@ class HandlesNewUserRegistration implements ShouldQueue private function sendAdminRegistrationNotification(User $user, OwnerNotifiable $owner): void { - $sendMail = (bool)FireflyConfig::get('notification_admin_new_reg', true)->data; + $sendMail = (bool) FireflyConfig::get('notification_admin_new_reg', true)->data; if (!$sendMail) { return; } @@ -122,7 +121,7 @@ class HandlesNewUserRegistration implements ShouldQueue private function sendRegistrationMail(User $user): void { - $sendMail = (bool)FireflyConfig::get('notification_user_new_reg', true)->data; + $sendMail = (bool) FireflyConfig::get('notification_user_new_reg', true)->data; if (!$sendMail) { return; } diff --git a/app/Listeners/Security/System/NotifiesAboutNewInvitation.php b/app/Listeners/Security/System/NotifiesAboutNewInvitation.php index b6e5a02054..ae0f293667 100644 --- a/app/Listeners/Security/System/NotifiesAboutNewInvitation.php +++ b/app/Listeners/Security/System/NotifiesAboutNewInvitation.php @@ -36,7 +36,6 @@ use FireflyIII\Support\Facades\FireflyConfig; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; -use Illuminate\Support\Facades\Notification; class NotifiesAboutNewInvitation implements ShouldQueue { @@ -69,6 +68,6 @@ class NotifiesAboutNewInvitation implements ShouldQueue return; } - NotificationSender::send(new OwnerNotifiable(), new UserInvitation($invitee)); + NotificationSender::send(new OwnerNotifiable(), new UserInvitation($invitee)); } } diff --git a/app/Listeners/Security/System/NotifiesOwnerAboutNewVersion.php b/app/Listeners/Security/System/NotifiesOwnerAboutNewVersion.php index b5552011e2..9dc4799e45 100644 --- a/app/Listeners/Security/System/NotifiesOwnerAboutNewVersion.php +++ b/app/Listeners/Security/System/NotifiesOwnerAboutNewVersion.php @@ -30,7 +30,6 @@ use FireflyIII\Notifications\Notifiables\OwnerNotifiable; use FireflyIII\Notifications\NotificationSender; use FireflyIII\Support\Facades\FireflyConfig; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Support\Facades\Notification; class NotifiesOwnerAboutNewVersion implements ShouldQueue { @@ -41,7 +40,7 @@ class NotifiesOwnerAboutNewVersion implements ShouldQueue return; } - $owner = new OwnerNotifiable(); - NotificationSender ::send($owner, new VersionCheckResult($event->message)); + $owner = new OwnerNotifiable(); + NotificationSender::send($owner, new VersionCheckResult($event->message)); } } diff --git a/app/Listeners/Security/User/NotifiesUserAboutNewAccessToken.php b/app/Listeners/Security/User/NotifiesUserAboutNewAccessToken.php index c81c992d79..0e267ce06f 100644 --- a/app/Listeners/Security/User/NotifiesUserAboutNewAccessToken.php +++ b/app/Listeners/Security/User/NotifiesUserAboutNewAccessToken.php @@ -1,4 +1,7 @@ find((int)$event->userId); + $user = $repository->find((int) $event->userId); if (null !== $user) { NotificationSender::send($user, new NewAccessToken()); diff --git a/app/Listeners/Security/User/NotifiesUserAboutNewIpAddress.php b/app/Listeners/Security/User/NotifiesUserAboutNewIpAddress.php index 94f33fd69c..f872e55ff2 100644 --- a/app/Listeners/Security/User/NotifiesUserAboutNewIpAddress.php +++ b/app/Listeners/Security/User/NotifiesUserAboutNewIpAddress.php @@ -24,14 +24,11 @@ declare(strict_types=1); namespace FireflyIII\Listeners\Security\User; -use Exception; use FireflyIII\Events\Security\User\UserLoggedInFromNewIpAddress; use FireflyIII\Notifications\NotificationSender; use FireflyIII\Notifications\User\UserLogin; use FireflyIII\Support\Facades\Preferences; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\Notification; class NotifiesUserAboutNewIpAddress implements ShouldQueue { @@ -51,7 +48,7 @@ class NotifiesUserAboutNewIpAddress implements ShouldQueue /** @var array $entry */ foreach ($list as $index => $entry) { if (false === $entry['notified']) { - NotificationSender::send($user, new UserLogin()); + NotificationSender::send($user, new UserLogin()); } $list[$index]['notified'] = true; } diff --git a/app/Listeners/Security/User/NotifiesUserAboutNoCodesLeft.php b/app/Listeners/Security/User/NotifiesUserAboutNoCodesLeft.php index f77a326c17..199ac74368 100644 --- a/app/Listeners/Security/User/NotifiesUserAboutNoCodesLeft.php +++ b/app/Listeners/Security/User/NotifiesUserAboutNoCodesLeft.php @@ -24,13 +24,11 @@ declare(strict_types=1); namespace FireflyIII\Listeners\Security\User; -use Exception; use FireflyIII\Events\Security\User\UserHasNoMFABackupCodesLeft; use FireflyIII\Notifications\NotificationSender; use FireflyIII\Notifications\Security\MFABackupNoLeftNotification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\Notification; class NotifiesUserAboutNoCodesLeft implements ShouldQueue { @@ -40,6 +38,6 @@ class NotifiesUserAboutNoCodesLeft implements ShouldQueue $user = $event->user; - NotificationSender::send($user, new MFABackupNoLeftNotification($user)); + NotificationSender::send($user, new MFABackupNoLeftNotification($user)); } } diff --git a/app/Listeners/Security/User/NotifiesUserAboutRepeatedMFAFailures.php b/app/Listeners/Security/User/NotifiesUserAboutRepeatedMFAFailures.php index 29c565dff5..323f4c05a9 100644 --- a/app/Listeners/Security/User/NotifiesUserAboutRepeatedMFAFailures.php +++ b/app/Listeners/Security/User/NotifiesUserAboutRepeatedMFAFailures.php @@ -24,13 +24,11 @@ declare(strict_types=1); namespace FireflyIII\Listeners\Security\User; -use Exception; use FireflyIII\Events\Security\User\UserKeepsFailingMFA; use FireflyIII\Notifications\NotificationSender; use FireflyIII\Notifications\Security\MFAManyFailedAttemptsNotification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\Notification; class NotifiesUserAboutRepeatedMFAFailures implements ShouldQueue { @@ -40,6 +38,6 @@ class NotifiesUserAboutRepeatedMFAFailures implements ShouldQueue $user = $event->user; $count = $event->count; - NotificationSender::send($user, new MFAManyFailedAttemptsNotification($user, $count)); + NotificationSender::send($user, new MFAManyFailedAttemptsNotification($user, $count)); } } diff --git a/app/Listeners/Security/User/NotifiesUserAboutUsedBackupCode.php b/app/Listeners/Security/User/NotifiesUserAboutUsedBackupCode.php index e88811d698..a36e2c24e7 100644 --- a/app/Listeners/Security/User/NotifiesUserAboutUsedBackupCode.php +++ b/app/Listeners/Security/User/NotifiesUserAboutUsedBackupCode.php @@ -24,13 +24,11 @@ declare(strict_types=1); namespace FireflyIII\Listeners\Security\User; -use Exception; use FireflyIII\Events\Security\User\UserHasUsedBackupCode; use FireflyIII\Notifications\NotificationSender; use FireflyIII\Notifications\Security\MFAUsedBackupCodeNotification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\Notification; class NotifiesUserAboutUsedBackupCode implements ShouldQueue { @@ -39,6 +37,6 @@ class NotifiesUserAboutUsedBackupCode implements ShouldQueue Log::debug(sprintf('Now in %s', __METHOD__)); $user = $event->user; - NotificationSender::send($user, new MFAUsedBackupCodeNotification($user)); + NotificationSender::send($user, new MFAUsedBackupCodeNotification($user)); } } diff --git a/app/Listeners/System/RecalculatesPrimaryCurrencyAmounts.php b/app/Listeners/System/RecalculatesPrimaryCurrencyAmounts.php index 6dfa1752af..8b9fee70cf 100644 --- a/app/Listeners/System/RecalculatesPrimaryCurrencyAmounts.php +++ b/app/Listeners/System/RecalculatesPrimaryCurrencyAmounts.php @@ -1,4 +1,7 @@ autoBudgets as $autoBudget) { - if ('' === (string)$autoBudget->native_amount) { + if ('' === (string) $autoBudget->native_amount) { continue; } Log::debug(sprintf('Resetting native_amount for budget #%d and auto budget #%d.', $budget->id, $autoBudget->id)); @@ -82,7 +84,7 @@ class RecalculatesPrimaryCurrencyAmounts $autoBudget->saveQuietly(); } foreach ($budget->budgetlimits as $limit) { - if ('' !== (string)$limit->native_amount) { + if ('' !== (string) $limit->native_amount) { Log::debug(sprintf('Resetting native_amount for budget #%d and budget limit #%d.', $budget->id, $limit->id)); $limit->native_amount = null; $limit->saveQuietly(); @@ -92,20 +94,20 @@ class RecalculatesPrimaryCurrencyAmounts private function resetPiggyBank(PiggyBank $piggyBank): void { - if ('' !== (string)$piggyBank->native_target_amount) { + if ('' !== (string) $piggyBank->native_target_amount) { Log::debug(sprintf('Resetting native_target_amount for piggy bank #%d.', $piggyBank->id)); $piggyBank->native_target_amount = null; $piggyBank->saveQuietly(); } foreach ($piggyBank->accounts as $account) { - if ('' !== (string)$account->pivot->native_current_amount) { + if ('' !== (string) $account->pivot->native_current_amount) { Log::debug(sprintf('Resetting native_current_amount for piggy bank #%d and account #%d.', $piggyBank->id, $account->id)); $account->pivot->native_current_amount = null; $account->pivot->save(); } } foreach ($piggyBank->piggyBankEvents as $event) { - if ('' !== (string)$event->native_amount) { + if ('' !== (string) $event->native_amount) { Log::debug(sprintf('Resetting native_amount for piggy bank #%d and event #%d.', $piggyBank->id, $event->id)); $event->native_amount = null; $event->saveQuietly(); @@ -116,14 +118,19 @@ class RecalculatesPrimaryCurrencyAmounts private function resetTransactions(UserGroup $userGroup): void { // custom query because of the potential size of this update. - $success = DB::table('transactions')->join('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transaction_journals.user_group_id', $userGroup->id) - ->where(static function (Builder $q): void { - $q->whereNotNull('native_amount') - ->orWhereNotNull('native_foreign_amount') - ->orWhere('native_amount', '!=', '') - ->orWhere('native_foreign_amount', '!=', ''); - }) - ->update(['native_amount' => null, 'native_foreign_amount' => null]); + $success = DB::table('transactions') + ->join('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') + ->where('transaction_journals.user_group_id', $userGroup->id) + ->where(static function (Builder $q): void { + $q + ->whereNotNull('native_amount') + ->orWhereNotNull('native_foreign_amount') + ->orWhere('native_amount', '!=', '') + ->orWhere('native_foreign_amount', '!=', '') + ; + }) + ->update(['native_amount' => null, 'native_foreign_amount' => null]) + ; Log::debug(sprintf('Reset %d transactions.', $success)); } @@ -144,7 +151,7 @@ class RecalculatesPrimaryCurrencyAmounts { $repository = app(BudgetRepositoryInterface::class); $repository->setUserGroup($userGroup); - $set = $repository->getBudgets(); + $set = $repository->getBudgets(); Log::debug(sprintf('Reset primary currency of %d budget(s).', $set->count())); @@ -153,5 +160,4 @@ class RecalculatesPrimaryCurrencyAmounts $this->resetBudget($budget); } } - } diff --git a/app/Listeners/Test/SendsTestNotification.php b/app/Listeners/Test/SendsTestNotification.php index 91e2cb977c..42eac938de 100644 --- a/app/Listeners/Test/SendsTestNotification.php +++ b/app/Listeners/Test/SendsTestNotification.php @@ -37,7 +37,7 @@ use Illuminate\Support\Facades\Log; class SendsTestNotification { - public function handle(OwnerTestsNotificationChannel | UserTestsNotificationChannel $event): void + public function handle(OwnerTestsNotificationChannel|UserTestsNotificationChannel $event): void { Log::debug(sprintf('Now in SendsTestNotification::handle(%s->"%s")', get_class($event), $event->channel)); diff --git a/app/Notifications/NotificationSender.php b/app/Notifications/NotificationSender.php index 61b97d8b8c..092e915feb 100644 --- a/app/Notifications/NotificationSender.php +++ b/app/Notifications/NotificationSender.php @@ -1,4 +1,7 @@ where('name', 'recurrence_id'); - $q1->where('data', json_encode((string)$recurrence->id)); + $q1->where('data', json_encode((string) $recurrence->id)); })->get(['journal_meta.transaction_journal_id']); // there are X journals made for this recurrence. Any of them meant for today? foreach ($set as $journalMeta) { $count = TransactionJournalMeta::where(static function (Builder $q2) use ($date): void { - $string = (string)$date; + $string = (string) $date; Log::debug(sprintf('Search for date: %s', json_encode($string))); $q2->where('name', 'recurrence_date'); $q2->where('data', json_encode($string)); @@ -103,7 +105,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte ->orderBy('active', 'DESC') ->orderBy('transaction_type_id', 'ASC') ->orderBy('title', 'ASC') - ->get(); + ->get() + ; } /** @@ -129,9 +132,10 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte { // grab ALL recurring transactions: return Recurrence::with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions']) - ->orderBy('active', 'DESC') - ->orderBy('title', 'ASC') - ->get(); + ->orderBy('active', 'DESC') + ->orderBy('title', 'ASC') + ->get() + ; } public function getBillId(RecurrenceTransaction $recTransaction): ?int @@ -141,7 +145,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte /** @var RecurrenceTransactionMeta $meta */ foreach ($recTransaction->recurrenceTransactionMeta as $meta) { if ('bill_id' === $meta->name) { - $return = (int)$meta->value; + $return = (int) $meta->value; } } @@ -158,7 +162,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte /** @var RecurrenceTransactionMeta $meta */ foreach ($recTransaction->recurrenceTransactionMeta as $meta) { if ('budget_id' === $meta->name) { - $return = (int)$meta->value; + $return = (int) $meta->value; } } @@ -175,7 +179,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte /** @var RecurrenceTransactionMeta $meta */ foreach ($recTransaction->recurrenceTransactionMeta as $meta) { if ('category_id' === $meta->name) { - $return = (int)$meta->value; + $return = (int) $meta->value; } } @@ -192,7 +196,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte /** @var RecurrenceTransactionMeta $meta */ foreach ($recTransaction->recurrenceTransactionMeta as $meta) { if ('category_name' === $meta->name) { - $return = (string)$meta->value; + $return = (string) $meta->value; } } @@ -206,10 +210,11 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte { Log::debug(sprintf('Now in getJournalCount(#%d, "%s", "%s")', $recurrence->id, $start?->format('Y-m-d H:i:s'), $end?->format('Y-m-d H:i:s'))); $query = TransactionJournal::leftJoin('journal_meta', 'journal_meta.transaction_journal_id', '=', 'transaction_journals.id') - ->where('transaction_journals.user_id', $recurrence->user_id) - ->whereNull('transaction_journals.deleted_at') - ->where('journal_meta.name', 'recurrence_id') - ->where('journal_meta.data', '"' . $recurrence->id . '"'); + ->where('transaction_journals.user_id', $recurrence->user_id) + ->whereNull('transaction_journals.deleted_at') + ->where('journal_meta.name', 'recurrence_id') + ->where('journal_meta.data', '"'.$recurrence->id.'"') + ; if ($start instanceof Carbon) { $query->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00')); } @@ -228,12 +233,13 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte public function getJournalIds(Recurrence $recurrence): array { return TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') - ->where('transaction_journals.user_id', $this->user->id) - ->where('journal_meta.name', '=', 'recurrence_id') - ->where('journal_meta.data', '=', json_encode((string)$recurrence->id)) - ->get(['journal_meta.transaction_journal_id']) - ->pluck('transaction_journal_id') - ->toArray(); + ->where('transaction_journals.user_id', $this->user->id) + ->where('journal_meta.name', '=', 'recurrence_id') + ->where('journal_meta.data', '=', json_encode((string) $recurrence->id)) + ->get(['journal_meta.transaction_journal_id']) + ->pluck('transaction_journal_id') + ->toArray() + ; } /** @@ -244,7 +250,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte /** @var null|Note $note */ $note = $recurrence->notes()->first(); - return (string)$note?->text; + return (string) $note?->text; } public function getPiggyBank(RecurrenceTransaction $transaction): ?int @@ -254,7 +260,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte /** @var RecurrenceTransactionMeta $metaEntry */ foreach ($meta as $metaEntry) { if ('piggy_bank_id' === $metaEntry->name) { - return (int)$metaEntry->value; + return (int) $metaEntry->value; } } @@ -271,7 +277,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte /** @var RecurrenceMeta $meta */ foreach ($transaction->recurrenceTransactionMeta as $meta) { if ('tags' === $meta->name && '' !== $meta->value) { - $tags = json_decode((string)$meta->value, true, 512, JSON_THROW_ON_ERROR); + $tags = json_decode((string) $meta->value, true, 512, JSON_THROW_ON_ERROR); } } @@ -281,20 +287,21 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte public function getTransactionPaginator(Recurrence $recurrence, int $page, int $pageSize): LengthAwarePaginator { $journalMeta = TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') - ->whereNull('transaction_journals.deleted_at') - ->where('transaction_journals.user_id', $this->user->id) - ->where('name', 'recurrence_id') - ->where('data', json_encode((string)$recurrence->id)) - ->get() - ->pluck('transaction_journal_id') - ->toArray(); + ->whereNull('transaction_journals.deleted_at') + ->where('transaction_journals.user_id', $this->user->id) + ->where('name', 'recurrence_id') + ->where('data', json_encode((string) $recurrence->id)) + ->get() + ->pluck('transaction_journal_id') + ->toArray() + ; $search = []; foreach ($journalMeta as $journalId) { - $search[] = (int)$journalId; + $search[] = (int) $journalId; } /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setUser($recurrence->user); $collector->withCategoryInformation()->withBudgetInformation()->setLimit($pageSize)->setPage($page)->withAccountInformation(); @@ -306,24 +313,25 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte public function getTransactions(Recurrence $recurrence): Collection { $journalMeta = TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') - ->whereNull('transaction_journals.deleted_at') - ->where('transaction_journals.user_id', $this->user->id) - ->where('name', 'recurrence_id') - ->where('data', json_encode((string)$recurrence->id)) - ->get() - ->pluck('transaction_journal_id') - ->toArray(); + ->whereNull('transaction_journals.deleted_at') + ->where('transaction_journals.user_id', $this->user->id) + ->where('name', 'recurrence_id') + ->where('data', json_encode((string) $recurrence->id)) + ->get() + ->pluck('transaction_journal_id') + ->toArray() + ; $search = []; foreach ($journalMeta as $journalId) { - $search[] = (int)$journalId; + $search[] = (int) $journalId; } if (0 === count($search)) { return new Collection(); } /** @var GroupCollectorInterface $collector */ - $collector = app(GroupCollectorInterface::class); + $collector = app(GroupCollectorInterface::class); $collector->setUser($recurrence->user); $collector->withCategoryInformation()->withBudgetInformation()->withAccountInformation(); @@ -436,51 +444,51 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte if (is_array($language)) { $language = 'en_US'; } - $language = (string)$language; + $language = (string) $language; if ('daily' === $repetition->repetition_type) { - return (string)trans('firefly.recurring_daily', [], $language); + return (string) trans('firefly.recurring_daily', [], $language); } if ('weekly' === $repetition->repetition_type) { $dayOfWeek = trans(sprintf('config.dow_%s', $repetition->repetition_moment), [], $language); if ($repetition->repetition_skip > 0) { - return (string)trans('firefly.recurring_weekly_skip', ['weekday' => $dayOfWeek, 'skip' => $repetition->repetition_skip + 1], $language); + return (string) trans('firefly.recurring_weekly_skip', ['weekday' => $dayOfWeek, 'skip' => $repetition->repetition_skip + 1], $language); } - return (string)trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek], $language); + return (string) trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek], $language); } if ('monthly' === $repetition->repetition_type) { if ($repetition->repetition_skip > 0) { - return (string)trans( + return (string) trans( 'firefly.recurring_monthly_skip', - ['dayOfMonth' => $repetition->repetition_moment, 'skip' => $repetition->repetition_skip + 1], + ['dayOfMonth' => $repetition->repetition_moment, 'skip' => $repetition->repetition_skip + 1], $language ); } - return (string)trans( + return (string) trans( 'firefly.recurring_monthly', - ['dayOfMonth' => $repetition->repetition_moment, 'skip' => $repetition->repetition_skip - 1], + ['dayOfMonth' => $repetition->repetition_moment, 'skip' => $repetition->repetition_skip - 1], $language ); } if ('ndom' === $repetition->repetition_type) { - $parts = explode(',', $repetition->repetition_moment); + $parts = explode(',', $repetition->repetition_moment); // first part is number of week, second is weekday. $dayOfWeek = trans(sprintf('config.dow_%s', $parts[1]), [], $language); - return (string)trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $parts[0]], $language); + return (string) trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $parts[0]], $language); } if ('yearly' === $repetition->repetition_type) { - $today = today(config('app.timezone'))->endOfYear(); - $repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment); + $today = today(config('app.timezone'))->endOfYear(); + $repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment); if (!$repDate instanceof Carbon) { $repDate = clone $today; } - $diffInYears = (int)$today->diffInYears($repDate, true); + $diffInYears = (int) $today->diffInYears($repDate, true); $repDate->addYears($diffInYears); // technically not necessary. - $string = $repDate->isoFormat((string)trans('config.month_and_day_no_year_js')); + $string = $repDate->isoFormat((string) trans('config.month_and_day_no_year_js')); - return (string)trans('firefly.recurring_yearly', ['date' => $string], $language); + return (string) trans('firefly.recurring_yearly', ['date' => $string], $language); } return ''; @@ -512,16 +520,16 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte public function totalTransactions(Recurrence $recurrence, RecurrenceRepetition $repetition): int { // if repeat = null just return 0. - if (null === $recurrence->repeat_until && 0 === (int)$recurrence->repetitions) { + if (null === $recurrence->repeat_until && 0 === (int) $recurrence->repetitions) { return 0; } // expect X transactions then stop. Return that number - if (null === $recurrence->repeat_until && 0 !== (int)$recurrence->repetitions) { - return (int)$recurrence->repetitions; + if (null === $recurrence->repeat_until && 0 !== (int) $recurrence->repetitions) { + return (int) $recurrence->repetitions; } // need to calculate, this depends on the repetition: - if (null !== $recurrence->repeat_until && 0 === (int)$recurrence->repetitions) { + if (null !== $recurrence->repeat_until && 0 === (int) $recurrence->repetitions) { $occurrences = $this->getOccurrencesInRange($repetition, $recurrence->first_date ?? today(), $recurrence->repeat_until); return count($occurrences); @@ -538,7 +546,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte $occurrences = []; $mutator = clone $start; $mutator->startOfDay(); - $skipMod = $repetition->repetition_skip + 1; + $skipMod = $repetition->repetition_skip + 1; Log::debug(sprintf('Calculating occurrences for rep type "%s"', $repetition->repetition_type)); Log::debug(sprintf('Mutator is now: %s', $mutator->format('Y-m-d'))); @@ -588,12 +596,13 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte } } - #[\Override] + #[Override] public function setLatestDate(Recurrence $recurrence, ?Carbon $date): Recurrence { $recurrence->latest_date = $date; $recurrence->latest_date_tz = $date?->format('e'); $recurrence->save(); + return $recurrence; } } diff --git a/app/Repositories/Recurring/RecurringRepositoryInterface.php b/app/Repositories/Recurring/RecurringRepositoryInterface.php index 39fde3c6d6..22cc3a2145 100644 --- a/app/Repositories/Recurring/RecurringRepositoryInterface.php +++ b/app/Repositories/Recurring/RecurringRepositoryInterface.php @@ -49,6 +49,7 @@ use Illuminate\Support\Collection; interface RecurringRepositoryInterface { public function setLatestDate(Recurrence $recurrence, Carbon $date): Recurrence; + public function createdPreviously(Recurrence $recurrence, Carbon $date): bool; /** diff --git a/app/Services/Internal/Destroy/GenericDestroyService.php b/app/Services/Internal/Destroy/GenericDestroyService.php index e9a4c2a732..f7c30453d1 100644 --- a/app/Services/Internal/Destroy/GenericDestroyService.php +++ b/app/Services/Internal/Destroy/GenericDestroyService.php @@ -1,4 +1,7 @@ forceDelete(); } - } diff --git a/app/Services/Internal/Recalculate/PrimaryAmountRecalculationService.php b/app/Services/Internal/Recalculate/PrimaryAmountRecalculationService.php index 7ae9249cbd..ad080e661e 100644 --- a/app/Services/Internal/Recalculate/PrimaryAmountRecalculationService.php +++ b/app/Services/Internal/Recalculate/PrimaryAmountRecalculationService.php @@ -1,4 +1,7 @@ calculateTransactions($userGroup, $currency); } - private function recalculateAccounts(UserGroup $userGroup): void { $set = $userGroup @@ -93,7 +95,8 @@ class PrimaryAmountRecalculationService $q->orWhere('virtual_balance', '!=', ''); } }) - ->get(); + ->get() + ; /** @var Account $account */ foreach ($set as $account) { @@ -102,28 +105,27 @@ class PrimaryAmountRecalculationService Log::debug(sprintf('Recalculated %d accounts for user group #%d.', $set->count(), $userGroup->id)); } - private function recalculatePiggyBanks(UserGroup $userGroup, TransactionCurrency $currency): void { - $converter = new ExchangeRateConverter(); + $converter = new ExchangeRateConverter(); $converter->setUserGroup($userGroup); $converter->setIgnoreSettings(true); $repository = app(PiggyBankRepositoryInterface::class); $repository->setUserGroup($userGroup); - $set = $repository->getPiggyBanks(); - $set = $set->filter(static fn(PiggyBank $piggyBank): bool => $currency->id !== $piggyBank->transaction_currency_id); + $set = $repository->getPiggyBanks(); + $set = $set->filter(static fn (PiggyBank $piggyBank): bool => $currency->id !== $piggyBank->transaction_currency_id); foreach ($set as $piggyBank) { $piggyBank->encrypted = false; $piggyBank->save(); foreach ($piggyBank->accounts as $account) { $account->pivot->native_current_amount = null; - if (0 !== bccomp((string)$account->pivot->current_amount, '0')) { + if (0 !== bccomp((string) $account->pivot->current_amount, '0')) { $account->pivot->native_current_amount = $converter->convert( $piggyBank->transactionCurrency, $currency, today(), - (string)$account->pivot->current_amount + (string) $account->pivot->current_amount ); } $account->pivot->save(); @@ -133,7 +135,6 @@ class PrimaryAmountRecalculationService Log::debug(sprintf('Recalculated %d piggy banks for user group #%d.', $set->count(), $userGroup->id)); } - private function recalculatePiggyBankEvents(PiggyBank $piggyBank): void { $set = $piggyBank->piggyBankEvents()->get(); @@ -155,7 +156,6 @@ class PrimaryAmountRecalculationService Log::debug(sprintf('Recalculated %d budgets.', $set->count())); } - private function recalculateBudgetLimits(Budget $budget, TransactionCurrency $currency): void { $set = $budget->budgetlimits()->where('transaction_currency_id', '!=', $currency->id)->get(); @@ -192,7 +192,6 @@ class PrimaryAmountRecalculationService Log::debug(sprintf('Recalculated %d available budgets.', $set->count())); } - private function recalculateBills(UserGroup $userGroup, TransactionCurrency $currency): void { $set = $userGroup->bills()->where('transaction_currency_id', '!=', $currency->id)->get(); @@ -208,21 +207,22 @@ class PrimaryAmountRecalculationService { // custom query because of the potential size of this update. $set = DB::table('transactions') - ->join('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') - ->where('transaction_journals.user_group_id', $userGroup->id) - ->where(static function (DatabaseBuilder $q1) use ($currency): void { - $q1->where(static function (DatabaseBuilder $q2) use ($currency): void { - $q2->whereNot('transactions.transaction_currency_id', $currency->id)->whereNull('transactions.foreign_currency_id'); - })->orWhere(static function (DatabaseBuilder $q3) use ($currency): void { - $q3->whereNot('transactions.transaction_currency_id', $currency->id)->whereNot('transactions.foreign_currency_id', $currency->id); - }); - }) + ->join('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') + ->where('transaction_journals.user_group_id', $userGroup->id) + ->where(static function (DatabaseBuilder $q1) use ($currency): void { + $q1->where(static function (DatabaseBuilder $q2) use ($currency): void { + $q2->whereNot('transactions.transaction_currency_id', $currency->id)->whereNull('transactions.foreign_currency_id'); + })->orWhere(static function (DatabaseBuilder $q3) use ($currency): void { + $q3->whereNot('transactions.transaction_currency_id', $currency->id)->whereNot('transactions.foreign_currency_id', $currency->id); + }); + }) // ->where(static function (DatabaseBuilder $q) use ($currency): void { // $q->whereNot('transactions.transaction_currency_id', $currency->id) // ->whereNot('transactions.foreign_currency_id', $currency->id) // ; // }) - ->get(['transactions.id']); + ->get(['transactions.id']) + ; TransactionObserver::$recalculate = false; foreach ($set as $item) { // here we are. @@ -233,6 +233,4 @@ class PrimaryAmountRecalculationService TransactionObserver::$recalculate = true; Log::debug(sprintf('Recalculated %d transactions.', $set->count())); } - - } diff --git a/app/Support/Models/AccountBalanceCalculator.php b/app/Support/Models/AccountBalanceCalculator.php index b7ba22bb58..4308bf0983 100644 --- a/app/Support/Models/AccountBalanceCalculator.php +++ b/app/Support/Models/AccountBalanceCalculator.php @@ -53,6 +53,7 @@ class AccountBalanceCalculator { if ($forced) { Transaction::whereNull('deleted_at')->update(['balance_dirty' => true]); + // also delete account balances. // AccountBalance::whereNotNull('created_at')->delete(); } @@ -66,17 +67,17 @@ class AccountBalanceCalculator return; } Log::debug(__METHOD__); - $object = new self(); + $object = new self(); - $set = []; + $set = []; foreach ($transactionJournal->transactions as $transaction) { $set[$transaction->account_id] = $transaction->account; } $accounts = new Collection()->push(...$set); // find meta value: - $date = $transactionJournal->date; - $meta = $transactionJournal->transactionJournalMeta()->where('name', '_internal_previous_date')->where('data', '!=', '')->first(); + $date = $transactionJournal->date; + $meta = $transactionJournal->transactionJournalMeta()->where('name', '_internal_previous_date')->where('data', '!=', '')->first(); Log::debug(sprintf('Date used is "%s"', $date->toW3cString())); if (null !== $meta) { $date = Carbon::parse($meta->data); @@ -93,28 +94,29 @@ class AccountBalanceCalculator return '0'; } - $query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') - ->whereNull('transactions.deleted_at') - ->where('transactions.transaction_currency_id', $currencyId) - ->whereNull('transaction_journals.deleted_at') + $query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') + ->whereNull('transactions.deleted_at') + ->where('transactions.transaction_currency_id', $currencyId) + ->whereNull('transaction_journals.deleted_at') // this order is the same as GroupCollector - ->orderBy('transaction_journals.date', 'DESC') - ->orderBy('transaction_journals.order', 'ASC') - ->orderBy('transaction_journals.id', 'DESC') - ->orderBy('transaction_journals.description', 'DESC') - ->orderBy('transactions.amount', 'DESC') - ->where('transactions.account_id', $accountId); + ->orderBy('transaction_journals.date', 'DESC') + ->orderBy('transaction_journals.order', 'ASC') + ->orderBy('transaction_journals.id', 'DESC') + ->orderBy('transaction_journals.description', 'DESC') + ->orderBy('transactions.amount', 'DESC') + ->where('transactions.account_id', $accountId) + ; $query->where('transaction_journals.date', '<', $notBefore); - $first = $query->first([ - 'transactions.id', - 'transactions.balance_dirty', - 'transactions.transaction_currency_id', - 'transaction_journals.date', - 'transactions.account_id', - 'transactions.amount', - 'transactions.balance_after', - ]); + $first = $query->first([ + 'transactions.id', + 'transactions.balance_dirty', + 'transactions.transaction_currency_id', + 'transaction_journals.date', + 'transactions.account_id', + 'transactions.amount', + 'transactions.balance_after', + ]); if (null === $first) { Log::debug(sprintf('Found no transactions for currency #%d and account #%d, return 0.', $currencyId, $accountId)); @@ -122,13 +124,13 @@ class AccountBalanceCalculator return '0'; } - $balance = (string)($first->balance_after ?? '0'); + $balance = (string) ($first->balance_after ?? '0'); Log::debug(sprintf( - 'getLatestBalance: found balance: %s in transaction #%d on moment %s', - Steam::bcround($balance, 2), - $first->id ?? 0, - $notBefore->format('Y-m-d H:i:s') - )); + 'getLatestBalance: found balance: %s in transaction #%d on moment %s', + Steam::bcround($balance, 2), + $first->id ?? 0, + $notBefore->format('Y-m-d H:i:s') + )); return $balance; } @@ -147,14 +149,15 @@ class AccountBalanceCalculator $balances = []; $count = 0; $query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') - ->whereNull('transactions.deleted_at') - ->whereNull('transaction_journals.deleted_at') + ->whereNull('transactions.deleted_at') + ->whereNull('transaction_journals.deleted_at') // this order is the same as GroupCollector, but in the exact reverse. - ->orderBy('transaction_journals.date', 'asc') - ->orderBy('transaction_journals.order', 'desc') - ->orderBy('transaction_journals.id', 'asc') - ->orderBy('transaction_journals.description', 'asc') - ->orderBy('transactions.amount', 'asc'); + ->orderBy('transaction_journals.date', 'asc') + ->orderBy('transaction_journals.order', 'desc') + ->orderBy('transaction_journals.id', 'asc') + ->orderBy('transaction_journals.description', 'asc') + ->orderBy('transactions.amount', 'asc') + ; if ($accounts->count() > 0) { $query->whereIn('transactions.account_id', $accounts->pluck('id')->toArray()); } @@ -162,14 +165,14 @@ class AccountBalanceCalculator $query->where('transaction_journals.date', '>=', $notBefore); } - $set = $query->get([ - 'transactions.id', - 'transactions.balance_dirty', - 'transactions.transaction_currency_id', - 'transaction_journals.date', - 'transactions.account_id', - 'transactions.amount', - ]); + $set = $query->get([ + 'transactions.id', + 'transactions.balance_dirty', + 'transactions.transaction_currency_id', + 'transaction_journals.date', + 'transactions.account_id', + 'transactions.amount', + ]); Log::debug(sprintf('Found %d transaction(s)', $set->count())); // the balance value is an array. @@ -186,8 +189,8 @@ class AccountBalanceCalculator ]; // before and after are easy: - $before = $balances[$entry->account_id][$entry->transaction_currency_id][0]; - $after = bcadd($before, (string)$entry->amount); + $before = $balances[$entry->account_id][$entry->transaction_currency_id][0]; + $after = bcadd($before, (string) $entry->amount); // Log::debug(sprintf('Before:%s, after:%s', Steam::bcround($before, 2), Steam::bcround($after, 2))); diff --git a/composer.lock b/composer.lock index 19ffe2097c..92e2a1324e 100644 --- a/composer.lock +++ b/composer.lock @@ -130,16 +130,16 @@ }, { "name": "brick/math", - "version": "0.14.3", + "version": "0.14.5", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "6af96b11de3f7d99730c118c200418c48274edb4" + "reference": "618a8077b3c326045e10d5788ed713b341fcfe40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/6af96b11de3f7d99730c118c200418c48274edb4", - "reference": "6af96b11de3f7d99730c118c200418c48274edb4", + "url": "https://api.github.com/repos/brick/math/zipball/618a8077b3c326045e10d5788ed713b341fcfe40", + "reference": "618a8077b3c326045e10d5788ed713b341fcfe40", "shasum": "" }, "require": { @@ -178,7 +178,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.14.3" + "source": "https://github.com/brick/math/tree/0.14.5" }, "funding": [ { @@ -186,7 +186,7 @@ "type": "github" } ], - "time": "2026-02-01T15:18:05+00:00" + "time": "2026-02-03T18:06:51+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -3894,16 +3894,16 @@ }, { "name": "nette/utils", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "c99059c0315591f1a0db7ad6002000288ab8dc72" + "reference": "f76b5dc3d6c6d3043c8d937df2698515b99cbaf5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/c99059c0315591f1a0db7ad6002000288ab8dc72", - "reference": "c99059c0315591f1a0db7ad6002000288ab8dc72", + "url": "https://api.github.com/repos/nette/utils/zipball/f76b5dc3d6c6d3043c8d937df2698515b99cbaf5", + "reference": "f76b5dc3d6c6d3043c8d937df2698515b99cbaf5", "shasum": "" }, "require": { @@ -3916,7 +3916,7 @@ "require-dev": { "jetbrains/phpstorm-attributes": "^1.2", "nette/tester": "^2.5", - "phpstan/phpstan-nette": "^2.0@stable", + "phpstan/phpstan": "^2.0@stable", "tracy/tracy": "^2.9" }, "suggest": { @@ -3977,9 +3977,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.1.1" + "source": "https://github.com/nette/utils/tree/v4.1.2" }, - "time": "2025-12-22T12:14:32+00:00" + "time": "2026-02-03T17:21:09+00:00" }, { "name": "nunomaduro/collision", diff --git a/config/firefly.php b/config/firefly.php index 05bec86be8..238b23095c 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -78,8 +78,8 @@ return [ 'running_balance_column' => (bool)envNonEmpty('USE_RUNNING_BALANCE', true), // this is only the default value, is not used. // see cer.php for exchange rates feature flag. ], - 'version' => 'develop/2026-02-02', - 'build_time' => 1770044049, + 'version' => 'develop/2026-02-04', + 'build_time' => 1770187668, 'api_version' => '2.1.0', // field is no longer used. 'db_version' => 28, // field is no longer used. diff --git a/package-lock.json b/package-lock.json index 3121e41224..99ec488050 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3848,9 +3848,9 @@ } }, "node_modules/alpinejs": { - "version": "3.15.6", - "resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.15.6.tgz", - "integrity": "sha512-ETE0k88xU74URryk2JyvmrvyCyZG0Wo+2/tZux9gEvaPc/k5XcBSdvFHyW76puIFqhD+nHgeO/5j3pRRsHh6HA==", + "version": "3.15.8", + "resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.15.8.tgz", + "integrity": "sha512-zxIfCRTBGvF1CCLIOMQOxAyBuqibxSEwS6Jm1a3HGA9rgrJVcjEWlwLcQTVGAWGS8YhAsTRLVrtQ5a5QT9bSSQ==", "license": "MIT", "dependencies": { "@vue/reactivity": "~3.1.1" @@ -5783,9 +5783,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.283", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.283.tgz", - "integrity": "sha512-3vifjt1HgrGW/h76UEeny+adYApveS9dH2h3p57JYzBSXJIKUJAvtmIytDKjcSCt9xHfrNCFJ7gts6vkhuq++w==", + "version": "1.5.286", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.286.tgz", + "integrity": "sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A==", "dev": true, "license": "ISC" }, @@ -5840,14 +5840,14 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.18.4", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.4.tgz", - "integrity": "sha512-LgQMM4WXU3QI+SYgEc2liRgznaD5ojbmY3sb8LxyguVkIg5FxdpTkvk72te2R38/TGKxH634oLxXRGY6d7AP+Q==", + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.19.0.tgz", + "integrity": "sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg==", "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" + "tapable": "^2.3.0" }, "engines": { "node": ">=10.13.0" @@ -6645,7 +6645,7 @@ "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", "dev": true, "license": "ISC", "dependencies": { @@ -7118,9 +7118,9 @@ } }, "node_modules/i18next": { - "version": "25.8.0", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-25.8.0.tgz", - "integrity": "sha512-urrg4HMFFMQZ2bbKRK7IZ8/CTE7D8H4JRlAwqA2ZwDRFfdd0K/4cdbNNLgfn9mo+I/h9wJu61qJzH7jCFAhUZQ==", + "version": "25.8.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-25.8.1.tgz", + "integrity": "sha512-nFFxhwcRNggIrkv2hx/xMYVMG7Z8iMUA4ZuH4tgcbZiI0bK1jn3kSDIXNWuQDt1xVAu7mb7Qn82TpH7ZAk/okA==", "funding": [ { "type": "individual", @@ -11801,9 +11801,9 @@ "license": "BSD-2-Clause" }, "node_modules/webpack": { - "version": "5.104.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.104.1.tgz", - "integrity": "sha512-Qphch25abbMNtekmEGJmeRUhLDbe+QfiWTiqpKYkpCOWY64v9eyl+KRRLmqOFA2AvKPpc9DC6+u2n76tQLBoaA==", + "version": "5.105.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.105.0.tgz", + "integrity": "sha512-gX/dMkRQc7QOMzgTe6KsYFM7DxeIONQSui1s0n/0xht36HvrgbxtM1xBlgx596NbpHuQU8P7QpKwrZYwUX48nw==", "dev": true, "license": "MIT", "dependencies": { @@ -11817,7 +11817,7 @@ "acorn-import-phases": "^1.0.3", "browserslist": "^4.28.1", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.17.4", + "enhanced-resolve": "^5.19.0", "es-module-lexer": "^2.0.0", "eslint-scope": "5.1.1", "events": "^3.2.0", @@ -11830,7 +11830,7 @@ "schema-utils": "^4.3.3", "tapable": "^2.3.0", "terser-webpack-plugin": "^5.3.16", - "watchpack": "^2.4.4", + "watchpack": "^2.5.1", "webpack-sources": "^3.3.3" }, "bin": {