Files
firefly-iii/app/Repositories/Journal/JournalRepositoryInterface.php

203 lines
5.3 KiB
PHP
Raw Normal View History

2015-02-09 07:23:39 +01:00
<?php
/**
* JournalRepositoryInterface.php
2020-02-16 14:00:57 +01:00
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2017-10-21 08:40:00 +02:00
*
* This program is distributed in the hope that it will be useful,
2017-10-21 08:40:00 +02:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2017-10-21 08:40:00 +02:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2017-03-24 15:01:53 +01:00
declare(strict_types=1);
2015-02-09 07:23:39 +01:00
namespace FireflyIII\Repositories\Journal;
2018-03-10 22:34:02 +01:00
use Carbon\Carbon;
2019-12-20 21:01:27 +01:00
use FireflyIII\Models\Account;
2019-03-30 07:09:52 +01:00
use FireflyIII\Models\TransactionGroup;
2015-04-07 18:26:14 +02:00
use FireflyIII\Models\TransactionJournal;
2018-12-20 22:03:34 +01:00
use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Models\TransactionJournalMeta;
use FireflyIII\User;
use Illuminate\Support\Collection;
2015-02-09 07:23:39 +01:00
2015-02-11 07:35:10 +01:00
/**
2017-11-15 12:25:49 +01:00
* Interface JournalRepositoryInterface.
2015-02-11 07:35:10 +01:00
*/
interface JournalRepositoryInterface
{
2019-06-10 20:14:00 +02:00
/**
2019-08-10 08:42:46 +02:00
* TODO maybe create JSON repository?
*
* Search in journal descriptions.
*
* @param string $search
* @return Collection
*/
public function searchJournalDescriptions(string $search): Collection;
2017-07-04 16:31:16 +02:00
/**
2019-03-30 07:09:52 +01:00
* Deletes a transaction group.
2017-07-04 16:31:16 +02:00
*
2019-03-30 07:09:52 +01:00
* @param TransactionGroup $transactionGroup
2017-07-04 16:31:16 +02:00
*/
2019-03-30 07:09:52 +01:00
public function destroyGroup(TransactionGroup $transactionGroup): void;
2017-07-04 16:31:16 +02:00
2016-10-30 06:14:07 +01:00
/**
2016-11-05 11:47:21 +01:00
* Deletes a journal.
*
2016-10-30 06:14:07 +01:00
* @param TransactionJournal $journal
*/
2019-03-30 07:09:52 +01:00
public function destroyJournal(TransactionJournal $journal): void;
2016-10-30 06:14:07 +01:00
2019-03-23 08:10:59 +01:00
2018-06-06 21:23:00 +02:00
/**
2019-08-10 08:42:46 +02:00
* TODO move to import repository.
*
2018-06-06 21:23:00 +02:00
* Find a journal by its hash.
*
* @param string $hash
*
* @return TransactionJournalMeta|null
*/
public function findByHash(string $hash): ?TransactionJournalMeta;
2018-04-24 19:26:16 +02:00
/**
2019-08-10 08:42:46 +02:00
* TODO Refactor to "find".
2018-04-24 19:26:16 +02:00
* Find a specific journal.
*
* @param int $journalId
*
* @return TransactionJournal|null
*/
public function findNull(int $journalId): ?TransactionJournal;
2018-04-02 15:10:40 +02:00
/**
* Get users very first transaction journal.
*
* @return TransactionJournal|null
*/
public function firstNull(): ?TransactionJournal;
/**
* 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
2019-08-10 08:42:46 +02:00
* @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
2019-08-10 08:42:46 +02:00
* @deprecated
* @return Collection
*/
public function getJournalSourceAccounts(TransactionJournal $journal): Collection;
2019-12-20 21:01:27 +01:00
/**
* Returns the source account of the journal.
*
* @param TransactionJournal $journal
* @return Account
*/
public function getSourceAccount(TransactionJournal $journal): Account;
/**
* Returns the destination account of the journal.
*
* @param TransactionJournal $journal
* @return Account
*/
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;
/**
2019-08-10 08:42:46 +02:00
* TODO used only in transformer, so only for API use.
* @param TransactionJournalLink $link
*
* @return string
*/
public function getLinkNoteText(TransactionJournalLink $link): string;
2018-03-10 22:34:02 +01:00
2019-08-02 05:44:51 +02:00
/**
* 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;
2018-03-11 16:24:07 +01:00
/**
2019-08-10 08:42:46 +02:00
* TODO maybe move to account repository?
*
2019-06-23 05:53:01 +02:00
* @param int $journalId
2018-02-28 21:32:59 +01:00
*/
2019-06-23 05:53:01 +02:00
public function reconcileById(int $journalId): void;
2018-02-28 21:32:59 +01:00
2017-01-30 16:46:30 +01:00
/**
* @param User $user
*/
public function setUser(User $user);
2016-05-15 12:08:41 +02:00
2018-02-23 16:21:28 +01:00
/**
* Update budget for a journal.
*
* @param TransactionJournal $journal
2019-06-10 20:14:00 +02:00
* @param int $budgetId
2018-02-23 16:21:28 +01:00
*
* @return TransactionJournal
*/
public function updateBudget(TransactionJournal $journal, int $budgetId): TransactionJournal;
/**
* Update category for a journal.
*
* @param TransactionJournal $journal
2019-06-10 20:14:00 +02:00
* @param string $category
2018-02-23 16:21:28 +01:00
*
* @return TransactionJournal
*/
public function updateCategory(TransactionJournal $journal, string $category): TransactionJournal;
/**
* Update tag(s) for a journal.
*
* @param TransactionJournal $journal
2019-06-10 20:14:00 +02:00
* @param array $tags
2018-02-23 16:21:28 +01:00
*
* @return TransactionJournal
*/
public function updateTags(TransactionJournal $journal, array $tags): TransactionJournal;
2015-03-29 08:14:32 +02:00
}