mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup
This commit is contained in:
@@ -163,16 +163,16 @@ class BackToJournals extends Command
|
||||
private function migrateBudgetsForJournal(TransactionJournal $journal): void
|
||||
{
|
||||
// grab category from first transaction
|
||||
/** @var Transaction $transaction */
|
||||
/** @var Transaction|null $transaction */
|
||||
$transaction = $journal->transactions->first();
|
||||
if (null === $transaction) {
|
||||
$this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
|
||||
|
||||
return;
|
||||
}
|
||||
/** @var Budget $budget */
|
||||
/** @var Budget|null $budget */
|
||||
$budget = $transaction->budgets->first();
|
||||
/** @var Budget $journalBudget */
|
||||
/** @var Budget|null $journalBudget */
|
||||
$journalBudget = $journal->budgets->first();
|
||||
|
||||
// both have a budget, but they don't match.
|
||||
@@ -239,16 +239,16 @@ class BackToJournals extends Command
|
||||
private function migrateCategoriesForJournal(TransactionJournal $journal): void
|
||||
{
|
||||
// grab category from first transaction
|
||||
/** @var Transaction $transaction */
|
||||
/** @var Transaction|null $transaction */
|
||||
$transaction = $journal->transactions->first();
|
||||
if (null === $transaction) {
|
||||
$this->info(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
|
||||
|
||||
return;
|
||||
}
|
||||
/** @var Category $category */
|
||||
/** @var Category|null $category */
|
||||
$category = $transaction->categories->first();
|
||||
/** @var Category $journalCategory */
|
||||
/** @var Category|null $journalCategory */
|
||||
$journalCategory = $journal->categories->first();
|
||||
|
||||
// both have a category, but they don't match.
|
||||
|
@@ -134,6 +134,7 @@ class CreateGroupMemberships extends Command
|
||||
throw new FireflyException('Firefly III could not find a user role. Please make sure all validations have run.');
|
||||
}
|
||||
|
||||
/** @var GroupMembership|null $membership */
|
||||
$membership = GroupMembership::create(
|
||||
[
|
||||
'user_id' => $user->id,
|
||||
|
@@ -81,11 +81,7 @@ class MigrateJournalNotes extends Command
|
||||
$note->text = $meta->data;
|
||||
$note->save();
|
||||
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
|
||||
try {
|
||||
$meta->delete();
|
||||
} catch (QueryException $e) {
|
||||
Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage()));
|
||||
}
|
||||
$meta->delete();
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Models\RecurrenceMeta;
|
||||
use FireflyIII\Models\RecurrenceTransactionMeta;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -124,6 +125,7 @@ class MigrateRecurrenceMeta extends Command
|
||||
*/
|
||||
private function migrateEntry(RecurrenceMeta $meta): int
|
||||
{
|
||||
/** @var Recurrence|null $recurrence */
|
||||
$recurrence = $meta->recurrence;
|
||||
if (null === $recurrence) {
|
||||
return 0;
|
||||
|
@@ -351,7 +351,7 @@ class MigrateToGroups extends Command
|
||||
Log::debug('Now in getTransactionBudget()');
|
||||
|
||||
// try to get a budget ID from the left transaction:
|
||||
/** @var Budget $budget */
|
||||
/** @var Budget|null $budget */
|
||||
$budget = $left->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
|
||||
@@ -360,7 +360,7 @@ class MigrateToGroups extends Command
|
||||
}
|
||||
|
||||
// try to get a budget ID from the right transaction:
|
||||
/** @var Budget $budget */
|
||||
/** @var Budget|null $budget */
|
||||
$budget = $right->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
|
||||
@@ -384,7 +384,7 @@ class MigrateToGroups extends Command
|
||||
Log::debug('Now in getTransactionCategory()');
|
||||
|
||||
// try to get a category ID from the left transaction:
|
||||
/** @var Category $category */
|
||||
/** @var Category|null $category */
|
||||
$category = $left->categories()->first();
|
||||
if (null !== $category) {
|
||||
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
|
||||
@@ -393,7 +393,7 @@ class MigrateToGroups extends Command
|
||||
}
|
||||
|
||||
// try to get a category ID from the left transaction:
|
||||
/** @var Category $category */
|
||||
/** @var Category|null $category */
|
||||
$category = $right->categories()->first();
|
||||
if (null !== $category) {
|
||||
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
|
||||
|
@@ -57,8 +57,6 @@ class TransactionIdentifier extends Command
|
||||
private $cliRepository;
|
||||
/** @var int */
|
||||
private $count;
|
||||
/** @var JournalRepositoryInterface */
|
||||
private $journalRepository;
|
||||
|
||||
/**
|
||||
* This method gives all transactions which are part of a split journal (so more than 2) a sort of "order" so they are easier
|
||||
@@ -117,7 +115,6 @@ class TransactionIdentifier extends Command
|
||||
*/
|
||||
private function stupidLaravel(): void
|
||||
{
|
||||
$this->journalRepository = app(JournalRepositoryInterface::class);
|
||||
$this->cliRepository = app(JournalCLIRepositoryInterface::class);
|
||||
$this->count = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user