mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 01:06:46 +00:00
Code cleanup.
This commit is contained in:
@@ -30,7 +30,6 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Storage;
|
||||
|
||||
/**
|
||||
* Class JournalAPIRepository
|
||||
@@ -41,34 +40,27 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
|
||||
|
||||
/**
|
||||
* Returns transaction by ID. Used to validate attachments.
|
||||
*
|
||||
* @param int $transactionId
|
||||
*
|
||||
* @return Transaction|null
|
||||
*/
|
||||
public function findTransaction(int $transactionId): ?Transaction
|
||||
{
|
||||
return 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.*']);
|
||||
->where('transaction_journals.user_id', $this->user->id)
|
||||
->where('transactions.id', $transactionId)
|
||||
->first(['transactions.*'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO pretty sure method duplicated.
|
||||
*
|
||||
* Return all attachments for journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAttachments(TransactionJournal $journal): Collection
|
||||
{
|
||||
$set = $journal->attachments;
|
||||
|
||||
/** @var Storage $disk */
|
||||
$disk = Storage::disk('upload');
|
||||
/** @var \Storage $disk */
|
||||
$disk = \Storage::disk('upload');
|
||||
|
||||
return $set->each(
|
||||
static function (Attachment $attachment) use ($disk) {
|
||||
@@ -81,9 +73,6 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getJournalLinks(TransactionJournal $journal): Collection
|
||||
{
|
||||
$collection = $journal->destJournalLinks()->get();
|
||||
@@ -93,10 +82,6 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
|
||||
|
||||
/**
|
||||
* Get all piggy bank events for a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getPiggyBankEvents(TransactionJournal $journal): Collection
|
||||
{
|
||||
@@ -110,10 +95,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
|
||||
return $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User|Authenticatable|null $user
|
||||
*/
|
||||
public function setUser(User | Authenticatable | null $user): void
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
|
@@ -36,42 +36,23 @@ interface JournalAPIRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Returns transaction by ID. Used to validate attachments.
|
||||
*
|
||||
* @param int $transactionId
|
||||
*
|
||||
* @return Transaction|null
|
||||
*/
|
||||
public function findTransaction(int $transactionId): ?Transaction;
|
||||
|
||||
/**
|
||||
* Return all attachments for journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAttachments(TransactionJournal $journal): Collection;
|
||||
|
||||
/**
|
||||
* Return all journal links for journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalLinks(TransactionJournal $journal): Collection;
|
||||
|
||||
/**
|
||||
* Get all piggy bank events for a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getPiggyBankEvents(TransactionJournal $journal): Collection;
|
||||
|
||||
/**
|
||||
* @param User|Authenticatable|null $user
|
||||
*/
|
||||
public function setUser(User | Authenticatable | null $user): void;
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
}
|
||||
|
@@ -24,13 +24,11 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class JournalCLIRepository
|
||||
@@ -39,25 +37,18 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Get all transaction journals with a specific type, regardless of user.
|
||||
*
|
||||
* @param array $types
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllJournals(array $types): Collection
|
||||
{
|
||||
return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereIn('transaction_types.type', $types)
|
||||
->with(['user', 'transactionType', 'transactionCurrency', 'transactions', 'transactions.account'])
|
||||
->get(['transaction_journals.*']);
|
||||
->whereIn('transaction_types.type', $types)
|
||||
->with(['user', 'transactionType', 'transactionCurrency', 'transactions', 'transactions.account'])
|
||||
->get(['transaction_journals.*'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ID of the budget linked to the journal (if any) or the transactions (if any).
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getJournalBudgetId(TransactionJournal $journal): int
|
||||
{
|
||||
@@ -75,10 +66,6 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
|
||||
/**
|
||||
* Return the ID of the category linked to the journal (if any) or to the transactions (if any).
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getJournalCategoryId(TransactionJournal $journal): int
|
||||
{
|
||||
@@ -96,8 +83,6 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
|
||||
/**
|
||||
* Return all journals without a group, used in an upgrade routine.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getJournalsWithoutGroup(): array
|
||||
{
|
||||
@@ -106,11 +91,6 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
|
||||
/**
|
||||
* Return Carbon value of a meta field (or NULL).
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|Carbon
|
||||
*/
|
||||
public function getMetaDate(TransactionJournal $journal, string $field): ?Carbon
|
||||
{
|
||||
@@ -135,11 +115,6 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
|
||||
/**
|
||||
* Return value of a meta field (or NULL) as a string.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getMetaField(TransactionJournal $journal, string $field): ?string
|
||||
{
|
||||
@@ -175,10 +150,6 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
|
||||
/**
|
||||
* Return text of a note attached to journal, or NULL
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNoteText(TransactionJournal $journal): ?string
|
||||
{
|
||||
@@ -193,16 +164,16 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
/**
|
||||
* Returns all journals with more than 2 transactions. Should only return empty collections
|
||||
* in Firefly III > v4.8,0.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getSplitJournals(): Collection
|
||||
{
|
||||
$query = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->groupBy('transaction_journals.id');
|
||||
$result = $query->get(['transaction_journals.id as id', DB::raw('count(transactions.id) as transaction_count')]); // @phpstan-ignore-line
|
||||
->groupBy('transaction_journals.id')
|
||||
;
|
||||
$result = $query->get(['transaction_journals.id as id', \DB::raw('count(transactions.id) as transaction_count')]); // @phpstan-ignore-line
|
||||
$journalIds = [];
|
||||
/** @var stdClass $row */
|
||||
|
||||
/** @var \stdClass $row */
|
||||
foreach ($result as $row) {
|
||||
if ((int)$row->transaction_count > 2) {
|
||||
$journalIds[] = (int)$row->id;
|
||||
@@ -211,25 +182,19 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
$journalIds = array_unique($journalIds);
|
||||
|
||||
return TransactionJournal::with(['transactions'])
|
||||
->whereIn('id', $journalIds)->get();
|
||||
->whereIn('id', $journalIds)->get()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all tags as strings in an array.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTags(TransactionJournal $journal): array
|
||||
{
|
||||
return $journal->tags()->get()->pluck('tag')->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User|Authenticatable|null $user
|
||||
*/
|
||||
public function setUser(User | Authenticatable | null $user): void
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
@@ -36,86 +36,49 @@ interface JournalCLIRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Get all transaction journals with a specific type, regardless of user.
|
||||
*
|
||||
* @param array $types
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllJournals(array $types): Collection;
|
||||
|
||||
/**
|
||||
* Return the ID of the budget linked to the journal (if any) or the transactions (if any).
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getJournalBudgetId(TransactionJournal $journal): int;
|
||||
|
||||
/**
|
||||
* Return the ID of the category linked to the journal (if any) or to the transactions (if any).
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getJournalCategoryId(TransactionJournal $journal): int;
|
||||
|
||||
/**
|
||||
* Return all journals without a group, used in an upgrade routine.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getJournalsWithoutGroup(): array;
|
||||
|
||||
/**
|
||||
* Return Carbon value of a meta field (or NULL).
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|Carbon
|
||||
*/
|
||||
public function getMetaDate(TransactionJournal $journal, string $field): ?Carbon;
|
||||
|
||||
/**
|
||||
* Return value of a meta field (or NULL).
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getMetaField(TransactionJournal $journal, string $field): ?string;
|
||||
|
||||
/**
|
||||
* Return text of a note attached to journal, or NULL
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNoteText(TransactionJournal $journal): ?string;
|
||||
|
||||
/**
|
||||
* Returns all journals with more than 2 transactions. Should only return empty collections
|
||||
* in Firefly III > v4.8,0.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getSplitJournals(): Collection;
|
||||
|
||||
/**
|
||||
* Return all tags as strings in an array.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTags(TransactionJournal $journal): array;
|
||||
|
||||
/**
|
||||
* @param User|Authenticatable|null $user
|
||||
*/
|
||||
public function setUser(User | Authenticatable | null $user): void;
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
}
|
||||
|
@@ -45,13 +45,8 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class JournalRepository implements JournalRepositoryInterface
|
||||
{
|
||||
/** @var User */
|
||||
private User $user;
|
||||
|
||||
/**
|
||||
* @param TransactionGroup $transactionGroup
|
||||
*
|
||||
*/
|
||||
public function destroyGroup(TransactionGroup $transactionGroup): void
|
||||
{
|
||||
/** @var TransactionGroupDestroyService $service */
|
||||
@@ -59,10 +54,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$service->destroy($transactionGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
*/
|
||||
public function destroyJournal(TransactionJournal $journal): void
|
||||
{
|
||||
/** @var JournalDestroyService $service */
|
||||
@@ -70,26 +61,22 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$service->destroy($journal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function findByType(array $types): Collection
|
||||
{
|
||||
return $this->user
|
||||
->transactionJournals()
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereIn('transaction_types.type', $types)
|
||||
->get(['transaction_journals.*']);
|
||||
->get(['transaction_journals.*'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users first transaction journal or NULL.
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function firstNull(): ?TransactionJournal
|
||||
{
|
||||
/** @var TransactionJournal|null $entry */
|
||||
/** @var null|TransactionJournal $entry */
|
||||
$entry = $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
|
||||
$result = null;
|
||||
if (null !== $entry) {
|
||||
@@ -99,12 +86,9 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDestinationAccount(TransactionJournal $journal): Account
|
||||
{
|
||||
/** @var Transaction|null $transaction */
|
||||
/** @var null|Transaction $transaction */
|
||||
$transaction = $journal->transactions()->with('account')->where('amount', '>', 0)->first();
|
||||
if (null === $transaction) {
|
||||
throw new FireflyException(sprintf('Your administration is broken. Transaction journal #%d has no destination transaction.', $journal->id));
|
||||
@@ -115,10 +99,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
/**
|
||||
* Return total amount of journal. Is always positive.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJournalTotal(TransactionJournal $journal): string
|
||||
{
|
||||
@@ -137,12 +117,9 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function getLast(): ?TransactionJournal
|
||||
{
|
||||
/** @var TransactionJournal|null $entry */
|
||||
/** @var null|TransactionJournal $entry */
|
||||
$entry = $this->user->transactionJournals()->orderBy('date', 'DESC')->first(['transaction_journals.*']);
|
||||
$result = null;
|
||||
if (null !== $entry) {
|
||||
@@ -152,25 +129,16 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkNoteText(TransactionJournalLink $link): string
|
||||
{
|
||||
/** @var Note|null $note */
|
||||
/** @var null|Note $note */
|
||||
$note = $link->notes()->first();
|
||||
|
||||
return (string)$note?->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Carbon value of a meta field (or NULL).
|
||||
*
|
||||
* @param int $journalId
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|Carbon
|
||||
*/
|
||||
public function getMetaDateById(int $journalId, string $field): ?Carbon
|
||||
{
|
||||
@@ -183,7 +151,8 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return new Carbon($cache->get());
|
||||
}
|
||||
$entry = TransactionJournalMeta::where('transaction_journal_id', $journalId)
|
||||
->where('name', $field)->first();
|
||||
->where('name', $field)->first()
|
||||
;
|
||||
if (null === $entry) {
|
||||
return null;
|
||||
}
|
||||
@@ -193,12 +162,9 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSourceAccount(TransactionJournal $journal): Account
|
||||
{
|
||||
/** @var Transaction|null $transaction */
|
||||
/** @var null|Transaction $transaction */
|
||||
$transaction = $journal->transactions()->with('account')->where('amount', '<', 0)->first();
|
||||
if (null === $transaction) {
|
||||
throw new FireflyException(sprintf('Your administration is broken. Transaction journal #%d has no source transaction.', $journal->id));
|
||||
@@ -207,22 +173,15 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $transaction->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $journalId
|
||||
*/
|
||||
public function reconcileById(int $journalId): void
|
||||
{
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = $this->user->transactionJournals()->find($journalId);
|
||||
$journal?->transactions()->update(['reconciled' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a specific journal.
|
||||
*
|
||||
* @param int $journalId
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function find(int $journalId): ?TransactionJournal
|
||||
{
|
||||
@@ -231,16 +190,12 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
/**
|
||||
* Search in journal descriptions.
|
||||
*
|
||||
* @param string $search
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchJournalDescriptions(string $search, int $limit): Collection
|
||||
{
|
||||
$query = $this->user->transactionJournals()
|
||||
->orderBy('date', 'DESC');
|
||||
->orderBy('date', 'DESC')
|
||||
;
|
||||
if ('' !== $search) {
|
||||
$query->where('description', 'LIKE', sprintf('%%%s%%', $search));
|
||||
}
|
||||
@@ -248,33 +203,22 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $query->take($limit)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User|Authenticatable|null $user
|
||||
*/
|
||||
public function setUser(User | Authenticatable | null $user): void
|
||||
public function setUser(null|Authenticatable|User $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function unreconcileById(int $journalId): void
|
||||
{
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = $this->user->transactionJournals()->find($journalId);
|
||||
$journal?->transactions()->update(['reconciled' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update budget for a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param int $budgetId
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function updateBudget(TransactionJournal $journal, int $budgetId): TransactionJournal
|
||||
{
|
||||
@@ -295,11 +239,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
/**
|
||||
* Update category for a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $category
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function updateCategory(TransactionJournal $journal, string $category): TransactionJournal
|
||||
{
|
||||
@@ -319,11 +258,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
/**
|
||||
* Update tag(s) for a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param array $tags
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function updateTags(TransactionJournal $journal, array $tags): TransactionJournal
|
||||
{
|
||||
|
@@ -40,148 +40,83 @@ interface JournalRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Deletes a transaction group.
|
||||
*
|
||||
* @param TransactionGroup $transactionGroup
|
||||
*/
|
||||
public function destroyGroup(TransactionGroup $transactionGroup): void;
|
||||
|
||||
/**
|
||||
* Deletes a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*/
|
||||
public function destroyJournal(TransactionJournal $journal): void;
|
||||
|
||||
/**
|
||||
* Find a specific journal.
|
||||
*
|
||||
* @param int $journalId
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function find(int $journalId): ?TransactionJournal;
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function findByType(array $types): Collection;
|
||||
|
||||
/**
|
||||
* Get users very first transaction journal.
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function firstNull(): ?TransactionJournal;
|
||||
|
||||
/**
|
||||
* Returns the destination account of the journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Account
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getDestinationAccount(TransactionJournal $journal): Account;
|
||||
|
||||
/**
|
||||
* Return total amount of journal. Is always positive.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJournalTotal(TransactionJournal $journal): string;
|
||||
|
||||
/**
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function getLast(): ?TransactionJournal;
|
||||
|
||||
/**
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkNoteText(TransactionJournalLink $link): string;
|
||||
|
||||
/**
|
||||
* Return Carbon value of a meta field (or NULL).
|
||||
*
|
||||
* @param int $journalId
|
||||
* @param string $field
|
||||
*
|
||||
* @return null|Carbon
|
||||
*/
|
||||
public function getMetaDateById(int $journalId, string $field): ?Carbon;
|
||||
|
||||
/**
|
||||
* Returns the source account of the journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Account
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getSourceAccount(TransactionJournal $journal): Account;
|
||||
|
||||
/**
|
||||
* TODO Maybe to account repository? Do this wen reconcile is API only.
|
||||
*
|
||||
* @param int $journalId
|
||||
*/
|
||||
public function reconcileById(int $journalId): void;
|
||||
|
||||
/**
|
||||
* Search in journal descriptions.
|
||||
*
|
||||
* @param string $search
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchJournalDescriptions(string $search, int $limit): Collection;
|
||||
|
||||
/**
|
||||
* @param User|Authenticatable|null $user
|
||||
*/
|
||||
public function setUser(User | Authenticatable | null $user): void;
|
||||
public function setUser(null|Authenticatable|User $user): void;
|
||||
|
||||
/**
|
||||
* TODO Maybe to account repository? Do this wen reconcile is API only.
|
||||
*
|
||||
* @param int $journalId
|
||||
*/
|
||||
public function unreconcileById(int $journalId): void;
|
||||
|
||||
/**
|
||||
* Update budget for a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param int $budgetId
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function updateBudget(TransactionJournal $journal, int $budgetId): TransactionJournal;
|
||||
|
||||
/**
|
||||
* Update category for a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $category
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function updateCategory(TransactionJournal $journal, string $category): TransactionJournal;
|
||||
|
||||
/**
|
||||
* Update tag(s) for a journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param array $tags
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function updateTags(TransactionJournal $journal, array $tags): TransactionJournal;
|
||||
}
|
||||
|
Reference in New Issue
Block a user