Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -32,7 +32,6 @@ use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Schema;
/**
* Class TransactionIdentifier
@@ -57,7 +56,6 @@ class TransactionIdentifier extends Command
* When either of these are the same amount, FF3 can't keep them apart: +3/-3, +3/-3, +3/-3. This happens more
* often than you would think. So each set gets a number (1,2,3) to keep them apart.
*
* @return int
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
@@ -73,11 +71,12 @@ class TransactionIdentifier extends Command
}
// if table does not exist, return false
if (!Schema::hasTable('transaction_journals')) {
if (!\Schema::hasTable('transaction_journals')) {
return 0;
}
$journals = $this->cliRepository->getSplitJournals();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$this->updateJournalIdentifiers($journal);
@@ -99,8 +98,6 @@ class TransactionIdentifier extends Command
* Laravel will execute ALL __construct() methods for ALL commands whenever a SINGLE command is
* executed. This leads to noticeable slow-downs and class calls. To prevent this, this method should
* be called from the handle method instead of using the constructor to initialize the command.
*
*/
private function stupidLaravel(): void
{
@@ -109,7 +106,6 @@ class TransactionIdentifier extends Command
}
/**
* @return bool
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
@@ -126,8 +122,6 @@ class TransactionIdentifier extends Command
/**
* Grab all positive transactions from this journal that are not deleted. for each one, grab the negative opposing
* one which has 0 as an identifier and give it the same identifier.
*
* @param TransactionJournal $transactionJournal
*/
private function updateJournalIdentifiers(TransactionJournal $transactionJournal): void
{
@@ -146,18 +140,12 @@ class TransactionIdentifier extends Command
$opposing->save();
$exclude[] = $transaction->id;
$exclude[] = $opposing->id;
$this->count++;
++$this->count;
}
++$identifier;
}
}
/**
* @param Transaction $transaction
* @param array $exclude
*
* @return Transaction|null
*/
private function findOpposing(Transaction $transaction, array $exclude): ?Transaction
{
// find opposing:
@@ -166,9 +154,10 @@ class TransactionIdentifier extends Command
try {
/** @var Transaction $opposing */
$opposing = Transaction::where('transaction_journal_id', $transaction->transaction_journal_id)
->where('amount', $amount)->where('identifier', '=', 0)
->whereNotIn('id', $exclude)
->first();
->where('amount', $amount)->where('identifier', '=', 0)
->whereNotIn('id', $exclude)
->first()
;
} catch (QueryException $e) {
app('log')->error($e->getMessage());
$this->friendlyError('Firefly III could not find the "identifier" field in the "transactions" table.');
@@ -182,9 +171,6 @@ class TransactionIdentifier extends Command
return $opposing;
}
/**
*
*/
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);