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

203 lines
4.7 KiB
PHP
Raw Normal View History

2015-02-09 07:23:39 +01:00
<?php
2016-02-05 12:08:25 +01: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;
use FireflyIII\Models\Account;
2016-03-12 11:07:54 +01:00
use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\Transaction;
2015-03-29 21:27:51 +02:00
use FireflyIII\Models\TransactionJournal;
2015-03-13 08:44:07 +01:00
use Illuminate\Support\Collection;
2015-03-29 21:27:51 +02:00
2015-02-11 07:35:10 +01:00
/**
* Interface AccountRepositoryInterface
*
* @package FireflyIII\Repositories\Account
*/
2015-02-09 07:23:39 +01:00
interface AccountRepositoryInterface
{
/**
* @param array $types
*
* @return int
*/
2016-02-06 16:22:12 +01:00
public function countAccounts(array $types): int;
/**
* @param Account $account
2015-07-10 20:48:45 +02:00
* @param Account $moveTo
*
2016-04-06 09:27:45 +02:00
* @return bool
*/
2016-03-12 11:05:26 +01:00
public function destroy(Account $account, Account $moveTo): bool;
2016-05-13 15:53:39 +02:00
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function earnedInPeriod(Collection $accounts, Carbon $start, Carbon $end): string;
2015-03-13 08:44:07 +01:00
/**
2016-02-05 09:25:15 +01:00
* @param int $accountId
*
2016-01-19 13:59:54 +01:00
* @return Account
*/
2016-02-06 16:22:12 +01:00
public function find(int $accountId): Account;
2016-05-13 15:53:39 +02:00
/**
* @param Account $account
*
* @return Carbon
*/
public function firstUseDate(Account $account): Carbon;
/**
* Gets all the accounts by ID, for a given set.
*
* @param array $ids
*
2016-02-23 15:54:13 +01:00
* @return \Illuminate\Support\Collection
*/
2016-02-06 16:22:12 +01:00
public function get(array $ids): Collection;
/**
2016-05-13 15:53:39 +02:00
* @param array $accountIds
2015-12-27 07:59:00 +01:00
*
2015-04-07 10:14:10 +02:00
* @return Collection
*/
2016-05-13 15:53:39 +02:00
public function getAccountsById(array $accountIds): Collection;
2015-04-07 10:14:10 +02:00
2016-04-03 11:14:36 +02:00
/**
2016-05-13 15:53:39 +02:00
* @param array $types
2016-04-03 11:14:36 +02:00
*
* @return Collection
*/
2016-05-13 15:53:39 +02:00
public function getAccountsByType(array $types): Collection;
2016-04-03 11:14:36 +02:00
/**
2016-01-19 13:59:54 +01:00
* @param TransactionJournal $journal
* @param Account $account
*
2016-01-19 13:59:54 +01:00
* @return Transaction
*/
2016-02-06 16:22:12 +01:00
public function getFirstTransaction(TransactionJournal $journal, Account $account): Transaction;
2015-03-13 08:44:07 +01:00
/**
2016-01-19 13:59:54 +01:00
* Get the accounts of a user that have piggy banks connected to them.
*
2016-05-13 17:22:24 +02:00
* @param Carbon $start
* @param Carbon $end
*
2016-01-19 13:59:54 +01:00
* @return Collection
2015-04-07 20:54:43 +02:00
*/
2016-05-13 17:22:24 +02:00
public function getPiggyBankAccounts(Carbon $start, Carbon $end): Collection;
2015-04-07 20:54:43 +02:00
2015-02-21 12:16:41 +01:00
/**
2016-05-13 17:22:24 +02:00
* Get savings accounts.
*
* @param Carbon $start
* @param Carbon $end
2015-02-21 12:16:41 +01:00
*
* @return Collection
2015-02-21 12:16:41 +01:00
*/
2016-05-13 17:22:24 +02:00
public function getSavingsAccounts(Carbon $start, Carbon $end): Collection;
2016-05-15 17:46:53 +02:00
/**
* This method will call AccountRepositoryInterface::journalsInPeriod and get all deposits made by the given $accounts,
* as well as the transfers that move away from those $accounts. This is a slightly sharper selection
* than made by journalsInPeriod itself.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @see AccountRepositoryInterface::journalsInPeriod
*
* @return Collection
*/
public function incomesInPeriod(Collection $accounts, Carbon $start, Carbon $end): Collection;
2015-02-21 12:16:41 +01:00
/**
2016-05-13 15:53:39 +02:00
* @param Collection $accounts
* @param array $types
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
public function journalsInPeriod(Collection $accounts, array $types, Carbon $start, Carbon $end): Collection;
/**
*
2015-02-21 12:16:41 +01:00
* @param Account $account
2015-05-20 19:55:53 +02:00
* @param Carbon $date
2015-02-21 12:16:41 +01:00
*
2016-02-06 16:22:12 +01:00
* @return string
2015-02-21 12:16:41 +01:00
*/
2016-02-06 16:22:12 +01:00
public function leftOnAccount(Account $account, Carbon $date): string;
2015-02-24 21:10:25 +01:00
/**
* Returns the date of the very last transaction in this account.
*
* @param Account $account
*
* @return Carbon
*/
public function newestJournalDate(Account $account): Carbon;
/**
* Returns the date of the very first transaction in this account.
*
* @param Account $account
*
* @return Carbon
*/
public function oldestJournalDate(Account $account): Carbon;
2015-02-24 21:10:25 +01:00
/**
2016-05-13 15:53:39 +02:00
*
2015-02-24 21:10:25 +01:00
* @param Account $account
*
2016-02-06 16:22:12 +01:00
* @return TransactionJournal
2015-02-24 21:10:25 +01:00
*/
2016-02-06 16:22:12 +01:00
public function openingBalanceTransaction(Account $account) : TransactionJournal;
2015-03-21 08:51:34 +01:00
2016-05-13 15:53:39 +02:00
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function spentInPeriod(Collection $accounts, Carbon $start, Carbon $end): string;
2015-03-21 08:51:34 +01:00
/**
* @param array $data
2015-03-21 08:51:34 +01:00
*
* @return Account
2015-03-21 08:51:34 +01:00
*/
2016-02-06 16:22:12 +01:00
public function store(array $data) : Account;
2016-03-12 11:07:54 +01:00
/**
* @param $account
* @param $name
* @param $value
*
* @return AccountMeta
*/
2016-04-05 22:00:03 +02:00
public function storeMeta(Account $account, string $name, $value): AccountMeta;
2016-03-12 11:07:54 +01:00
/**
* @param Account $account
* @param array $data
*
* @return Account
*/
2016-02-06 16:22:12 +01:00
public function update(Account $account, array $data): Account;
2015-03-29 08:14:32 +02:00
}