Cleanup journal repository

This commit is contained in:
James Cole
2019-08-10 08:42:46 +02:00
parent edb038c822
commit 94b8bb8f66
3 changed files with 31 additions and 354 deletions

View File

@@ -42,6 +42,8 @@ interface JournalRepositoryInterface
{
/**
* TODO maybe create JSON repository?
*
* Search in journal descriptions.
*
* @param string $search
@@ -50,6 +52,8 @@ interface JournalRepositoryInterface
public function searchJournalDescriptions(string $search): Collection;
/**
* TODO maybe create command line repository?
*
* Get all transaction journals with a specific type, regardless of user.
*
* @param array $types
@@ -57,24 +61,6 @@ interface JournalRepositoryInterface
*/
public function getAllJournals(array $types): Collection;
/**
* Get all transaction journals with a specific type, for the logged in user.
*
* @param array $types
* @return Collection
*/
public function getJournals(array $types): Collection;
/**
* @param TransactionJournal $journal
* @param TransactionType $type
* @param Account $source
* @param Account $destination
*
* @return MessageBag
*/
public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag;
/**
* Deletes a transaction group.
*
@@ -90,9 +76,9 @@ interface JournalRepositoryInterface
public function destroyJournal(TransactionJournal $journal): void;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* TODO move to import repository.
*
* Find a journal by its hash.
*
* @param string $hash
@@ -102,6 +88,7 @@ interface JournalRepositoryInterface
public function findByHash(string $hash): ?TransactionJournalMeta;
/**
* TODO Refactor to "find".
* Find a specific journal.
*
* @param int $journalId
@@ -111,6 +98,8 @@ interface JournalRepositoryInterface
public function findNull(int $journalId): ?TransactionJournal;
/**
* TODO maybe create API repository?
*
* @param int $transactionid
*
* @return Transaction|null
@@ -125,13 +114,8 @@ interface JournalRepositoryInterface
public function firstNull(): ?TransactionJournal;
/**
* @param TransactionJournal $journal
* TODO maybe create API repository?
*
* @return Transaction|null
*/
public function getAssetTransaction(TransactionJournal $journal): ?Transaction;
/**
* Return all attachments for journal.
*
* @param TransactionJournal $journal
@@ -141,15 +125,8 @@ interface JournalRepositoryInterface
public function getAttachments(TransactionJournal $journal): Collection;
/**
* Returns the first positive transaction for the journal. Useful when editing journals.
* TODO console repository?
*
* @param TransactionJournal $journal
*
* @return Transaction
*/
public function getFirstPosTransaction(TransactionJournal $journal): Transaction;
/**
* Return the ID of the budget linked to the journal (if any) or the transactions (if any).
*
* @param TransactionJournal $journal
@@ -159,6 +136,8 @@ interface JournalRepositoryInterface
public function getJournalBudgetId(TransactionJournal $journal): int;
/**
* TODO console repository?
*
* Return the ID of the category linked to the journal (if any) or to the transactions (if any).
*
* @param TransactionJournal $journal
@@ -168,39 +147,21 @@ interface JournalRepositoryInterface
public function getJournalCategoryId(TransactionJournal $journal): int;
/**
* Return the name of the category linked to the journal (if any) or to the transactions (if any).
*
* @param TransactionJournal $journal
*
* @return string
*/
public function getJournalCategoryName(TransactionJournal $journal): string;
/**
* Return requested date as string. When it's a NULL return the date of journal,
* otherwise look for meta field and return that one.
*
* @param TransactionJournal $journal
* @param null|string $field
*
* @return string
*/
public function getJournalDate(TransactionJournal $journal, ?string $field): string;
/**
* TODO this method is no longer well-fitted in 4.8.0. Should be refactored and/or removed.
* Return a list of all destination accounts related to journal.
*
* @param TransactionJournal $journal
*
* @deprecated
* @return Collection
*/
public function getJournalDestinationAccounts(TransactionJournal $journal): Collection;
/**
* TODO this method is no longer well-fitted in 4.8.0. Should be refactored and/or removed.
* Return a list of all source accounts related to journal.
*
* @param TransactionJournal $journal
*
* @deprecated
* @return Collection
*/
public function getJournalSourceAccounts(TransactionJournal $journal): Collection;
@@ -215,6 +176,7 @@ interface JournalRepositoryInterface
public function getJournalTotal(TransactionJournal $journal): string;
/**
* TODO only used on command line.
* Return all journals without a group, used in an upgrade routine.
*
* @return array
@@ -222,6 +184,7 @@ interface JournalRepositoryInterface
public function getJournalsWithoutGroup(): array;
/**
* TODO used only in transformer, so only for API use.
* @param TransactionJournalLink $link
*
* @return string
@@ -229,6 +192,7 @@ interface JournalRepositoryInterface
public function getLinkNoteText(TransactionJournalLink $link): string;
/**
* TODO used only on console
* Return Carbon value of a meta field (or NULL).
*
* @param TransactionJournal $journal
@@ -249,16 +213,8 @@ interface JournalRepositoryInterface
public function getMetaDateById(int $journalId, string $field): ?Carbon;
/**
* Return string value of a meta date (or NULL).
* TODO used only on the console.
*
* @param TransactionJournal $journal
* @param string $field
*
* @return null|string
*/
public function getMetaDateString(TransactionJournal $journal, string $field): ?string;
/**
* Return value of a meta field (or NULL).
*
* @param TransactionJournal $journal
@@ -269,6 +225,8 @@ interface JournalRepositoryInterface
public function getMetaField(TransactionJournal $journal, string $field): ?string;
/**
* TODO used only on the console.
*
* Return text of a note attached to journal, or NULL
*
* @param TransactionJournal $journal
@@ -278,6 +236,8 @@ interface JournalRepositoryInterface
public function getNoteText(TransactionJournal $journal): ?string;
/**
* TODO used only in the API
*
* @param TransactionJournal $journal
*
* @return Collection
@@ -285,6 +245,8 @@ interface JournalRepositoryInterface
public function getPiggyBankEvents(TransactionJournal $journal): Collection;
/**
* TODO used only on the console.
*
* Returns all journals with more than 2 transactions. Should only return empty collections
* in Firefly III > v4.8.0.
*
@@ -293,6 +255,8 @@ interface JournalRepositoryInterface
public function getSplitJournals(): Collection;
/**
* TODO used only on the console.
*
* Return all tags as strings in an array.
*
* @param TransactionJournal $journal
@@ -302,43 +266,12 @@ interface JournalRepositoryInterface
public function getTags(TransactionJournal $journal): array;
/**
* Return the transaction type of the journal.
* TODO maybe move to account repository?
*
* @param TransactionJournal $journal
*
* @return string
*/
public function getTransactionType(TransactionJournal $journal): string;
/**
* Will tell you if journal is reconciled or not.
*
* @param TransactionJournal $journal
*
* @return bool
*/
public function isJournalReconciled(TransactionJournal $journal): bool;
/**
* @param Transaction $transaction
*
* @return bool
*/
public function reconcile(Transaction $transaction): bool;
/**
* @param int $journalId
*/
public function reconcileById(int $journalId): void;
/**
* @param TransactionJournal $journal
* @param int $order
*
* @return bool
*/
public function setOrder(TransactionJournal $journal, int $order): bool;
/**
* @param User $user
*/