Skip to content

Firefly III: a personal finances manager

Clean up code and fix phpstan issues.

James Coleaaa540914a37
diff --git a/app/Api/V1/Controllers/User/PreferencesController.php b/app/Api/V1/Controllers/User/PreferencesController.php
index ebfa16cb95..cc37ff7b56 100644
--- a/app/Api/V1/Controllers/User/PreferencesController.php
+++ b/app/Api/V1/Controllers/User/PreferencesController.php
@@ -37,6 +37,7 @@ use Illuminate\Support\Collection;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
+use function Safe\preg_match;
/**
* Class PreferencesController
@@ -130,10 +131,10 @@ final class PreferencesController extends Controller
if ('currencyPreference' === $data['name']) {
throw new FireflyException('Please use api/v1/currencies/default instead.');
}
- if ('language' === $data['name'] && !in_array($data['data'], array_keys(config('firefly.languages')))) {
+ if ('language' === $data['name'] && !in_array($data['data'], array_keys(config('firefly.languages')), true)) {
throw new FireflyException('Invalid language specified.');
}
- if ('locale' === $data['name'] && 'equal' !== $data['data'] && false === preg_match('/^[A-Za-z0-9_.@-]+$/', $data['data'])) {
+ if ('locale' === $data['name'] && 'equal' !== $data['data'] && 0 === preg_match('/^[A-Za-z0-9_.@-]+$/', $data['data'])) {
throw new FireflyException('Invalid locale specified.');
}
diff --git a/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php b/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php
index bac48235ac..9991315f76 100644
--- a/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php
+++ b/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php
@@ -33,18 +33,17 @@ class ClearsEmptyForeignAmounts extends Command
use ShowsFriendlyMessages;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'correction:clears-empty-foreign-amounts';
-
+ protected $description = 'Removes references to foreign amounts if there is no amount.';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'Removes references to foreign amounts if there is no amount.';
+ protected $signature = 'correction:clears-empty-foreign-amounts';
/**
* Execute the console command.
diff --git a/app/Console/Commands/Correction/ConvertsDatesToUTC.php b/app/Console/Commands/Correction/ConvertsDatesToUTC.php
index 4fabf8cc3a..bf9053c2b5 100644
--- a/app/Console/Commands/Correction/ConvertsDatesToUTC.php
+++ b/app/Console/Commands/Correction/ConvertsDatesToUTC.php
@@ -63,6 +63,14 @@ class ConvertsDatesToUTC extends Command
return Command::SUCCESS;
}
+ private function ConvertModeltoUTC(string $model, array $fields): void
+ {
+ /** @var string $field */
+ foreach ($fields as $field) {
+ $this->convertFieldtoUTC($model, $field);
+ }
+ }
+
private function convertFieldtoUTC(string $model, string $field): void
{
$this->info(sprintf('Converting %s.%s to UTC', $model, $field));
@@ -84,19 +92,11 @@ class ConvertsDatesToUTC extends Command
}
$this->friendlyInfo(sprintf('Converting field "%s" of model "%s" to UTC.', $field, $shortModel));
$items->each(static function (Model $item) use ($field, $timezoneField): void {
- $date = Carbon::parse($item->{$field}, $item->{$timezoneField});
+ $date = Carbon::parse($item->{$field}, $item->{$timezoneField});
$date->setTimezone('UTC');
$item->{$field} = $date->format('Y-m-d H:i:s');
$item->{$timezoneField} = 'UTC';
$item->save();
});
}
-
- private function ConvertModeltoUTC(string $model, array $fields): void
- {
- /** @var string $field */
- foreach ($fields as $field) {
- $this->convertFieldtoUTC($model, $field);
- }
- }
}
diff --git a/app/Console/Commands/Correction/CorrectsAccountTypes.php b/app/Console/Commands/Correction/CorrectsAccountTypes.php
index 8247db585b..17a64883aa 100644
--- a/app/Console/Commands/Correction/CorrectsAccountTypes.php
+++ b/app/Console/Commands/Correction/CorrectsAccountTypes.php
@@ -43,11 +43,11 @@ class CorrectsAccountTypes extends Command
{
use ShowsFriendlyMessages;
- protected $description = 'Make sure all journals have the correct from/to account types.';
- protected $signature = 'correction:account-types';
- private int $count;
- private array $expected;
- private AccountFactory $factory;
+ protected $description = 'Make sure all journals have the correct from/to account types.';
+ protected $signature = 'correction:account-types';
+ private int $count;
+ private array $expected;
+ private AccountFactory $factory;
private AccountRepositoryInterface $repository;
/**
@@ -62,18 +62,17 @@ class CorrectsAccountTypes extends Command
$this->expected = config('firefly.source_dests');
$expected = config('firefly.source_dests');
- $query = TransactionJournal::leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
- ->leftJoin('transactions as source', static function (JoinClause $join): void {
- $join->on('transaction_journals.id', '=', 'source.transaction_journal_id')->where('source.amount', '<', 0);
- })
- ->leftJoin('transactions as destination', static function (JoinClause $join): void {
- $join->on('transaction_journals.id', '=', 'destination.transaction_journal_id')->where('destination.amount', '>', 0);
- })
- ->leftJoin('accounts as source_account', 'source.account_id', '=', 'source_account.id')
- ->leftJoin('accounts as destination_account', 'destination.account_id', '=', 'destination_account.id')
- ->leftJoin('account_types as source_account_type', 'source_account.account_type_id', '=', 'source_account_type.id')
- ->leftJoin('account_types as destination_account_type', 'destination_account.account_type_id', '=', 'destination_account_type.id')
- ;
+ $query = TransactionJournal::leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
+ ->leftJoin('transactions as source', static function (JoinClause $join): void {
+ $join->on('transaction_journals.id', '=', 'source.transaction_journal_id')->where('source.amount', '<', 0);
+ })
+ ->leftJoin('transactions as destination', static function (JoinClause $join): void {
+ $join->on('transaction_journals.id', '=', 'destination.transaction_journal_id')->where('destination.amount', '>', 0);
+ })
+ ->leftJoin('accounts as source_account', 'source.account_id', '=', 'source_account.id')
+ ->leftJoin('accounts as destination_account', 'destination.account_id', '=', 'destination_account.id')
+ ->leftJoin('account_types as source_account_type', 'source_account.account_type_id', '=', 'source_account_type.id')
+ ->leftJoin('account_types as destination_account_type', 'destination_account.account_type_id', '=', 'destination_account_type.id');
// list all valid combinations, those are allowed. So we select those which are broken.
$query->where(static function (Builder $q) use ($expected): void {
@@ -90,19 +89,19 @@ class CorrectsAccountTypes extends Command
}
});
- $resultSet = $query->get([
- 'transaction_journals.id',
- // 'transaction_type_id as type_id',
- 'transaction_types.type as journal_type',
- // 'source.id as source_transaction_id',
- // 'source_account.id as source_account_id',
- // 'source_account_type.id as source_account_type_id',
- 'source_account_type.type as source_account_type',
- // 'destination.id as destination_transaction_id',
- // 'destination_account.id as destination_account_id',
- // 'destination_account_type.id as destination_account_type_id',
- 'destination_account_type.type as destination_account_type',
- ]);
+ $resultSet = $query->get([
+ 'transaction_journals.id',
+ // 'transaction_type_id as type_id',
+ 'transaction_types.type as journal_type',
+ // 'source.id as source_transaction_id',
+ // 'source_account.id as source_account_id',
+ // 'source_account_type.id as source_account_type_id',
+ 'source_account_type.type as source_account_type',
+ // 'destination.id as destination_transaction_id',
+ // 'destination_account.id as destination_account_id',
+ // 'destination_account_type.id as destination_account_type_id',
+ 'destination_account_type.type as destination_account_type',
+ ]);
if ($resultSet->count() > 0) {
$this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));
foreach ($resultSet as $entry) {
@@ -139,13 +138,13 @@ class CorrectsAccountTypes extends Command
private function fixJournal(TransactionJournal $journal, string $transactionType, Transaction $source, Transaction $dest): void
{
Log::debug(sprintf('Going to fix journal #%d', $journal->id));
- $this->repository = app(AccountRepositoryInterface::class);
+ $this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($journal->user);
++$this->count;
// variables:
- $sourceType = $source->account->accountType->type;
- $destinationType = $dest->account->accountType->type;
- $combination = sprintf('%s%s%s', $transactionType, $source->account->accountType->type, $dest->account->accountType->type);
+ $sourceType = $source->account->accountType->type;
+ $destinationType = $dest->account->accountType->type;
+ $combination = sprintf('%s%s%s', $transactionType, $source->account->accountType->type, $dest->account->accountType->type);
Log::debug(sprintf('Combination is "%s"', $combination));
if ($this->shouldBeTransfer($transactionType, $sourceType, $destinationType)) {
@@ -170,9 +169,9 @@ class CorrectsAccountTypes extends Command
}
// transaction has no valid source.
- $validSources = array_keys($this->expected[$transactionType]);
- $canCreateSource = $this->canCreateSource($validSources);
- $hasValidSource = $this->hasValidAccountType($validSources, $sourceType);
+ $validSources = array_keys($this->expected[$transactionType]);
+ $canCreateSource = $this->canCreateSource($validSources);
+ $hasValidSource = $this->hasValidAccountType($validSources, $sourceType);
if (!$hasValidSource && $canCreateSource) {
$this->giveNewRevenue($journal, $source);
@@ -255,7 +254,7 @@ class CorrectsAccountTypes extends Command
$oldDest = $destTransaction->account;
$destTransaction->account_id = $newDestination->id;
$destTransaction->save();
- $message = sprintf(
+ $message = sprintf(
'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").',
$journal->id,
$oldDest->id,
@@ -277,12 +276,12 @@ class CorrectsAccountTypes extends Command
$destination->account()->associate($newDestination);
$destination->save();
$this->friendlyPositive(sprintf(
- 'Firefly III gave transaction #%d a new destination %s: #%d ("%s").',
- $journal->transaction_group_id,
- AccountTypeEnum::EXPENSE->value,
- $newDestination->id,
- $newDestination->name
- ));
+ 'Firefly III gave transaction #%d a new destination %s: #%d ("%s").',
+ $journal->transaction_group_id,
+ AccountTypeEnum::EXPENSE->value,
+ $newDestination->id,
+ $newDestination->name
+ ));
Log::debug(sprintf('Associated account #%d with transaction #%d', $newDestination->id, $destination->id));
$this->inspectJournal($journal);
}
@@ -296,12 +295,12 @@ class CorrectsAccountTypes extends Command
$source->account()->associate($newSource);
$source->save();
$this->friendlyPositive(sprintf(
- 'Firefly III gave transaction #%d a new source %s: #%d ("%s").',
- $journal->transaction_group_id,
- AccountTypeEnum::REVENUE->value,
- $newSource->id,
- $newSource->name
- ));
+ 'Firefly III gave transaction #%d a new source %s: #%d ("%s").',
+ $journal->transaction_group_id,
+ AccountTypeEnum::REVENUE->value,
+ $newSource->id,
+ $newSource->name
+ ));
Log::debug(sprintf('Associated account #%d with transaction #%d', $newSource->id, $source->id));
$this->inspectJournal($journal);
}
@@ -314,7 +313,7 @@ class CorrectsAccountTypes extends Command
private function inspectJournal(TransactionJournal $journal): void
{
Log::debug(sprintf('Now inspecting journal #%d', $journal->id));
- $transactions = $journal->transactions()->count();
+ $transactions = $journal->transactions()->count();
if (2 !== $transactions) {
Log::debug(sprintf('Journal has %d transactions, so can\'t fix.', $transactions));
$this->friendlyError(sprintf('Cannot inspect transaction journal #%d because it has %d transaction(s) instead of 2.', $journal->id, $transactions));
@@ -341,7 +340,7 @@ class CorrectsAccountTypes extends Command
return;
}
- $expectedTypes = $this->expected[$type][$sourceAccountType];
+ $expectedTypes = $this->expected[$type][$sourceAccountType];
if (!in_array($destAccountType, $expectedTypes, strict: true)) {
Log::debug(sprintf('[b] Going to fix journal #%d', $journal->id));
$this->fixJournal($journal, $type, $sourceTransaction, $destTransaction);
@@ -399,7 +398,7 @@ class CorrectsAccountTypes extends Command
$oldSource = $source->account;
$source->account()->associate($result);
$source->save();
- $message = sprintf(
+ $message = sprintf(
'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").',
$journal->id,
$oldSource->id,
@@ -418,7 +417,7 @@ class CorrectsAccountTypes extends Command
$withdrawal = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL->value)->first();
$journal->transactionType()->associate($withdrawal);
$journal->save();
- $message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id);
+ $message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id);
$this->friendlyInfo($message);
Log::debug($message);
// check it again:
diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.php
index 6ca9daebc7..f785157a59 100644
--- a/app/Console/Commands/Correction/CorrectsAmounts.php
+++ b/app/Console/Commands/Correction/CorrectsAmounts.php
@@ -51,10 +51,10 @@ class CorrectsAmounts extends Command
{
use ShowsFriendlyMessages;
- protected $description = 'This command makes sure positive and negative amounts are recorded correctly.';
- protected $signature = 'correction:amounts';
- private JournalDestroyService $service;
+ protected $description = 'This command makes sure positive and negative amounts are recorded correctly.';
+ protected $signature = 'correction:amounts';
private GenericDestroyService $genericService;
+ private JournalDestroyService $service;
public function handle(): int
{
@@ -193,18 +193,17 @@ class CorrectsAmounts extends Command
$repository = app(AccountRepositoryInterface::class);
$type = TransactionType::query()->where('type', TransactionTypeEnum::TRANSFER->value)->first();
$journals = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->whereNotNull('transactions.foreign_amount')
- ->where('transaction_journals.transaction_type_id', $type->id)
- ->distinct()
- ->get(['transaction_journals.*'])
- ;
+ ->whereNotNull('transactions.foreign_amount')
+ ->where('transaction_journals.transaction_type_id', $type->id)
+ ->distinct()
+ ->get(['transaction_journals.*']);
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$repository->setUser($journal->user);
- $primary = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);
+ $primary = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);
- $valid = $this->validateJournal($journal);
+ $valid = $this->validateJournal($journal);
if (false === $valid) {
// Log::debug(sprintf('Journal #%d does not need to be fixed or is invalid (see previous messages)', $journal->id));
@@ -222,8 +221,8 @@ class CorrectsAmounts extends Command
if ($sourceCurrency->id === $destCurrency->id) {
Log::debug('Both accounts have the same currency. Removing foreign currency info.');
- $source->foreign_currency_id = null;
- $source->foreign_amount = null;
+ $source->foreign_currency_id = null;
+ $source->foreign_amount = null;
$source->save();
$destination->foreign_currency_id = null;
$destination->foreign_amount = null;
@@ -235,23 +234,23 @@ class CorrectsAmounts extends Command
// validate source transaction
if ($destCurrency->id !== $source->foreign_currency_id) {
Log::debug(sprintf(
- '[a] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".',
- $journal->id,
- $source->id,
- $source->foreignCurrency->code,
- $destCurrency->code
- ));
+ '[a] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".',
+ $journal->id,
+ $source->id,
+ $source->foreignCurrency->code,
+ $destCurrency->code
+ ));
$source->foreign_currency_id = $destCurrency->id;
$source->save();
}
if ($sourceCurrency->id !== $source->transaction_currency_id) {
Log::debug(sprintf(
- '[b] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".',
- $journal->id,
- $source->id,
- $source->transactionCurrency->code,
- $sourceCurrency->code
- ));
+ '[b] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".',
+ $journal->id,
+ $source->id,
+ $source->transactionCurrency->code,
+ $sourceCurrency->code
+ ));
$source->transaction_currency_id = $sourceCurrency->id;
$source->save();
}
@@ -259,24 +258,24 @@ class CorrectsAmounts extends Command
// validate destination:
if ($sourceCurrency->id !== $destination->foreign_currency_id) {
Log::debug(sprintf(
- '[c] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".',
- $journal->id,
- $destination->id,
- $destination->foreignCurrency->code,
- $sourceCurrency->code
- ));
+ '[c] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".',
+ $journal->id,
+ $destination->id,
+ $destination->foreignCurrency->code,
+ $sourceCurrency->code
+ ));
$destination->foreign_currency_id = $sourceCurrency->id;
$destination->save();
}
if ($destCurrency->id !== $destination->transaction_currency_id) {
Log::debug(sprintf(
- '[d] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".',
- $journal->id,
- $destination->id,
- $destination->transactionCurrency->code,
- $destCurrency->code
- ));
+ '[d] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".',
+ $journal->id,
+ $destination->id,
+ $destination->transactionCurrency->code,
+ $destCurrency->code
+ ));
$destination->transaction_currency_id = $destCurrency->id;
$destination->save();
}
@@ -292,9 +291,8 @@ class CorrectsAmounts extends Command
private function fixAutoBudgets(): void
{
$count = AutoBudget::query()
- ->where('amount', '<', 0)
- ->update(['amount' => DB::raw('amount * -1')])
- ;
+ ->where('amount', '<', 0)
+ ->update(['amount' => DB::raw('amount * -1')]);
if (0 === $count) {
return;
}
@@ -304,9 +302,8 @@ class CorrectsAmounts extends Command
private function fixAvailableBudgets(): void
{
$count = AvailableBudget::query()
- ->where('amount', '<', 0)
- ->update(['amount' => DB::raw('amount * -1')])
- ;
+ ->where('amount', '<', 0)
+ ->update(['amount' => DB::raw('amount * -1')]);
if (0 === $count) {
return;
}
@@ -317,13 +314,11 @@ class CorrectsAmounts extends Command
{
$count = 0;
$count += Bill::query()
- ->where('amount_max', '<', 0)
- ->update(['amount_max' => DB::raw('amount_max * -1')])
- ;
+ ->where('amount_max', '<', 0)
+ ->update(['amount_max' => DB::raw('amount_max * -1')]);
$count += Bill::query()
- ->where('amount_min', '<', 0)
- ->update(['amount_min' => DB::raw('amount_min * -1')])
- ;
+ ->where('amount_min', '<', 0)
+ ->update(['amount_min' => DB::raw('amount_min * -1')]);
if (0 === $count) {
return;
}
@@ -333,9 +328,8 @@ class CorrectsAmounts extends Command
private function fixBudgetLimits(): void
{
$count = BudgetLimit::query()
- ->where('amount', '<', 0)
- ->update(['amount' => DB::raw('amount * -1')])
- ;
+ ->where('amount', '<', 0)
+ ->update(['amount' => DB::raw('amount * -1')]);
if (0 === $count) {
return;
}
@@ -345,9 +339,8 @@ class CorrectsAmounts extends Command
private function fixExchangeRates(): void
{
$count = CurrencyExchangeRate::query()
- ->where('rate', '<', 0)
- ->update(['rate' => DB::raw('rate * -1')])
- ;
+ ->where('rate', '<', 0)
+ ->update(['rate' => DB::raw('rate * -1')]);
if (0 === $count) {
return;
}
@@ -357,9 +350,8 @@ class CorrectsAmounts extends Command
private function fixPiggyBanks(): void
{
$count = PiggyBank::query()
- ->where('target_amount', '<', 0)
- ->update(['target_amount' => DB::raw('target_amount * -1')])
- ;
+ ->where('target_amount', '<', 0)
+ ->update(['target_amount' => DB::raw('target_amount * -1')]);
if (0 === $count) {
return;
}
@@ -370,13 +362,11 @@ class CorrectsAmounts extends Command
{
$count = 0;
$count += RecurrenceTransaction::query()
- ->where('amount', '<', 0)
- ->update(['amount' => DB::raw('amount * -1')])
- ;
+ ->where('amount', '<', 0)
+ ->update(['amount' => DB::raw('amount * -1')]);
$count += RecurrenceTransaction::query()
- ->where('foreign_amount', '<', 0)
- ->update(['foreign_amount' => DB::raw('foreign_amount * -1')])
- ;
+ ->where('foreign_amount', '<', 0)
+ ->update(['foreign_amount' => DB::raw('foreign_amount * -1')]);
if (0 === $count) {
return;
}
@@ -386,14 +376,14 @@ class CorrectsAmounts extends Command
private function fixRuleTrigger(RuleTrigger $item): bool
{
try {
- $check = bccomp((string) $item->trigger_value, '0');
+ $check = bccomp((string)$item->trigger_value, '0');
} catch (ValueError) {
$this->friendlyError(sprintf(
- 'Rule #%d contained invalid %s-trigger "%s". The trigger has been removed, and the rule is disabled.',
- $item->rule_id,
- $item->trigger_type,
- $item->trigger_value
- ));
+ 'Rule #%d contained invalid %s-trigger "%s". The trigger has been removed, and the rule is disabled.',
+ $item->rule_id,
+ $item->trigger_type,
+ $item->trigger_value
+ ));
$item->rule->active = false;
$item->rule->save();
$this->genericService->deleteRuleTrigger($item);
@@ -433,8 +423,8 @@ class CorrectsAmounts extends Command
private function validateJournal(TransactionJournal $journal): bool
{
- $countSource = $journal->transactions()->where('amount', '<', 0)->count();
- $countDest = $journal->transactions()->where('amount', '>', 0)->count();
+ $countSource = $journal->transactions()->where('amount', '<', 0)->count();
+ $countDest = $journal->transactions()->where('amount', '>', 0)->count();
if (1 !== $countSource || 1 !== $countDest) {
$this->friendlyError(sprintf('Transaction journal #%d has bad transaction information. Will delete.', $journal->id));
@@ -445,10 +435,10 @@ class CorrectsAmounts extends Command
}
/** @var null|Transaction $source */
- $source = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $journal->transactions()->where('amount', '<', 0)->first();
/** @var null|Transaction $destination */
- $destination = $journal->transactions()->where('amount', '>', 0)->first();
+ $destination = $journal->transactions()->where('amount', '>', 0)->first();
if (null === $source || null === $destination) {
$this->friendlyError(sprintf('Could not find source OR destination for journal #%d .', $journal->id));
@@ -464,7 +454,7 @@ class CorrectsAmounts extends Command
}
if (null === $source->foreign_amount || null === $destination->foreign_amount) {
$this->friendlyError(sprintf('Transactions of journal #%d have no foreign amount, but have foreign currency info. Will reset this.', $journal->id));
- $source->foreign_currency_id = null;
+ $source->foreign_currency_id = null;
$source->save();
$destination->foreign_currency_id = null;
$source->save();
diff --git a/app/Console/Commands/Correction/CorrectsCurrencies.php b/app/Console/Commands/Correction/CorrectsCurrencies.php
index 21a46ba24b..f1181729db 100644
--- a/app/Console/Commands/Correction/CorrectsCurrencies.php
+++ b/app/Console/Commands/Correction/CorrectsCurrencies.php
@@ -61,60 +61,58 @@ class CorrectsCurrencies extends Command
private function correctCurrencies(UserGroup $userGroup): void
{
/** @var CurrencyRepositoryInterface $repos */
- $repos = app(CurrencyRepositoryInterface::class);
+ $repos = app(CurrencyRepositoryInterface::class);
// first check if the user has any default currency (not necessarily the case, so can be forced).
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($userGroup);
Log::debug(sprintf('Now correcting currencies for user group #%d', $userGroup->id));
- $found = [$primaryCurrency->id];
+ $found = [$primaryCurrency->id];
// get all meta entries
- $meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
- ->where('accounts.user_group_id', $userGroup->id)
- ->where('account_meta.name', 'currency_id')
- ->groupBy('data')
- ->get(['data'])
- ;
+ $meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
+ ->where('accounts.user_group_id', $userGroup->id)
+ ->where('account_meta.name', 'currency_id')
+ ->groupBy('data')
+ ->get(['data']);
foreach ($meta as $entry) {
- $found[] = (int) $entry->data;
+ $found[] = (int)$entry->data;
}
// get all from journals:
- $journals = TransactionJournal::query()->where('user_group_id', $userGroup->id)->groupBy('transaction_currency_id')->get(['transaction_currency_id']);
+ $journals = TransactionJournal::query()->where('user_group_id', $userGroup->id)->groupBy('transaction_currency_id')->get(['transaction_currency_id']);
foreach ($journals as $entry) {
- $found[] = (int) $entry->transaction_currency_id;
+ $found[] = (int)$entry->transaction_currency_id;
}
// get all from transactions
- $transactions = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->where('transaction_journals.user_group_id', $userGroup->id)
- ->groupBy('transactions.transaction_currency_id', 'transactions.foreign_currency_id')
- ->get(['transactions.transaction_currency_id', 'transactions.foreign_currency_id'])
- ;
+ $transactions = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->where('transaction_journals.user_group_id', $userGroup->id)
+ ->groupBy('transactions.transaction_currency_id', 'transactions.foreign_currency_id')
+ ->get(['transactions.transaction_currency_id', 'transactions.foreign_currency_id']);
foreach ($transactions as $entry) {
- $found[] = (int) $entry->transaction_currency_id;
- $found[] = (int) $entry->foreign_currency_id;
+ $found[] = (int)$entry->transaction_currency_id;
+ $found[] = (int)$entry->foreign_currency_id;
}
// get all from budget limits
- $limits = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')->groupBy('transaction_currency_id')->get([
- 'budget_limits.transaction_currency_id',
- ]);
+ $limits = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')->groupBy('transaction_currency_id')->get([
+ 'budget_limits.transaction_currency_id',
+ ]);
foreach ($limits as $entry) {
$found[] = $entry->transaction_currency_id;
}
// also get all currencies already enabled.
- $alreadyEnabled = $userGroup->currencies()->get(['transaction_currencies.id'])->pluck('id')->toArray();
+ $alreadyEnabled = $userGroup->currencies()->get(['transaction_currencies.id'])->pluck('id')->toArray();
foreach ($alreadyEnabled as $currencyId) {
$found[] = $currencyId;
}
- $found = array_values(array_unique($found));
- $found = array_values(array_filter($found, static fn (int $currencyId): bool => 0 !== $currencyId));
+ $found = array_values(array_unique($found));
+ $found = array_values(array_filter($found, static fn(int $currencyId): bool => 0 !== $currencyId));
- $valid = new Collection();
+ $valid = new Collection();
/** @var int $currencyId */
foreach ($found as $currencyId) {
@@ -123,7 +121,7 @@ class CorrectsCurrencies extends Command
$valid->push($currency);
}
}
- $ids = $valid->pluck('id')->toArray();
+ $ids = $valid->pluck('id')->toArray();
Log::debug(sprintf('Found currencies for user group #%d: %s', $userGroup->id, implode(', ', $ids)));
$userGroup->currencies()->sync($ids);
diff --git a/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php b/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php
index 56b4a83ec2..6c8105b29e 100644
--- a/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php
+++ b/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php
@@ -59,7 +59,7 @@ class CorrectsFrontpageAccounts extends Command
private function fixPreference(Preference $preference): void
{
- $fixed = [];
+ $fixed = [];
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
@@ -67,11 +67,11 @@ class CorrectsFrontpageAccounts extends Command
return;
}
$repository->setUser($preference->user);
- $data = $preference->data;
+ $data = $preference->data;
if (is_array($data)) {
/** @var string $accountId */
foreach ($data as $accountId) {
- $accountIdInt = (int) $accountId;
+ $accountIdInt = (int)$accountId;
$account = $repository->find($accountIdInt);
if (
null !== $account
diff --git a/app/Console/Commands/Correction/CorrectsGroupAccounts.php b/app/Console/Commands/Correction/CorrectsGroupAccounts.php
index 51968680e6..66a2a3c023 100644
--- a/app/Console/Commands/Correction/CorrectsGroupAccounts.php
+++ b/app/Console/Commands/Correction/CorrectsGroupAccounts.php
@@ -48,16 +48,16 @@ class CorrectsGroupAccounts extends Command
public function handle(): int
{
Log::debug('Start of correction:group-accounts');
- $groups = [];
- $res = TransactionJournal::query()->groupBy('transaction_group_id')->get([
- 'transaction_group_id',
- DB::raw('COUNT(transaction_group_id) as the_count'),
- ]);
+ $groups = [];
+ $res = TransactionJournal::query()->groupBy('transaction_group_id')->get([
+ 'transaction_group_id',
+ DB::raw('COUNT(transaction_group_id) as the_count'),
+ ]);
/** @var TransactionJournal $journal */
foreach ($res as $journal) {
- if ((int) $journal->the_count > 1) {
- $groups[] = (int) $journal->transaction_group_id;
+ if ((int)$journal->the_count > 1) {
+ $groups[] = (int)$journal->transaction_group_id;
}
}
$flags = new TransactionGroupEventFlags();
diff --git a/app/Console/Commands/Correction/CorrectsGroupInformation.php b/app/Console/Commands/Correction/CorrectsGroupInformation.php
index ddb2a400ef..d2698d8ff6 100644
--- a/app/Console/Commands/Correction/CorrectsGroupInformation.php
+++ b/app/Console/Commands/Correction/CorrectsGroupInformation.php
@@ -79,7 +79,7 @@ class CorrectsGroupInformation extends Command
return;
}
- $set = [
+ $set = [
Account::class,
Attachment::class,
AvailableBudget::class,
@@ -113,11 +113,11 @@ class CorrectsGroupInformation extends Command
}
if (0 !== $result) {
$this->friendlyPositive(sprintf(
- 'User #%d: Moved %d %s objects to the correct group.',
- $user->id,
- $result,
- str_replace('FireflyIII\Models\\', '', $className)
- ));
+ 'User #%d: Moved %d %s objects to the correct group.',
+ $user->id,
+ $result,
+ str_replace('FireflyIII\Models\\', '', $className)
+ ));
}
}
}
diff --git a/app/Console/Commands/Correction/CorrectsIbans.php b/app/Console/Commands/Correction/CorrectsIbans.php
index 4c7e6e571e..58fb8f3399 100644
--- a/app/Console/Commands/Correction/CorrectsIbans.php
+++ b/app/Console/Commands/Correction/CorrectsIbans.php
@@ -35,9 +35,9 @@ class CorrectsIbans extends Command
{
use ShowsFriendlyMessages;
- protected $description = 'Removes spaces from IBANs';
- protected $signature = 'correction:ibans';
- private int $count = 0;
+ protected $description = 'Removes spaces from IBANs';
+ protected $signature = 'correction:ibans';
+ private int $count = 0;
/**
* Execute the console command.
@@ -57,13 +57,13 @@ class CorrectsIbans extends Command
/** @var Account $account */
foreach ($accounts as $account) {
- $userId = $account->user_id;
+ $userId = $account->user_id;
$set[$userId] ??= [];
- $iban = (string) $account->iban;
+ $iban = (string)$account->iban;
if ('' === $iban) {
continue;
}
- $type = $account->accountType->type;
+ $type = $account->accountType->type;
if (in_array($type, [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value], true)) {
$type = 'liabilities';
}
@@ -80,12 +80,12 @@ class CorrectsIbans extends Command
}
if ($showWarningAndCorrect) {
$this->friendlyWarning(sprintf(
- 'IBAN "%s" is used more than once and will be removed from %s #%d ("%s")',
- $iban,
- $account->accountType->type,
- $account->id,
- $account->name
- ));
+ 'IBAN "%s" is used more than once and will be removed from %s #%d ("%s")',
+ $iban,
+ $account->accountType->type,
+ $account->id,
+ $account->name
+ ));
$account->iban = null;
$account->save();
++$this->count;
@@ -101,8 +101,8 @@ class CorrectsIbans extends Command
{
/** @var Account $account */
foreach ($accounts as $account) {
- $iban = (string) $account->iban;
- $newIban = Steam::filterSpaces($iban);
+ $iban = (string)$account->iban;
+ $newIban = Steam::filterSpaces($iban);
if ('' !== $iban && $iban !== $newIban) {
$account->iban = $newIban;
$account->save();
@@ -112,7 +112,7 @@ class CorrectsIbans extends Command
// same for account number:
$accountNumber = $account->accountMeta->where('name', 'account_number')->first();
if (null !== $accountNumber) {
- $number = (string) $accountNumber->value;
+ $number = (string)$accountNumber->value;
$newNumber = Steam::filterSpaces($number);
if ('' !== $number && $number !== $newNumber) {
$accountNumber->value = $newNumber;
diff --git a/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php b/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php
index 35b1603875..25575c3efc 100644
--- a/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php
+++ b/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php
@@ -35,18 +35,17 @@ class CorrectsInvertedBudgetLimits extends Command
use ShowsFriendlyMessages;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'correction:corrects-inverted-budget-limits';
-
+ protected $description = 'Reverse budget limits where the dates are inverted.';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'Reverse budget limits where the dates are inverted.';
+ protected $signature = 'correction:corrects-inverted-budget-limits';
/**
* Execute the console command.
diff --git a/app/Console/Commands/Correction/CorrectsLongDescriptions.php b/app/Console/Commands/Correction/CorrectsLongDescriptions.php
index c57c4eb1c6..26b0e9b7f2 100644
--- a/app/Console/Commands/Correction/CorrectsLongDescriptions.php
+++ b/app/Console/Commands/Correction/CorrectsLongDescriptions.php
@@ -36,8 +36,8 @@ class CorrectsLongDescriptions extends Command
private const int MAX_LENGTH = 1000;
- protected $description = 'Fixes long descriptions in journals and groups.';
- protected $signature = 'correction:long-descriptions';
+ protected $description = 'Fixes long descriptions in journals and groups.';
+ protected $signature = 'correction:long-descriptions';
/**
* Execute the console command.
@@ -49,20 +49,20 @@ class CorrectsLongDescriptions extends Command
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
- if (strlen((string) $journal->description) > self::MAX_LENGTH) {
- $journal->description = substr((string) $journal->description, 0, self::MAX_LENGTH);
+ if (strlen((string)$journal->description) > self::MAX_LENGTH) {
+ $journal->description = substr((string)$journal->description, 0, self::MAX_LENGTH);
$journal->save();
$this->friendlyWarning(sprintf('Truncated description of transaction journal #%d', $journal->id));
++$count;
}
}
- $groups = TransactionGroup::query()->where(DB::raw('LENGTH(title)'), '>', self::MAX_LENGTH)->get(['id', 'title']);
+ $groups = TransactionGroup::query()->where(DB::raw('LENGTH(title)'), '>', self::MAX_LENGTH)->get(['id', 'title']);
/** @var TransactionGroup $group */
foreach ($groups as $group) {
- if (strlen((string) $group->title) > self::MAX_LENGTH) {
- $group->title = substr((string) $group->title, 0, self::MAX_LENGTH);
+ if (strlen((string)$group->title) > self::MAX_LENGTH) {
+ $group->title = substr((string)$group->title, 0, self::MAX_LENGTH);
$group->save();
$this->friendlyWarning(sprintf('Truncated description of transaction group #%d', $group->id));
++$count;
diff --git a/app/Console/Commands/Correction/CorrectsMetaDataFields.php b/app/Console/Commands/Correction/CorrectsMetaDataFields.php
index 82adce9563..20293ea17f 100644
--- a/app/Console/Commands/Correction/CorrectsMetaDataFields.php
+++ b/app/Console/Commands/Correction/CorrectsMetaDataFields.php
@@ -35,7 +35,7 @@ class CorrectsMetaDataFields extends Command
protected $description = 'Rename changed meta fields.';
protected $signature = 'correction:meta-fields';
- private int $count = 0;
+ private int $count = 0;
/**
* Execute the console command.
@@ -68,7 +68,7 @@ class CorrectsMetaDataFields extends Command
private function rename(string $original, string $update): void
{
- $total = DB::table('journal_meta')->where('name', '=', $original)->update(['name' => $update]);
+ $total = DB::table('journal_meta')->where('name', '=', $original)->update(['name' => $update]);
$this->count += $total;
}
}
diff --git a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php
index 7160a488ba..619ffc00f4 100644
--- a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php
+++ b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php
@@ -110,20 +110,19 @@ class CorrectsOpeningBalanceCurrencies extends Command
{
/** @var Collection */
return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->whereNull('transaction_journals.deleted_at')
- ->where('transaction_types.type', TransactionTypeEnum::OPENING_BALANCE->value)
- ->get(['transaction_journals.*'])
- ;
+ ->whereNull('transaction_journals.deleted_at')
+ ->where('transaction_types.type', TransactionTypeEnum::OPENING_BALANCE->value)
+ ->get(['transaction_journals.*']);
}
private function setCorrectCurrency(Account $account, TransactionJournal $journal): int
{
$currency = $this->getCurrency($account);
$count = 0;
- if ((int) $journal->transaction_currency_id !== $currency->id) {
+ if ((int)$journal->transaction_currency_id !== $currency->id) {
$journal->transaction_currency_id = $currency->id;
$journal->save();
- $count = 1;
+ $count = 1;
}
/** @var Transaction $transaction */
@@ -131,7 +130,7 @@ class CorrectsOpeningBalanceCurrencies extends Command
if ($transaction->transaction_currency_id !== $currency->id) {
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
- $count = 1;
+ $count = 1;
}
}
diff --git a/app/Console/Commands/Correction/CorrectsPreferences.php b/app/Console/Commands/Correction/CorrectsPreferences.php
index 8113234e31..10615fb8c6 100644
--- a/app/Console/Commands/Correction/CorrectsPreferences.php
+++ b/app/Console/Commands/Correction/CorrectsPreferences.php
@@ -33,7 +33,7 @@ class CorrectsPreferences extends Command
{
protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.';
- protected $signature = 'correction:preferences';
+ protected $signature = 'correction:preferences';
/**
* Execute the console command.
diff --git a/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php b/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php
index e635dc9961..38e67c0cd1 100644
--- a/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php
+++ b/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php
@@ -36,7 +36,7 @@ class CorrectsPrimaryCurrencyAmounts extends Command
protected $description = 'Recalculate primary currency amounts for all objects.';
- protected $signature = 'correction:recalculate-pc-amounts';
+ protected $signature = 'correction:recalculate-pc-amounts';
/**
* Execute the console command.
diff --git a/app/Console/Commands/Correction/CorrectsRecurringTransactions.php b/app/Console/Commands/Correction/CorrectsRecurringTransactions.php
index afbd042833..b91de2eb36 100644
--- a/app/Console/Commands/Correction/CorrectsRecurringTransactions.php
+++ b/app/Console/Commands/Correction/CorrectsRecurringTransactions.php
@@ -37,11 +37,11 @@ class CorrectsRecurringTransactions extends Command
{
use ShowsFriendlyMessages;
- protected $description = 'Fixes recurring transactions with the wrong transaction type.';
- protected $signature = 'correction:recurring-transactions';
- private int $count = 0;
+ protected $description = 'Fixes recurring transactions with the wrong transaction type.';
+ protected $signature = 'correction:recurring-transactions';
+ private int $count = 0;
private RecurringRepositoryInterface $recurringRepos;
- private UserRepositoryInterface $userRepos;
+ private UserRepositoryInterface $userRepos;
/**
* Execute the console command.
@@ -78,13 +78,13 @@ class CorrectsRecurringTransactions extends Command
$destination = $transaction->destinationAccount;
$type = $recurrence->transactionType;
$link = config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
- if (null !== $link && strtolower((string) $type->type) !== strtolower($link)) {
+ if (null !== $link && strtolower((string)$type->type) !== strtolower($link)) {
$this->friendlyWarning(sprintf(
- 'Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.',
- $recurrence->id,
- $link,
- $type->type
- ));
+ 'Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.',
+ $recurrence->id,
+ $link,
+ $type->type
+ ));
$transactionType = TransactionType::whereType($link)->first();
if (null !== $transactionType) {
$recurrence->transaction_type_id = $transactionType->id;
diff --git a/app/Console/Commands/Correction/CorrectsTimezoneInformation.php b/app/Console/Commands/Correction/CorrectsTimezoneInformation.php
index d35b4b50d4..3a6faee97f 100644
--- a/app/Console/Commands/Correction/CorrectsTimezoneInformation.php
+++ b/app/Console/Commands/Correction/CorrectsTimezoneInformation.php
@@ -45,22 +45,23 @@ class CorrectsTimezoneInformation extends Command
{
use ShowsFriendlyMessages;
- public static array $models = [
- AvailableBudget::class => ['start_date', 'end_date'], // done
- Bill::class => ['date', 'end_date', 'extension_date'], // done
- BudgetLimit::class => ['start_date', 'end_date'], // done
- CurrencyExchangeRate::class => ['date'], // done
- InvitedUser::class => ['expires'],
- PiggyBankEvent::class => ['date'],
- PiggyBankRepetition::class => ['start_date', 'target_date'],
- PiggyBank::class => ['start_date', 'target_date'], // done
- Recurrence::class => ['first_date', 'repeat_until', 'latest_date'],
- Tag::class => ['date'],
- TransactionJournal::class => ['date'],
- ];
+ public static array $models
+ = [
+ AvailableBudget::class => ['start_date', 'end_date'], // done
+ Bill::class => ['date', 'end_date', 'extension_date'], // done
+ BudgetLimit::class => ['start_date', 'end_date'], // done
+ CurrencyExchangeRate::class => ['date'], // done
+ InvitedUser::class => ['expires'],
+ PiggyBankEvent::class => ['date'],
+ PiggyBankRepetition::class => ['start_date', 'target_date'],
+ PiggyBank::class => ['start_date', 'target_date'], // done
+ Recurrence::class => ['first_date', 'repeat_until', 'latest_date'],
+ Tag::class => ['date'],
+ TransactionJournal::class => ['date'],
+ ];
- protected $description = 'Make sure all dates have a timezone.';
- protected $signature = 'correction:timezones';
+ protected $description = 'Make sure all dates have a timezone.';
+ protected $signature = 'correction:timezones';
/**
* Execute the console command.
diff --git a/app/Console/Commands/Correction/CorrectsTransactionTypes.php b/app/Console/Commands/Correction/CorrectsTransactionTypes.php
index 6c900f6f3a..5f50ae577d 100644
--- a/app/Console/Commands/Correction/CorrectsTransactionTypes.php
+++ b/app/Console/Commands/Correction/CorrectsTransactionTypes.php
@@ -86,7 +86,7 @@ class CorrectsTransactionTypes extends Command
private function fixJournal(TransactionJournal $journal): bool
{
- $type = $journal->transactionType->type;
+ $type = $journal->transactionType->type;
try {
$source = $this->getSourceAccount($journal);
@@ -96,16 +96,16 @@ class CorrectsTransactionTypes extends Command
return false;
}
- $expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
+ $expectedType = (string)config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
if ($expectedType !== $type) {
$this->friendlyWarning(sprintf(
- 'Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',
- $journal->id,
- $type,
- $expectedType,
- $source->accountType->type,
- $destination->accountType->type
- ));
+ 'Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',
+ $journal->id,
+ $type,
+ $expectedType,
+ $source->accountType->type,
+ $destination->accountType->type
+ ));
$this->changeJournal($journal, $expectedType);
return true;
@@ -119,7 +119,7 @@ class CorrectsTransactionTypes extends Command
*/
private function getDestinationAccount(TransactionJournal $journal): Account
{
- $collection = $journal->transactions->filter(static fn (Transaction $transaction): bool => $transaction->amount > 0);
+ $collection = $journal->transactions->filter(static fn(Transaction $transaction): bool => $transaction->amount > 0);
if (0 === $collection->count()) {
throw new FireflyException(sprintf('300004: Journal #%d has no destination transaction.', $journal->id));
}
@@ -131,7 +131,7 @@ class CorrectsTransactionTypes extends Command
$transaction = $collection->first();
/** @var null|Account $account */
- $account = $transaction->account;
+ $account = $transaction->account;
if (null === $account) {
throw new FireflyException(sprintf('300006: Journal #%d, transaction #%d has no destination account.', $journal->id, $transaction->id));
}
@@ -144,7 +144,7 @@ class CorrectsTransactionTypes extends Command
*/
private function getSourceAccount(TransactionJournal $journal): Account
{
- $collection = $journal->transactions->filter(static fn (Transaction $transaction): bool => $transaction->amount < 0);
+ $collection = $journal->transactions->filter(static fn(Transaction $transaction): bool => $transaction->amount < 0);
if (0 === $collection->count()) {
throw new FireflyException(sprintf('300001: Journal #%d has no source transaction.', $journal->id));
}
@@ -156,7 +156,7 @@ class CorrectsTransactionTypes extends Command
$transaction = $collection->first();
/** @var null|Account $account */
- $account = $transaction->account;
+ $account = $transaction->account;
if (null === $account) {
throw new FireflyException(sprintf('300003: Journal #%d, transaction #%d has no source account.', $journal->id, $transaction->id));
}
diff --git a/app/Console/Commands/Correction/CorrectsTransferBudgets.php b/app/Console/Commands/Correction/CorrectsTransferBudgets.php
index 7eabfa372b..4521827a87 100644
--- a/app/Console/Commands/Correction/CorrectsTransferBudgets.php
+++ b/app/Console/Commands/Correction/CorrectsTransferBudgets.php
@@ -43,13 +43,12 @@ class CorrectsTransferBudgets extends Command
public function handle(): int
{
$set = TransactionJournal::query()
- ->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', [TransactionTypeEnum::WITHDRAWAL->value])
- ->whereNotNull('budget_transaction_journal.budget_id')
- ->get(['transaction_journals.*'])
- ;
+ ->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', [TransactionTypeEnum::WITHDRAWAL->value])
+ ->whereNotNull('budget_transaction_journal.budget_id')
+ ->get(['transaction_journals.*']);
$count = 0;
/** @var TransactionJournal $entry */
diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
index 5bbdf0845b..b658e53ebc 100644
--- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php
+++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
@@ -43,8 +43,8 @@ class CorrectsUnevenAmount extends Command
{
use ShowsFriendlyMessages;
- protected $description = 'Fix journals with uneven amounts.';
- protected $signature = 'correction:uneven-amounts';
+ protected $description = 'Fix journals with uneven amounts.';
+ protected $signature = 'correction:uneven-amounts';
private int $count;
/**
@@ -73,31 +73,30 @@ class CorrectsUnevenAmount extends Command
private function convertOldStyleTransactions(): void
{
/** @var AccountRepositoryInterface $repository */
- $repository = app(AccountRepositoryInterface::class);
+ $repository = app(AccountRepositoryInterface::class);
Log::debug('convertOldStyleTransactions()');
$count = 0;
$transactions = Transaction::query()
- ->distinct()
- ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
- ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
- ->leftJoin('accounts', 'accounts.id', 'transactions.account_id')
- ->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id')
- ->whereNot('transaction_types.type', TransactionTypeEnum::TRANSFER->value)
- ->whereNotNull('foreign_currency_id')
- ->whereNotNull('foreign_amount')
- ->whereIn('account_types.type', [
- AccountTypeEnum::ASSET->value,
- AccountTypeEnum::DEBT->value,
- AccountTypeEnum::MORTGAGE->value,
- AccountTypeEnum::LOAN->value,
- ])
- ->get(['transactions.transaction_journal_id'])
- ;
+ ->distinct()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
+ ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
+ ->leftJoin('accounts', 'accounts.id', 'transactions.account_id')
+ ->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id')
+ ->whereNot('transaction_types.type', TransactionTypeEnum::TRANSFER->value)
+ ->whereNotNull('foreign_currency_id')
+ ->whereNotNull('foreign_amount')
+ ->whereIn('account_types.type', [
+ AccountTypeEnum::ASSET->value,
+ AccountTypeEnum::DEBT->value,
+ AccountTypeEnum::MORTGAGE->value,
+ AccountTypeEnum::LOAN->value,
+ ])
+ ->get(['transactions.transaction_journal_id']);
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
/** @var null|TransactionJournal $journal */
- $journal = TransactionJournal::find($transaction->transaction_journal_id);
+ $journal = TransactionJournal::find($transaction->transaction_journal_id);
$repository->setUser($journal->user);
if (null === $journal) {
Log::debug('Found no journal, continue.');
@@ -121,15 +120,15 @@ class CorrectsUnevenAmount extends Command
continue;
}
if (
- 0 === bccomp((string) $source->amount, (string) $source->foreign_amount)
- && 0 === bccomp((string) $source->foreign_amount, (string) $source->amount)
+ 0 === bccomp((string)$source->amount, (string)$source->foreign_amount)
+ && 0 === bccomp((string)$source->foreign_amount, (string)$source->amount)
) {
Log::debug('Already fixed, continue.');
continue;
}
// source transaction. Switch info when does not match.
- if ((int) $source->transaction_currency_id !== (int) $sourceCurrency->id) {
+ if ((int)$source->transaction_currency_id !== (int)$sourceCurrency->id) {
Log::debug(sprintf('Ready to swap data in transaction #%d.', $source->id));
// swap amounts.
$amount = $source->amount;
@@ -147,7 +146,7 @@ class CorrectsUnevenAmount extends Command
++$count;
}
// same but for destination
- if ((int) $destination->transaction_currency_id !== (int) $destCurrency->id) {
+ if ((int)$destination->transaction_currency_id !== (int)$destCurrency->id) {
++$count;
Log::debug(sprintf('Ready to swap data in transaction #%d.', $destination->id));
// swap amounts.
@@ -190,20 +189,19 @@ class CorrectsUnevenAmount extends Command
Log::debug('convertOldStyleTransfers()');
// select transactions with a foreign amount and a foreign currency. and it's a transfer. and they are different.
$transactions = Transaction::query()
- ->distinct()
- ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
- ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
- ->where('transaction_types.type', TransactionTypeEnum::TRANSFER->value)
- ->whereNotNull('foreign_currency_id')
- ->whereNotNull('foreign_amount')
- ->get(['transactions.transaction_journal_id'])
- ;
+ ->distinct()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
+ ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
+ ->where('transaction_types.type', TransactionTypeEnum::TRANSFER->value)
+ ->whereNotNull('foreign_currency_id')
+ ->whereNotNull('foreign_amount')
+ ->get(['transactions.transaction_journal_id']);
$count = 0;
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
/** @var null|TransactionJournal $journal */
- $journal = TransactionJournal::find($transaction->transaction_journal_id);
+ $journal = TransactionJournal::find($transaction->transaction_journal_id);
if (null === $journal) {
Log::debug('Found no journal, continue.');
@@ -220,7 +218,7 @@ class CorrectsUnevenAmount extends Command
$destination = $journal->transactions()->where('amount', '>', 0)->first();
/** @var null|Transaction $source */
- $source = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $journal->transactions()->where('amount', '<', 0)->first();
if (null === $destination || null === $source) {
Log::debug('Source or destination transaction is NULL, continue.');
@@ -250,54 +248,50 @@ class CorrectsUnevenAmount extends Command
private function fixJournal(int $param): void
{
// one of the transactions is bad.
- $journal = TransactionJournal::find($param);
+ $journal = TransactionJournal::find($param);
if (null === $journal) {
return;
}
/** @var null|Transaction $source */
- $source = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $journal->transactions()->where('amount', '<', 0)->first();
if (null === $source) {
$this->friendlyError(sprintf(
- 'Journal #%d ("%s") has no source transaction. It will be deleted to maintain database consistency.',
- $journal->id ?? 0,
- $journal->description ?? ''
- ));
+ 'Journal #%d ("%s") has no source transaction. It will be deleted to maintain database consistency.',
+ $journal->id ?? 0,
+ $journal->description ?? ''
+ ));
Transaction::query()
- ->where('transaction_journal_id', $journal->id ?? 0)
- ->forceDelete()
- ;
+ ->where('transaction_journal_id', $journal->id ?? 0)
+ ->forceDelete();
TransactionJournal::query()
- ->where('id', $journal->id ?? 0)
- ->forceDelete()
- ;
+ ->where('id', $journal->id ?? 0)
+ ->forceDelete();
++$this->count;
return;
}
- $amount = bcmul('-1', (string) $source->amount);
+ $amount = bcmul('-1', (string)$source->amount);
// fix amount of destination:
/** @var null|Transaction $destination */
- $destination = $journal->transactions()->where('amount', '>', 0)->first();
+ $destination = $journal->transactions()->where('amount', '>', 0)->first();
if (null === $destination) {
$this->friendlyError(sprintf(
- 'Journal #%d ("%s") has no destination transaction. It will be deleted to maintain database consistency.',
- $journal->id ?? 0,
- $journal->description ?? ''
- ));
+ 'Journal #%d ("%s") has no destination transaction. It will be deleted to maintain database consistency.',
+ $journal->id ?? 0,
+ $journal->description ?? ''
+ ));
Transaction::query()
- ->where('transaction_journal_id', $journal->id ?? 0)
- ->forceDelete()
- ;
+ ->where('transaction_journal_id', $journal->id ?? 0)
+ ->forceDelete();
TransactionJournal::query()
- ->where('id', $journal->id ?? 0)
- ->forceDelete()
- ;
+ ->where('id', $journal->id ?? 0)
+ ->forceDelete();
++$this->count;
return;
@@ -310,7 +304,7 @@ class CorrectsUnevenAmount extends Command
return;
}
- $message = sprintf('Sum of journal #%d is not zero, journal is broken and now fixed.', $journal->id);
+ $message = sprintf('Sum of journal #%d is not zero, journal is broken and now fixed.', $journal->id);
$this->friendlyWarning($message);
Log::warning($message);
@@ -318,7 +312,7 @@ class CorrectsUnevenAmount extends Command
$destination->amount = $amount;
$destination->save();
- $message = sprintf('Corrected amount in transaction journal #%d', $param);
+ $message = sprintf('Corrected amount in transaction journal #%d', $param);
$this->friendlyInfo($message);
++$this->count;
}
@@ -327,14 +321,13 @@ class CorrectsUnevenAmount extends Command
{
Log::debug('fixUnevenAmounts()');
$journals = DB::table('transactions')
- ->groupBy('transaction_journal_id')
- ->whereNull('deleted_at')
- ->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')])
- ;
+ ->groupBy('transaction_journal_id')
+ ->whereNull('deleted_at')
+ ->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
/** @var stdClass $entry */
foreach ($journals as $entry) {
- $sum = (string) $entry->the_sum;
+ $sum = (string)$entry->the_sum;
$sum = Steam::floatalize($sum);
if (!is_numeric($sum) || str_contains($sum, 'e') || str_contains($sum, ',')) {
$message = sprintf('Journal #%d has an invalid sum ("%s"). No sure what to do.', $entry->transaction_journal_id, $entry->the_sum);
@@ -354,7 +347,7 @@ class CorrectsUnevenAmount extends Command
Log::error($e->getTraceAsString());
}
if (0 !== $res) {
- $this->fixJournal((int) $entry->transaction_journal_id);
+ $this->fixJournal((int)$entry->transaction_journal_id);
}
}
}
@@ -362,7 +355,7 @@ class CorrectsUnevenAmount extends Command
private function isBetweenAssetAndLiability(TransactionJournal $journal): bool
{
/** @var null|Transaction $sourceTransaction */
- $sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
+ $sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
/** @var null|Transaction $destinationTransaction */
$destinationTransaction = $journal->transactions()->where('amount', '>', 0)->first();
@@ -377,15 +370,15 @@ class CorrectsUnevenAmount extends Command
return false;
}
- $source = $sourceTransaction->account;
- $destination = $destinationTransaction->account;
+ $source = $sourceTransaction->account;
+ $destination = $destinationTransaction->account;
if (null === $source || null === $destination) {
Log::warning('Either is false, stop.');
return false;
}
- $sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
+ $sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
// source is liability, destination is asset
if (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) {
@@ -413,7 +406,7 @@ class CorrectsUnevenAmount extends Command
$destination = $journal->transactions()->where('amount', '>', 0)->first();
/** @var Transaction $source */
- $source = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $journal->transactions()->where('amount', '<', 0)->first();
// safety catch on NULL should not be necessary, we just had that catch.
// source amount = dest foreign amount
@@ -428,7 +421,7 @@ class CorrectsUnevenAmount extends Command
0 === bccomp(Steam::positive($source->amount), Steam::positive($destination->foreign_amount))
&& $source->transaction_currency_id === $destination->foreign_currency_id
&& 0 === bccomp(Steam::positive($destination->amount), Steam::positive($source->foreign_amount))
- && (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id;
+ && (int)$destination->transaction_currency_id === (int)$source->foreign_currency_id;
}
private function matchCurrencies(): void
@@ -439,7 +432,7 @@ class CorrectsUnevenAmount extends Command
DB::raw('transaction_journals.transaction_currency_id')
)->get(['transaction_journals.*']);
- $count = 0;
+ $count = 0;
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
diff --git a/app/Console/Commands/Correction/CreatesAccessTokens.php b/app/Console/Commands/Correction/CreatesAccessTokens.php
index 47b6d96201..d4f4e632a2 100644
--- a/app/Console/Commands/Correction/CreatesAccessTokens.php
+++ b/app/Console/Commands/Correction/CreatesAccessTokens.php
@@ -37,7 +37,7 @@ class CreatesAccessTokens extends Command
protected $description = 'Creates user access tokens which are used for command line access to personal data.';
- protected $signature = 'correction:access-tokens';
+ protected $signature = 'correction:access-tokens';
/**
* Execute the console command.
@@ -50,8 +50,8 @@ class CreatesAccessTokens extends Command
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
- $count = 0;
- $users = $repository->all();
+ $count = 0;
+ $users = $repository->all();
/** @var User $user */
foreach ($users as $user) {
diff --git a/app/Console/Commands/Correction/CreatesGroupMemberships.php b/app/Console/Commands/Correction/CreatesGroupMemberships.php
index 9b5d9976a5..557e5996f7 100644
--- a/app/Console/Commands/Correction/CreatesGroupMemberships.php
+++ b/app/Console/Commands/Correction/CreatesGroupMemberships.php
@@ -39,8 +39,8 @@ class CreatesGroupMemberships extends Command
public const string CONFIG_NAME = '560_create_group_memberships';
- protected $description = 'Update group memberships';
- protected $signature = 'correction:create-group-memberships';
+ protected $description = 'Update group memberships';
+ protected $signature = 'correction:create-group-memberships';
/**
* TODO move to helper.
@@ -50,22 +50,21 @@ class CreatesGroupMemberships extends Command
public static function createGroupMembership(User $user): void
{
// check if membership exists
- $userGroup = UserGroup::query()->where('title', $user->email)->first();
+ $userGroup = UserGroup::query()->where('title', $user->email)->first();
if (null === $userGroup) {
$userGroup = UserGroup::create(['title' => $user->email]);
}
- $userRole = UserRole::query()->where('title', UserRoleEnum::OWNER->value)->first();
+ $userRole = UserRole::query()->where('title', UserRoleEnum::OWNER->value)->first();
if (null === $userRole) {
throw new FireflyException('Firefly III could not find a user role. Please make sure all migrations have run.');
}
$membership = GroupMembership::query()
- ->where('user_id', $user->id)
- ->where('user_group_id', $userGroup->id)
- ->where('user_role_id', $userRole->id)
- ->first()
- ;
+ ->where('user_id', $user->id)
+ ->where('user_group_id', $userGroup->id)
+ ->where('user_role_id', $userRole->id)
+ ->first();
if (null === $membership) {
GroupMembership::create(['user_id' => $user->id, 'user_role_id' => $userRole->id, 'user_group_id' => $userGroup->id]);
}
diff --git a/app/Console/Commands/Correction/CreatesLinkTypes.php b/app/Console/Commands/Correction/CreatesLinkTypes.php
index 7aa9098c60..6aab976053 100644
--- a/app/Console/Commands/Correction/CreatesLinkTypes.php
+++ b/app/Console/Commands/Correction/CreatesLinkTypes.php
@@ -34,7 +34,7 @@ class CreatesLinkTypes extends Command
protected $description = 'Creates all link types.';
- protected $signature = 'correction:link-types';
+ protected $signature = 'correction:link-types';
/**
* Execute the console command.
@@ -49,7 +49,7 @@ class CreatesLinkTypes extends Command
'Reimbursement' => ['(partially) reimburses', 'is (partially) reimbursed by'],
];
foreach ($set as $name => $values) {
- $link = LinkType::query()->where('name', $name)->first();
+ $link = LinkType::query()->where('name', $name)->first();
if (null === $link) {
$link = new LinkType();
$link->name = $name;
diff --git a/app/Console/Commands/Correction/RemovesBills.php b/app/Console/Commands/Correction/RemovesBills.php
index 7fd46bd5d8..2bd992482b 100644
--- a/app/Console/Commands/Correction/RemovesBills.php
+++ b/app/Console/Commands/Correction/RemovesBills.php
@@ -47,7 +47,7 @@ class RemovesBills extends Command
if (null === $withdrawal) {
return 0;
}
- $journals = TransactionJournal::query()->whereNotNull('bill_id')->where('transaction_type_id', '!=', $withdrawal->id)->get();
+ $journals = TransactionJournal::query()->whereNotNull('bill_id')->where('transaction_type_id', '!=', $withdrawal->id)->get();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
diff --git a/app/Console/Commands/Correction/RemovesEmptyGroups.php b/app/Console/Commands/Correction/RemovesEmptyGroups.php
index 018c5d80a0..2f428fce21 100644
--- a/app/Console/Commands/Correction/RemovesEmptyGroups.php
+++ b/app/Console/Commands/Correction/RemovesEmptyGroups.php
@@ -44,13 +44,12 @@ class RemovesEmptyGroups extends Command
public function handle(): int
{
$groupIds = TransactionGroup::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')
- ->whereNull('transaction_journals.id')
- ->get(['transaction_groups.id'])
- ->pluck('id')
- ->toArray()
- ;
+ ->whereNull('transaction_journals.id')
+ ->get(['transaction_groups.id'])
+ ->pluck('id')
+ ->toArray();
- $total = count($groupIds);
+ $total = count($groupIds);
if ($total > 0) {
$this->friendlyInfo(sprintf('Deleted %d empty transaction group(s).', $total));
diff --git a/app/Console/Commands/Correction/RemovesEmptyJournals.php b/app/Console/Commands/Correction/RemovesEmptyJournals.php
index df4ea15ca8..eb659df7c1 100644
--- a/app/Console/Commands/Correction/RemovesEmptyJournals.php
+++ b/app/Console/Commands/Correction/RemovesEmptyJournals.php
@@ -38,7 +38,7 @@ class RemovesEmptyJournals extends Command
protected $description = 'Delete empty and uneven transaction journals.';
- protected $signature = 'correction:empty-journals';
+ protected $signature = 'correction:empty-journals';
/**
* Execute the console command.
@@ -55,10 +55,9 @@ 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 {
@@ -81,18 +80,17 @@ class RemovesEmptyJournals extends Command
private function deleteUnevenJournals(): void
{
$set = Transaction::query()
- ->whereNull('deleted_at')
- ->groupBy('transactions.transaction_journal_id')
- ->get([
- DB::raw('COUNT(transactions.transaction_journal_id) as the_count'),
- 'transaction_journal_id',
- ])
- ;
+ ->whereNull('deleted_at')
+ ->groupBy('transactions.transaction_journal_id')
+ ->get([
+ DB::raw('COUNT(transactions.transaction_journal_id) as the_count'),
+ 'transaction_journal_id',
+ ]);
$total = 0;
/** @var Transaction $row */
foreach ($set as $row) {
- $count = (int) $row->the_count;
+ $count = (int)$row->the_count;
if (1 === ($count % 2)) {
// uneven number, delete journal and transactions:
try {
@@ -106,9 +104,9 @@ class RemovesEmptyJournals extends Command
Transaction::query()->where('transaction_journal_id', $row->transaction_journal_id)->delete();
$this->friendlyWarning(sprintf(
- 'Deleted transaction journal #%d because it had an uneven number of transactions.',
- $row->transaction_journal_id
- ));
+ 'Deleted transaction journal #%d because it had an uneven number of transactions.',
+ $row->transaction_journal_id
+ ));
++$total;
}
}
diff --git a/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php b/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php
index d333317462..92f2b8313e 100644
--- a/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php
+++ b/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php
@@ -39,18 +39,17 @@ class RemovesLinksToDeletedObjects extends Command
use ShowsFriendlyMessages;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'correction:remove-links-to-deleted-objects';
-
+ protected $description = 'Removes deleted entries from intermediate tables.';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'Removes deleted entries from intermediate tables.';
+ protected $signature = 'correction:remove-links-to-deleted-objects';
/**
* Execute the console command.
@@ -58,33 +57,29 @@ class RemovesLinksToDeletedObjects extends Command
public function handle(): void
{
$deletedTags = Tag::query()
- ->withTrashed()
- ->whereNotNull('deleted_at')
- ->get('tags.id')
- ->pluck('id')
- ->toArray()
- ;
+ ->withTrashed()
+ ->whereNotNull('deleted_at')
+ ->get('tags.id')
+ ->pluck('id')
+ ->toArray();
$deletedJournals = TransactionJournal::query()
- ->withTrashed()
- ->whereNotNull('deleted_at')
- ->get('transaction_journals.id')
- ->pluck('id')
- ->toArray()
- ;
+ ->withTrashed()
+ ->whereNotNull('deleted_at')
+ ->get('transaction_journals.id')
+ ->pluck('id')
+ ->toArray();
$deletedBudgets = Budget::query()
- ->withTrashed()
- ->whereNotNull('deleted_at')
- ->get('budgets.id')
- ->pluck('id')
- ->toArray()
- ;
+ ->withTrashed()
+ ->whereNotNull('deleted_at')
+ ->get('budgets.id')
+ ->pluck('id')
+ ->toArray();
$deletedCategories = Category::query()
- ->withTrashed()
- ->whereNotNull('deleted_at')
- ->get('categories.id')
- ->pluck('id')
- ->toArray()
- ;
+ ->withTrashed()
+ ->whereNotNull('deleted_at')
+ ->get('categories.id')
+ ->pluck('id')
+ ->toArray();
if (count($deletedTags) > 0) {
$this->cleanupTags($deletedTags);
@@ -102,7 +97,7 @@ class RemovesLinksToDeletedObjects extends Command
// count and clean up available budgets in currencies with no budget limits.
// this is not entirely the place for it but OK.
/** @var AvailableBudgetRepositoryInterface $repository */
- $repository = app(AvailableBudgetRepositoryInterface::class);
+ $repository = app(AvailableBudgetRepositoryInterface::class);
/** @var User $user */
foreach (User::get() as $user) {
diff --git a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php
index 8f088b43d0..21235d700d 100644
--- a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php
+++ b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php
@@ -40,7 +40,7 @@ class RemovesOrphanedTransactions extends Command
protected $description = 'Deletes orphaned transactions.';
- protected $signature = 'correction:orphaned-transactions';
+ protected $signature = 'correction:orphaned-transactions';
/**
* Execute the console command.
@@ -69,10 +69,10 @@ class RemovesOrphanedTransactions extends Command
$journal?->delete();
Transaction::query()->where('transaction_journal_id', $transaction->transaction_journal_id)->delete();
$this->friendlyWarning(sprintf(
- 'Deleted transaction journal #%d because account #%d was already deleted.',
- $transaction->transaction_journal_id,
- $transaction->account_id
- ));
+ 'Deleted transaction journal #%d because account #%d was already deleted.',
+ $transaction->transaction_journal_id,
+ $transaction->account_id
+ ));
++$count;
}
}
@@ -80,10 +80,9 @@ class RemovesOrphanedTransactions extends Command
private function deleteOrphanedJournals(): void
{
$set = TransactionJournal::leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id')
- ->whereNotNull('transaction_groups.deleted_at')
- ->whereNull('transaction_journals.deleted_at')
- ->get(['transaction_journals.id', 'transaction_journals.transaction_group_id'])
- ;
+ ->whereNotNull('transaction_groups.deleted_at')
+ ->whereNull('transaction_journals.deleted_at')
+ ->get(['transaction_journals.id', 'transaction_journals.transaction_group_id']);
$count = $set->count();
if (0 === $count) {
// $this->friendlyPositive('No orphaned journals.');
@@ -97,10 +96,10 @@ class RemovesOrphanedTransactions extends Command
if (null !== $journal) {
$journal->delete();
$this->friendlyWarning(sprintf(
- 'Journal #%d (part of deleted transaction group #%d) has been deleted as well.',
- $entry->id,
- $entry->transaction_group_id
- ));
+ 'Journal #%d (part of deleted transaction group #%d) has been deleted as well.',
+ $entry->id,
+ $entry->transaction_group_id
+ ));
}
}
}
@@ -112,22 +111,21 @@ class RemovesOrphanedTransactions extends Command
{
$count = 0;
$set = Transaction::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->whereNotNull('transaction_journals.deleted_at')
- ->whereNull('transactions.deleted_at')
- ->whereNotNull('transactions.id')
- ->get(['transaction_journals.id as journal_id', 'transactions.id as transaction_id'])
- ;
+ ->whereNotNull('transaction_journals.deleted_at')
+ ->whereNull('transactions.deleted_at')
+ ->whereNotNull('transactions.id')
+ ->get(['transaction_journals.id as journal_id', 'transactions.id as transaction_id']);
/** @var stdClass $entry */
foreach ($set as $entry) {
- $transaction = Transaction::find((int) $entry->transaction_id);
+ $transaction = Transaction::find((int)$entry->transaction_id);
if (null !== $transaction) {
$transaction->delete();
$this->friendlyWarning(sprintf(
- 'Transaction #%d (part of deleted transaction journal #%d) has been deleted as well.',
- $entry->transaction_id,
- $entry->journal_id
- ));
+ 'Transaction #%d (part of deleted transaction journal #%d) has been deleted as well.',
+ $entry->transaction_id,
+ $entry->journal_id
+ ));
++$count;
}
}
diff --git a/app/Console/Commands/Correction/RemovesZeroAmount.php b/app/Console/Commands/Correction/RemovesZeroAmount.php
index c7d19f59c5..b339816dd8 100644
--- a/app/Console/Commands/Correction/RemovesZeroAmount.php
+++ b/app/Console/Commands/Correction/RemovesZeroAmount.php
@@ -35,7 +35,7 @@ class RemovesZeroAmount extends Command
protected $description = 'Delete transactions with zero amount.';
- protected $signature = 'correction:zero-amounts';
+ protected $signature = 'correction:zero-amounts';
/**
* Execute the console command.
diff --git a/app/Console/Commands/Correction/RestoresOAuthKeys.php b/app/Console/Commands/Correction/RestoresOAuthKeys.php
index c7a9657707..5f2832a508 100644
--- a/app/Console/Commands/Correction/RestoresOAuthKeys.php
+++ b/app/Console/Commands/Correction/RestoresOAuthKeys.php
@@ -29,7 +29,6 @@ use FireflyIII\Support\System\OAuthKeys;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Laravel\Passport\Passport;
-
use function Safe\chmod;
class RestoresOAuthKeys extends Command
diff --git a/app/Console/Commands/Correction/RollbacksSingleMigration.php b/app/Console/Commands/Correction/RollbacksSingleMigration.php
index c9b49700d1..ca500e5a29 100644
--- a/app/Console/Commands/Correction/RollbacksSingleMigration.php
+++ b/app/Console/Commands/Correction/RollbacksSingleMigration.php
@@ -33,18 +33,17 @@ class RollbacksSingleMigration extends Command
use ShowsFriendlyMessages;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'correction:rollback-single-migration {--force}';
-
+ protected $description = 'Removes the last entry from the migration table. ';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'Removes the last entry from the migration table. ';
+ protected $signature = 'correction:rollback-single-migration {--force}';
/**
* Execute the console command.
@@ -68,7 +67,7 @@ class RollbacksSingleMigration extends Command
$this->friendlyLine('');
$this->friendlyLine('If this doesn\'t work, run the command a few times to remove more rows and try "php artisan migrate" again.');
$this->friendlyLine('');
- $res = true;
+ $res = true;
if (!$this->option('force')) {
$this->friendlyWarning('Use this command at your own risk.');
$res = $this->confirm('Are you sure you want to continue?');
@@ -76,9 +75,8 @@ class RollbacksSingleMigration extends Command
if ($res) {
DB::table('migrations')
- ->where('id', (int) $entry->id)
- ->delete()
- ;
+ ->where('id', (int)$entry->id)
+ ->delete();
$this->friendlyInfo(sprintf('Database migration #%d ("%s") is deleted.', $entry->id, $entry->migration));
$this->friendlyLine('');
$this->friendlyLine('Try running "php artisan migrate" now.');
diff --git a/app/Console/Commands/Explain/ExplainAvailableBudget.php b/app/Console/Commands/Explain/ExplainAvailableBudget.php
index 3b99efe934..2309f12457 100644
--- a/app/Console/Commands/Explain/ExplainAvailableBudget.php
+++ b/app/Console/Commands/Explain/ExplainAvailableBudget.php
@@ -35,39 +35,38 @@ class ExplainAvailableBudget extends Command
{
use VerifiesAccessToken;
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Explains why the available budget amount is what it is.';
/**
* The name and signature of the console command.
*
* @var string
*/
- protected $signature = 'explain:available-budget
+ protected $signature = 'explain:available-budget
{--date=now : A date formatted YYYY-MM-DD or the word "now"}
{--user=1 : The user ID.}
{--token= : The user\'s access token.}
';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Explains why the available budget amount is what it is.';
-
/**
* Execute the console command.
*/
public function handle(): int
{
- $date = $this->getDate((string) $this->option('date'));
+ $date = $this->getDate((string)$this->option('date'));
$range = Preferences::getForUser($this->getUser(), 'viewRange', '1M')->data ?? '1M';
$title = Navigation::periodShow($date, $range);
$this->line('This command explains why the "available" budget bar at the top of your /budget bar means.');
$this->line(sprintf(
- 'You submitted date %s and your settings show a %s period, so this explanation concerns the period "%s".',
- $date->format('Y-m-d'),
- $range,
- $title
- ));
+ 'You submitted date %s and your settings show a %s period, so this explanation concerns the period "%s".',
+ $date->format('Y-m-d'),
+ $range,
+ $title
+ ));
return Command::SUCCESS;
}
diff --git a/app/Console/Commands/Export/ExportsData.php b/app/Console/Commands/Export/ExportsData.php
index 736ae1f882..1bc87fb53e 100644
--- a/app/Console/Commands/Export/ExportsData.php
+++ b/app/Console/Commands/Export/ExportsData.php
@@ -40,7 +40,6 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use InvalidArgumentException;
use Safe\Exceptions\FilesystemException;
-
use function Safe\file_put_contents;
class ExportsData extends Command
@@ -50,7 +49,7 @@ class ExportsData extends Command
protected $description = 'Command to export data from Firefly III.';
- protected $signature = 'firefly-iii:export-data
+ protected $signature = 'firefly-iii:export-data
{--user=1 : The user ID that the export should run for.}
{--token= : The user\'s access token.}
{--start= : First transaction to export. Defaults to your very first transaction. Only applies to transaction export.}
@@ -85,7 +84,7 @@ class ExportsData extends Command
}
// set up repositories.
$this->stupidLaravel();
- $user = $this->getUser();
+ $user = $this->getUser();
$this->journalRepository->setUser($user);
$this->accountRepository->setUser($user);
@@ -100,7 +99,7 @@ class ExportsData extends Command
// make export object and configure it.
/** @var ExportDataGenerator $exporter */
- $exporter = app(ExportDataGenerator::class);
+ $exporter = app(ExportDataGenerator::class);
$exporter->setUser($user);
$exporter->setStart($options['start']);
@@ -115,7 +114,7 @@ class ExportsData extends Command
$exporter->setExportRules($options['export']['rules']);
$exporter->setExportBills($options['export']['bills']);
$exporter->setExportPiggies($options['export']['piggies']);
- $data = $exporter->export();
+ $data = $exporter->export();
if (0 === count($data)) {
$this->friendlyError('You must export *something*. Use --export-transactions or another option. See docs.firefly-iii.org');
}
@@ -161,7 +160,7 @@ class ExportsData extends Command
{
$final = new Collection();
$accounts = new Collection();
- $accountList = (string) $this->option('accounts');
+ $accountList = (string)$this->option('accounts');
$types = [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
if ('' !== $accountList) {
$accountIds = explode(',', $accountList);
@@ -243,7 +242,7 @@ class ExportsData extends Command
*/
private function getExportDirectory(): string
{
- $directory = (string) $this->option('export_directory');
+ $directory = (string)$this->option('export_directory');
if ('' === $directory) {
$directory = './';
}
diff --git a/app/Console/Commands/Integrity/ReportsEmptyObjects.php b/app/Console/Commands/Integrity/ReportsEmptyObjects.php
index 2dda07a5e2..1dbae20f63 100644
--- a/app/Console/Commands/Integrity/ReportsEmptyObjects.php
+++ b/app/Console/Commands/Integrity/ReportsEmptyObjects.php
@@ -38,7 +38,7 @@ class ReportsEmptyObjects extends Command
protected $description = 'Reports on empty database objects.';
- protected $signature = 'integrity:empty-objects';
+ protected $signature = 'integrity:empty-objects';
/**
* Execute the console command.
@@ -60,11 +60,10 @@ class ReportsEmptyObjects extends Command
private function reportAccounts(): void
{
$set = Account::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
- ->leftJoin('users', 'accounts.user_id', '=', 'users.id')
- ->groupBy(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])
- ->whereNull('transactions.account_id')
- ->get(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])
- ;
+ ->leftJoin('users', 'accounts.user_id', '=', 'users.id')
+ ->groupBy(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])
+ ->whereNull('transactions.account_id')
+ ->get(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email']);
/** @var stdClass $entry */
foreach ($set as $entry) {
@@ -80,11 +79,10 @@ class ReportsEmptyObjects extends Command
private function reportBudgetLimits(): void
{
$set = Budget::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
- ->leftJoin('users', 'budgets.user_id', '=', 'users.id')
- ->groupBy(['budgets.id', 'budgets.name', 'budgets.encrypted', 'budgets.user_id', 'users.email'])
- ->whereNull('budget_limits.id')
- ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'budgets.encrypted', 'users.email'])
- ;
+ ->leftJoin('users', 'budgets.user_id', '=', 'users.id')
+ ->groupBy(['budgets.id', 'budgets.name', 'budgets.encrypted', 'budgets.user_id', 'users.email'])
+ ->whereNull('budget_limits.id')
+ ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'budgets.encrypted', 'users.email']);
/** @var Budget $entry */
foreach ($set as $entry) {
@@ -99,12 +97,11 @@ class ReportsEmptyObjects extends Command
private function reportEmptyBudgets(): void
{
$set = Budget::leftJoin('budget_transaction_journal', 'budgets.id', '=', 'budget_transaction_journal.budget_id')
- ->leftJoin('users', 'budgets.user_id', '=', 'users.id')
- ->distinct()
- ->whereNull('budget_transaction_journal.budget_id')
- ->whereNull('budgets.deleted_at')
- ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email'])
- ;
+ ->leftJoin('users', 'budgets.user_id', '=', 'users.id')
+ ->distinct()
+ ->whereNull('budget_transaction_journal.budget_id')
+ ->whereNull('budgets.deleted_at')
+ ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']);
/** @var stdClass $entry */
foreach ($set as $entry) {
@@ -119,12 +116,11 @@ class ReportsEmptyObjects extends Command
private function reportEmptyCategories(): void
{
$set = Category::leftJoin('category_transaction_journal', 'categories.id', '=', 'category_transaction_journal.category_id')
- ->leftJoin('users', 'categories.user_id', '=', 'users.id')
- ->distinct()
- ->whereNull('category_transaction_journal.category_id')
- ->whereNull('categories.deleted_at')
- ->get(['categories.id', 'categories.name', 'categories.user_id', 'users.email'])
- ;
+ ->leftJoin('users', 'categories.user_id', '=', 'users.id')
+ ->distinct()
+ ->whereNull('category_transaction_journal.category_id')
+ ->whereNull('categories.deleted_at')
+ ->get(['categories.id', 'categories.name', 'categories.user_id', 'users.email']);
/** @var stdClass $entry */
foreach ($set as $entry) {
@@ -136,12 +132,11 @@ class ReportsEmptyObjects extends Command
private function reportEmptyTags(): void
{
$set = Tag::leftJoin('tag_transaction_journal', 'tags.id', '=', 'tag_transaction_journal.tag_id')
- ->leftJoin('users', 'tags.user_id', '=', 'users.id')
- ->distinct()
- ->whereNull('tag_transaction_journal.tag_id')
- ->whereNull('tags.deleted_at')
- ->get(['tags.id', 'tags.tag', 'tags.user_id', 'users.email'])
- ;
+ ->leftJoin('users', 'tags.user_id', '=', 'users.id')
+ ->distinct()
+ ->whereNull('tag_transaction_journal.tag_id')
+ ->whereNull('tags.deleted_at')
+ ->get(['tags.id', 'tags.tag', 'tags.user_id', 'users.email']);
/** @var stdClass $entry */
foreach ($set as $entry) {
diff --git a/app/Console/Commands/Integrity/ReportsIntegrity.php b/app/Console/Commands/Integrity/ReportsIntegrity.php
index 6f66b89df1..dabee7ebb3 100644
--- a/app/Console/Commands/Integrity/ReportsIntegrity.php
+++ b/app/Console/Commands/Integrity/ReportsIntegrity.php
@@ -34,7 +34,7 @@ class ReportsIntegrity extends Command
protected $description = 'Will report on the integrity of your database.';
- protected $signature = 'firefly-iii:report-integrity';
+ protected $signature = 'firefly-iii:report-integrity';
/**
* Execute the console command.
diff --git a/app/Console/Commands/Integrity/ReportsSums.php b/app/Console/Commands/Integrity/ReportsSums.php
index 3ebf1d7fc6..1e137d778e 100644
--- a/app/Console/Commands/Integrity/ReportsSums.php
+++ b/app/Console/Commands/Integrity/ReportsSums.php
@@ -57,8 +57,8 @@ class ReportsSums extends Command
/** @var User $user */
foreach ($userRepository->all() as $user) {
- $sum = (string) $user->transactions()->selectRaw('SUM(amount) as total')->value('total');
- $foreign = (string) $user->transactions()->selectRaw('SUM(foreign_amount) as total')->value('total');
+ $sum = (string)$user->transactions()->selectRaw('SUM(amount) as total')->value('total');
+ $foreign = (string)$user->transactions()->selectRaw('SUM(foreign_amount) as total')->value('total');
$sum = '' === $sum ? '0' : $sum;
$foreign = '' === $foreign ? '0' : $foreign;
$sum = Steam::floatalize($sum);
diff --git a/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php b/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php
index d77b8ff2a6..b469072955 100644
--- a/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php
+++ b/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php
@@ -71,9 +71,9 @@ class ValidatesEnvironmentVariables extends Command
private function validateLanguage(): bool
{
- $language = config('firefly.default_language');
- $locale = config('firefly.default_locale');
- $options = array_keys(config('firefly.languages'));
+ $language = config('firefly.default_language');
+ $locale = config('firefly.default_locale');
+ $options = array_keys(config('firefly.languages'));
if (!in_array($language, $options, true)) {
$this->friendlyError(sprintf('DEFAULT_LANGUAGE "%s" is not a valid language for Firefly III.', $language));
@@ -96,7 +96,7 @@ class ValidatesEnvironmentVariables extends Command
private function validateStaticToken(): bool
{
- $token = (string) config('firefly.static_cron_token');
+ $token = (string)config('firefly.static_cron_token');
if ('' !== $token && 32 !== strlen($token)) {
$this->friendlyError('STATIC_CRON_TOKEN must be empty or a 32-character string.');
$this->friendlyError('Please check your .env file and make sure you use a valid setting.');
diff --git a/app/Console/Commands/Integrity/ValidatesFilePermissions.php b/app/Console/Commands/Integrity/ValidatesFilePermissions.php
index 68a9787210..36420f16e4 100644
--- a/app/Console/Commands/Integrity/ValidatesFilePermissions.php
+++ b/app/Console/Commands/Integrity/ValidatesFilePermissions.php
@@ -33,18 +33,17 @@ class ValidatesFilePermissions extends Command
use ShowsFriendlyMessages;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'integrity:file-permissions';
-
+ protected $description = 'Command description';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'Command description';
+ protected $signature = 'integrity:file-permissions';
/**
* Execute the console command.
@@ -62,7 +61,7 @@ class ValidatesFilePermissions extends Command
$message = sprintf('Directory "%s" cannot found. It is necessary to allow files to be uploaded.', $directory);
Log::error($message);
$this->friendlyError($message);
- $errors = true;
+ $errors = true;
continue;
}
@@ -71,7 +70,7 @@ class ValidatesFilePermissions extends Command
$message = sprintf('Directory "%s" is not writeable. Uploading attachments may fail silently.', $directory);
$this->friendlyError($message);
Log::error($message);
- $errors = true;
+ $errors = true;
}
Log::debug('It is writeable!');
Log::debug(sprintf('Done processing %s', $directory));
diff --git a/app/Console/Commands/SendTestEmail.php b/app/Console/Commands/SendTestEmail.php
index c40d50371e..a5f072435b 100644
--- a/app/Console/Commands/SendTestEmail.php
+++ b/app/Console/Commands/SendTestEmail.php
@@ -35,29 +35,28 @@ class SendTestEmail extends Command
use VerifiesAccessToken;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'firefly-iii:send-test-email
- {--user=1 : The user ID.}
- {--token= : The user\'s access token.}';
-
+ protected $description = 'Send test email';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'Send test email';
+ protected $signature = 'firefly-iii:send-test-email
+ {--user=1 : The user ID.}
+ {--token= : The user\'s access token.}';
/**
* Execute the console command.
*/
public function handle(): int
{
- $user = $this->getUser();
+ $user = $this->getUser();
if (!$user->hasRole('owner')) {
- $this->friendlyError((string) trans('firefly.must_be_owner'));
+ $this->friendlyError((string)trans('firefly.must_be_owner'));
return Command::FAILURE;
}
@@ -65,12 +64,12 @@ class SendTestEmail extends Command
/** @var int $lastNotification */
$lastNotification = AppConfiguration::get('last_test_notification', 123)->data;
if ((time() - $lastNotification) < 120) {
- $this->friendlyError((string) trans('firefly.test_rate_limited'));
+ $this->friendlyError((string)trans('firefly.test_rate_limited'));
return Command::FAILURE;
}
- $owner = new OwnerNotifiable();
+ $owner = new OwnerNotifiable();
event(new OwnerTestsNotificationChannel('email', $owner));
AppConfiguration::set('last_test_notification', time());
diff --git a/app/Console/Commands/System/CreatesDatabase.php b/app/Console/Commands/System/CreatesDatabase.php
index d6a8e28752..f186cf80d0 100644
--- a/app/Console/Commands/System/CreatesDatabase.php
+++ b/app/Console/Commands/System/CreatesDatabase.php
@@ -37,7 +37,7 @@ class CreatesDatabase extends Command
protected $description = 'Tries to create the database if it doesn\'t exist yet.';
- protected $signature = 'firefly-iii:create-database';
+ protected $signature = 'firefly-iii:create-database';
public function handle(): int
{
@@ -53,15 +53,15 @@ class CreatesDatabase extends Command
return 0;
}
// try to set up a raw connection:
- $exists = false;
- $dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', config('database.connections.mysql.host'), config('database.connections.mysql.port'));
+ $exists = false;
+ $dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', config('database.connections.mysql.host'), config('database.connections.mysql.port'));
- if ('' !== (string) config('database.connections.mysql.unix_socket')) {
+ if ('' !== (string)config('database.connections.mysql.unix_socket')) {
$dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', config('database.connections.mysql.unix_socket'));
}
$this->friendlyLine(sprintf('DSN is %s', $dsn));
- $options = [
+ $options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
@@ -69,7 +69,7 @@ class CreatesDatabase extends Command
// when it fails, display error
try {
- $pdo = new PDO($dsn, (string) config('database.connections.mysql.username'), (string) config('database.connections.mysql.password'), $options);
+ $pdo = new PDO($dsn, (string)config('database.connections.mysql.username'), (string)config('database.connections.mysql.password'), $options);
} catch (PDOException $e) {
$this->friendlyError(sprintf('Error when connecting to DB: %s', $e->getMessage()));
@@ -79,7 +79,7 @@ class CreatesDatabase extends Command
// only continue when no error.
// with PDO, try to list DB's (
/** @var array $stmt */
- $stmt = $pdo->query('SHOW DATABASES;');
+ $stmt = $pdo->query('SHOW DATABASES;');
// slightly more complex but less error-prone.
foreach ($stmt as $row) {
$name = $row['Database'] ?? false;
diff --git a/app/Console/Commands/System/CreatesFirstUser.php b/app/Console/Commands/System/CreatesFirstUser.php
index f5ac718924..92192fc91b 100644
--- a/app/Console/Commands/System/CreatesFirstUser.php
+++ b/app/Console/Commands/System/CreatesFirstUser.php
@@ -39,7 +39,7 @@ class CreatesFirstUser extends Command
protected $description = 'Creates a new user and gives admin rights. Outputs the password on the command line. Strictly for testing.';
- protected $signature = 'system:create-first-user {email}';
+ protected $signature = 'system:create-first-user {email}';
private UserRepositoryInterface $repository;
/**
@@ -53,7 +53,7 @@ class CreatesFirstUser extends Command
return 1;
}
$this->stupidLaravel();
- $count = $this->repository->count();
+ $count = $this->repository->count();
if ($count > 0) {
$this->friendlyError('Already have more than zero users in DB.');
@@ -67,7 +67,7 @@ class CreatesFirstUser extends Command
$user->setRememberToken(Str::random(60));
Log::info(sprintf('Registered new user %s', $user->email));
- $owner = new OwnerNotifiable();
+ $owner = new OwnerNotifiable();
event(new NewUserRegistered($owner, $user));
$this->friendlyInfo(sprintf('Created new admin user (ID #%d) with email address "%s" and password "%s".', $user->id, $user->email, $password));
diff --git a/app/Console/Commands/System/ForcesDecimalSize.php b/app/Console/Commands/System/ForcesDecimalSize.php
index 6e60d35f41..265209ae87 100644
--- a/app/Console/Commands/System/ForcesDecimalSize.php
+++ b/app/Console/Commands/System/ForcesDecimalSize.php
@@ -42,7 +42,6 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
-
use function Safe\json_encode;
use function Safe\mb_regex_encoding;
@@ -55,38 +54,40 @@ class ForcesDecimalSize extends Command
{
use ShowsFriendlyMessages;
- protected $description = 'This command resizes DECIMAL columns in MySQL or PostgreSQL and correct amounts (only MySQL).';
- protected $signature = 'firefly-iii:force-decimal-size {--force}';
+ protected $description = 'This command resizes DECIMAL columns in MySQL or PostgreSQL and correct amounts (only MySQL).';
+ protected $signature = 'firefly-iii:force-decimal-size {--force}';
private string $cast;
- private array $classes = [
- 'accounts' => Account::class,
- 'auto_budgets' => AutoBudget::class,
- 'available_budgets' => AvailableBudget::class,
- 'bills' => Bill::class,
- 'budget_limits' => BudgetLimit::class,
- 'piggy_bank_events' => PiggyBankEvent::class,
- 'piggy_bank_repetitions' => PiggyBankRepetition::class,
- 'piggy_banks' => PiggyBank::class,
- 'recurrences_transactions' => RecurrenceTransaction::class,
- 'transactions' => Transaction::class,
- ];
+ private array $classes
+ = [
+ 'accounts' => Account::class,
+ 'auto_budgets' => AutoBudget::class,
+ 'available_budgets' => AvailableBudget::class,
+ 'bills' => Bill::class,
+ 'budget_limits' => BudgetLimit::class,
+ 'piggy_bank_events' => PiggyBankEvent::class,
+ 'piggy_bank_repetitions' => PiggyBankRepetition::class,
+ 'piggy_banks' => PiggyBank::class,
+ 'recurrences_transactions' => RecurrenceTransaction::class,
+ 'transactions' => Transaction::class,
+ ];
private string $operator;
private string $regularExpression;
- private array $tables = [
- 'accounts' => ['virtual_balance'],
- 'auto_budgets' => ['amount'],
- 'available_budgets' => ['amount'],
- 'bills' => ['amount_min', 'amount_max'],
- 'budget_limits' => ['amount'],
- 'currency_exchange_rates' => ['rate', 'user_rate'],
- 'limit_repetitions' => ['amount'],
- 'piggy_bank_events' => ['amount'],
- 'piggy_bank_repetitions' => ['current_amount'],
- 'piggy_banks' => ['target_amount'],
- 'recurrences_transactions' => ['amount', 'foreign_amount'],
- 'transactions' => ['amount', 'foreign_amount'],
- ];
+ private array $tables
+ = [
+ 'accounts' => ['virtual_balance'],
+ 'auto_budgets' => ['amount'],
+ 'available_budgets' => ['amount'],
+ 'bills' => ['amount_min', 'amount_max'],
+ 'budget_limits' => ['amount'],
+ 'currency_exchange_rates' => ['rate', 'user_rate'],
+ 'limit_repetitions' => ['amount'],
+ 'piggy_bank_events' => ['amount'],
+ 'piggy_bank_repetitions' => ['current_amount'],
+ 'piggy_banks' => ['target_amount'],
+ 'recurrences_transactions' => ['amount', 'foreign_amount'],
+ 'transactions' => ['amount', 'foreign_amount'],
+ ];
/**
* Execute the console command.
@@ -122,10 +123,9 @@ class ForcesDecimalSize extends Command
$regularExpression = $this->regularExpression;
/** @var Builder $query */
- $query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
- ->where('account_meta.name', 'currency_id')
- ->where('account_meta.data', json_encode((string) $currency->id))
- ;
+ $query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
+ ->where('account_meta.name', 'currency_id')
+ ->where('account_meta.data', json_encode((string)$currency->id));
$query->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
foreach ($fields as $field) {
$q->orWhere(
@@ -135,7 +135,7 @@ class ForcesDecimalSize extends Command
);
}
});
- $result = $query->get(['accounts.*']);
+ $result = $query->get(['accounts.*']);
if (0 === $result->count()) {
$this->friendlyPositive(sprintf('All accounts in %s are OK', $currency->code));
@@ -146,13 +146,13 @@ class ForcesDecimalSize extends Command
foreach ($result as $account) {
/** @var string $field */
foreach ($fields as $field) {
- $value = $account->{$field};
+ $value = $account->{$field};
if (null === $value) {
continue;
}
// fix $field by rounding it down correctly.
- $pow = 10 ** $currency->decimal_places;
- $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
+ $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));
/** @var null|Account $updateAccount */
@@ -168,20 +168,19 @@ class ForcesDecimalSize extends Command
private function correctAmounts(): void
{
// if sqlite, add function?
- if ('sqlite' === (string) config('database.default')) {
+ if ('sqlite' === (string)config('database.default')) {
DB::connection()
- ->getPdo()
- ->sqliteCreateFunction('REGEXP', static function ($pattern, $value): int {
- mb_regex_encoding('UTF-8');
- $pattern = trim($pattern, '"');
-
- return mb_ereg($pattern, (string) $value) ? 1 : 0;
- })
- ;
+ ->getPdo()
+ ->sqliteCreateFunction('REGEXP', static function ($pattern, $value): int {
+ mb_regex_encoding('UTF-8');
+ $pattern = trim($pattern, '"');
+
+ return mb_ereg($pattern, (string)$value) ? 1 : 0;
+ });
}
- if (!in_array((string) config('database.default'), ['mysql', 'pgsql', 'sqlite'], true)) {
- $this->friendlyWarning(sprintf('Skip correcting amounts, does not support "%s"...', (string) config('database.default')));
+ if (!in_array((string)config('database.default'), ['mysql', 'pgsql', 'sqlite'], true)) {
+ $this->friendlyWarning(sprintf('Skip correcting amounts, does not support "%s"...', (string)config('database.default')));
return;
}
@@ -276,16 +275,15 @@ class ForcesDecimalSize extends Command
$regularExpression = $this->regularExpression;
/** @var Builder $query */
- $query = $class::where('transaction_currency_id', $currency->id)
- ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
- /** @var string $field */
- foreach ($fields as $field) {
- $q->orWhere(DB::raw(sprintf('CAST(%s AS %s)', $field, $cast)), $operator, DB::raw(sprintf($regularExpression, $currency->decimal_places)));
- }
- })
- ;
+ $query = $class::where('transaction_currency_id', $currency->id)
+ ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
+ /** @var string $field */
+ foreach ($fields as $field) {
+ $q->orWhere(DB::raw(sprintf('CAST(%s AS %s)', $field, $cast)), $operator, DB::raw(sprintf($regularExpression, $currency->decimal_places)));
+ }
+ });
- $result = $query->get();
+ $result = $query->get();
if (0 === $result->count()) {
$this->friendlyPositive(sprintf('All %s in %s are OK', $table, $currency->code));
@@ -296,17 +294,17 @@ class ForcesDecimalSize extends Command
foreach ($result as $item) {
/** @var string $field */
foreach ($fields as $field) {
- $value = $item->{$field};
+ $value = $item->{$field};
if (null === $value || '' === $value) {
continue;
}
// fix $field by rounding it down correctly.
$pow = 10 ** $currency->decimal_places;
- $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
+ $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));
/** @var null|Model $model */
- $model = $class::find($item->id);
+ $model = $class::find($item->id);
$model?->update([$field => $correct]);
}
}
@@ -322,22 +320,21 @@ class ForcesDecimalSize extends Command
$regularExpression = $this->regularExpression;
/** @var Builder $query */
- $query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
- ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
- ->where('account_meta.name', 'currency_id')
- ->where('account_meta.data', json_encode((string) $currency->id))
- ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
- foreach ($fields as $field) {
- $q->orWhere(
- DB::raw(sprintf('CAST(piggy_banks.%s AS %s)', $field, $cast)),
- $operator,
- DB::raw(sprintf($regularExpression, $currency->decimal_places))
- );
- }
- })
- ;
-
- $result = $query->get(['piggy_banks.*']);
+ $query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
+ ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
+ ->where('account_meta.name', 'currency_id')
+ ->where('account_meta.data', json_encode((string)$currency->id))
+ ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
+ foreach ($fields as $field) {
+ $q->orWhere(
+ DB::raw(sprintf('CAST(piggy_banks.%s AS %s)', $field, $cast)),
+ $operator,
+ DB::raw(sprintf($regularExpression, $currency->decimal_places))
+ );
+ }
+ });
+
+ $result = $query->get(['piggy_banks.*']);
if (0 === $result->count()) {
$this->friendlyPositive(sprintf('All piggy banks in %s are OK', $currency->code));
@@ -348,13 +345,13 @@ class ForcesDecimalSize extends Command
foreach ($result as $item) {
/** @var string $field */
foreach ($fields as $field) {
- $value = $item->{$field};
+ $value = $item->{$field};
if (null === $value) {
continue;
}
// fix $field by rounding it down correctly.
- $pow = 10 ** $currency->decimal_places;
- $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
+ $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));
/** @var null|PiggyBank $piggyBank */
@@ -374,23 +371,22 @@ class ForcesDecimalSize extends Command
$regularExpression = $this->regularExpression;
/** @var Builder $query */
- $query = PiggyBankEvent::leftJoin('piggy_banks', 'piggy_bank_events.piggy_bank_id', '=', 'piggy_banks.id')
- ->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
- ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
- ->where('account_meta.name', 'currency_id')
- ->where('account_meta.data', json_encode((string) $currency->id))
- ->where(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void {
- foreach ($fields as $field) {
- $q->orWhere(
- DB::raw(sprintf('CAST(piggy_bank_events.%s AS %s)', $field, $cast)),
- $operator,
- DB::raw(sprintf($regularExpression, $currency->decimal_places))
- );
- }
- })
- ;
-
- $result = $query->get(['piggy_bank_events.*']);
+ $query = PiggyBankEvent::leftJoin('piggy_banks', 'piggy_bank_events.piggy_bank_id', '=', 'piggy_banks.id')
+ ->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
+ ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
+ ->where('account_meta.name', 'currency_id')
+ ->where('account_meta.data', json_encode((string)$currency->id))
+ ->where(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void {
+ foreach ($fields as $field) {
+ $q->orWhere(
+ DB::raw(sprintf('CAST(piggy_bank_events.%s AS %s)', $field, $cast)),
+ $operator,
+ DB::raw(sprintf($regularExpression, $currency->decimal_places))
+ );
+ }
+ });
+
+ $result = $query->get(['piggy_bank_events.*']);
if (0 === $result->count()) {
$this->friendlyPositive(sprintf('All piggy bank events in %s are OK', $currency->code));
@@ -401,23 +397,23 @@ class ForcesDecimalSize extends Command
foreach ($result as $item) {
/** @var string $field */
foreach ($fields as $field) {
- $value = $item->{$field};
+ $value = $item->{$field};
if (null === $value) {
continue;
}
// fix $field by rounding it down correctly.
$pow = 10 ** $currency->decimal_places;
- $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
+ $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf(
- 'Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".',
- $item->id,
- $field,
- $value,
- $correct
- ));
+ 'Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".',
+ $item->id,
+ $field,
+ $value,
+ $correct
+ ));
/** @var null|PiggyBankEvent $event */
- $event = PiggyBankEvent::find($item->id);
+ $event = PiggyBankEvent::find($item->id);
$event?->update([$field => $correct]);
}
}
@@ -434,23 +430,22 @@ class ForcesDecimalSize extends Command
// select all piggy bank repetitions with this currency and issue.
/** @var Builder $query */
- $query = PiggyBankRepetition::leftJoin('piggy_banks', 'piggy_bank_repetitions.piggy_bank_id', '=', 'piggy_banks.id')
- ->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
- ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
- ->where('account_meta.name', 'currency_id')
- ->where('account_meta.data', json_encode((string) $currency->id))
- ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
- foreach ($fields as $field) {
- $q->orWhere(
- DB::raw(sprintf('CAST(piggy_bank_repetitions.%s AS %s)', $field, $cast)),
- $operator,
- DB::raw(sprintf($regularExpression, $currency->decimal_places))
- );
- }
- })
- ;
-
- $result = $query->get(['piggy_bank_repetitions.*']);
+ $query = PiggyBankRepetition::leftJoin('piggy_banks', 'piggy_bank_repetitions.piggy_bank_id', '=', 'piggy_banks.id')
+ ->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
+ ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
+ ->where('account_meta.name', 'currency_id')
+ ->where('account_meta.data', json_encode((string)$currency->id))
+ ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
+ foreach ($fields as $field) {
+ $q->orWhere(
+ DB::raw(sprintf('CAST(piggy_bank_repetitions.%s AS %s)', $field, $cast)),
+ $operator,
+ DB::raw(sprintf($regularExpression, $currency->decimal_places))
+ );
+ }
+ });
+
+ $result = $query->get(['piggy_bank_repetitions.*']);
if (0 === $result->count()) {
$this->friendlyPositive(sprintf('All piggy bank repetitions in %s', $currency->code));
@@ -461,20 +456,20 @@ class ForcesDecimalSize extends Command
foreach ($result as $item) {
/** @var string $field */
foreach ($fields as $field) {
- $value = $item->{$field};
+ $value = $item->{$field};
if (null === $value) {
continue;
}
// fix $field by rounding it down correctly.
- $pow = 10 ** $currency->decimal_places;
- $correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
+ $pow = 10 ** $currency->decimal_places;
+ $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf(
- 'Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".',
- $item->id,
- $field,
- $value,
- $correct
- ));
+ 'Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".',
+ $item->id,
+ $field,
+ $value,
+ $correct
+ ));
/** @var null|PiggyBankRepetition $repetition */
$repetition = PiggyBankRepetition::find($item->id);
@@ -490,14 +485,13 @@ class ForcesDecimalSize extends Command
{
// select all transactions with this currency and issue.
/** @var Builder $query */
- $query = Transaction::query()
- ->where('transaction_currency_id', $currency->id)
- ->where(
- DB::raw(sprintf('CAST(amount as %s)', $this->cast)),
- $this->operator,
- DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
- )
- ;
+ $query = Transaction::query()
+ ->where('transaction_currency_id', $currency->id)
+ ->where(
+ DB::raw(sprintf('CAST(amount as %s)', $this->cast)),
+ $this->operator,
+ DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
+ );
$result = $query->get(['transactions.*']);
if (0 === $result->count()) {
@@ -506,13 +500,13 @@ class ForcesDecimalSize extends Command
/** @var Transaction $item */
foreach ($result as $item) {
- $value = $item->amount;
+ $value = $item->amount;
if ('' === $value) {
continue;
}
// fix $field by rounding it down correctly.
- $pow = 10.0 ** $currency->decimal_places;
- $correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
+ $pow = 10.0 ** $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));
/** @var null|Transaction $transaction */
@@ -522,14 +516,13 @@ class ForcesDecimalSize extends Command
// select all transactions with this FOREIGN currency and issue.
/** @var Builder $query */
- $query = Transaction::query()
- ->where('foreign_currency_id', $currency->id)
- ->where(
- DB::raw(sprintf('CAST(foreign_amount as %s)', $this->cast)),
- $this->operator,
- DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
- )
- ;
+ $query = Transaction::query()
+ ->where('foreign_currency_id', $currency->id)
+ ->where(
+ DB::raw(sprintf('CAST(foreign_amount as %s)', $this->cast)),
+ $this->operator,
+ DB::raw(sprintf($this->regularExpression, $currency->decimal_places))
+ );
$result = $query->get();
if (0 === $result->count()) {
@@ -540,19 +533,19 @@ class ForcesDecimalSize extends Command
/** @var Transaction $item */
foreach ($result as $item) {
- $value = $item->foreign_amount;
+ $value = $item->foreign_amount;
if (null === $value) {
continue;
}
// fix $field by rounding it down correctly.
- $pow = 10.0 ** $currency->decimal_places;
- $correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
+ $pow = 10.0 ** $currency->decimal_places;
+ $correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf(
- 'Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".',
- $item->id,
- $value,
- $correct
- ));
+ 'Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".',
+ $item->id,
+ $value,
+ $correct
+ ));
/** @var null|Transaction $transaction */
$transaction = Transaction::find($item->id);
@@ -579,7 +572,7 @@ class ForcesDecimalSize extends Command
private function updateDecimals(): void
{
$this->friendlyInfo('Going to force the size of DECIMAL columns. Please hold.');
- $type = (string) config('database.default');
+ $type = (string)config('database.default');
/**
* @var string $name
diff --git a/app/Console/Commands/System/ForcesMigrations.php b/app/Console/Commands/System/ForcesMigrations.php
index 479031c62e..e94a67eca7 100644
--- a/app/Console/Commands/System/ForcesMigrations.php
+++ b/app/Console/Commands/System/ForcesMigrations.php
@@ -40,7 +40,7 @@ class ForcesMigrations extends Command
protected $description = 'This command will force-run all database migrations.';
- protected $signature = 'firefly-iii:force-migrations
+ protected $signature = 'firefly-iii:force-migrations
{--user=1 : The user ID.}
{--token= : The user\'s access token.}';
diff --git a/app/Console/Commands/System/OutputsInstructions.php b/app/Console/Commands/System/OutputsInstructions.php
index e342822bc0..e1495d0485 100644
--- a/app/Console/Commands/System/OutputsInstructions.php
+++ b/app/Console/Commands/System/OutputsInstructions.php
@@ -37,7 +37,7 @@ class OutputsInstructions extends Command
protected $description = 'Instructions in case of upgrade trouble.';
- protected $signature = 'firefly-iii:instructions {task=install}';
+ protected $signature = 'firefly-iii:instructions {task=install}';
/**
* Execute the console command.
@@ -89,26 +89,26 @@ class OutputsInstructions extends Command
*/
private function installInstructions(): void
{
- $version = (string) config('firefly.version');
+ $version = (string)config('firefly.version');
/** @var array $config */
- $config = config('upgrade.text.install');
- $text = '';
+ $config = config('upgrade.text.install');
+ $text = '';
/** @var string $compare */
foreach (array_keys($config) as $compare) {
// if string starts with:
if (str_starts_with($version, $compare)) {
- $text = (string) $config[$compare];
+ $text = (string)$config[$compare];
}
}
// validate some settings.
- if ('' === $text && 'local' === (string) config('app.env')) {
+ if ('' === $text && 'local' === (string)config('app.env')) {
$text = 'Please set APP_ENV=production for a safer environment.';
}
- $prefix = 'v';
+ $prefix = 'v';
if (str_starts_with($version, 'develop')) {
$prefix = '';
}
@@ -151,8 +151,8 @@ class OutputsInstructions extends Command
*/
private function showLogo(): void
{
- $today = Carbon::now()->format('m-d');
- $month = Carbon::now()->format('m');
+ $today = Carbon::now()->format('m-d');
+ $month = Carbon::now()->format('m');
// variation in colors and effects just because I can!
// default is Ukraine flag:
$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];
@@ -223,26 +223,26 @@ class OutputsInstructions extends Command
*/
private function updateInstructions(): void
{
- $version = (string) config('firefly.version');
+ $version = (string)config('firefly.version');
/** @var array $config */
- $config = config('upgrade.text.upgrade');
- $text = '';
+ $config = config('upgrade.text.upgrade');
+ $text = '';
/** @var string $compare */
foreach (array_keys($config) as $compare) {
// if string starts with:
if (str_starts_with($version, $compare)) {
- $text = (string) $config[$compare];
+ $text = (string)$config[$compare];
}
}
// validate some settings.
- if ('' === $text && 'local' === (string) config('app.env')) {
+ if ('' === $text && 'local' === (string)config('app.env')) {
$text = 'Please set APP_ENV=production for a safer environment.';
}
- $prefix = 'v';
+ $prefix = 'v';
if (str_starts_with($version, 'develop') || str_starts_with($version, 'branch')) {
$prefix = '';
}
diff --git a/app/Console/Commands/System/OutputsVersion.php b/app/Console/Commands/System/OutputsVersion.php
index 56050f3cd4..86a523f364 100644
--- a/app/Console/Commands/System/OutputsVersion.php
+++ b/app/Console/Commands/System/OutputsVersion.php
@@ -30,7 +30,7 @@ class OutputsVersion extends Command
{
protected $description = 'Outputs the Firefly III version';
- protected $signature = 'firefly-iii:output-version';
+ protected $signature = 'firefly-iii:output-version';
/**
* Execute the console command.
diff --git a/app/Console/Commands/System/RecalculatesRunningBalance.php b/app/Console/Commands/System/RecalculatesRunningBalance.php
index 3a35cf91ae..a330622062 100644
--- a/app/Console/Commands/System/RecalculatesRunningBalance.php
+++ b/app/Console/Commands/System/RecalculatesRunningBalance.php
@@ -45,7 +45,7 @@ class RecalculatesRunningBalance extends Command
*
* @var string
*/
- protected $signature = 'firefly-iii:refresh-running-balance {--F|force : Force the execution of this command.}';
+ protected $signature = 'firefly-iii:refresh-running-balance {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
diff --git a/app/Console/Commands/System/ResetsErrorMailLimit.php b/app/Console/Commands/System/ResetsErrorMailLimit.php
index 15dbda250d..875d059b4a 100644
--- a/app/Console/Commands/System/ResetsErrorMailLimit.php
+++ b/app/Console/Commands/System/ResetsErrorMailLimit.php
@@ -27,7 +27,6 @@ namespace FireflyIII\Console\Commands\System;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use Symfony\Component\Console\Command\Command as CommandAlias;
-
use function Safe\file_put_contents;
use function Safe\json_encode;
@@ -36,18 +35,17 @@ class ResetsErrorMailLimit extends Command
use ShowsFriendlyMessages;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'firefly-iii:reset-error-mail-limit';
-
+ protected $description = 'Resets the number of error mails sent.';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'Resets the number of error mails sent.';
+ protected $signature = 'firefly-iii:reset-error-mail-limit';
/**
* Execute the console command.
diff --git a/app/Console/Commands/System/ScansAttachments.php b/app/Console/Commands/System/ScansAttachments.php
index 0225cf0008..f1f2b76ce7 100644
--- a/app/Console/Commands/System/ScansAttachments.php
+++ b/app/Console/Commands/System/ScansAttachments.php
@@ -34,7 +34,6 @@ use Illuminate\Support\Facades\Storage;
use Safe\Exceptions\FileinfoException;
use Safe\Exceptions\FilesystemException;
use Safe\Exceptions\StringsException;
-
use function Safe\file_put_contents;
use function Safe\md5_file;
use function Safe\mime_content_type;
@@ -46,7 +45,7 @@ class ScansAttachments extends Command
protected $description = 'Rescan all attachments and re-set the correct MD5 hash and mime.';
- protected $signature = 'firefly-iii:scan-attachments';
+ protected $signature = 'firefly-iii:scan-attachments';
/**
* Execute the console command.
@@ -76,7 +75,7 @@ class ScansAttachments extends Command
Log::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
$decryptedContent = $encryptedContent;
}
- $tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
+ $tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
file_put_contents($tempFileName, $decryptedContent);
$attachment->md5 = md5_file($tempFileName);
$attachment->mime = mime_content_type($tempFileName);
diff --git a/app/Console/Commands/System/SetsLatestVersion.php b/app/Console/Commands/System/SetsLatestVersion.php
index cce25ac7de..a6b43ab4d5 100644
--- a/app/Console/Commands/System/SetsLatestVersion.php
+++ b/app/Console/Commands/System/SetsLatestVersion.php
@@ -34,7 +34,7 @@ class SetsLatestVersion extends Command
protected $description = 'Set latest version in DB.';
- protected $signature = 'firefly-iii:set-latest-version {--james-is-cool}';
+ protected $signature = 'firefly-iii:set-latest-version {--james-is-cool}';
/**
* Execute the console command.
@@ -46,7 +46,7 @@ class SetsLatestVersion extends Command
return 0;
}
- AppConfiguration::set('ff3_build_time', (int) config('firefly.build_time'));
+ AppConfiguration::set('ff3_build_time', (int)config('firefly.build_time'));
$this->friendlyInfo('Updated version.');
return 0;
diff --git a/app/Console/Commands/System/VerifySecurityAlerts.php b/app/Console/Commands/System/VerifySecurityAlerts.php
index daf99b9b77..07fc5fe353 100644
--- a/app/Console/Commands/System/VerifySecurityAlerts.php
+++ b/app/Console/Commands/System/VerifySecurityAlerts.php
@@ -32,7 +32,6 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\FilesystemException;
use Safe\Exceptions\JsonException;
-
use function Safe\json_decode;
class VerifySecurityAlerts extends Command
@@ -41,7 +40,7 @@ class VerifySecurityAlerts extends Command
protected $description = 'Verify security alerts';
- protected $signature = 'firefly-iii:verify-security-alerts';
+ protected $signature = 'firefly-iii:verify-security-alerts';
/**
* Execute the console command.
@@ -63,7 +62,7 @@ class VerifySecurityAlerts extends Command
return 0;
}
$content = $disk->get('alerts.json');
- $json = json_decode((string) $content, true, 10);
+ $json = json_decode((string)$content, true, 10);
/** @var array $array */
foreach ($json as $array) {
diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.php
index c318ad0d0e..d94715d7b2 100644
--- a/app/Console/Commands/Tools/ApplyRules.php
+++ b/app/Console/Commands/Tools/ApplyRules.php
@@ -47,7 +47,7 @@ class ApplyRules extends Command
protected $description = 'This command will apply your rules and rule groups on a selection of your transactions.';
- protected $signature = 'firefly-iii:apply-rules
+ protected $signature = 'firefly-iii:apply-rules
{--user=1 : The user ID.}
{--token= : The user\'s access token.}
{--accounts= : A comma-separated list of asset accounts or liabilities to apply your rules to.}
@@ -56,16 +56,16 @@ class ApplyRules extends Command
{--all_rules : If set, will overrule both settings and simply apply ALL of your rules.}
{--start_date= : The date of the earliest transaction to be included (inclusive). If omitted, will be your very first transaction ever. Format: YYYY-MM-DD}
{--end_date= : The date of the latest transaction to be included (inclusive). If omitted, will be your latest transaction ever. Format: YYYY-MM-DD}';
- private array $acceptedAccounts;
- private Collection $accounts;
- private bool $allRules;
- private Carbon $endDate;
- private Collection $groups;
+ private array $acceptedAccounts;
+ private Collection $accounts;
+ private bool $allRules;
+ private Carbon $endDate;
+ private Collection $groups;
private RuleGroupRepositoryInterface $ruleGroupRepository;
- private array $ruleGroupSelection;
- private RuleRepositoryInterface $ruleRepository;
- private array $ruleSelection;
- private Carbon $startDate;
+ private array $ruleGroupSelection;
+ private RuleRepositoryInterface $ruleRepository;
+ private array $ruleSelection;
+ private Carbon $startDate;
/**
* Execute the console command.
@@ -74,7 +74,7 @@ class ApplyRules extends Command
*/
public function handle(): int
{
- $start = microtime(true);
+ $start = microtime(true);
$this->stupidLaravel();
if (!$this->verifyAccessToken()) {
$this->friendlyError('Invalid access token.');
@@ -86,19 +86,19 @@ class ApplyRules extends Command
$this->ruleRepository->setUser($this->getUser());
$this->ruleGroupRepository->setUser($this->getUser());
- $result = $this->verifyInput();
+ $result = $this->verifyInput();
if (false === $result) {
return 1;
}
- $this->allRules = $this->option('all_rules');
+ $this->allRules = $this->option('all_rules');
// always get all the rules of the user.
$this->grabAllRules();
// loop all groups and rules and indicate if they're included:
- $rulesToApply = $this->getRulesToApply();
- $count = $rulesToApply->count();
+ $rulesToApply = $this->getRulesToApply();
+ $count = $rulesToApply->count();
if (0 === $count) {
$this->friendlyError('No rules or rule groups have been included.');
$this->friendlyWarning('Make a selection using:');
@@ -111,7 +111,7 @@ class ApplyRules extends Command
// create new rule engine:
/** @var RuleEngineInterface $ruleEngine */
- $ruleEngine = app(RuleEngineInterface::class);
+ $ruleEngine = app(RuleEngineInterface::class);
$ruleEngine->setRules($rulesToApply);
$ruleEngine->setUser($this->getUser());
@@ -120,7 +120,7 @@ class ApplyRules extends Command
foreach ($this->accounts as $account) {
$filterAccountList[] = $account->id;
}
- $list = implode(',', $filterAccountList);
+ $list = implode(',', $filterAccountList);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => $list]);
// add the date as a filter:
@@ -134,7 +134,7 @@ class ApplyRules extends Command
$ruleEngine->fire();
$this->friendlyLine('');
- $end = round(microtime(true) - $start, 2);
+ $end = round(microtime(true) - $start, 2);
$this->friendlyPositive(sprintf('Done in %s seconds!', $end));
return 0;
@@ -175,7 +175,7 @@ class ApplyRules extends Command
private function includeRule(Rule $rule, RuleGroup $group): bool
{
- return in_array((int) $group->id, $this->ruleGroupSelection, true) || in_array((int) $rule->id, $this->ruleSelection, true) || $this->allRules;
+ return in_array((int)$group->id, $this->ruleGroupSelection, true) || in_array((int)$rule->id, $this->ruleSelection, true) || $this->allRules;
}
/**
@@ -228,32 +228,32 @@ class ApplyRules extends Command
*/
private function verifyInputAccounts(): bool
{
- $accountString = $this->option('accounts');
+ $accountString = $this->option('accounts');
if (null === $accountString || '' === $accountString) {
$this->friendlyError('Please use the --accounts option to indicate the accounts to apply rules to.');
return false;
}
- $finalList = new Collection();
- $accountList = explode(',', $accountString);
+ $finalList = new Collection();
+ $accountList = explode(',', $accountString);
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$accountRepository->setUser($this->getUser());
foreach ($accountList as $accountId) {
- $accountId = (int) $accountId;
+ $accountId = (int)$accountId;
if (0 === $accountId) {
$this->friendlyWarning('You provided an account with ID 0 (zero). It will be ignored.');
continue;
}
- $account = $accountRepository->find($accountId);
+ $account = $accountRepository->find($accountId);
if (null === $account) {
$this->friendlyWarning(sprintf('There is no account with ID #%d, it cannot be added.', $accountId));
continue;
}
- $type = $account->accountType->type;
+ $type = $account->accountType->type;
if (!in_array($account->accountType->type, $this->acceptedAccounts, true)) {
$this->friendlyWarning(sprintf('Account "%s" with ID #%d is of type "%s" and cannot be added.', $account->name, $accountId, $type));
@@ -267,7 +267,7 @@ class ApplyRules extends Command
return false;
}
- $this->accounts = $finalList;
+ $this->accounts = $finalList;
return true;
}
@@ -278,13 +278,13 @@ class ApplyRules extends Command
private function verifyInputDates(): void
{
// parse start date.
- $inputStart = today(config('app.timezone'))->startOfMonth();
- $startString = $this->option('start_date');
+ $inputStart = today(config('app.timezone'))->startOfMonth();
+ $startString = $this->option('start_date');
if (null === $startString) {
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$repository->setUser($this->getUser());
- $first = $repository->firstNull();
+ $first = $repository->firstNull();
if (null !== $first) {
$inputStart = $first->date;
}
@@ -294,8 +294,8 @@ class ApplyRules extends Command
}
// parse end date
- $inputEnd = today(config('app.timezone'));
- $endString = $this->option('end_date');
+ $inputEnd = today(config('app.timezone'));
+ $endString = $this->option('end_date');
if (null !== $endString && '' !== $endString) {
$inputEnd = Carbon::createFromFormat('Y-m-d', $endString);
}
@@ -320,10 +320,10 @@ class ApplyRules extends Command
// can be empty.
return true;
}
- $ruleGroupList = explode(',', $ruleGroupString);
+ $ruleGroupList = explode(',', $ruleGroupString);
foreach ($ruleGroupList as $ruleGroupId) {
- $ruleGroupId = (int) $ruleGroupId;
+ $ruleGroupId = (int)$ruleGroupId;
if (0 === $ruleGroupId) {
$this->friendlyWarning('You added a rule group with ID 0 (zero). It will be skipped.');
@@ -331,7 +331,7 @@ class ApplyRules extends Command
continue;
}
- $ruleGroup = $this->ruleGroupRepository->find($ruleGroupId);
+ $ruleGroup = $this->ruleGroupRepository->find($ruleGroupId);
if (null === $ruleGroup) {
$this->friendlyWarning(sprintf('There is no rule group with ID #%d, this ID will be ignored.', $ruleGroupId));
@@ -356,16 +356,16 @@ class ApplyRules extends Command
// can be empty.
return true;
}
- $ruleList = explode(',', $ruleString);
+ $ruleList = explode(',', $ruleString);
foreach ($ruleList as $ruleId) {
- $ruleId = (int) $ruleId;
+ $ruleId = (int)$ruleId;
if (0 === $ruleId) {
$this->friendlyWarning('You added a rule with ID 0 (zero). It will be skipped.');
continue;
}
- $rule = $this->ruleRepository->find($ruleId);
+ $rule = $this->ruleRepository->find($ruleId);
if (null === $rule) {
$this->friendlyWarning(sprintf('There is no rule with ID #%d, this ID will be ignored.', $ruleId));
diff --git a/app/Console/Commands/Tools/ChecksForUpdates.php b/app/Console/Commands/Tools/ChecksForUpdates.php
index 9169e0fea0..f717ff107f 100644
--- a/app/Console/Commands/Tools/ChecksForUpdates.php
+++ b/app/Console/Commands/Tools/ChecksForUpdates.php
@@ -35,26 +35,25 @@ class ChecksForUpdates extends Command
use ShowsFriendlyMessages;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'firefly-iii:check-for-updates {--force}';
-
+ protected $description = 'Checks for Firefly III updates';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'Checks for Firefly III updates';
+ protected $signature = 'firefly-iii:check-for-updates {--force}';
/**
* Execute the console command.
*/
public function handle(): int
{
- $build = Carbon::createFromTimestamp(config('firefly.build_time'), config('app.timezone'));
- $version = config('firefly.version');
+ $build = Carbon::createFromTimestamp(config('firefly.build_time'), config('app.timezone'));
+ $version = config('firefly.version');
$this->friendlyLine(sprintf('You are running version "%s", built on %s', $version, $build->format('Y-m-d H:i')));
$permission = AppConfiguration::get('permission_update_check', -1)->data;
@@ -68,9 +67,9 @@ class ChecksForUpdates extends Command
}
/** @var UpdateRequestInterface $request */
- $request = app(UpdateRequestInterface::class);
+ $request = app(UpdateRequestInterface::class);
// stable, alpha or beta
- $info = $request->getUpdateInformation($version, $build, 'stable');
+ $info = $request->getUpdateInformation($version, $build, 'stable');
if ('' !== $info->getError()) {
$this->friendlyError($info->getError());
diff --git a/app/Console/Commands/Tools/Cron.php b/app/Console/Commands/Tools/Cron.php
index 41905428b9..6e29ec99ea 100644
--- a/app/Console/Commands/Tools/Cron.php
+++ b/app/Console/Commands/Tools/Cron.php
@@ -46,7 +46,7 @@ class Cron extends Command
protected $description = 'Runs all Firefly III cron-job related commands. Configure a cron job according to the official Firefly III documentation.';
- protected $signature = 'firefly-iii:cron
+ protected $signature = 'firefly-iii:cron
{--F|force : Force the cron job(s) to execute.}
{--date= : Set the date in YYYY-MM-DD to make Firefly III think that\'s the current date.}
{--check-version : Check if there is a new Firefly III version. Other tasks will be skipped unless also requested.}
@@ -62,8 +62,8 @@ class Cron extends Command
public function handle(): int
{
/** @var UserRepositoryInterface $repository */
- $repository = app(UserRepositoryInterface::class);
- $admin = $repository->getUsersByRole('owner')->first();
+ $repository = app(UserRepositoryInterface::class);
+ $admin = $repository->getUsersByRole('owner')->first();
if (null === $admin) {
$this->friendlyError('There is no user in the system with the "owner"-role, cannot continue.');
@@ -71,11 +71,11 @@ class Cron extends Command
}
$this->admin = $admin;
$doAll = !$this->option('download-cer')
- && !$this->option('create-recurring')
- && !$this->option('create-auto-budgets')
- && !$this->option('send-subscription-warnings')
- && !$this->option('check-version')
- && !$this->option('send-webhook-messages');
+ && !$this->option('create-recurring')
+ && !$this->option('create-auto-budgets')
+ && !$this->option('send-subscription-warnings')
+ && !$this->option('check-version')
+ && !$this->option('send-webhook-messages');
$date = null;
try {
@@ -83,7 +83,7 @@ class Cron extends Command
} catch (InvalidArgumentException $e) {
$this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date')));
}
- $force = (bool) $this->option('force');
+ $force = (bool)$this->option('force');
// Fire exchange rates cron job.
if (true === AppConfiguration::get('enable_external_rates', config('cer.download_enabled'))->data && ($doAll || $this->option('download-cer'))) {
diff --git a/app/Console/Commands/Tools/VerifiesDatabaseConnection.php b/app/Console/Commands/Tools/VerifiesDatabaseConnection.php
index 355e0f27b5..e455bf6aa2 100644
--- a/app/Console/Commands/Tools/VerifiesDatabaseConnection.php
+++ b/app/Console/Commands/Tools/VerifiesDatabaseConnection.php
@@ -33,18 +33,17 @@ class VerifiesDatabaseConnection extends Command
use VerifiesDatabaseConnectionTrait;
/**
- * The name and signature of the console command.
+ * The console command description.
*
* @var string
*/
- protected $signature = 'firefly-iii:verify-database-connection';
-
+ protected $description = 'This command tries to connect to the database.';
/**
- * The console command description.
+ * The name and signature of the console command.
*
* @var string
*/
- protected $description = 'This command tries to connect to the database.';
+ protected $signature = 'firefly-iii:verify-database-connection';
/**
* Execute the console command.
diff --git a/app/Console/Commands/Tools/VerifiesDatabaseConnectionTrait.php b/app/Console/Commands/Tools/VerifiesDatabaseConnectionTrait.php
index 44f70fd7ab..14de0ba925 100644
--- a/app/Console/Commands/Tools/VerifiesDatabaseConnectionTrait.php
+++ b/app/Console/Commands/Tools/VerifiesDatabaseConnectionTrait.php
@@ -33,10 +33,10 @@ trait VerifiesDatabaseConnectionTrait
{
protected function verifyDatabaseConnection(): bool
{
- $loops = 30;
- $loop = 0;
- $queries = ['pgsql' => 'SELECT * FROM pg_catalog.pg_tables;', 'sqlite' => 'SELECT name FROM sqlite_schema;', 'mysql' => 'SHOW TABLES;'];
- $default = config('database.default');
+ $loops = 30;
+ $loop = 0;
+ $queries = ['pgsql' => 'SELECT * FROM pg_catalog.pg_tables;', 'sqlite' => 'SELECT name FROM sqlite_schema;', 'mysql' => 'SHOW TABLES;'];
+ $default = config('database.default');
if (!array_key_exists($default, $queries)) {
$this->friendlyWarning(sprintf('Cannot validate database connection for "%s"', $default));
diff --git a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php
index 65e0ee96df..d04ffe7ddc 100644
--- a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php
+++ b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php
@@ -40,10 +40,10 @@ class AddsTransactionIdentifiers extends Command
public const string CONFIG_NAME = '480_transaction_identifier';
- protected $description = 'Fixes transaction identifiers.';
- protected $signature = 'upgrade:480-transaction-identifiers {--F|force : Force the execution of this command.}';
+ protected $description = 'Fixes transaction identifiers.';
+ protected $signature = 'upgrade:480-transaction-identifiers {--F|force : Force the execution of this command.}';
private JournalCLIRepositoryInterface $cliRepository;
- private int $count;
+ private int $count;
/**
* This method gives all transactions which are part of a split journal (so more than 2) a sort of "order" so they
@@ -94,12 +94,11 @@ class AddsTransactionIdentifiers extends Command
try {
/** @var Transaction $opposing */
$opposing = Transaction::query()
- ->where('transaction_journal_id', $transaction->transaction_journal_id)
- ->where('amount', $amount)
- ->where('identifier', '=', 0)
- ->whereNotIn('id', $exclude)
- ->first()
- ;
+ ->where('transaction_journal_id', $transaction->transaction_journal_id)
+ ->where('amount', $amount)
+ ->where('identifier', '=', 0)
+ ->whereNotIn('id', $exclude)
+ ->first();
} catch (QueryException $e) {
Log::error($e->getMessage());
$this->friendlyError('Firefly III could not find the "identifier" field in the "transactions" table.');
@@ -117,7 +116,7 @@ class AddsTransactionIdentifiers extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -155,8 +154,8 @@ class AddsTransactionIdentifiers extends Command
$opposing->identifier = $identifier;
$transaction->save();
$opposing->save();
- $exclude[] = $transaction->id;
- $exclude[] = $opposing->id;
+ $exclude[] = $transaction->id;
+ $exclude[] = $opposing->id;
++$this->count;
}
++$identifier;
diff --git a/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php b/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
index 9ae22a900c..ced07d11f1 100644
--- a/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
+++ b/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php
@@ -35,7 +35,6 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use JsonException;
use stdClass;
-
use function Safe\json_decode;
class RemovesDatabaseDecryption extends Command
@@ -110,8 +109,8 @@ class RemovesDatabaseDecryption extends Command
if (null === $original) {
return;
}
- $id = (int) $row->id;
- $value = '';
+ $id = (int)$row->id;
+ $value = '';
try {
$value = $this->tryDecrypt($original);
@@ -159,7 +158,7 @@ class RemovesDatabaseDecryption extends Command
Log::error($e->getMessage());
}
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
/**
diff --git a/app/Console/Commands/Upgrade/RepairsAccountBalances.php b/app/Console/Commands/Upgrade/RepairsAccountBalances.php
index 2c024cad75..e7214041b8 100644
--- a/app/Console/Commands/Upgrade/RepairsAccountBalances.php
+++ b/app/Console/Commands/Upgrade/RepairsAccountBalances.php
@@ -35,8 +35,8 @@ class RepairsAccountBalances extends Command
public const string CONFIG_NAME = '610_correct_balances';
- protected $description = 'Recalculate all account balance amounts';
- protected $signature = 'upgrade:610-account-balances {--F|force : Force the execution of this command.}';
+ protected $description = 'Recalculate all account balance amounts';
+ protected $signature = 'upgrade:610-account-balances {--F|force : Force the execution of this command.}';
public function handle(): int
{
@@ -67,7 +67,7 @@ class RepairsAccountBalances extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
diff --git a/app/Console/Commands/Upgrade/RepairsPostgresSequences.php b/app/Console/Commands/Upgrade/RepairsPostgresSequences.php
index f0a11c8d6c..da52835d6f 100644
--- a/app/Console/Commands/Upgrade/RepairsPostgresSequences.php
+++ b/app/Console/Commands/Upgrade/RepairsPostgresSequences.php
@@ -36,7 +36,7 @@ class RepairsPostgresSequences extends Command
protected $description = 'Fixes issues with PostgreSQL sequences.';
- protected $signature = 'upgrade:600-pgsql-sequences';
+ protected $signature = 'upgrade:600-pgsql-sequences';
/**
* Execute the console command.
@@ -116,9 +116,8 @@ class RepairsPostgresSequences extends Command
try {
$nextId = DB::table($tableToCheck)
- ->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))
- ->first()
- ;
+ ->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))
+ ->first();
} catch (QueryException $e) {
Log::warning(sprintf('Could not get nextval, but will ignore this: %s', $e->getMessage()));
$nextId = null;
@@ -133,9 +132,8 @@ class RepairsPostgresSequences extends Command
DB::select(sprintf('SELECT setval(\'%s_id_seq\', %d)', $tableToCheck, $highestId->max));
$highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->first();
$nextId = DB::table($tableToCheck)
- ->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))
- ->first()
- ;
+ ->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))
+ ->first();
if ($nextId->nextval > $highestId->max) {
$this->friendlyInfo(sprintf('Table "%s" autoincrement corrected.', $tableToCheck));
}
diff --git a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
index 3c5b0f4f5e..f6932c769b 100644
--- a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
+++ b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php
@@ -44,11 +44,11 @@ class UpgradesAccountCurrencies extends Command
public const string CONFIG_NAME = '480_account_currencies';
- protected $description = 'Give all accounts proper currency info.';
- protected $signature = 'upgrade:480-account-currencies {--F|force : Force the execution of this command.}';
+ protected $description = 'Give all accounts proper currency info.';
+ protected $signature = 'upgrade:480-account-currencies {--F|force : Force the execution of this command.}';
private AccountRepositoryInterface $accountRepos;
- private int $count;
- private UserRepositoryInterface $userRepos;
+ private int $count;
+ private UserRepositoryInterface $userRepos;
/**
* Each (asset) account must have a reference to a preferred currency. If the account does not have one, it's
@@ -77,7 +77,7 @@ class UpgradesAccountCurrencies extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -100,9 +100,9 @@ class UpgradesAccountCurrencies extends Command
private function updateAccount(Account $account, TransactionCurrency $currency): void
{
$this->accountRepos->setUser($account->user);
- $accountCurrency = (int) $this->accountRepos->getMetaValue($account, 'currency_id');
+ $accountCurrency = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
$openingBalance = $this->accountRepos->getOpeningBalance($account);
- $obCurrency = (int) $openingBalance?->transaction_currency_id;
+ $obCurrency = (int)$openingBalance?->transaction_currency_id;
// both 0? set to default currency:
if (0 === $accountCurrency && 0 === $obCurrency) {
@@ -147,7 +147,7 @@ class UpgradesAccountCurrencies extends Command
private function updateCurrenciesForUser(User $user): void
{
$this->accountRepos->setUser($user);
- $accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);
+ $accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);
// get user's currency preference:
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
diff --git a/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php b/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php
index b35d480e88..aab895d062 100644
--- a/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php
+++ b/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php
@@ -36,9 +36,9 @@ class UpgradesAccountMetaData extends Command
public const string CONFIG_NAME = '480_rename_account_meta';
- protected $description = 'Rename account meta-data to new format.';
+ protected $description = 'Rename account meta-data to new format.';
- protected $signature = 'upgrade:480-account-meta {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:480-account-meta {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -85,7 +85,7 @@ class UpgradesAccountMetaData extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
diff --git a/app/Console/Commands/Upgrade/UpgradesAttachments.php b/app/Console/Commands/Upgrade/UpgradesAttachments.php
index b62d7a38c0..5875977186 100644
--- a/app/Console/Commands/Upgrade/UpgradesAttachments.php
+++ b/app/Console/Commands/Upgrade/UpgradesAttachments.php
@@ -38,9 +38,9 @@ class UpgradesAttachments extends Command
public const string CONFIG_NAME = '480_migrate_attachments';
- protected $description = 'Migrates attachment meta-data.';
+ protected $description = 'Migrates attachment meta-data.';
- protected $signature = 'upgrade:480-attachments {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:480-attachments {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -49,7 +49,7 @@ class UpgradesAttachments extends Command
*/
public function handle(): int
{
- $start = microtime(true);
+ $start = microtime(true);
if ($this->isExecuted() && true !== $this->option('force')) {
$this->friendlyInfo('This command has already been executed.');
@@ -62,15 +62,15 @@ class UpgradesAttachments extends Command
/** @var Attachment $att */
foreach ($attachments as $att) {
// move description:
- $attDescription = (string) $att->description;
+ $attDescription = (string)$att->description;
if ('' !== $attDescription) {
// find or create note:
- $note = $att->notes()->first();
+ $note = $att->notes()->first();
if (null === $note) {
$note = new Note();
$note->noteable()->associate($att);
}
- $note->text = $attDescription;
+ $note->text = $attDescription;
$note->save();
// clear description:
@@ -84,7 +84,7 @@ class UpgradesAttachments extends Command
if (0 !== $count) {
$this->friendlyInfo(sprintf('Updated %d attachment(s).', $count));
}
- $end = round(microtime(true) - $start, 2);
+ $end = round(microtime(true) - $start, 2);
$this->friendlyInfo(sprintf('Migrated attachment notes in %s seconds.', $end));
$this->markAsExecuted();
@@ -95,7 +95,7 @@ class UpgradesAttachments extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
diff --git a/app/Console/Commands/Upgrade/UpgradesBillsToRules.php b/app/Console/Commands/Upgrade/UpgradesBillsToRules.php
index bd18021dd2..0f16a5933f 100644
--- a/app/Console/Commands/Upgrade/UpgradesBillsToRules.php
+++ b/app/Console/Commands/Upgrade/UpgradesBillsToRules.php
@@ -44,14 +44,14 @@ class UpgradesBillsToRules extends Command
public const string CONFIG_NAME = '480_bills_to_rules';
- protected $description = 'Migrate bills to rules.';
+ protected $description = 'Migrate bills to rules.';
- protected $signature = 'upgrade:480-bills-to-rules {--F|force : Force the execution of this command.}';
- private BillRepositoryInterface $billRepository;
- private int $count;
+ protected $signature = 'upgrade:480-bills-to-rules {--F|force : Force the execution of this command.}';
+ private BillRepositoryInterface $billRepository;
+ private int $count;
private RuleGroupRepositoryInterface $ruleGroupRepository;
- private RuleRepositoryInterface $ruleRepository;
- private UserRepositoryInterface $userRepository;
+ private RuleRepositoryInterface $ruleRepository;
+ private UserRepositoryInterface $userRepository;
/**
* Execute the console command.
@@ -88,7 +88,7 @@ class UpgradesBillsToRules extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -101,17 +101,17 @@ class UpgradesBillsToRules extends Command
if ('MIGRATED_TO_RULES' === $bill->match) {
return;
}
- $languageString = null !== $language->data && !is_array($language->data) ? (string) $language->data : 'en_US';
+ $languageString = null !== $language->data && !is_array($language->data) ? (string)$language->data : 'en_US';
// get match thing:
- $match = implode(' ', explode(',', $bill->match));
- $newRule = [
+ $match = implode(' ', explode(',', $bill->match));
+ $newRule = [
'rule_group_id' => $ruleGroup->id,
'active' => true,
'strict' => false,
'stop_processing' => false, // field is no longer used.
- 'title' => (string) trans('firefly.rule_for_bill_title', ['name' => $bill->name], $languageString),
- 'description' => (string) trans('firefly.rule_for_bill_description', ['name' => $bill->name], $languageString),
+ 'title' => (string)trans('firefly.rule_for_bill_title', ['name' => $bill->name], $languageString),
+ 'description' => (string)trans('firefly.rule_for_bill_description', ['name' => $bill->name], $languageString),
'trigger' => 'store-journal',
'triggers' => [['type' => 'description_contains', 'value' => $match]],
'actions' => [['type' => 'link_to_bill', 'value' => $bill->name]],
@@ -129,7 +129,7 @@ class UpgradesBillsToRules extends Command
$this->ruleRepository->store($newRule);
// update bill:
- $newBillData = [
+ $newBillData = [
'currency_id' => $bill->transaction_currency_id,
'name' => $bill->name,
'match' => 'MIGRATED_TO_RULES',
@@ -155,18 +155,18 @@ class UpgradesBillsToRules extends Command
/** @var Preference $lang */
$lang = Preferences::getForUser($user, 'language', 'en_US');
- $language = null !== $lang->data && !is_array($lang->data) ? (string) $lang->data : 'en_US';
- $groupTitle = (string) trans('firefly.rulegroup_for_bills_title', [], $language);
+ $language = null !== $lang->data && !is_array($lang->data) ? (string)$lang->data : 'en_US';
+ $groupTitle = (string)trans('firefly.rulegroup_for_bills_title', [], $language);
$ruleGroup = $this->ruleGroupRepository->findByTitle($groupTitle);
if (!$ruleGroup instanceof RuleGroup) {
$ruleGroup = $this->ruleGroupRepository->store([
- 'title' => (string) trans('firefly.rulegroup_for_bills_title', [], $language),
- 'description' => (string) trans('firefly.rulegroup_for_bills_description', [], $language),
- 'active' => true,
- ]);
+ 'title' => (string)trans('firefly.rulegroup_for_bills_title', [], $language),
+ 'description' => (string)trans('firefly.rulegroup_for_bills_description', [], $language),
+ 'active' => true,
+ ]);
}
- $bills = $this->billRepository->getBills();
+ $bills = $this->billRepository->getBills();
/** @var Bill $bill */
foreach ($bills as $bill) {
diff --git a/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php b/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php
index 1b131553b9..d85924a704 100644
--- a/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php
+++ b/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php
@@ -36,9 +36,9 @@ class UpgradesBudgetLimitPeriods extends Command
public const string CONFIG_NAME = '550_budget_limit_periods';
- protected $description = 'Append budget limits with their (estimated) timeframe.';
+ protected $description = 'Append budget limits with their (estimated) timeframe.';
- protected $signature = 'upgrade:550-budget-limit-periods {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:550-budget-limit-periods {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -59,7 +59,7 @@ class UpgradesBudgetLimitPeriods extends Command
private function fixLimit(BudgetLimit $limit): void
{
- $period = $this->getLimitPeriod($limit);
+ $period = $this->getLimitPeriod($limit);
if (null === $period) {
$message = sprintf(
@@ -76,7 +76,7 @@ class UpgradesBudgetLimitPeriods extends Command
$limit->period = $period;
$limit->saveQuietly();
- $msg = sprintf(
+ $msg = sprintf(
'Budget limit #%d (%s - %s) period is "%s".',
$limit->id,
$limit->start_date->format('Y-m-d'),
@@ -96,7 +96,7 @@ class UpgradesBudgetLimitPeriods extends Command
if (
'1' === $limit->start_date->format('N')
&& '7' === $limit->end_date->format('N')
- && 6 === (int) $limit->end_date->diffInDays($limit->start_date, true)
+ && 6 === (int)$limit->end_date->diffInDays($limit->start_date, true)
) {
return 'weekly';
}
@@ -116,7 +116,7 @@ class UpgradesBudgetLimitPeriods extends Command
if (
in_array($limit->start_date->format('j-n'), $start, true) // start of quarter
&& in_array($limit->end_date->format('j-n'), $end, true) // end of quarter
- && 2 === (int) $limit->start_date->diffInMonths($limit->end_date, true)
+ && 2 === (int)$limit->start_date->diffInMonths($limit->end_date, true)
) {
return 'quarterly';
}
@@ -126,7 +126,7 @@ class UpgradesBudgetLimitPeriods extends Command
if (
in_array($limit->start_date->format('j-n'), $start, true) // start of quarter
&& in_array($limit->end_date->format('j-n'), $end, true) // end of quarter
- && 5 === (int) $limit->start_date->diffInMonths($limit->end_date, true)
+ && 5 === (int)$limit->start_date->diffInMonths($limit->end_date, true)
) {
return 'half_year';
}
@@ -142,7 +142,7 @@ class UpgradesBudgetLimitPeriods extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar->data;
+ return (bool)$configVar->data;
}
private function markAsExecuted(): void
diff --git a/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php b/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php
index 166bdb2cf4..fdddea86e5 100644
--- a/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php
+++ b/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php
@@ -39,9 +39,9 @@ class UpgradesBudgetLimits extends Command
public const string CONFIG_NAME = '480_bl_currency';
- protected $description = 'Give budget limits a currency';
+ protected $description = 'Give budget limits a currency';
- protected $signature = 'upgrade:480-budget-limit-currencies {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:480-budget-limit-currencies {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -72,11 +72,11 @@ class UpgradesBudgetLimits extends Command
$budgetLimit->transaction_currency_id = $currency->id;
$budgetLimit->saveQuietly();
$this->friendlyInfo(sprintf(
- 'Budget limit #%d (part of budget "%s") now has a currency setting (%s).',
- $budgetLimit->id,
- $budget->name,
- $currency->name
- ));
+ 'Budget limit #%d (part of budget "%s") now has a currency setting (%s).',
+ $budgetLimit->id,
+ $budget->name,
+ $currency->name
+ ));
++$count;
}
}
@@ -91,7 +91,7 @@ class UpgradesBudgetLimits extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
diff --git a/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php b/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php
index ffba93fd6d..f59efa8bc0 100644
--- a/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php
+++ b/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php
@@ -39,8 +39,8 @@ class UpgradesCreditCardLiabilities extends Command
public const string CONFIG_NAME = '480_cc_liabilities';
- protected $description = 'Convert old credit card liabilities.';
- protected $signature = 'upgrade:480-cc-liabilities {--F|force : Force the execution of this command.}';
+ protected $description = 'Convert old credit card liabilities.';
+ protected $signature = 'upgrade:480-cc-liabilities {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -84,7 +84,7 @@ class UpgradesCreditCardLiabilities extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
diff --git a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php
index 9ebb20ab85..c21f751ba9 100644
--- a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php
+++ b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php
@@ -41,9 +41,9 @@ class UpgradesCurrencyPreferences extends Command
public const string CONFIG_NAME = '610_upgrade_currency_prefs';
- protected $description = 'Upgrade user currency preferences';
+ protected $description = 'Upgrade user currency preferences';
- protected $signature = 'upgrade:610-currency-preferences {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:610-currency-preferences {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -67,17 +67,16 @@ class UpgradesCurrencyPreferences extends Command
private function getPreference(User $user): string
{
$preference = Preference::query()
- ->where('user_id', $user->id)
- ->where('name', 'currencyPreference')
- ->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at'])
- ;
+ ->where('user_id', $user->id)
+ ->where('name', 'currencyPreference')
+ ->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);
if (null === $preference) {
return 'EUR';
}
if (null !== $preference->data && !is_array($preference->data)) {
- return (string) $preference->data;
+ return (string)$preference->data;
}
return 'EUR';
@@ -87,7 +86,7 @@ class UpgradesCurrencyPreferences extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -104,7 +103,7 @@ class UpgradesCurrencyPreferences extends Command
$this->upgradeGroupPreferences($group);
}
- $users = User::get();
+ $users = User::get();
/** @var User $user */
foreach ($users as $user) {
diff --git a/app/Console/Commands/Upgrade/UpgradesDatabase.php b/app/Console/Commands/Upgrade/UpgradesDatabase.php
index 4ad2e9ec23..0e59f9fc0a 100644
--- a/app/Console/Commands/Upgrade/UpgradesDatabase.php
+++ b/app/Console/Commands/Upgrade/UpgradesDatabase.php
@@ -29,7 +29,6 @@ use FireflyIII\Support\Facades\AppConfiguration;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Safe\Exceptions\InfoException;
-
use function Safe\set_time_limit;
try {
@@ -87,7 +86,7 @@ class UpgradesDatabase extends Command
$this->call($command, $args);
}
// index will set FF3 version.
- AppConfiguration::set('ff3_build_time', (int) config('firefly.build_time'));
+ AppConfiguration::set('ff3_build_time', (int)config('firefly.build_time'));
return 0;
}
diff --git a/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php b/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php
index 3f830bcf36..a7c9799f43 100644
--- a/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php
+++ b/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php
@@ -40,9 +40,9 @@ class UpgradesJournalMetaData extends Command
public const string CONFIG_NAME = '480_back_to_journals';
- protected $description = 'Move meta data back to journals, not individual transactions.';
+ protected $description = 'Move meta data back to journals, not individual transactions.';
- protected $signature = 'upgrade:480-journal-meta-data {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:480-journal-meta-data {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -100,14 +100,14 @@ class UpgradesJournalMetaData extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar->data;
+ return (bool)$configVar->data;
}
private function isMigrated(): bool
{
$configVar = AppConfiguration::get(UpgradesToGroups::CONFIG_NAME, false);
- return (bool) $configVar->data;
+ return (bool)$configVar->data;
}
private function markAsExecuted(): void
@@ -145,7 +145,7 @@ class UpgradesJournalMetaData extends Command
{
// grab category from first transaction
/** @var null|Transaction $transaction */
- $transaction = $journal->transactions->first();
+ $transaction = $journal->transactions->first();
if (null === $transaction) {
$this->friendlyInfo(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
@@ -153,7 +153,7 @@ class UpgradesJournalMetaData extends Command
}
/** @var null|Budget $budget */
- $budget = $transaction->budgets->first();
+ $budget = $transaction->budgets->first();
/** @var null|Budget $journalBudget */
$journalBudget = $journal->budgets->first();
@@ -178,7 +178,7 @@ class UpgradesJournalMetaData extends Command
$journals = new Collection();
$allIds = $this->getIdsForCategories();
- $chunks = array_chunk($allIds, 500);
+ $chunks = array_chunk($allIds, 500);
foreach ($chunks as $chunk) {
$collected = TransactionJournal::query()->whereIn('id', $chunk)->with(['transactions', 'categories', 'transactions.categories'])->get();
$journals = $journals->merge($collected);
@@ -194,7 +194,7 @@ class UpgradesJournalMetaData extends Command
{
// grab category from first transaction
/** @var null|Transaction $transaction */
- $transaction = $journal->transactions->first();
+ $transaction = $journal->transactions->first();
if (null === $transaction) {
$this->friendlyInfo(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));
@@ -202,7 +202,7 @@ class UpgradesJournalMetaData extends Command
}
/** @var null|Category $category */
- $category = $transaction->categories->first();
+ $category = $transaction->categories->first();
/** @var null|Category $journalCategory */
$journalCategory = $journal->categories->first();
diff --git a/app/Console/Commands/Upgrade/UpgradesJournalNotes.php b/app/Console/Commands/Upgrade/UpgradesJournalNotes.php
index e3132be9c8..609e4251c6 100644
--- a/app/Console/Commands/Upgrade/UpgradesJournalNotes.php
+++ b/app/Console/Commands/Upgrade/UpgradesJournalNotes.php
@@ -37,9 +37,9 @@ class UpgradesJournalNotes extends Command
public const string CONFIG_NAME = '480_migrate_notes';
- protected $description = 'Migrate notes for transaction journals.';
+ protected $description = 'Migrate notes for transaction journals.';
- protected $signature = 'upgrade:480-notes {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:480-notes {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -59,8 +59,8 @@ class UpgradesJournalNotes extends Command
/** @var TransactionJournalMeta $meta */
foreach ($set as $meta) {
- $journal = $meta->transactionJournal;
- $note = $journal->notes()->first();
+ $journal = $meta->transactionJournal;
+ $note = $journal->notes()->first();
if (null === $note) {
$note = new Note();
$note->noteable()->associate($journal);
@@ -78,7 +78,7 @@ class UpgradesJournalNotes extends Command
$this->friendlyInfo(sprintf('Migrated %d note(s).', $count));
}
- $end = round(microtime(true) - $start, 2);
+ $end = round(microtime(true) - $start, 2);
$this->friendlyInfo(sprintf('Migrated notes in %s seconds.', $end));
$this->markAsExecuted();
@@ -89,7 +89,7 @@ class UpgradesJournalNotes extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
diff --git a/app/Console/Commands/Upgrade/UpgradesLiabilities.php b/app/Console/Commands/Upgrade/UpgradesLiabilities.php
index bd4431af8f..7aae7c8dd5 100644
--- a/app/Console/Commands/Upgrade/UpgradesLiabilities.php
+++ b/app/Console/Commands/Upgrade/UpgradesLiabilities.php
@@ -41,8 +41,8 @@ class UpgradesLiabilities extends Command
public const string CONFIG_NAME = '560_upgrade_liabilities';
- protected $description = 'Upgrade liabilities to new 5.6.0 structure.';
- protected $signature = 'upgrade:560-liabilities {--F|force : Force the execution of this command.}';
+ protected $description = 'Upgrade liabilities to new 5.6.0 structure.';
+ protected $signature = 'upgrade:560-liabilities {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -95,7 +95,7 @@ class UpgradesLiabilities extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -109,8 +109,7 @@ class UpgradesLiabilities extends Command
->accounts()
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->whereIn('account_types.type', config('firefly.valid_liabilities'))
- ->get(['accounts.*'])
- ;
+ ->get(['accounts.*']);
/** @var Account $account */
foreach ($accounts as $account) {
@@ -134,7 +133,7 @@ class UpgradesLiabilities extends Command
private function upgradeLiability(Account $account): void
{
/** @var AccountRepositoryInterface $repository */
- $repository = app(AccountRepositoryInterface::class);
+ $repository = app(AccountRepositoryInterface::class);
$repository->setUser($account->user);
// get opening balance, and correct if necessary.
@@ -145,7 +144,7 @@ class UpgradesLiabilities extends Command
}
// add liability direction property (if it does not yet exist!)
- $value = $repository->getMetaValue($account, 'liability_direction');
+ $value = $repository->getMetaValue($account, 'liability_direction');
if (null === $value) {
/** @var AccountMetaFactory $factory */
$factory = app(AccountMetaFactory::class);
diff --git a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php
index 3aef1d4bee..4baad177df 100644
--- a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php
+++ b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php
@@ -44,8 +44,8 @@ class UpgradesLiabilitiesEight extends Command
public const string CONFIG_NAME = '600_upgrade_liabilities';
- protected $description = 'Upgrade liabilities to new 6.0.0 structure.';
- protected $signature = 'upgrade:600-liabilities {--F|force : Force the execution of this command.}';
+ protected $description = 'Upgrade liabilities to new 6.0.0 structure.';
+ protected $signature = 'upgrade:600-liabilities {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -67,10 +67,9 @@ class UpgradesLiabilitiesEight extends Command
{
$liabilityType = TransactionType::whereType(TransactionTypeEnum::LIABILITY_CREDIT->value)->first();
$liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->where('transaction_journals.transaction_type_id', $liabilityType->id)
- ->first(['transaction_journals.*'])
- ;
+ ->where('transactions.account_id', $account->id)
+ ->where('transaction_journals.transaction_type_id', $liabilityType->id)
+ ->first(['transaction_journals.*']);
if (null !== $liabilityJournal && null !== $liabilityJournal->transactionGroup) {
$group = $liabilityJournal->transactionGroup;
$service = new TransactionGroupDestroyService();
@@ -86,7 +85,7 @@ class UpgradesLiabilitiesEight extends Command
$account->id
)->get(['transaction_journals.*']);
- $service = app(TransactionGroupDestroyService::class);
+ $service = app(TransactionGroupDestroyService::class);
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
@@ -105,24 +104,22 @@ class UpgradesLiabilitiesEight extends Command
$openingBalanceType = TransactionType::whereType(TransactionTypeEnum::OPENING_BALANCE->value)->first();
/** @var TransactionType $liabilityType */
- $liabilityType = TransactionType::whereType(TransactionTypeEnum::LIABILITY_CREDIT->value)->first();
+ $liabilityType = TransactionType::whereType(TransactionTypeEnum::LIABILITY_CREDIT->value)->first();
/** @var null|TransactionJournal $openingJournal */
- $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
- ->first(['transaction_journals.*'])
- ;
+ $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->where('transactions.account_id', $account->id)
+ ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
+ ->first(['transaction_journals.*']);
if (null === $openingJournal) {
return false;
}
/** @var null|TransactionJournal $liabilityJournal */
- $liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->where('transaction_journals.transaction_type_id', $liabilityType->id)
- ->first(['transaction_journals.*'])
- ;
+ $liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->where('transactions.account_id', $account->id)
+ ->where('transaction_journals.transaction_type_id', $liabilityType->id)
+ ->first(['transaction_journals.*']);
if (null === $liabilityJournal) {
return false;
}
@@ -134,7 +131,7 @@ class UpgradesLiabilitiesEight extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -147,17 +144,16 @@ class UpgradesLiabilitiesEight extends Command
$openingBalanceType = TransactionType::whereType(TransactionTypeEnum::OPENING_BALANCE->value)->first();
/** @var TransactionJournal $openingJournal */
- $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
- ->first(['transaction_journals.*'])
- ;
+ $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->where('transactions.account_id', $account->id)
+ ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)
+ ->first(['transaction_journals.*']);
/** @var null|Transaction $source */
- $source = $openingJournal->transactions()->where('amount', '<', 0)->first();
+ $source = $openingJournal->transactions()->where('amount', '<', 0)->first();
/** @var null|Transaction $dest */
- $dest = $openingJournal->transactions()->where('amount', '>', 0)->first();
+ $dest = $openingJournal->transactions()->where('amount', '>', 0)->first();
if (null !== $source && null !== $dest) {
$sourceId = $source->account_id;
$destId = $dest->account_id;
@@ -177,8 +173,7 @@ class UpgradesLiabilitiesEight extends Command
->accounts()
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->whereIn('account_types.type', config('firefly.valid_liabilities'))
- ->get(['accounts.*'])
- ;
+ ->get(['accounts.*']);
/** @var Account $account */
foreach ($accounts as $account) {
@@ -205,7 +200,7 @@ class UpgradesLiabilitiesEight extends Command
$repository = app(AccountRepositoryInterface::class);
$repository->setUser($account->user);
- $direction = $repository->getMetaValue($account, 'liability_direction');
+ $direction = $repository->getMetaValue($account, 'liability_direction');
if ('credit' === $direction && $this->hasBadOpening($account)) {
$this->deleteCreditTransaction($account);
$this->reverseOpeningBalance($account);
diff --git a/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php b/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php
index 7e2d385682..47a6cca8ae 100644
--- a/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php
+++ b/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php
@@ -39,10 +39,10 @@ class UpgradesMultiPiggyBanks extends Command
public const string CONFIG_NAME = '620_make_multi_piggies';
- protected $description = 'Upgrade piggy banks so they can use multiple accounts.';
+ protected $description = 'Upgrade piggy banks so they can use multiple accounts.';
- protected $signature = 'upgrade:620-piggy-banks {--F|force : Force the execution of this command.}';
- private AccountRepositoryInterface $accountRepository;
+ protected $signature = 'upgrade:620-piggy-banks {--F|force : Force the execution of this command.}';
+ private AccountRepositoryInterface $accountRepository;
private PiggyBankRepositoryInterface $repository;
/**
@@ -67,7 +67,7 @@ class UpgradesMultiPiggyBanks extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -85,8 +85,8 @@ class UpgradesMultiPiggyBanks extends Command
}
$this->repository->setUser($piggyBank->account->user);
$this->accountRepository->setUser($piggyBank->account->user);
- $repetition = $this->repository->getRepetition($piggyBank, true);
- $currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? Amount::getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);
+ $repetition = $this->repository->getRepetition($piggyBank, true);
+ $currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? Amount::getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);
// update piggy bank to have a currency.
$piggyBank->transaction_currency_id = $currency->id;
@@ -94,7 +94,7 @@ class UpgradesMultiPiggyBanks extends Command
// store current amount in account association.
$piggyBank->accounts()->sync([$piggyBank->account->id => ['current_amount' => $repetition->current_amount]]);
- $piggyBank->account_id = null;
+ $piggyBank->account_id = null;
$piggyBank->saveQuietly();
// remove all repetitions (no longer used)
diff --git a/app/Console/Commands/Upgrade/UpgradesPrimaryCurrencyAmounts.php b/app/Console/Commands/Upgrade/UpgradesPrimaryCurrencyAmounts.php
index 5d927e7a07..eeef4a801c 100644
--- a/app/Console/Commands/Upgrade/UpgradesPrimaryCurrencyAmounts.php
+++ b/app/Console/Commands/Upgrade/UpgradesPrimaryCurrencyAmounts.php
@@ -35,9 +35,9 @@ class UpgradesPrimaryCurrencyAmounts extends Command
public const string CONFIG_NAME = '620_pc_amounts';
- protected $description = 'Runs the primary currency amounts calculations.';
+ protected $description = 'Runs the primary currency amounts calculations.';
- protected $signature = 'upgrade:620-pc-amounts {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:620-pc-amounts {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -61,7 +61,7 @@ class UpgradesPrimaryCurrencyAmounts extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
diff --git a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php
index 3c1b67b325..b5f21859d8 100644
--- a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php
+++ b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php
@@ -30,7 +30,6 @@ use FireflyIII\Models\RecurrenceMeta;
use FireflyIII\Models\RecurrenceTransactionMeta;
use FireflyIII\Support\Facades\AppConfiguration;
use Illuminate\Console\Command;
-
use function Safe\json_encode;
class UpgradesRecurrenceMetaData extends Command
@@ -39,9 +38,9 @@ class UpgradesRecurrenceMetaData extends Command
public const string CONFIG_NAME = '481_migrate_recurrence_meta';
- protected $description = 'Migrate recurrence meta data';
+ protected $description = 'Migrate recurrence meta data';
- protected $signature = 'upgrade:481-recurrence-meta {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:481-recurrence-meta {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -68,7 +67,7 @@ class UpgradesRecurrenceMetaData extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -79,7 +78,7 @@ class UpgradesRecurrenceMetaData extends Command
private function migrateEntry(RecurrenceMeta $meta): int
{
/** @var null|Recurrence $recurrence */
- $recurrence = $meta->recurrence;
+ $recurrence = $meta->recurrence;
if (null === $recurrence) {
return 0;
}
@@ -87,7 +86,7 @@ class UpgradesRecurrenceMetaData extends Command
if (null === $firstTransaction) {
return 0;
}
- $value = $meta->value;
+ $value = $meta->value;
if ('tags' === $meta->name) {
$array = explode(',', $meta->value);
@@ -102,7 +101,7 @@ class UpgradesRecurrenceMetaData extends Command
private function migrateMetaData(): int
{
- $count = 0;
+ $count = 0;
// get all recurrence meta data:
$collection = RecurrenceMeta::query()->with('recurrence')->get();
diff --git a/app/Console/Commands/Upgrade/UpgradesRuleActions.php b/app/Console/Commands/Upgrade/UpgradesRuleActions.php
index 38d55c2156..ae5bc0af06 100644
--- a/app/Console/Commands/Upgrade/UpgradesRuleActions.php
+++ b/app/Console/Commands/Upgrade/UpgradesRuleActions.php
@@ -35,9 +35,9 @@ class UpgradesRuleActions extends Command
public const string CONFIG_NAME = '610_migrate_rule_actions';
- protected $description = 'Migrate rule actions away from expression engine';
+ protected $description = 'Migrate rule actions away from expression engine';
- protected $signature = 'upgrade:600-rule-actions {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:600-rule-actions {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -65,7 +65,7 @@ class UpgradesRuleActions extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -80,8 +80,8 @@ class UpgradesRuleActions extends Command
/** @var RuleAction $action */
foreach ($actions as $action) {
- if (str_starts_with((string) $action->action_value, '=')) {
- $action->action_value = sprintf('%s%s', '\=', substr((string) $action->action_value, 1));
+ if (str_starts_with((string)$action->action_value, '=')) {
+ $action->action_value = sprintf('%s%s', '\=', substr((string)$action->action_value, 1));
$action->save();
++$count;
}
diff --git a/app/Console/Commands/Upgrade/UpgradesTagLocations.php b/app/Console/Commands/Upgrade/UpgradesTagLocations.php
index 9845827939..f63ef5f5e0 100644
--- a/app/Console/Commands/Upgrade/UpgradesTagLocations.php
+++ b/app/Console/Commands/Upgrade/UpgradesTagLocations.php
@@ -36,9 +36,9 @@ class UpgradesTagLocations extends Command
public const string CONFIG_NAME = '500_migrate_tag_locations';
- protected $description = 'Migrate tag locations.';
+ protected $description = 'Migrate tag locations.';
- protected $signature = 'upgrade:500-tag-locations {--F|force : Force the execution of this command.}';
+ protected $signature = 'upgrade:500-tag-locations {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -65,7 +65,7 @@ class UpgradesTagLocations extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -82,9 +82,9 @@ class UpgradesTagLocations extends Command
$location->locatable()->associate($tag);
$location->save();
- $tag->longitude = null;
- $tag->latitude = null;
- $tag->zoomLevel = null;
+ $tag->longitude = null;
+ $tag->latitude = null;
+ $tag->zoomLevel = null;
$tag->save();
}
diff --git a/app/Console/Commands/Upgrade/UpgradesToGroups.php b/app/Console/Commands/Upgrade/UpgradesToGroups.php
index 1cb86fa1fd..7ded66b1e9 100644
--- a/app/Console/Commands/Upgrade/UpgradesToGroups.php
+++ b/app/Console/Commands/Upgrade/UpgradesToGroups.php
@@ -47,13 +47,13 @@ class UpgradesToGroups extends Command
public const string CONFIG_NAME = '480_migrated_to_groups';
- protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';
- protected $signature = 'upgrade:480-migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
+ protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';
+ protected $signature = 'upgrade:480-migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
private JournalCLIRepositoryInterface $cliRepository;
- private int $count;
- private TransactionGroupFactory $groupFactory;
- private JournalRepositoryInterface $journalRepository;
- private JournalDestroyService $service;
+ private int $count;
+ private TransactionGroupFactory $groupFactory;
+ private JournalRepositoryInterface $journalRepository;
+ private JournalDestroyService $service;
/**
* Execute the console command.
@@ -86,7 +86,7 @@ class UpgradesToGroups extends Command
private function findOpposingTransaction(TransactionJournal $journal, Transaction $transaction): ?Transaction
{
$set = $journal->transactions->filter(static function (Transaction $subject) use ($transaction): bool {
- $amount = -(float) $transaction->amount === (float) $subject->amount; // intentional float
+ $amount = -(float)$transaction->amount === (float)$subject->amount; // intentional float
$identifier = $transaction->identifier === $subject->identifier;
Log::debug(sprintf('Amount the same? %s', var_export($amount, return: true)));
Log::debug(sprintf('ID the same? %s', var_export($identifier, return: true)));
@@ -104,14 +104,14 @@ class UpgradesToGroups extends Command
private function generateTransaction(TransactionJournal $journal, Transaction $transaction): array
{
Log::debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
- $opposingTr = $this->findOpposingTransaction($journal, $transaction);
+ $opposingTr = $this->findOpposingTransaction($journal, $transaction);
if (!$opposingTr instanceof Transaction) {
$this->friendlyError(sprintf(
- 'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',
- $journal->id,
- $transaction->id
- ));
+ 'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',
+ $journal->id,
+ $transaction->id
+ ));
return [];
}
@@ -143,11 +143,11 @@ class UpgradesToGroups extends Command
$invoiceDate = $this->cliRepository->getMetaDate($journal, 'invoice_date');
// overrule journal category with transaction category.
- $budgetId = $this->getTransactionBudget($transaction, $opposingTr) ?? $budgetId;
- $categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;
+ $budgetId = $this->getTransactionBudget($transaction, $opposingTr) ?? $budgetId;
+ $categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;
return [
- 'type' => strtolower((string) $journal->transactionType->type),
+ 'type' => strtolower((string)$journal->transactionType->type),
'date' => $journal->date,
'user' => $journal->user,
'user_group' => $journal->user->userGroup,
@@ -189,7 +189,7 @@ class UpgradesToGroups extends Command
private function getDestinationTransactions(TransactionJournal $journal): Collection
{
- return $journal->transactions->filter(static fn (Transaction $transaction): bool => $transaction->amount > 0);
+ return $journal->transactions->filter(static fn(Transaction $transaction): bool => $transaction->amount > 0);
}
private function getTransactionBudget(Transaction $left, Transaction $right): ?int
@@ -249,11 +249,11 @@ class UpgradesToGroups extends Command
private function giveGroup(array $array): void
{
$groupId = DB::table('transaction_groups')->insertGetId([
- 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
- 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
- 'title' => null,
- 'user_id' => $array['user_id'],
- ]);
+ 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
+ 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
+ 'title' => null,
+ 'user_id' => $array['user_id'],
+ ]);
DB::table('transaction_journals')->where('id', $array['id'])->update(['transaction_group_id' => $groupId]);
++$this->count;
}
@@ -262,7 +262,7 @@ class UpgradesToGroups extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
/**
@@ -330,7 +330,7 @@ class UpgradesToGroups extends Command
$data['transactions'][] = $this->generateTransaction($journal, $transaction);
}
Log::debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));
- $group = $this->groupFactory->create($data);
+ $group = $this->groupFactory->create($data);
Log::debug('Done calling transaction journal factory');
// delete the old transaction journal.
@@ -340,17 +340,17 @@ class UpgradesToGroups extends Command
// report on result:
Log::debug(sprintf(
- 'Migrated journal #%d into group #%d with these journals: #%s',
- $journal->id,
- $group->id,
- implode(', #', $group->transactionJournals->pluck('id')->toArray())
- ));
+ 'Migrated journal #%d into group #%d with these journals: #%s',
+ $journal->id,
+ $group->id,
+ implode(', #', $group->transactionJournals->pluck('id')->toArray())
+ ));
$this->friendlyInfo(sprintf(
- 'Migrated journal #%d into group #%d with these journals: #%s',
- $journal->id,
- $group->id,
- implode(', #', $group->transactionJournals->pluck('id')->toArray())
- ));
+ 'Migrated journal #%d into group #%d with these journals: #%s',
+ $journal->id,
+ $group->id,
+ implode(', #', $group->transactionJournals->pluck('id')->toArray())
+ ));
}
private function markAsMigrated(): void
diff --git a/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php
index b340f8c5c4..2ef6cd9493 100644
--- a/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php
+++ b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php
@@ -40,14 +40,14 @@ class UpgradesTransferCurrencies extends Command
{
use ShowsFriendlyMessages;
- public const string CONFIG_NAME = '480_transfer_currencies';
+ public const string CONFIG_NAME = '480_transfer_currencies';
- protected $description = 'Updates transfer currency information.';
- protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';
- private array $accountCurrencies;
- private AccountRepositoryInterface $accountRepos;
+ protected $description = 'Updates transfer currency information.';
+ protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';
+ private array $accountCurrencies;
+ private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos;
- private int $count;
+ private int $count;
private ?Account $destinationAccount = null;
private ?TransactionCurrency $destinationCurrency = null;
@@ -78,31 +78,6 @@ class UpgradesTransferCurrencies extends Command
return 0;
}
- /**
- * The destination transaction must have the correct currency. If not, it will be set by
- * taking it from the destination account's preference.
- */
- private function fixDestinationUnmatchedCurrency(): void
- {
- if (
- $this->destinationCurrency instanceof TransactionCurrency
- && null === $this->destinationTransaction->foreign_amount
- && (int) $this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
- ) {
- $message = sprintf(
- 'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
- $this->destinationTransaction->id,
- $this->destinationTransaction->transaction_currency_id,
- $this->destinationAccount->id,
- $this->destinationTransaction->amount
- );
- $this->friendlyWarning($message);
- ++$this->count;
- $this->destinationTransaction->transaction_currency_id = $this->destinationCurrency->id;
- $this->destinationTransaction->save();
- }
- }
-
/**
* The destination transaction must have a currency. If not, it will be added by
* taking it from the destination account's preference.
@@ -133,10 +108,35 @@ class UpgradesTransferCurrencies extends Command
$this->destinationTransaction->save();
++$this->count;
$this->friendlyInfo(sprintf(
- 'Restored foreign amount of destination transaction #%d to %s',
+ 'Restored foreign amount of destination transaction #%d to %s',
+ $this->destinationTransaction->id,
+ $this->destinationTransaction->foreign_amount
+ ));
+ }
+ }
+
+ /**
+ * The destination transaction must have the correct currency. If not, it will be set by
+ * taking it from the destination account's preference.
+ */
+ private function fixDestinationUnmatchedCurrency(): void
+ {
+ if (
+ $this->destinationCurrency instanceof TransactionCurrency
+ && null === $this->destinationTransaction->foreign_amount
+ && (int)$this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
+ ) {
+ $message = sprintf(
+ 'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
$this->destinationTransaction->id,
- $this->destinationTransaction->foreign_amount
- ));
+ $this->destinationTransaction->transaction_currency_id,
+ $this->destinationAccount->id,
+ $this->destinationTransaction->amount
+ );
+ $this->friendlyWarning($message);
+ ++$this->count;
+ $this->destinationTransaction->transaction_currency_id = $this->destinationCurrency->id;
+ $this->destinationTransaction->save();
}
}
@@ -149,8 +149,8 @@ class UpgradesTransferCurrencies extends Command
{
if ($this->destinationCurrency->id === $this->sourceCurrency->id) {
// update both transactions to match:
- $this->sourceTransaction->foreign_amount = null;
- $this->sourceTransaction->foreign_currency_id = null;
+ $this->sourceTransaction->foreign_amount = null;
+ $this->sourceTransaction->foreign_currency_id = null;
$this->destinationTransaction->foreign_amount = null;
$this->destinationTransaction->foreign_currency_id = null;
@@ -177,10 +177,10 @@ class UpgradesTransferCurrencies extends Command
$this->destinationTransaction->save();
++$this->count;
$this->friendlyInfo(sprintf(
- 'Verified foreign currency ID of transaction #%d and #%d',
- $this->sourceTransaction->id,
- $this->destinationTransaction->id
- ));
+ 'Verified foreign currency ID of transaction #%d and #%d',
+ $this->sourceTransaction->id,
+ $this->destinationTransaction->id
+ ));
}
}
@@ -214,10 +214,10 @@ class UpgradesTransferCurrencies extends Command
$this->sourceTransaction->save();
++$this->count;
$this->friendlyInfo(sprintf(
- 'Restored foreign amount of source transaction #%d to %s',
- $this->sourceTransaction->id,
- $this->sourceTransaction->foreign_amount
- ));
+ 'Restored foreign amount of source transaction #%d to %s',
+ $this->sourceTransaction->id,
+ $this->sourceTransaction->foreign_amount
+ ));
}
}
@@ -230,9 +230,9 @@ class UpgradesTransferCurrencies extends Command
if (
$this->sourceCurrency instanceof TransactionCurrency
&& null === $this->sourceTransaction->foreign_amount
- && (int) $this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
+ && (int)$this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
) {
- $message = sprintf(
+ $message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
$this->sourceTransaction->id,
$this->sourceTransaction->transaction_currency_id,
@@ -251,7 +251,7 @@ class UpgradesTransferCurrencies extends Command
*/
private function fixTransactionJournalCurrency(TransactionJournal $journal): void
{
- if ((int) $journal->transaction_currency_id !== $this->sourceCurrency->id) {
+ if ((int)$journal->transaction_currency_id !== $this->sourceCurrency->id) {
$oldCurrencyCode = $journal->transactionCurrency->code ?? '(nothing)';
$journal->transaction_currency_id = $this->sourceCurrency->id;
$message = sprintf(
@@ -269,14 +269,14 @@ class UpgradesTransferCurrencies extends Command
private function getCurrency(Account $account): ?TransactionCurrency
{
- $accountId = $account->id;
+ $accountId = $account->id;
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
return null;
}
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
return $this->accountCurrencies[$accountId];
}
- $currency = $this->accountRepos->getAccountCurrency($account);
+ $currency = $this->accountRepos->getAccountCurrency($account);
if (!$currency instanceof TransactionCurrency) {
$this->accountCurrencies[$accountId] = 0;
@@ -335,7 +335,7 @@ class UpgradesTransferCurrencies extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function isNoCurrencyPresent(): bool
@@ -448,9 +448,9 @@ class UpgradesTransferCurrencies extends Command
if ($this->isNoCurrencyPresent()) {
$this->friendlyError(sprintf(
- 'Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.',
- $transfer->id
- ));
+ 'Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.',
+ $transfer->id
+ ));
return;
}
diff --git a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php
index e9729aa84a..b0461ecbda 100644
--- a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php
+++ b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php
@@ -43,13 +43,13 @@ class UpgradesVariousCurrencyInformation extends Command
public const string CONFIG_NAME = '480_other_currencies';
- protected $description = 'Update all journal currency information.';
- protected $signature = 'upgrade:480-currency-information {--F|force : Force the execution of this command.}';
- private array $accountCurrencies;
- private AccountRepositoryInterface $accountRepos;
+ protected $description = 'Update all journal currency information.';
+ protected $signature = 'upgrade:480-currency-information {--F|force : Force the execution of this command.}';
+ private array $accountCurrencies;
+ private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos;
- private int $count;
- private JournalRepositoryInterface $journalRepos;
+ private int $count;
+ private JournalRepositoryInterface $journalRepos;
/**
* Execute the console command.
@@ -74,14 +74,14 @@ class UpgradesVariousCurrencyInformation extends Command
private function getCurrency(Account $account): ?TransactionCurrency
{
- $accountId = $account->id;
+ $accountId = $account->id;
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
return null;
}
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
return $this->accountCurrencies[$accountId];
}
- $currency = $this->accountRepos->getAccountCurrency($account);
+ $currency = $this->accountRepos->getAccountCurrency($account);
if (!$currency instanceof TransactionCurrency) {
$this->accountCurrencies[$accountId] = 0;
@@ -125,8 +125,7 @@ class UpgradesVariousCurrencyInformation extends Command
->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')
->where('account_types.type', '!=', AccountTypeEnum::INITIAL_BALANCE->value)
- ->first(['transactions.*'])
- ;
+ ->first(['transactions.*']);
break;
@@ -138,8 +137,7 @@ class UpgradesVariousCurrencyInformation extends Command
->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')
->where('account_types.type', '!=', AccountTypeEnum::RECONCILIATION->value)
- ->first(['transactions.*'])
- ;
+ ->first(['transactions.*']);
break;
}
@@ -151,7 +149,7 @@ class UpgradesVariousCurrencyInformation extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function isMultiCurrency(Account $account): bool
@@ -202,11 +200,11 @@ class UpgradesVariousCurrencyInformation extends Command
$isMultiCurrency = $this->isMultiCurrency($account);
if (!$currency instanceof TransactionCurrency) {
$this->friendlyError(sprintf(
- 'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',
- $account->id,
- $account->name,
- $journal->id
- ));
+ 'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',
+ $account->id,
+ $account->name,
+ $journal->id
+ ));
++$this->count;
return;
@@ -243,11 +241,11 @@ class UpgradesVariousCurrencyInformation extends Command
private function updateOtherJournalsCurrencies(): void
{
$set = $this->cliRepos->getAllJournals([
- TransactionTypeEnum::WITHDRAWAL->value,
- TransactionTypeEnum::DEPOSIT->value,
- TransactionTypeEnum::OPENING_BALANCE->value,
- TransactionTypeEnum::RECONCILIATION->value,
- ]);
+ TransactionTypeEnum::WITHDRAWAL->value,
+ TransactionTypeEnum::DEPOSIT->value,
+ TransactionTypeEnum::OPENING_BALANCE->value,
+ TransactionTypeEnum::RECONCILIATION->value,
+ ]);
/** @var TransactionJournal $journal */
foreach ($set as $journal) {
diff --git a/app/Console/Commands/Upgrade/UpgradesWebhooks.php b/app/Console/Commands/Upgrade/UpgradesWebhooks.php
index 865b510524..5806e905a3 100644
--- a/app/Console/Commands/Upgrade/UpgradesWebhooks.php
+++ b/app/Console/Commands/Upgrade/UpgradesWebhooks.php
@@ -41,8 +41,8 @@ class UpgradesWebhooks extends Command
public const string CONFIG_NAME = '640_upgrade_webhooks';
- protected $description = 'Upgrade webhooks so they can handle multiple triggers.';
- protected $signature = 'upgrade:640-upgrade-webhooks {--F|force : Force the execution of this command.}';
+ protected $description = 'Upgrade webhooks so they can handle multiple triggers.';
+ protected $signature = 'upgrade:640-upgrade-webhooks {--F|force : Force the execution of this command.}';
/**
* Execute the console command.
@@ -66,7 +66,7 @@ class UpgradesWebhooks extends Command
{
$configVar = AppConfiguration::get(self::CONFIG_NAME, false);
- return (bool) $configVar?->data;
+ return (bool)$configVar?->data;
}
private function markAsExecuted(): void
@@ -76,17 +76,17 @@ class UpgradesWebhooks extends Command
private function upgradeWebhook(Webhook $webhook): void
{
- $delivery = WebhookDelivery::tryFrom((int) $webhook->delivery);
- $response = WebhookResponse::tryFrom((int) $webhook->response);
- $trigger = WebhookTrigger::tryFrom((int) $webhook->trigger);
+ $delivery = WebhookDelivery::tryFrom((int)$webhook->delivery);
+ $response = WebhookResponse::tryFrom((int)$webhook->response);
+ $trigger = WebhookTrigger::tryFrom((int)$webhook->trigger);
if (in_array(null, [$delivery, $response, $trigger], true)) {
$this->friendlyError(sprintf('[a] Webhook #%d has an invalid delivery, response or trigger value. Will not upgrade.', $webhook->id));
return;
}
- $deliveryModel = WebhookDeliveryModel::query()->where('key', $delivery->value)->first();
- $responseModel = WebhookResponseModel::query()->where('key', $response->value)->first();
- $triggerModel = WebhookTriggerModel::query()->where('key', $trigger->value)->first();
+ $deliveryModel = WebhookDeliveryModel::query()->where('key', $delivery->value)->first();
+ $responseModel = WebhookResponseModel::query()->where('key', $response->value)->first();
+ $triggerModel = WebhookTriggerModel::query()->where('key', $trigger->value)->first();
if (in_array(null, [$deliveryModel, $responseModel, $triggerModel], true)) {
$this->friendlyError(sprintf('[b] Webhook #%d has an invalid delivery, response or trigger model. Will not upgrade.', $webhook->id));
diff --git a/app/Console/Commands/VerifiesAccessToken.php b/app/Console/Commands/VerifiesAccessToken.php
index 67aee2cfc1..b7d20d5e70 100644
--- a/app/Console/Commands/VerifiesAccessToken.php
+++ b/app/Console/Commands/VerifiesAccessToken.php
@@ -37,21 +37,12 @@ use Illuminate\Support\Facades\Log;
*/
trait VerifiesAccessToken
{
- /**
- * Abstract method to make sure trait knows about method "option".
- *
- * @param null|string $key
- *
- * @return mixed
- */
- abstract public function option($key = null);
-
/**
* @throws FireflyException
*/
public function getUser(): User
{
- $userId = (int) $this->option('user');
+ $userId = (int)$this->option('user');
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
@@ -63,17 +54,26 @@ trait VerifiesAccessToken
return $user;
}
+ /**
+ * Abstract method to make sure trait knows about method "option".
+ *
+ * @param null|string $key
+ *
+ * @return mixed
+ */
+ abstract public function option($key = null);
+
/**
* Returns false when given token does not match given user token.
*/
protected function verifyAccessToken(): bool
{
- $userId = (int) $this->option('user');
- $token = (string) $this->option('token');
+ $userId = (int)$this->option('user');
+ $token = (string)$this->option('token');
/** @var UserRepositoryInterface $repository */
- $repository = app(UserRepositoryInterface::class);
- $user = $repository->find($userId);
+ $repository = app(UserRepositoryInterface::class);
+ $user = $repository->find($userId);
if (null === $user) {
Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));
diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php
index 1242192601..ef20fe9a26 100644
--- a/app/Http/Controllers/Auth/TwoFactorController.php
+++ b/app/Http/Controllers/Auth/TwoFactorController.php
@@ -131,7 +131,10 @@ final class TwoFactorController extends Controller
++$preference;
Log::channel('audit')->info(sprintf('MFA failure count is set to %d.', $preference));
Preferences::set('mfa_failure_count', $preference, true);
- sleep(2 ** $preference);
+ $preference = clamp($preference, 2, 16);
+ $count = 2 ** $preference;
+ Log::debug(sprintf('Sleeping for %d seconds to slow down brute force attacks.', $count));
+ sleep($count);
}
private function addToMFAHistory(string $mfaCode): void