2015-02-09 07:23:39 +01:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* JournalRepositoryInterface.php
|
2020-02-16 14:00:57 +01:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2016-05-20 12:41:23 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* 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
|
|
|
*
|
2019-10-02 06:37:26 +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
|
2019-10-02 06:37:26 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +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/>.
|
2016-05-20 12:41:23 +02:00
|
|
|
*/
|
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;
|
2018-05-05 13:53:12 +02:00
|
|
|
use FireflyIII\Models\TransactionJournalMeta;
|
2017-01-30 16:40:49 +01:00
|
|
|
use FireflyIII\User;
|
2017-01-20 19:50:22 +01:00
|
|
|
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-07-01 20:22:35 +02:00
|
|
|
/**
|
2019-08-10 08:42:46 +02:00
|
|
|
* TODO maybe create JSON repository?
|
|
|
|
*
|
2019-07-01 20:22:35 +02:00
|
|
|
* 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;
|
|
|
|
|
2018-02-24 14:31:20 +01:00
|
|
|
/**
|
2019-08-12 17:10:58 +02:00
|
|
|
* TODO this method is no longer well-fitted in 4.8,0. Should be refactored and/or removed.
|
2018-02-24 14:31:20 +01:00
|
|
|
* Return a list of all destination accounts related to journal.
|
|
|
|
*
|
|
|
|
* @param TransactionJournal $journal
|
2019-08-10 08:42:46 +02:00
|
|
|
* @deprecated
|
2018-02-24 14:31:20 +01:00
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getJournalDestinationAccounts(TransactionJournal $journal): Collection;
|
|
|
|
|
|
|
|
/**
|
2019-08-12 17:10:58 +02:00
|
|
|
* TODO this method is no longer well-fitted in 4.8,0. Should be refactored and/or removed.
|
2018-02-24 14:31:20 +01:00
|
|
|
* Return a list of all source accounts related to journal.
|
|
|
|
*
|
|
|
|
* @param TransactionJournal $journal
|
2019-08-10 08:42:46 +02:00
|
|
|
* @deprecated
|
2018-02-24 14:31:20 +01:00
|
|
|
* @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;
|
|
|
|
|
2018-02-25 19:09:05 +01:00
|
|
|
/**
|
|
|
|
* Return total amount of journal. Is always positive.
|
|
|
|
*
|
|
|
|
* @param TransactionJournal $journal
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getJournalTotal(TransactionJournal $journal): string;
|
|
|
|
|
2019-02-12 21:49:28 +01:00
|
|
|
/**
|
2019-08-10 08:42:46 +02:00
|
|
|
* TODO used only in transformer, so only for API use.
|
2019-02-12 21:49:28 +01:00
|
|
|
* @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-02-24 14:31:20 +01:00
|
|
|
|
|
|
|
|
2018-03-11 16:24:07 +01:00
|
|
|
|
2018-02-24 14:31:20 +01:00
|
|
|
|
|
|
|
/**
|
2019-08-10 08:42:46 +02:00
|
|
|
* TODO maybe move to account repository?
|
2018-02-24 14:31:20 +01:00
|
|
|
*
|
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
|
|
|
}
|