mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 16:13:54 +00:00
Reformat various code.
This commit is contained in:
@@ -155,7 +155,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
private function setCurrency(TransactionJournal $journal, TransactionCurrency $currency): int
|
||||
{
|
||||
$count = 0;
|
||||
if ((int)$journal->transaction_currency_id !== (int)$currency->id) {
|
||||
if ((int) $journal->transaction_currency_id !== (int) $currency->id) {
|
||||
$journal->transaction_currency_id = $currency->id;
|
||||
$journal->save();
|
||||
$count = 1;
|
||||
@@ -163,7 +163,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
|
||||
if ((int) $transaction->transaction_currency_id !== (int) $currency->id) {
|
||||
$transaction->transaction_currency_id = $currency->id;
|
||||
$transaction->save();
|
||||
$count = 1;
|
||||
|
@@ -73,18 +73,18 @@ class DeleteEmptyJournals extends Command
|
||||
$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 {
|
||||
TransactionJournal::find((int)$row->transaction_journal_id)->delete();
|
||||
TransactionJournal::find((int) $row->transaction_journal_id)->delete();
|
||||
|
||||
} catch (Exception $e) { // @phpstan-ignore-line
|
||||
Log::info(sprintf('Could not delete journal: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
|
||||
Transaction::where('transaction_journal_id', (int)$row->transaction_journal_id)->delete();
|
||||
Transaction::where('transaction_journal_id', (int) $row->transaction_journal_id)->delete();
|
||||
$this->info(sprintf('Deleted transaction journal #%d because it had an uneven number of transactions.', $row->transaction_journal_id));
|
||||
$total++;
|
||||
}
|
||||
|
@@ -84,7 +84,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$transaction = Transaction::find((int)$entry->transaction_id);
|
||||
$transaction = Transaction::find((int) $entry->transaction_id);
|
||||
$transaction->delete();
|
||||
$this->info(
|
||||
sprintf(
|
||||
@@ -106,7 +106,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
private function deleteFromOrphanedAccounts(): void
|
||||
{
|
||||
$set
|
||||
= Transaction
|
||||
= Transaction
|
||||
::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
||||
->whereNotNull('accounts.deleted_at')
|
||||
->get(['transactions.*']);
|
||||
@@ -114,7 +114,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
// delete journals
|
||||
$journal = TransactionJournal::find((int)$transaction->transaction_journal_id);
|
||||
$journal = TransactionJournal::find((int) $transaction->transaction_journal_id);
|
||||
if ($journal) {
|
||||
try {
|
||||
$journal->delete();
|
||||
@@ -124,7 +124,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
}
|
||||
|
||||
}
|
||||
Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete();
|
||||
Transaction::where('transaction_journal_id', (int) $transaction->transaction_journal_id)->delete();
|
||||
$this->line(
|
||||
sprintf(
|
||||
'Deleted transaction journal #%d because account #%d was already deleted.',
|
||||
|
@@ -63,30 +63,30 @@ class EnableCurrencies extends Command
|
||||
/** @var Collection $meta */
|
||||
$meta = AccountMeta::where('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::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::groupBy('transaction_currency_id', 'foreign_currency_id')->get(['transaction_currency_id', '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::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
|
||||
foreach ($limits as $entry) {
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
$found[] = (int) $entry->transaction_currency_id;
|
||||
}
|
||||
|
||||
$found = array_values(array_unique($found));
|
||||
$found = array_values(
|
||||
$found = array_values(array_unique($found));
|
||||
$found = array_values(
|
||||
array_filter(
|
||||
$found, function (int $currencyId) {
|
||||
return $currencyId !== 0;
|
||||
|
@@ -88,7 +88,7 @@ class FixFrontpageAccounts extends Command
|
||||
if (is_array($data)) {
|
||||
/** @var string $accountId */
|
||||
foreach ($data as $accountId) {
|
||||
$accountIdInt = (int)$accountId;
|
||||
$accountIdInt = (int) $accountId;
|
||||
$account = $repository->find($accountIdInt);
|
||||
if (null !== $account
|
||||
&& in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)
|
||||
|
@@ -62,8 +62,8 @@ class FixGroupAccounts extends Command
|
||||
->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;
|
||||
}
|
||||
}
|
||||
$handler = new UpdatedGroupEventHandler;
|
||||
|
@@ -58,7 +58,7 @@ class FixIbans extends Command
|
||||
$iban = $account->iban;
|
||||
if (str_contains($iban, ' ')) {
|
||||
|
||||
$iban = app('steam')->filterSpaces((string)$account->iban);
|
||||
$iban = app('steam')->filterSpaces((string) $account->iban);
|
||||
if ('' !== $iban) {
|
||||
$account->iban = $iban;
|
||||
$account->save();
|
||||
|
@@ -68,7 +68,7 @@ class FixLongDescriptions extends Command
|
||||
$groups = TransactionGroup::get(['id', 'title']);
|
||||
/** @var TransactionGroup $group */
|
||||
foreach ($groups as $group) {
|
||||
if (strlen((string)$group->title) > self::MAX_LENGTH) {
|
||||
if (strlen((string) $group->title) > self::MAX_LENGTH) {
|
||||
$group->title = substr($group->title, 0, self::MAX_LENGTH);
|
||||
$group->save();
|
||||
$this->line(sprintf('Truncated description of transaction group #%d', $group->id));
|
||||
|
@@ -106,7 +106,7 @@ class FixTransactionTypes 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->line(sprintf('Transaction journal #%d was of type "%s" but is corrected to "%s"', $journal->id, $type, $expectedType));
|
||||
$this->changeJournal($journal, $expectedType);
|
||||
|
@@ -65,11 +65,11 @@ class FixUnevenAmount extends Command
|
||||
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($journals as $entry) {
|
||||
if (0 !== bccomp((string)$entry->the_sum, '0')) {
|
||||
if (0 !== bccomp((string) $entry->the_sum, '0')) {
|
||||
$message = sprintf('Sum of journal #%d is %s instead of zero.', $entry->transaction_journal_id, $entry->the_sum);
|
||||
$this->warn($message);
|
||||
Log::warning($message);
|
||||
$this->fixJournal((int)$entry->transaction_journal_id);
|
||||
$this->fixJournal((int) $entry->transaction_journal_id);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class FixUnevenAmount extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$amount = bcmul('-1', (string)$source->amount);
|
||||
$amount = bcmul('-1', (string) $source->amount);
|
||||
|
||||
// fix amount of destination:
|
||||
/** @var Transaction $destination */
|
||||
|
Reference in New Issue
Block a user