firefly-iii/app/Repositories/Budget/BudgetRepositoryInterface.php

251 lines
6.1 KiB
PHP
Raw Normal View History

2015-02-22 02:46:21 -06:00
<?php
2016-02-05 05:08:25 -06:00
declare(strict_types = 1);
2015-02-22 02:46:21 -06:00
namespace FireflyIII\Repositories\Budget;
2015-02-23 14:19:16 -06:00
use Carbon\Carbon;
2015-02-22 02:46:21 -06:00
use FireflyIII\Models\Budget;
2015-02-22 08:40:13 -06:00
use FireflyIII\Models\LimitRepetition;
2015-05-26 13:28:18 -05:00
use Illuminate\Pagination\LengthAwarePaginator;
2015-04-05 03:36:28 -05:00
use Illuminate\Support\Collection;
2015-02-23 14:19:16 -06:00
2015-02-22 02:46:21 -06:00
/**
* Interface BudgetRepositoryInterface
*
* @package FireflyIII\Repositories\Budget
*/
interface BudgetRepositoryInterface
{
2016-01-01 12:46:12 -06:00
2016-01-20 08:21:27 -06:00
/**
*
* Same as ::spentInPeriod but corrects journals for a set of accounts
*
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return string
*/
public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts);
/**
* @return void
*/
public function cleanupBudgets();
2015-12-29 01:27:13 -06:00
/**
* @param Budget $budget
*
2016-01-20 08:21:27 -06:00
* @return boolean
2015-12-29 01:27:13 -06:00
*/
2016-01-20 08:21:27 -06:00
public function destroy(Budget $budget);
2015-12-29 01:27:13 -06:00
/**
* @param Budget $budget
*
* @return Carbon
*/
public function firstActivity(Budget $budget);
/**
* @return Collection
*/
2016-01-20 08:21:27 -06:00
public function getActiveBudgets();
2016-01-01 12:46:12 -06:00
/**
* @param Carbon $start
* @param Carbon $end
*
2016-01-20 08:21:27 -06:00
* @return Collection
*/
2016-01-20 08:21:27 -06:00
public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end);
2016-01-01 06:54:23 -06:00
/**
2016-01-20 08:21:27 -06:00
* Get the budgeted amounts for each budgets in each year.
2016-01-01 06:54:23 -06:00
*
2016-01-20 08:21:27 -06:00
* @param Collection $budgets
2016-01-01 14:15:03 -06:00
* @param Carbon $start
* @param Carbon $end
2016-01-01 06:54:23 -06:00
*
2016-01-20 08:21:27 -06:00
* @return Collection
2016-01-01 06:54:23 -06:00
*/
2016-01-20 08:21:27 -06:00
public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end);
2015-02-22 08:40:13 -06:00
/**
2016-01-20 08:21:27 -06:00
* @return Collection
2015-02-22 08:40:13 -06:00
*/
2016-01-20 08:21:27 -06:00
public function getBudgets();
2015-02-22 02:46:21 -06:00
2015-12-28 10:57:03 -06:00
/**
* Returns an array with every budget in it and the expenses for each budget
* per month.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end);
/**
* Returns an array with every budget in it and the expenses for each budget
* per year for.
*
* @param Collection $budgets
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
2015-12-28 10:57:03 -06:00
*
* @return array
*/
public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end);
2015-12-28 10:57:03 -06:00
2015-04-05 03:36:28 -05:00
/**
2016-01-20 08:21:27 -06:00
* Returns a list of budgets, budget limits and limit repetitions
* (doubling any of them in a left join)
*
2016-01-20 08:21:27 -06:00
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
2016-01-20 08:21:27 -06:00
public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end);
2015-04-05 03:36:28 -05:00
2016-01-01 06:54:23 -06:00
/**
2016-01-20 08:21:27 -06:00
* @param Budget $budget
2016-01-01 06:54:23 -06:00
* @param Carbon $start
* @param Carbon $end
*
2016-01-20 08:21:27 -06:00
* @return LimitRepetition|null
*/
2016-01-20 08:21:27 -06:00
public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end);
2015-04-03 12:39:36 -05:00
2015-12-27 14:17:04 -06:00
/**
2016-01-20 08:21:27 -06:00
* Returns the expenses for this budget grouped per day, with the date
* in "date" (a string, not a Carbon) and the amount in "dailyAmount".
2015-12-27 14:17:04 -06:00
*
2016-01-20 08:21:27 -06:00
* @param Budget $budget
2015-12-27 14:17:04 -06:00
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
2016-01-20 08:21:27 -06:00
public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end);
2015-12-27 14:17:04 -06:00
2015-04-07 10:51:22 -05:00
/**
* @param Budget $budget
*
* @return Carbon
*/
public function getFirstBudgetLimitDate(Budget $budget);
2015-04-05 03:36:28 -05:00
/**
* @return Collection
*/
public function getInactiveBudgets();
2015-04-05 03:36:28 -05:00
/**
* Returns all the transaction journals for a limit, possibly limited by a limit repetition.
*
* @param Budget $budget
* @param LimitRepetition $repetition
* @param int $take
*
2015-05-26 13:28:18 -05:00
* @return LengthAwarePaginator
*/
2016-02-05 02:30:06 -06:00
public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50);
/**
* @param Carbon $start
* @param Carbon $end
2015-04-05 03:36:28 -05:00
*
* @return Collection
*/
public function getWithoutBudget(Carbon $start, Carbon $end);
2015-04-05 03:36:28 -05:00
/**
* @param Carbon $start
* @param Carbon $end
2015-04-05 03:36:28 -05:00
*
* @return mixed
2015-04-05 03:36:28 -05:00
*/
public function getWithoutBudgetSum(Carbon $start, Carbon $end);
2015-04-05 03:36:28 -05:00
/**
2016-01-20 08:21:27 -06:00
* Returns an array with the following key:value pairs:
*
2016-01-20 08:21:27 -06:00
* yyyy-mm-dd:<array>
*
2016-01-20 08:21:27 -06:00
* That array contains:
*
* budgetid:<amount>
*
* Where yyyy-mm-dd is the date and <amount> is the money spent using WITHDRAWALS in the $budget
* from the given users accounts..
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
2016-01-20 08:21:27 -06:00
*
* @return array
*/
public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end);
/**
* Returns a list of expenses (in the field "spent", grouped per budget per account.
*
* @param Collection $budgets
* @param Collection $accounts
2016-01-20 08:21:27 -06:00
* @param Carbon $start
* @param Carbon $end
*
2016-01-20 08:21:27 -06:00
* @return Collection
*/
2016-01-20 08:21:27 -06:00
public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end);
/**
* Returns an array with the following key:value pairs:
*
* yyyy-mm-dd:<amount>
*
* Where yyyy-mm-dd is the date and <amount> is the money spent using WITHDRAWALS in the $budget
* from all the users accounts.
*
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
2016-02-10 05:01:45 -06:00
public function spentPerDay(Budget $budget, Carbon $start, Carbon $end): array;
2015-02-22 08:40:13 -06:00
/**
* @param array $data
*
* @return Budget
*/
public function store(array $data);
/**
* @param Budget $budget
2015-02-23 14:19:16 -06:00
* @param array $data
2015-02-22 08:40:13 -06:00
*
* @return Budget
*/
public function update(Budget $budget, array $data);
/**
* @param Budget $budget
* @param Carbon $date
2016-02-05 08:41:40 -06:00
* @param int $amount
2015-02-22 08:40:13 -06:00
*
* @return mixed
2015-02-22 08:40:13 -06:00
*/
2016-02-05 08:41:40 -06:00
public function updateLimitAmount(Budget $budget, Carbon $date, int $amount);
2015-02-22 08:40:13 -06:00
2015-03-29 01:14:32 -05:00
}