Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
First fixes for level 7.
James Cole23178614d561
diff --git a/app/Console/Commands/Correction/RemovesEmptyJournals.php b/app/Console/Commands/Correction/RemovesEmptyJournals.phpindex 229ab1c1d9..7da374b89c 100644--- a/app/Console/Commands/Correction/RemovesEmptyJournals.php+++ b/app/Console/Commands/Correction/RemovesEmptyJournals.php@@ -36,7 +36,7 @@ class RemovesEmptyJournals extends Commandprotected $description = 'Delete empty and uneven transaction journals.';- protected $signature = 'correction:empty-journals';+ protected $signature = 'correction:empty-journals';/*** Execute the console command.@@ -55,8 +55,8 @@ class RemovesEmptyJournals extends Commandprivate function deleteUnevenJournals(): void{$set = Transaction::whereNull('deleted_at')- ->groupBy('transactions.transaction_journal_id')- ->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line+ ->groupBy('transactions.transaction_journal_id')+ ->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line;$total = 0;@@ -87,14 +87,15 @@ class RemovesEmptyJournals extends Command{$count = 0;$set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->groupBy('transaction_journals.id')- ->whereNull('transactions.transaction_journal_id')- ->get(['transaction_journals.id'])- ;+ ->groupBy('transaction_journals.id')+ ->whereNull('transactions.transaction_journal_id')+ ->get(['transaction_journals.id']);foreach ($set as $entry) {try {- TransactionJournal::find($entry->id)->delete();+ /** @var TransactionJournal|null $journal */+ $journal = TransactionJournal::find($entry->id);+ $journal?->delete();} catch (QueryException $e) {app('log')->info(sprintf('Could not delete entry: %s', $e->getMessage()));app('log')->error($e->getTraceAsString());diff --git a/app/Console/Commands/System/ForcesDecimalSize.php b/app/Console/Commands/System/ForcesDecimalSize.phpindex 66c97cdfdd..4605fee6c1 100644--- a/app/Console/Commands/System/ForcesDecimalSize.php+++ b/app/Console/Commands/System/ForcesDecimalSize.php@@ -264,7 +264,9 @@ class ForcesDecimalSize extends Command$pow = 10 ** $currency->decimal_places;$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);$this->friendlyInfo(sprintf('Account #%d has %s with value "%s", this has been corrected to "%s".', $account->id, $field, $value, $correct));- Account::find($account->id)->update([$field => $correct]);+ /** @var Account|null $updateAccount */+ $updateAccount = Account::find($account->id);+ $updateAccount?->update([$field => $correct]);}}}@@ -313,7 +315,9 @@ class ForcesDecimalSize extends Command$pow = 10 ** $currency->decimal_places;$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct));- $class::find($item->id)->update([$field => $correct]);+ /** @var Model|null $model */+ $model = $class::find($item->id);+ $model?->update([$field => $correct]);}}}@@ -365,7 +369,9 @@ class ForcesDecimalSize extends Command$this->friendlyWarning(sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));- PiggyBankEvent::find($item->id)->update([$field => $correct]);+ /** @var PiggyBankEvent|null $event */+ $event = PiggyBankEvent::find($item->id);+ $event?->update([$field => $correct]);}}}@@ -418,7 +424,9 @@ class ForcesDecimalSize extends Command$this->friendlyWarning(sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));- PiggyBankRepetition::find($item->id)->update([$field => $correct]);+ /** @var PiggyBankRepetition|null $repetition */+ $repetition = PiggyBankRepetition::find($item->id);+ $repetition->update([$field => $correct]);}}}@@ -467,7 +475,9 @@ class ForcesDecimalSize extends Command$pow = 10 ** $currency->decimal_places;$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('Piggy bank #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));- PiggyBank::find($item->id)->update([$field => $correct]);+ /** @var PiggyBank|null $piggyBank */+ $piggyBank = PiggyBank::find($item->id);+ $piggyBank?->update([$field => $correct]);}}}@@ -500,7 +510,9 @@ class ForcesDecimalSize extends Command$pow = (float) 10 ** $currency->decimal_places;$correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));- Transaction::find($item->id)->update(['amount' => $correct]);+ /** @var Transaction|null $transaction */+ $transaction = Transaction::find($item->id);+ $transaction?->update(['amount' => $correct]);}// select all transactions with this FOREIGN currency and issue.@@ -530,7 +542,9 @@ class ForcesDecimalSize extends Command$this->friendlyWarning(sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));- Transaction::find($item->id)->update(['foreign_amount' => $correct]);+ /** @var Transaction|null $transaction */+ $transaction = Transaction::find($item->id);+ $transaction?->update(['foreign_amount' => $correct]);}}diff --git a/app/Handlers/Events/Model/BudgetLimitHandler.php b/app/Handlers/Events/Model/BudgetLimitHandler.phpindex a0a60b60e1..952c8d70b6 100644--- a/app/Handlers/Events/Model/BudgetLimitHandler.php+++ b/app/Handlers/Events/Model/BudgetLimitHandler.php@@ -53,9 +53,11 @@ class BudgetLimitHandlerprivate function updateAvailableBudget(BudgetLimit $budgetLimit): void{Log::debug(sprintf('Now in updateAvailableBudget(limit #%d)', $budgetLimit->id));+ /** @var Budget|null $budget */$budget = Budget::find($budgetLimit->budget_id);if (null === $budget) {Log::warning('Budget is null, probably deleted, find deleted version.');+ /** @var Budget|null $budget */$budget = Budget::withTrashed()->find($budgetLimit->budget_id);}if (null === $budget) {diff --git a/config/sanctum.php b/config/sanctum.phpindex 67921d9dd2..ccd61aee7f 100644--- a/config/sanctum.php+++ b/config/sanctum.php@@ -37,7 +37,7 @@ return [|*/- 'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', '')),+ 'stateful' => explode(',', (string) env('SANCTUM_STATEFUL_DOMAINS', '')),/*|--------------------------------------------------------------------------