mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup.
This commit is contained in:
@@ -40,24 +40,24 @@ class TransferBudgets extends Command
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$set = TransactionJournal::distinct()
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
|
||||
->whereNotIn('transaction_types.type', [TransactionType::WITHDRAWAL])
|
||||
->whereNotNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*']);
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
|
||||
->whereNotIn('transaction_types.type', [TransactionType::WITHDRAWAL])
|
||||
->whereNotNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])
|
||||
;
|
||||
$count = 0;
|
||||
|
||||
/** @var TransactionJournal $entry */
|
||||
foreach ($set as $entry) {
|
||||
$message = sprintf('Transaction journal #%d is a %s, so has no longer a budget.', $entry->id, $entry->transactionType->type);
|
||||
$this->friendlyInfo($message);
|
||||
app('log')->debug($message);
|
||||
$entry->budgets()->sync([]);
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
if (0 === $count) {
|
||||
$message = 'No invalid budget/journal entries.';
|
||||
@@ -68,6 +68,7 @@ class TransferBudgets extends Command
|
||||
app('log')->debug($message);
|
||||
$this->friendlyInfo($message);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user