mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 06:01:21 +00:00
Refactor journal repository and fix tests.
This commit is contained in:
@@ -47,10 +47,6 @@ use stdClass;
|
||||
|
||||
/**
|
||||
* Class JournalRepository.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
|
||||
*/
|
||||
class JournalRepository implements JournalRepositoryInterface
|
||||
{
|
||||
@@ -146,21 +142,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $this->user->transactionJournals()->where('id', $journalId)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $transactionid
|
||||
*
|
||||
* @return Transaction|null
|
||||
*/
|
||||
public function findTransaction(int $transactionid): ?Transaction
|
||||
{
|
||||
$transaction = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.user_id', $this->user->id)
|
||||
->where('transactions.id', $transactionid)
|
||||
->first(['transactions.*']);
|
||||
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users first transaction journal or NULL.
|
||||
*
|
||||
@@ -178,31 +159,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all attachments for journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAttachments(TransactionJournal $journal): Collection
|
||||
{
|
||||
return $journal->attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all attachments connected to the transaction group.
|
||||
*
|
||||
* @param TransactionJournal $transactionJournal
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAttachmentsByJournal(TransactionJournal $transactionJournal): Collection
|
||||
{
|
||||
// TODO: Implement getAttachmentsByJournal() method.
|
||||
throw new NotImplementedException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ID of the budget linked to the journal (if any) or the transactions (if any).
|
||||
*
|
||||
@@ -447,23 +403,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $note->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getPiggyBankEvents(TransactionJournal $journal): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$events = $journal->piggyBankEvents()->get();
|
||||
$events->each(
|
||||
function (PiggyBankEvent $event) {
|
||||
$event->piggyBank = $event->piggyBank()->withTrashed()->first();
|
||||
}
|
||||
);
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all journals with more than 2 transactions. Should only return empty collections
|
||||
|
||||
Reference in New Issue
Block a user