2015-02-09 07:23:39 +01:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* AccountRepositoryInterface.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-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2015-02-09 07:23:39 +01:00
|
|
|
|
|
|
|
namespace FireflyIII\Repositories\Account;
|
|
|
|
|
2015-03-29 21:27:51 +02:00
|
|
|
use Carbon\Carbon;
|
2015-02-14 14:25:29 +01:00
|
|
|
use FireflyIII\Models\Account;
|
2018-08-04 17:30:47 +02:00
|
|
|
use FireflyIII\Models\AccountType;
|
2019-12-30 12:12:08 +01:00
|
|
|
use FireflyIII\Models\Location;
|
2018-12-15 07:59:49 +01:00
|
|
|
use FireflyIII\Models\TransactionCurrency;
|
2019-06-16 13:16:04 +02:00
|
|
|
use FireflyIII\Models\TransactionGroup;
|
2017-01-19 21:54:27 +01:00
|
|
|
use FireflyIII\Models\TransactionJournal;
|
2017-01-30 16:40:49 +01:00
|
|
|
use FireflyIII\User;
|
2016-10-10 07:25:27 +02:00
|
|
|
use Illuminate\Support\Collection;
|
2021-03-28 11:46:23 +02:00
|
|
|
|
2015-02-11 07:35:10 +01:00
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Interface AccountRepositoryInterface.
|
2015-02-11 07:35:10 +01:00
|
|
|
*/
|
2015-02-09 07:23:39 +01:00
|
|
|
interface AccountRepositoryInterface
|
|
|
|
{
|
2017-12-31 10:40:27 +01:00
|
|
|
/**
|
2016-10-09 08:18:47 +02:00
|
|
|
* Moved here from account CRUD.
|
|
|
|
*
|
|
|
|
* @param array $types
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function count(array $types): int;
|
2016-02-04 08:53:15 +01:00
|
|
|
|
2016-10-09 08:20:29 +02:00
|
|
|
/**
|
|
|
|
* Moved here from account CRUD.
|
|
|
|
*
|
2021-03-07 16:19:14 +01:00
|
|
|
* @param Account $account
|
2018-02-23 16:21:28 +01:00
|
|
|
* @param Account|null $moveTo
|
2016-10-09 08:20:29 +02:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-02-23 16:21:28 +01:00
|
|
|
public function destroy(Account $account, ?Account $moveTo): bool;
|
2016-10-09 08:20:29 +02:00
|
|
|
|
2019-09-03 22:35:41 +02:00
|
|
|
/**
|
|
|
|
* Find account with same name OR same IBAN or both, but not the same type or ID.
|
|
|
|
*
|
|
|
|
* @param Collection $accounts
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function expandWithDoubles(Collection $accounts): Collection;
|
|
|
|
|
2018-03-24 18:55:02 +01:00
|
|
|
/**
|
|
|
|
* @param string $iban
|
2021-03-07 16:19:14 +01:00
|
|
|
* @param array $types
|
2018-03-24 18:55:02 +01:00
|
|
|
*
|
|
|
|
* @return Account|null
|
|
|
|
*/
|
|
|
|
public function findByIbanNull(string $iban, array $types): ?Account;
|
|
|
|
|
2016-10-10 07:49:39 +02:00
|
|
|
/**
|
|
|
|
* @param string $name
|
2021-03-07 16:19:14 +01:00
|
|
|
* @param array $types
|
2016-10-10 07:49:39 +02:00
|
|
|
*
|
2018-02-16 15:19:19 +01:00
|
|
|
* @return Account|null
|
2016-10-10 07:49:39 +02:00
|
|
|
*/
|
2018-02-16 15:19:19 +01:00
|
|
|
public function findByName(string $name, array $types): ?Account;
|
2016-10-10 07:49:39 +02:00
|
|
|
|
2018-02-16 22:14:53 +01:00
|
|
|
/**
|
|
|
|
* @param int $accountId
|
|
|
|
*
|
|
|
|
* @return Account|null
|
|
|
|
*/
|
|
|
|
public function findNull(int $accountId): ?Account;
|
|
|
|
|
2019-02-13 17:38:41 +01:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return TransactionCurrency|null
|
|
|
|
*/
|
|
|
|
public function getAccountCurrency(Account $account): ?TransactionCurrency;
|
|
|
|
|
2018-08-04 17:30:47 +02:00
|
|
|
/**
|
|
|
|
* Return account type or null if not found.
|
|
|
|
*
|
|
|
|
* @param string $type
|
|
|
|
*
|
|
|
|
* @return AccountType|null
|
|
|
|
*/
|
|
|
|
public function getAccountTypeByType(string $type): ?AccountType;
|
|
|
|
|
2016-10-10 07:49:39 +02:00
|
|
|
/**
|
|
|
|
* @param array $accountIds
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getAccountsById(array $accountIds): Collection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $types
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getAccountsByType(array $types): Collection;
|
|
|
|
|
2016-10-10 07:53:12 +02:00
|
|
|
/**
|
|
|
|
* @param array $types
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getActiveAccountsByType(array $types): Collection;
|
|
|
|
|
2019-10-19 19:17:14 +02:00
|
|
|
/**
|
2021-03-12 06:20:01 +01:00
|
|
|
* @param Account $account
|
2019-10-19 19:17:14 +02:00
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2021-03-12 06:20:01 +01:00
|
|
|
public function getAttachments(Account $account): Collection;
|
2019-10-19 19:17:14 +02:00
|
|
|
|
2017-06-05 11:12:50 +02:00
|
|
|
/**
|
|
|
|
* @return Account
|
|
|
|
*/
|
|
|
|
public function getCashAccount(): Account;
|
|
|
|
|
2021-03-12 06:20:01 +01:00
|
|
|
/**
|
|
|
|
* @param array $types
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getInactiveAccountsByType(array $types): Collection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get account location, if any.
|
|
|
|
*
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return Location|null
|
|
|
|
*/
|
|
|
|
public function getLocation(Account $account): ?Location;
|
|
|
|
|
2018-03-19 08:17:31 +01:00
|
|
|
/**
|
|
|
|
* Return meta value for account. Null if not found.
|
|
|
|
*
|
|
|
|
* @param Account $account
|
2021-03-07 16:19:14 +01:00
|
|
|
* @param string $field
|
2018-03-19 08:17:31 +01:00
|
|
|
*
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getMetaValue(Account $account, string $field): ?string;
|
|
|
|
|
2018-03-19 19:39:02 +01:00
|
|
|
/**
|
|
|
|
* Get note text or null.
|
|
|
|
*
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getNoteText(Account $account): ?string;
|
|
|
|
|
2019-09-03 22:35:41 +02:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return TransactionJournal|null
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getOpeningBalance(Account $account): ?TransactionJournal;
|
|
|
|
|
2018-02-16 22:14:53 +01:00
|
|
|
/**
|
|
|
|
* Returns the amount of the opening balance for this account.
|
|
|
|
*
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getOpeningBalanceAmount(Account $account): ?string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return date of opening balance as string or null.
|
|
|
|
*
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return null|string
|
|
|
|
*/
|
|
|
|
public function getOpeningBalanceDate(Account $account): ?string;
|
|
|
|
|
2021-04-10 17:26:36 +02:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return TransactionGroup|null
|
|
|
|
*/
|
|
|
|
public function getCreditTransactionGroup(Account $account): ?TransactionGroup;
|
|
|
|
|
2019-09-03 22:35:41 +02:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return TransactionGroup|null
|
|
|
|
*/
|
|
|
|
public function getOpeningBalanceGroup(Account $account): ?TransactionGroup;
|
|
|
|
|
2018-12-09 13:09:43 +01:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getPiggyBanks(Account $account): Collection;
|
|
|
|
|
2017-11-22 17:49:06 +01:00
|
|
|
/**
|
|
|
|
* Find or create the opposing reconciliation account.
|
|
|
|
*
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return Account|null
|
|
|
|
*/
|
|
|
|
public function getReconciliation(Account $account): ?Account;
|
|
|
|
|
2021-03-12 06:20:01 +01:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getUsedCurrencies(Account $account): Collection;
|
2018-12-09 13:09:43 +01:00
|
|
|
|
2018-08-22 21:18:15 +02:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isLiability(Account $account): bool;
|
|
|
|
|
2021-03-21 09:15:40 +01:00
|
|
|
/**
|
|
|
|
* @param string $type
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function maxOrder(string $type): int;
|
|
|
|
|
2017-01-19 21:54:27 +01:00
|
|
|
/**
|
|
|
|
* Returns the date of the very first transaction in this account.
|
|
|
|
*
|
|
|
|
* @param Account $account
|
2018-08-04 17:30:47 +02:00
|
|
|
*
|
2018-07-24 20:30:52 +02:00
|
|
|
* @return TransactionJournal|null
|
2017-01-19 21:54:27 +01:00
|
|
|
*/
|
2018-07-24 20:30:52 +02:00
|
|
|
public function oldestJournal(Account $account): ?TransactionJournal;
|
2017-01-19 21:54:27 +01:00
|
|
|
|
2016-04-08 14:50:18 +02:00
|
|
|
/**
|
|
|
|
* Returns the date of the very first transaction in this account.
|
|
|
|
*
|
|
|
|
* @param Account $account
|
|
|
|
*
|
2018-08-07 19:29:10 +02:00
|
|
|
* @return Carbon|null
|
2016-04-08 14:50:18 +02:00
|
|
|
*/
|
2018-08-07 19:29:10 +02:00
|
|
|
public function oldestJournalDate(Account $account): ?Carbon;
|
2016-04-08 14:50:18 +02:00
|
|
|
|
2021-03-12 06:20:01 +01:00
|
|
|
/**
|
|
|
|
* Reset order types of the mentioned accounts.
|
|
|
|
*/
|
2021-03-13 12:01:01 +01:00
|
|
|
public function resetAccountOrder(): void;
|
2021-03-12 06:20:01 +01:00
|
|
|
|
2019-03-02 14:12:09 +01:00
|
|
|
/**
|
|
|
|
* @param string $query
|
2021-03-07 16:19:14 +01:00
|
|
|
* @param array $types
|
|
|
|
* @param int $limit
|
2019-03-02 14:12:09 +01:00
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2020-07-21 06:20:31 +02:00
|
|
|
public function searchAccount(string $query, array $types, int $limit): Collection;
|
2019-03-02 14:12:09 +01:00
|
|
|
|
2020-08-22 12:24:01 +02:00
|
|
|
/**
|
|
|
|
* @param string $query
|
2021-03-07 16:19:14 +01:00
|
|
|
* @param array $types
|
|
|
|
* @param int $limit
|
2020-08-22 12:24:01 +02:00
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function searchAccountNr(string $query, array $types, int $limit): Collection;
|
|
|
|
|
2017-01-30 16:42:58 +01:00
|
|
|
/**
|
|
|
|
* @param User $user
|
|
|
|
*/
|
|
|
|
public function setUser(User $user);
|
|
|
|
|
2016-10-10 08:03:03 +02:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @return Account
|
|
|
|
*/
|
2016-11-28 18:55:56 +01:00
|
|
|
public function store(array $data): Account;
|
2016-10-10 08:03:03 +02:00
|
|
|
|
2017-04-14 07:11:30 +02:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
2021-03-07 16:19:14 +01:00
|
|
|
* @param array $data
|
2017-04-14 07:11:30 +02:00
|
|
|
*
|
|
|
|
* @return Account
|
|
|
|
*/
|
|
|
|
public function update(Account $account, array $data): Account;
|
2015-03-29 08:14:32 +02:00
|
|
|
}
|