2015-02-09 00:23:39 -06:00
|
|
|
<?php
|
2016-05-20 05:41:23 -05:00
|
|
|
/**
|
|
|
|
* AccountRepositoryInterface.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
|
|
|
* of the MIT license. See the LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
2016-02-05 05:08:25 -06: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;
|
2015-04-03 02:30:44 -05:00
|
|
|
use FireflyIII\Models\Transaction;
|
2015-03-29 14:27:51 -05:00
|
|
|
use FireflyIII\Models\TransactionJournal;
|
2015-03-13 02:44:07 -05:00
|
|
|
use Illuminate\Support\Collection;
|
2015-03-29 14:27:51 -05:00
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
|
|
|
* Interface AccountRepositoryInterface
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Repositories\Account
|
|
|
|
*/
|
2015-02-09 00:23:39 -06:00
|
|
|
interface AccountRepositoryInterface
|
|
|
|
{
|
2016-02-04 01:53:15 -06:00
|
|
|
|
2015-04-04 14:23:37 -05:00
|
|
|
/**
|
|
|
|
* @param array $types
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
2016-02-06 09:22:12 -06:00
|
|
|
public function countAccounts(array $types): int;
|
2015-04-04 14:23:37 -05:00
|
|
|
|
2016-05-19 23:58:13 -05:00
|
|
|
/**
|
|
|
|
* This method is almost the same as ::earnedInPeriod, but only works for revenue accounts
|
|
|
|
* instead of the implied asset accounts for ::earnedInPeriod. ::earnedInPeriod will tell you
|
|
|
|
* how much money was earned by the given asset accounts. This method will tell you how much money
|
|
|
|
* these given revenue accounts sent. Ie. how much money was made FROM these revenue accounts.
|
|
|
|
*
|
|
|
|
* @param Collection $accounts
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function earnedFromInPeriod(Collection $accounts, Carbon $start, Carbon $end): string;
|
|
|
|
|
2016-05-13 08:53:39 -05:00
|
|
|
/**
|
|
|
|
* @param Collection $accounts
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function earnedInPeriod(Collection $accounts, Carbon $start, Carbon $end): string;
|
|
|
|
|
2016-05-19 23:58:13 -05:00
|
|
|
/**
|
|
|
|
* This method will call AccountRepositoryInterface::journalsInPeriod and get all withdrawaks made from 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 expensesInPeriod(Collection $accounts, Carbon $start, Carbon $end): Collection;
|
|
|
|
|
2016-05-13 08:53:39 -05:00
|
|
|
/**
|
|
|
|
* @param Account $account
|
|
|
|
*
|
|
|
|
* @return Carbon
|
|
|
|
*/
|
|
|
|
public function firstUseDate(Account $account): Carbon;
|
|
|
|
|
2016-02-04 01:53:15 -06:00
|
|
|
/**
|
|
|
|
* Gets all the accounts by ID, for a given set.
|
|
|
|
*
|
|
|
|
* @param array $ids
|
|
|
|
*
|
2016-02-23 08:54:13 -06:00
|
|
|
* @return \Illuminate\Support\Collection
|
2016-02-04 01:53:15 -06:00
|
|
|
*/
|
2016-02-06 09:22:12 -06:00
|
|
|
public function get(array $ids): Collection;
|
2016-02-04 01:53:15 -06:00
|
|
|
|
2015-04-13 13:43:58 -05:00
|
|
|
/**
|
2016-01-19 06:59:54 -06:00
|
|
|
* @param TransactionJournal $journal
|
|
|
|
* @param Account $account
|
2015-04-13 13:43:58 -05:00
|
|
|
*
|
2016-01-19 06:59:54 -06:00
|
|
|
* @return Transaction
|
2015-04-13 13:43:58 -05:00
|
|
|
*/
|
2016-02-06 09:22:12 -06:00
|
|
|
public function getFirstTransaction(TransactionJournal $journal, Account $account): Transaction;
|
2015-04-13 13:43:58 -05:00
|
|
|
|
2015-03-13 02:44:07 -05:00
|
|
|
/**
|
2016-01-19 06:59:54 -06:00
|
|
|
* Get the accounts of a user that have piggy banks connected to them.
|
|
|
|
*
|
2016-05-13 10:22:24 -05:00
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
2016-01-19 06:59:54 -06:00
|
|
|
* @return Collection
|
2015-04-07 13:54:43 -05:00
|
|
|
*/
|
2016-05-13 10:22:24 -05:00
|
|
|
public function getPiggyBankAccounts(Carbon $start, Carbon $end): Collection;
|
2015-04-07 13:54:43 -05:00
|
|
|
|
2015-02-21 05:16:41 -06:00
|
|
|
/**
|
2016-05-13 10:22:24 -05:00
|
|
|
* Get savings accounts.
|
|
|
|
*
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
2015-02-21 05:16:41 -06:00
|
|
|
*
|
2015-04-04 14:23:37 -05:00
|
|
|
* @return Collection
|
2015-02-21 05:16:41 -06:00
|
|
|
*/
|
2016-05-13 10:22:24 -05:00
|
|
|
public function getSavingsAccounts(Carbon $start, Carbon $end): Collection;
|
2015-02-14 07:25:29 -06:00
|
|
|
|
2016-05-15 10:46:53 -05:00
|
|
|
/**
|
2016-05-15 11:16:31 -05:00
|
|
|
* This method will call AccountRepositoryInterface::journalsInPeriod and get all deposits made to the given $accounts,
|
2016-05-16 02:05:06 -05:00
|
|
|
* as well as the transfers that move to to those $accounts. This is a slightly sharper selection
|
2016-05-15 10:46:53 -05:00
|
|
|
* 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 05:16:41 -06:00
|
|
|
/**
|
2016-05-13 08:53:39 -05: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 05:16:41 -06:00
|
|
|
* @param Account $account
|
2015-05-20 12:55:53 -05:00
|
|
|
* @param Carbon $date
|
2015-02-21 05:16:41 -06:00
|
|
|
*
|
2016-02-06 09:22:12 -06:00
|
|
|
* @return string
|
2015-02-21 05:16:41 -06:00
|
|
|
*/
|
2016-02-06 09:22:12 -06:00
|
|
|
public function leftOnAccount(Account $account, Carbon $date): string;
|
2015-02-24 14:10:25 -06:00
|
|
|
|
2016-04-08 07:50:18 -05: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 14:10:25 -06:00
|
|
|
/**
|
2016-05-13 08:53:39 -05:00
|
|
|
*
|
2015-02-24 14:10:25 -06:00
|
|
|
* @param Account $account
|
|
|
|
*
|
2016-02-06 09:22:12 -06:00
|
|
|
* @return TransactionJournal
|
2015-02-24 14:10:25 -06:00
|
|
|
*/
|
2016-02-06 09:22:12 -06:00
|
|
|
public function openingBalanceTransaction(Account $account) : TransactionJournal;
|
2015-03-21 02:51:34 -05:00
|
|
|
|
2016-05-19 23:58:13 -05:00
|
|
|
/**
|
|
|
|
* This method is almost the same as ::spentInPeriod, but only works for expense accounts
|
|
|
|
* instead of the implied asset accounts for ::spentInPeriod. ::spentInPeriod will tell you
|
|
|
|
* how much money was spent by the given asset accounts. This method will tell you how much money
|
|
|
|
* these given expense accounts received. Ie. how much money was spent AT these expense accounts.
|
|
|
|
*
|
|
|
|
* @param Collection $accounts
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function spentAtInPeriod(Collection $accounts, Carbon $start, Carbon $end): string;
|
|
|
|
|
2016-05-13 08:53:39 -05:00
|
|
|
/**
|
|
|
|
* @param Collection $accounts
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function spentInPeriod(Collection $accounts, Carbon $start, Carbon $end): string;
|
2016-05-20 04:02:07 -05:00
|
|
|
|
2015-03-29 01:14:32 -05:00
|
|
|
}
|