mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 14:12:15 +00:00
Various code cleanup.
This commit is contained in:
@@ -96,6 +96,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return int
|
||||
* @throws JsonException
|
||||
*/
|
||||
private function correctJournal(TransactionJournal $journal): int
|
||||
{
|
||||
@@ -146,7 +147,6 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
* @param Account $account
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
* @throws JsonException
|
||||
*/
|
||||
private function getCurrency(Account $account): TransactionCurrency
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ class CreateAccessTokens extends Command
|
||||
$users = $repository->all();
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
$pref = app('preferences')->getForUser($user, 'access_token', null);
|
||||
$pref = app('preferences')->getForUser($user, 'access_token');
|
||||
if (null === $pref) {
|
||||
$token = $user->generateAccessToken();
|
||||
app('preferences')->setForUser($user, 'access_token', $token);
|
||||
|
||||
@@ -57,7 +57,6 @@ class DeleteZeroAmount extends Command
|
||||
$start = microtime(true);
|
||||
$set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
|
||||
$set = array_unique($set);
|
||||
/** @var Collection $journals */
|
||||
$journals = TransactionJournal::whereIn('id', $set)->get();
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
|
||||
@@ -67,14 +67,12 @@ class EnableCurrencies extends Command
|
||||
}
|
||||
|
||||
// get all from journals:
|
||||
/** @var Collection $journals */
|
||||
$journals = TransactionJournal::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
|
||||
foreach ($journals as $entry) {
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
}
|
||||
|
||||
// get all from transactions
|
||||
/** @var Collection $transactions */
|
||||
$transactions = Transaction::groupBy('transaction_currency_id', 'foreign_currency_id')->get(['transaction_currency_id', 'foreign_currency_id']);
|
||||
foreach ($transactions as $entry) {
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
@@ -82,7 +80,6 @@ class EnableCurrencies extends Command
|
||||
}
|
||||
|
||||
// get all from budget limits
|
||||
/** @var Collection $limits */
|
||||
$limits = BudgetLimit::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
|
||||
foreach ($limits as $entry) {
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
|
||||
@@ -61,7 +61,7 @@ class FixFrontpageAccounts extends Command
|
||||
$users = User::get();
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
$preference = Preferences::getForUser($user, 'frontPageAccounts', null);
|
||||
$preference = Preferences::getForUser($user, 'frontPageAccounts');
|
||||
if (null !== $preference) {
|
||||
$this->fixPreference($preference);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ class FixPiggies extends Command
|
||||
*/
|
||||
protected $signature = 'firefly-iii:fix-piggies';
|
||||
|
||||
/** @var int */
|
||||
private $count;
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
@@ -58,8 +55,8 @@ class FixPiggies extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->count = 0;
|
||||
$start = microtime(true);
|
||||
$count = 0;
|
||||
$start = microtime(true);
|
||||
$set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();
|
||||
|
||||
/** @var PiggyBankEvent $event */
|
||||
@@ -74,7 +71,7 @@ class FixPiggies extends Command
|
||||
if (null === $journal) {
|
||||
$event->transaction_journal_id = null;
|
||||
$event->save();
|
||||
$this->count++;
|
||||
$count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -84,14 +81,14 @@ class FixPiggies extends Command
|
||||
$event->transaction_journal_id = null;
|
||||
$event->save();
|
||||
$this->line(sprintf('Piggy bank #%d was referenced by an invalid event. This has been fixed.', $event->piggy_bank_id));
|
||||
$this->count++;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if (0 === $this->count) {
|
||||
if (0 === $count) {
|
||||
$this->line('All piggy bank events are correct.');
|
||||
}
|
||||
if (0 !== $this->count) {
|
||||
$this->line(sprintf('Fixed %d piggy bank event(s).', $this->count));
|
||||
if (0 !== $count) {
|
||||
$this->line(sprintf('Fixed %d piggy bank event(s).', $count));
|
||||
}
|
||||
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
|
||||
Reference in New Issue
Block a user