Various code reshuffelling.

This commit is contained in:
James Cole
2021-03-12 06:20:01 +01:00
parent 97561ab9c9
commit 748d61fb8f
51 changed files with 1874 additions and 1873 deletions

View File

@@ -177,6 +177,17 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
return $return;
}
/**
* @inheritDoc
*/
public function getLocation(int $journalId): ?Location
{
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
return $journal->locations()->first();
}
/**
* Return object with all found meta field things as Carbon objects.
*
@@ -266,7 +277,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
->get(['piggy_bank_events.*']);
/** @var PiggyBankEvent $row */
foreach ($data as $row) {
if(null === $row->piggyBank) {
if (null === $row->piggyBank) {
continue;
}
// get currency preference.
@@ -294,6 +305,17 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
return $return;
}
/**
* @inheritDoc
*/
public function getTagObjects(int $journalId): Collection
{
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
return $journal->tags()->get();
}
/**
* Get the tags for a journal (by ID).
*
@@ -337,7 +359,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
} catch (DuplicateTransactionException $e) {
Log::warning('Group repository caught group factory with a duplicate exception!');
throw new DuplicateTransactionException($e->getMessage());
} catch(FireflyException $e) {
} catch (FireflyException $e) {
Log::warning('Group repository caught group factory with an exception!');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
@@ -397,9 +419,9 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
*/
private function expandTransaction(Transaction $transaction): array
{
$array = $transaction->toArray();
$array['account'] = $transaction->account->toArray();
$array['budgets'] = [];
$array = $transaction->toArray();
$array['account'] = $transaction->account->toArray();
$array['budgets'] = [];
$array['categories'] = [];
foreach ($transaction->categories as $category) {
@@ -462,26 +484,4 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
return $return;
}
/**
* @inheritDoc
*/
public function getTagObjects(int $journalId): Collection
{
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
return $journal->tags()->get();
}
/**
* @inheritDoc
*/
public function getLocation(int $journalId): ?Location
{
/** @var TransactionJournal $journal */
$journal = $this->user->transactionJournals()->find($journalId);
return $journal->locations()->first();
}
}

View File

@@ -77,6 +77,15 @@ interface TransactionGroupRepositoryInterface
*/
public function getLinks(TransactionGroup $group): array;
/**
* Get the location of a journal or NULL.
*
* @param int $journalId
*
* @return Location|null
*/
public function getLocation(int $journalId): ?Location;
/**
* Return object with all found meta field things as Carbon objects.
*
@@ -97,16 +106,6 @@ interface TransactionGroupRepositoryInterface
*/
public function getMetaFields(int $journalId, array $fields): NullArrayObject;
/**
* Get the location of a journal or NULL.
*
* @param int $journalId
*
* @return Location|null
*/
public function getLocation(int $journalId): ?Location;
/**
* Get the note text for a journal (by ID).
*
@@ -125,15 +124,6 @@ interface TransactionGroupRepositoryInterface
*/
public function getPiggyEvents(TransactionGroup $group): array;
/**
* Get the tags for a journal (by ID).
*
* @param int $journalId
*
* @return array
*/
public function getTags(int $journalId): array;
/**
* Get the tags for a journal (by ID) as Tag objects.
*
@@ -143,6 +133,15 @@ interface TransactionGroupRepositoryInterface
*/
public function getTagObjects(int $journalId): Collection;
/**
* Get the tags for a journal (by ID).
*
* @param int $journalId
*
* @return array
*/
public function getTags(int $journalId): array;
/**
* Set the user.
*