firefly-iii/app/Repositories/Account/AccountRepositoryInterface.php

292 lines
6.7 KiB
PHP
Raw Normal View History

2015-02-09 00:23:39 -06:00
<?php
/**
* AccountRepositoryInterface.php
2017-10-21 01:40:00 -05:00
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
2017-10-21 01:40:00 -05:00
* This file is part of Firefly III.
*
2017-10-21 01:40:00 -05:00
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 07:44:05 -06:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
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;
use FireflyIII\Models\Account;
2018-08-04 10:30:47 -05:00
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
2016-10-10 00:25:27 -05:00
use Illuminate\Support\Collection;
2015-03-29 14:27:51 -05:00
2018-08-04 10:30:47 -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
{
2019-03-02 07:12:09 -06:00
2019-06-10 13:14:00 -05:00
/**
* @param Account $account
* @return TransactionJournal|null
*/
public function getOpeningBalance(Account $account): ?TransactionJournal;
/**
* @param Account $account
* @return TransactionGroup|null
*/
public function getOpeningBalanceGroup(Account $account): ?TransactionGroup;
2017-12-31 03:40:27 -06:00
/**
* Moved here from account CRUD.
*
* @param array $types
*
* @return int
*/
public function count(array $types): int;
/**
* Moved here from account CRUD.
*
2019-06-10 13:14:00 -05:00
* @param Account $account
2018-02-23 09:21:28 -06:00
* @param Account|null $moveTo
*
* @return bool
*/
2018-02-23 09:21:28 -06:00
public function destroy(Account $account, ?Account $moveTo): bool;
2016-10-10 00:12:39 -05:00
/**
2018-07-22 11:50:27 -05:00
* Find by account number. Is used.
2016-10-10 00:12:39 -05:00
*
2016-10-10 00:14:01 -05:00
* @param string $number
2019-06-10 13:14:00 -05:00
* @param array $types
2016-10-10 00:14:01 -05:00
*
2018-05-09 13:53:39 -05:00
* @return Account|null
2016-10-10 00:14:01 -05:00
*/
2018-05-09 13:53:39 -05:00
public function findByAccountNumber(string $number, array $types): ?Account;
2016-10-10 00:14:01 -05:00
2018-03-24 12:55:02 -05:00
/**
* @param string $iban
2019-06-10 13:14:00 -05:00
* @param array $types
2018-03-24 12:55:02 -05:00
*
* @return Account|null
*/
public function findByIbanNull(string $iban, array $types): ?Account;
2016-10-10 00:49:39 -05:00
/**
* @param string $name
2019-06-10 13:14:00 -05:00
* @param array $types
2016-10-10 00:49:39 -05:00
*
2018-02-16 08:19:19 -06:00
* @return Account|null
2016-10-10 00:49:39 -05:00
*/
2018-02-16 08:19:19 -06:00
public function findByName(string $name, array $types): ?Account;
2016-10-10 00:49:39 -05:00
2018-02-16 15:14:53 -06:00
/**
* @param int $accountId
*
* @return Account|null
*/
public function findNull(int $accountId): ?Account;
2019-02-13 10:38:41 -06:00
/**
* @param Account $account
*
* @return TransactionCurrency|null
*/
public function getAccountCurrency(Account $account): ?TransactionCurrency;
/**
* @param Account $account
*
* @return string
*/
public function getAccountType(Account $account): string;
2018-08-04 10:30:47 -05:00
/**
* Return account type or null if not found.
*
* @param string $type
*
* @return AccountType|null
*/
public function getAccountTypeByType(string $type): ?AccountType;
2016-10-10 00:49:39 -05: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 00:53:12 -05:00
/**
* @param array $types
*
* @return Collection
*/
public function getActiveAccountsByType(array $types): Collection;
2017-06-05 04:12:50 -05:00
/**
* @return Account
*/
public function getCashAccount(): Account;
/**
* @param $account
*
* @return string
*/
public function getInterestPerDay(Account $account): string;
2018-03-19 02:17:31 -05:00
/**
* Return meta value for account. Null if not found.
*
* @param Account $account
2019-06-10 13:14:00 -05:00
* @param string $field
2018-03-19 02:17:31 -05:00
*
* @return null|string
*/
public function getMetaValue(Account $account, string $field): ?string;
/**
* Get note text or null.
*
* @param Account $account
*
* @return null|string
*/
public function getNoteText(Account $account): ?string;
2018-02-16 15:14:53 -06: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;
2018-12-09 06:09:43 -06:00
/**
* @param Account $account
*
* @return Collection
*/
public function getPiggyBanks(Account $account): Collection;
2017-11-22 10:49:06 -06:00
/**
* Find or create the opposing reconciliation account.
*
* @param Account $account
*
* @return Account|null
*/
public function getReconciliation(Account $account): ?Account;
2018-12-09 06:09:43 -06:00
/**
* @param Account $account
*
* @return bool
*/
public function isAsset(Account $account): bool;
/**
* @param Account $account
*
* @return bool
*/
public function isLiability(Account $account): bool;
/**
* Returns the date of the very first transaction in this account.
*
* @param Account $account
*
* @return TransactionJournal|null
*/
public function latestJournal(Account $account): ?TransactionJournal;
/**
* Returns the date of the very last transaction in this account.
*
* @param Account $account
*
* @return Carbon|null
*/
public function latestJournalDate(Account $account): ?Carbon;
/**
* Returns the date of the very first transaction in this account.
*
* @param Account $account
2018-08-04 10:30:47 -05:00
*
2018-07-24 13:30:52 -05:00
* @return TransactionJournal|null
*/
2018-07-24 13:30:52 -05:00
public function oldestJournal(Account $account): ?TransactionJournal;
/**
* Returns the date of the very first transaction in this account.
*
* @param Account $account
*
2018-08-07 12:29:10 -05:00
* @return Carbon|null
*/
2018-08-07 12:29:10 -05:00
public function oldestJournalDate(Account $account): ?Carbon;
2019-03-02 07:12:09 -06:00
/**
* @param string $query
2019-06-10 13:14:00 -05:00
* @param array $types
2019-03-02 07:12:09 -06:00
*
* @return Collection
*/
public function searchAccount(string $query, array $types): Collection;
2017-01-30 09:42:58 -06:00
/**
* @param User $user
*/
public function setUser(User $user);
2016-10-10 01:03:03 -05:00
/**
* @param array $data
*
* @return Account
*/
2016-11-28 11:55:56 -06:00
public function store(array $data): Account;
2016-10-10 01:03:03 -05:00
/**
* @param Account $account
2019-06-10 13:14:00 -05:00
* @param array $data
*
* @return Account
*/
public function update(Account $account, array $data): Account;
2015-03-29 01:14:32 -05:00
}