Fix code quality with rector [skip ci]

This commit is contained in:
James Cole
2025-11-09 09:08:03 +01:00
parent d2610be790
commit 68183a0a0e
209 changed files with 1021 additions and 1248 deletions

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Services\Internal\Destroy;
use Illuminate\Support\Facades\Log;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\Account;
use FireflyIII\Models\PiggyBank;
@@ -65,7 +66,7 @@ class AccountDestroyService
private function destroyOpeningBalance(Account $account): void
{
app('log')->debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
Log::debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
$set = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
@@ -74,7 +75,7 @@ class AccountDestroyService
;
if ($set->count() > 0) {
$journalId = $set->first()->transaction_journal_id;
app('log')->debug(sprintf('Found opening balance journal with ID #%d', $journalId));
Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId));
// get transactions with this journal (should be just one):
$transactions = Transaction::where('transaction_journal_id', $journalId)
@@ -84,9 +85,9 @@ class AccountDestroyService
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
app('log')->debug(sprintf('Found transaction with ID #%d', $transaction->id));
Log::debug(sprintf('Found transaction with ID #%d', $transaction->id));
$ibAccount = $transaction->account;
app('log')->debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name));
Log::debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name));
$ibAccount->accountMeta()->delete();
$transaction->delete();
@@ -105,7 +106,7 @@ class AccountDestroyService
public function moveTransactions(Account $account, Account $moveTo): void
{
app('log')->debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
Log::debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
$collection = Transaction::groupBy('transaction_journal_id', 'account_id')->where('account_id', $moveTo->id)->get(['transaction_journal_id', 'account_id', DB::raw('count(*) as the_count')]);
@@ -123,7 +124,7 @@ class AccountDestroyService
$journalId = $row->transaction_journal_id;
$journal = $user->transactionJournals()->find($journalId);
if (null !== $journal) {
app('log')->debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
Log::debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
$service->destroy($journal);
}
}