2015-02-09 00:23:39 -06:00
|
|
|
<?php
|
2022-12-29 12:42:26 -06:00
|
|
|
|
2016-05-20 05:41:23 -05:00
|
|
|
/**
|
|
|
|
* AccountRepositoryInterface.php
|
2020-02-16 07:00:57 -06:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2016-05-20 05:41:23 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-04 23:52:15 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05: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 01:40:00 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 01:40:00 -05:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-01 23:37:26 -05:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 01:40:00 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05: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 05:41:23 -05:00
|
|
|
*/
|
2017-04-09 00:44:22 -05:00
|
|
|
declare(strict_types=1);
|
2015-02-09 00:23:39 -06:00
|
|
|
|
|
|
|
namespace FireflyIII\Repositories\Account;
|
|
|
|
|
2015-03-29 14:27:51 -05:00
|
|
|
use Carbon\Carbon;
|
2015-02-14 07:25:29 -06:00
|
|
|
use FireflyIII\Models\Account;
|
2018-08-04 10:30:47 -05:00
|
|
|
use FireflyIII\Models\AccountType;
|
2019-12-30 05:12:08 -06:00
|
|
|
use FireflyIII\Models\Location;
|
2018-12-15 00:59:49 -06:00
|
|
|
use FireflyIII\Models\TransactionCurrency;
|
2019-06-16 06:16:04 -05:00
|
|
|
use FireflyIII\Models\TransactionGroup;
|
2017-01-19 14:54:27 -06:00
|
|
|
use FireflyIII\Models\TransactionJournal;
|
2017-01-30 09:40:49 -06:00
|
|
|
use FireflyIII\User;
|
2023-02-19 01:43:28 -06:00
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
2016-10-10 00:25:27 -05:00
|
|
|
use Illuminate\Support\Collection;
|
2021-03-28 04:46:23 -05:00
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
2017-11-15 05:25:49 -06:00
|
|
|
* Interface AccountRepositoryInterface.
|
2015-02-11 00:35:10 -06:00
|
|
|
*/
|
2015-02-09 00:23:39 -06:00
|
|
|
interface AccountRepositoryInterface
|
|
|
|
{
|
2017-12-31 03:40:27 -06:00
|
|
|
/**
|
2016-10-09 01:18:47 -05:00
|
|
|
* Moved here from account CRUD.
|
|
|
|
*/
|
|
|
|
public function count(array $types): int;
|
2016-02-04 01:53:15 -06:00
|
|
|
|
2016-10-09 01:20:29 -05:00
|
|
|
/**
|
|
|
|
* Moved here from account CRUD.
|
|
|
|
*/
|
2018-02-23 09:21:28 -06:00
|
|
|
public function destroy(Account $account, ?Account $moveTo): bool;
|
2016-10-09 01:20:29 -05:00
|
|
|
|
2019-09-03 15:35:41 -05:00
|
|
|
/**
|
|
|
|
* Find account with same name OR same IBAN or both, but not the same type or ID.
|
|
|
|
*/
|
|
|
|
public function expandWithDoubles(Collection $accounts): Collection;
|
|
|
|
|
2021-09-18 03:26:12 -05:00
|
|
|
public function find(int $accountId): ?Account;
|
|
|
|
|
2021-04-21 23:18:46 -05:00
|
|
|
public function findByAccountNumber(string $number, array $types): ?Account;
|
|
|
|
|
2018-03-24 12:55:02 -05:00
|
|
|
public function findByIbanNull(string $iban, array $types): ?Account;
|
|
|
|
|
2018-02-16 08:19:19 -06:00
|
|
|
public function findByName(string $name, array $types): ?Account;
|
2016-10-10 00:49:39 -05:00
|
|
|
|
2019-02-13 10:38:41 -06:00
|
|
|
public function getAccountCurrency(Account $account): ?TransactionCurrency;
|
|
|
|
|
2018-08-04 10:30:47 -05:00
|
|
|
/**
|
|
|
|
* Return account type or null if not found.
|
|
|
|
*/
|
|
|
|
public function getAccountTypeByType(string $type): ?AccountType;
|
|
|
|
|
2016-10-10 00:49:39 -05:00
|
|
|
public function getAccountsById(array $accountIds): Collection;
|
|
|
|
|
|
|
|
/**
|
2023-12-09 23:51:59 -06:00
|
|
|
* @param array<int, int|string> $types
|
2016-10-10 00:49:39 -05:00
|
|
|
*/
|
2021-05-24 01:06:56 -05:00
|
|
|
public function getAccountsByType(array $types, ?array $sort = []): Collection;
|
2016-10-10 00:49:39 -05:00
|
|
|
|
2016-10-10 00:53:12 -05:00
|
|
|
public function getActiveAccountsByType(array $types): Collection;
|
|
|
|
|
2021-03-11 23:20:01 -06:00
|
|
|
public function getAttachments(Account $account): Collection;
|
2019-10-19 12:17:14 -05:00
|
|
|
|
2017-06-05 04:12:50 -05:00
|
|
|
public function getCashAccount(): Account;
|
|
|
|
|
2021-09-18 03:26:12 -05:00
|
|
|
public function getCreditTransactionGroup(Account $account): ?TransactionGroup;
|
|
|
|
|
2021-03-11 23:20:01 -06:00
|
|
|
public function getInactiveAccountsByType(array $types): Collection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get account location, if any.
|
|
|
|
*/
|
|
|
|
public function getLocation(Account $account): ?Location;
|
|
|
|
|
2018-03-19 02:17:31 -05:00
|
|
|
/**
|
|
|
|
* Return meta value for account. Null if not found.
|
|
|
|
*/
|
|
|
|
public function getMetaValue(Account $account, string $field): ?string;
|
|
|
|
|
2018-03-19 13:39:02 -05:00
|
|
|
/**
|
|
|
|
* Get note text or null.
|
|
|
|
*/
|
|
|
|
public function getNoteText(Account $account): ?string;
|
|
|
|
|
2019-09-03 15:35:41 -05:00
|
|
|
public function getOpeningBalance(Account $account): ?TransactionJournal;
|
|
|
|
|
2018-02-16 15:14:53 -06:00
|
|
|
/**
|
|
|
|
* Returns the amount of the opening balance for this account.
|
|
|
|
*/
|
|
|
|
public function getOpeningBalanceAmount(Account $account): ?string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return date of opening balance as string or null.
|
|
|
|
*/
|
|
|
|
public function getOpeningBalanceDate(Account $account): ?string;
|
|
|
|
|
2019-09-03 15:35:41 -05:00
|
|
|
public function getOpeningBalanceGroup(Account $account): ?TransactionGroup;
|
|
|
|
|
2018-12-09 06:09:43 -06:00
|
|
|
public function getPiggyBanks(Account $account): Collection;
|
|
|
|
|
2017-11-22 10:49:06 -06:00
|
|
|
/**
|
|
|
|
* Find or create the opposing reconciliation account.
|
|
|
|
*/
|
|
|
|
public function getReconciliation(Account $account): ?Account;
|
|
|
|
|
2021-03-11 23:20:01 -06:00
|
|
|
public function getUsedCurrencies(Account $account): Collection;
|
2018-12-09 06:09:43 -06:00
|
|
|
|
2018-08-22 14:18:15 -05:00
|
|
|
public function isLiability(Account $account): bool;
|
|
|
|
|
2021-03-21 03:15:40 -05:00
|
|
|
public function maxOrder(string $type): int;
|
|
|
|
|
2017-01-19 14:54:27 -06:00
|
|
|
/**
|
|
|
|
* Returns the date of the very first transaction in this account.
|
|
|
|
*/
|
2018-07-24 13:30:52 -05:00
|
|
|
public function oldestJournal(Account $account): ?TransactionJournal;
|
2017-01-19 14:54:27 -06:00
|
|
|
|
2016-04-08 07:50:18 -05:00
|
|
|
/**
|
|
|
|
* Returns the date of the very first transaction in this account.
|
|
|
|
*/
|
2018-08-07 12:29:10 -05:00
|
|
|
public function oldestJournalDate(Account $account): ?Carbon;
|
2016-04-08 07:50:18 -05:00
|
|
|
|
2021-03-11 23:20:01 -06:00
|
|
|
/**
|
|
|
|
* Reset order types of the mentioned accounts.
|
|
|
|
*/
|
2021-03-13 05:01:01 -06:00
|
|
|
public function resetAccountOrder(): void;
|
2021-03-11 23:20:01 -06:00
|
|
|
|
2020-07-20 23:20:31 -05:00
|
|
|
public function searchAccount(string $query, array $types, int $limit): Collection;
|
2019-03-02 07:12:09 -06:00
|
|
|
|
2020-08-22 05:24:01 -05:00
|
|
|
public function searchAccountNr(string $query, array $types, int $limit): Collection;
|
|
|
|
|
2023-12-20 12:35:52 -06:00
|
|
|
public function setUser(null|Authenticatable|User $user): void;
|
2017-01-30 09:42:58 -06:00
|
|
|
|
2016-11-28 11:55:56 -06:00
|
|
|
public function store(array $data): Account;
|
2016-10-10 01:03:03 -05:00
|
|
|
|
2017-04-14 00:11:30 -05:00
|
|
|
public function update(Account $account, array $data): Account;
|
2015-03-29 01:14:32 -05:00
|
|
|
}
|