mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Use PSR-12 code style
This commit is contained in:
@@ -62,8 +62,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
// get all OB journals:
|
||||
$set = TransactionJournal
|
||||
::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
$set = TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->where('transaction_types.type', TransactionType::OPENING_BALANCE)->get(['transaction_journals.*']);
|
||||
|
||||
|
@@ -63,7 +63,7 @@ class CreateLinkTypes extends Command
|
||||
$link = LinkType::where('name', $name)
|
||||
->first();
|
||||
if (null === $link) {
|
||||
$link = new LinkType;
|
||||
$link = new LinkType();
|
||||
$link->name = $name;
|
||||
$link->inward = $values[1];
|
||||
$link->outward = $values[0];
|
||||
|
@@ -58,8 +58,7 @@ class DeleteEmptyGroups extends Command
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$start = microtime(true);
|
||||
$groupIds
|
||||
= TransactionGroup
|
||||
::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')
|
||||
= TransactionGroup::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')
|
||||
->whereNull('transaction_journals.id')->get(['transaction_groups.id'])->pluck('id')->toArray();
|
||||
|
||||
$total = count($groupIds);
|
||||
|
@@ -66,8 +66,7 @@ class DeleteEmptyJournals extends Command
|
||||
*/
|
||||
private function deleteUnevenJournals(): void
|
||||
{
|
||||
$set = Transaction
|
||||
::whereNull('deleted_at')
|
||||
$set = Transaction::whereNull('deleted_at')
|
||||
->groupBy('transactions.transaction_journal_id')
|
||||
->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']);
|
||||
$total = 0;
|
||||
@@ -78,7 +77,6 @@ class DeleteEmptyJournals extends Command
|
||||
// uneven number, delete journal and transactions:
|
||||
try {
|
||||
TransactionJournal::find((int) $row->transaction_journal_id)->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
|
||||
}
|
||||
@@ -106,7 +104,6 @@ class DeleteEmptyJournals extends Command
|
||||
foreach ($set as $entry) {
|
||||
try {
|
||||
TransactionJournal::find($entry->id)->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::info(sprintf('Could not delete entry: %s', $e->getMessage()));
|
||||
}
|
||||
@@ -121,5 +118,4 @@ class DeleteEmptyJournals extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified empty journals in %s seconds', $end));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -72,8 +72,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
private function deleteOrphanedTransactions(): void
|
||||
{
|
||||
$count = 0;
|
||||
$set = Transaction
|
||||
::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
$set = Transaction::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNotNull('transaction_journals.deleted_at')
|
||||
->whereNull('transactions.deleted_at')
|
||||
->whereNotNull('transactions.id')
|
||||
@@ -109,8 +108,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
private function deleteFromOrphanedAccounts(): void
|
||||
{
|
||||
$set
|
||||
= Transaction
|
||||
::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
||||
= Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
||||
->whereNotNull('accounts.deleted_at')
|
||||
->get(['transactions.*']);
|
||||
$count = 0;
|
||||
@@ -121,11 +119,9 @@ class DeleteOrphanedTransactions extends Command
|
||||
if ($journal) {
|
||||
try {
|
||||
$journal->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::info(sprintf('Could not delete journal %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
}
|
||||
Transaction::where('transaction_journal_id', (int) $transaction->transaction_journal_id)->delete();
|
||||
$this->line(
|
||||
@@ -144,8 +140,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
|
||||
private function deleteOrphanedJournals(): void
|
||||
{
|
||||
$set = TransactionJournal
|
||||
::leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id')
|
||||
$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']);
|
||||
|
@@ -62,7 +62,6 @@ class DeleteZeroAmount extends Command
|
||||
$this->info(sprintf('Deleted transaction journal #%d because the amount is zero (0.00).', $journal->id));
|
||||
try {
|
||||
$journal->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
|
@@ -88,9 +88,10 @@ class EnableCurrencies extends Command
|
||||
$found = array_values(array_unique($found));
|
||||
$found = array_values(
|
||||
array_filter(
|
||||
$found, function (int $currencyId) {
|
||||
return $currencyId !== 0;
|
||||
}
|
||||
$found,
|
||||
function (int $currencyId) {
|
||||
return $currencyId !== 0;
|
||||
}
|
||||
)
|
||||
);
|
||||
$message = sprintf('%d different currencies are currently in use.', count($found));
|
||||
|
@@ -48,7 +48,7 @@ class FixAccountTypes extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:fix-account-types';
|
||||
protected $signature = 'firefly-iii:fix-account-types';
|
||||
private int $count;
|
||||
private array $expected;
|
||||
private AccountFactory $factory;
|
||||
@@ -121,12 +121,10 @@ class FixAccountTypes extends Command
|
||||
$destAccountType = $destAccount->accountType->type;
|
||||
|
||||
if (!array_key_exists($type, $this->expected)) {
|
||||
|
||||
Log::info(sprintf('No source/destination info for transaction type %s.', $type));
|
||||
$this->info(sprintf('No source/destination info for transaction type %s.', $type));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
if (!array_key_exists($sourceAccountType, $this->expected[$type])) {
|
||||
Log::debug(sprintf('Going to fix journal #%d', $journal->id));
|
||||
@@ -211,8 +209,12 @@ class FixAccountTypes extends Command
|
||||
$dest->account()->associate($result);
|
||||
$dest->save();
|
||||
$message = sprintf(
|
||||
'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldDest->id, $oldDest->name,
|
||||
$result->id, $result->name
|
||||
'Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").',
|
||||
$journal->id,
|
||||
$oldDest->id,
|
||||
$oldDest->name,
|
||||
$result->id,
|
||||
$result->name
|
||||
);
|
||||
$this->info($message);
|
||||
Log::debug($message);
|
||||
@@ -227,8 +229,12 @@ class FixAccountTypes extends Command
|
||||
$source->account()->associate($result);
|
||||
$source->save();
|
||||
$message = sprintf(
|
||||
'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldSource->id, $oldSource->name,
|
||||
$result->id, $result->name
|
||||
'Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").',
|
||||
$journal->id,
|
||||
$oldSource->id,
|
||||
$oldSource->name,
|
||||
$result->id,
|
||||
$result->name
|
||||
);
|
||||
$this->info($message);
|
||||
Log::debug($message);
|
||||
@@ -244,7 +250,6 @@ class FixAccountTypes extends Command
|
||||
Log::debug($message);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -57,8 +57,7 @@ class FixGroupAccounts extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
$groups = [];
|
||||
$res = TransactionJournal
|
||||
::groupBy('transaction_group_id')
|
||||
$res = TransactionJournal::groupBy('transaction_group_id')
|
||||
->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]);
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($res as $journal) {
|
||||
@@ -66,7 +65,7 @@ class FixGroupAccounts extends Command
|
||||
$groups[] = (int) $journal->transaction_group_id;
|
||||
}
|
||||
}
|
||||
$handler = new UpdatedGroupEventHandler;
|
||||
$handler = new UpdatedGroupEventHandler();
|
||||
foreach ($groups as $groupId) {
|
||||
$group = TransactionGroup::find($groupId);
|
||||
$event = new UpdatedTransactionGroup($group);
|
||||
|
@@ -57,7 +57,6 @@ class FixIbans extends Command
|
||||
foreach ($accounts as $account) {
|
||||
$iban = $account->iban;
|
||||
if (str_contains($iban, ' ')) {
|
||||
|
||||
$iban = app('steam')->filterSpaces((string) $account->iban);
|
||||
if ('' !== $iban) {
|
||||
$account->iban = $iban;
|
||||
|
@@ -61,7 +61,6 @@ class FixPiggies extends Command
|
||||
|
||||
/** @var PiggyBankEvent $event */
|
||||
foreach ($set as $event) {
|
||||
|
||||
if (null === $event->transaction_journal_id) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -52,7 +52,6 @@ class FixPostgresSequences extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
if (DB::connection()->getName() !== 'pgsql') {
|
||||
$this->info('Command executed successfully.');
|
||||
|
||||
|
@@ -85,8 +85,7 @@ class FixTransactionTypes extends Command
|
||||
*/
|
||||
private function collectJournals(): Collection
|
||||
{
|
||||
return TransactionJournal
|
||||
::with(['transactionType', 'transactions', 'transactions.account', 'transactions.account.accountType'])
|
||||
return TransactionJournal::with(['transactionType', 'transactions', 'transactions.account', 'transactions.account.accountType'])
|
||||
->get();
|
||||
}
|
||||
|
||||
@@ -109,10 +108,15 @@ class FixTransactionTypes extends Command
|
||||
$expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
|
||||
if ($expectedType !== $type) {
|
||||
$this->line(
|
||||
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,
|
||||
));
|
||||
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,
|
||||
)
|
||||
);
|
||||
$this->changeJournal($journal, $expectedType);
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user