mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
PHP7 compatible function definitions.
This commit is contained in:
@@ -174,7 +174,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$journals = $this->user->transactionjournals()
|
||||
@@ -259,7 +259,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournals(Account $account, $page): LengthAwarePaginator
|
||||
public function getJournals(Account $account, int $page): LengthAwarePaginator
|
||||
{
|
||||
$offset = ($page - 1) * 50;
|
||||
$query = $this->user
|
||||
@@ -449,7 +449,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return AccountMeta
|
||||
*/
|
||||
public function storeMeta($account, $name, $value): AccountMeta
|
||||
public function storeMeta(Account $account, string $name, $value): AccountMeta
|
||||
{
|
||||
return AccountMeta::create(['name' => $name, 'data' => $value, 'account_id' => $account->id,]);
|
||||
}
|
||||
@@ -688,7 +688,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getIncomeByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function getIncomeByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$journals = $this->user->transactionjournals()
|
||||
|
@@ -82,7 +82,7 @@ interface AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
@@ -119,7 +119,7 @@ interface AccountRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getIncomeByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function getIncomeByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
@@ -127,7 +127,7 @@ interface AccountRepositoryInterface
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournals(Account $account, $page): LengthAwarePaginator;
|
||||
public function getJournals(Account $account, int $page): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Get the accounts of a user that have piggy banks connected to them.
|
||||
@@ -172,7 +172,7 @@ interface AccountRepositoryInterface
|
||||
*
|
||||
* @return AccountMeta
|
||||
*/
|
||||
public function storeMeta($account, $name, $value): AccountMeta;
|
||||
public function storeMeta(Account $account, string $name, $value): AccountMeta;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@@ -48,27 +48,28 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts): string
|
||||
{
|
||||
return $this->commonBalanceInPeriod($budget, $start, $end, $accounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function cleanupBudgets()
|
||||
public function cleanupBudgets(): bool
|
||||
{
|
||||
// delete limits with amount 0:
|
||||
BudgetLimit::where('amount', 0)->delete();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Budget $budget)
|
||||
public function destroy(Budget $budget): bool
|
||||
{
|
||||
$budget->delete();
|
||||
|
||||
@@ -114,7 +115,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function firstActivity(Budget $budget)
|
||||
public function firstActivity(Budget $budget): Carbon
|
||||
{
|
||||
$first = $budget->transactionjournals()->orderBy('date', 'ASC')->first();
|
||||
if ($first) {
|
||||
@@ -127,7 +128,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveBudgets()
|
||||
public function getActiveBudgets(): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->budgets()->where('active', 1)->get();
|
||||
@@ -147,7 +148,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end)
|
||||
public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
/** @var Collection $repetitions */
|
||||
return LimitRepetition::
|
||||
@@ -167,7 +168,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllWithoutBudget(Account $account, Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function getAllWithoutBudget(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
|
||||
@@ -192,7 +193,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end)
|
||||
public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$budgetIds = $budgets->pluck('id')->toArray();
|
||||
|
||||
@@ -218,7 +219,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBudgets()
|
||||
public function getBudgets(): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->budgets()->get();
|
||||
@@ -242,7 +243,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
|
||||
@@ -303,7 +304,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$budgetIds = $budgets->pluck('id')->toArray();
|
||||
@@ -362,7 +363,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end)
|
||||
public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user
|
||||
@@ -402,14 +403,17 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return LimitRepetition|null
|
||||
* @return LimitRepetition
|
||||
*/
|
||||
public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end)
|
||||
public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end): LimitRepetition
|
||||
{
|
||||
$data = $budget->limitrepetitions()
|
||||
->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00'))
|
||||
->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00'))
|
||||
->first(['limit_repetitions.*']);
|
||||
if(is_null($data)) {
|
||||
return new LimitRepetition;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -448,7 +452,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end)
|
||||
public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$set = $this->user->budgets()
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.budget_id', '=', 'budgets.id')
|
||||
@@ -471,7 +475,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getFirstBudgetLimitDate(Budget $budget)
|
||||
public function getFirstBudgetLimitDate(Budget $budget): Carbon
|
||||
{
|
||||
$limit = $budget->budgetlimits()->orderBy('startdate', 'ASC')->first();
|
||||
if ($limit) {
|
||||
@@ -484,7 +488,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getInactiveBudgets()
|
||||
public function getInactiveBudgets(): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->budgets()->where('active', 0)->get();
|
||||
@@ -507,7 +511,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50)
|
||||
public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50): LengthAwarePaginator
|
||||
{
|
||||
$offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0;
|
||||
$setQuery = $budget->transactionjournals()->expanded()
|
||||
@@ -539,7 +543,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end)
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
return $this->user
|
||||
->transactionjournals()
|
||||
@@ -559,7 +563,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
|
||||
@@ -633,7 +637,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
/** @var Collection $query */
|
||||
@@ -674,7 +678,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
$budgetIds = $budgets->pluck('id')->toArray();
|
||||
@@ -752,7 +756,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function store(array $data)
|
||||
public function store(array $data): Budget
|
||||
{
|
||||
$newBudget = new Budget(
|
||||
[
|
||||
@@ -771,7 +775,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function update(Budget $budget, array $data)
|
||||
public function update(Budget $budget, array $data): Budget
|
||||
{
|
||||
// update the account:
|
||||
$budget->name = $data['name'];
|
||||
@@ -788,7 +792,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return BudgetLimit
|
||||
*/
|
||||
public function updateLimitAmount(Budget $budget, Carbon $date, int $amount)
|
||||
public function updateLimitAmount(Budget $budget, Carbon $date, int $amount): BudgetLimit
|
||||
{
|
||||
// there should be a budget limit for this startdate:
|
||||
/** @var BudgetLimit $limit */
|
||||
|
@@ -6,6 +6,7 @@ namespace FireflyIII\Repositories\Budget;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -32,16 +33,16 @@ interface BudgetRepositoryInterface
|
||||
public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts);
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function cleanupBudgets();
|
||||
public function cleanupBudgets(): bool;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Budget $budget);
|
||||
public function destroy(Budget $budget): bool;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
@@ -67,12 +68,12 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function firstActivity(Budget $budget);
|
||||
public function firstActivity(Budget $budget): Carbon;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveBudgets();
|
||||
public function getActiveBudgets(): Collection;
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
@@ -80,17 +81,17 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end);
|
||||
public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $account
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllWithoutBudget(Account $account, Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function getAllWithoutBudget(Account $account, Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* Get the budgeted amounts for each budgets in each year.
|
||||
@@ -101,12 +102,12 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end);
|
||||
public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBudgets();
|
||||
public function getBudgets(): Collection;
|
||||
|
||||
/**
|
||||
* Returns an array with every budget in it and the expenses for each budget
|
||||
@@ -118,7 +119,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* Returns an array with every budget in it and the expenses for each budget
|
||||
@@ -131,7 +132,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* Returns a list of budgets, budget limits and limit repetitions
|
||||
@@ -142,16 +143,16 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end);
|
||||
public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return LimitRepetition|null
|
||||
* @return LimitRepetition
|
||||
*/
|
||||
public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end);
|
||||
public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end): LimitRepetition;
|
||||
|
||||
/**
|
||||
* Returns all expenses for the given budget and the given accounts, in the given period.
|
||||
@@ -175,19 +176,19 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end);
|
||||
public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end):Collection;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getFirstBudgetLimitDate(Budget $budget);
|
||||
public function getFirstBudgetLimitDate(Budget $budget):Carbon;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getInactiveBudgets();
|
||||
public function getInactiveBudgets(): Collection;
|
||||
|
||||
/**
|
||||
* Returns all the transaction journals for a limit, possibly limited by a limit repetition.
|
||||
@@ -198,7 +199,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50);
|
||||
public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
@@ -206,7 +207,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end);
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
@@ -215,7 +216,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
@@ -244,7 +245,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* Returns a list of expenses (in the field "spent", grouped per budget per account.
|
||||
@@ -256,7 +257,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* Returns an array with the following key:value pairs:
|
||||
@@ -279,7 +280,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function store(array $data);
|
||||
public function store(array $data): Budget;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
@@ -287,15 +288,15 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return Budget
|
||||
*/
|
||||
public function update(Budget $budget, array $data);
|
||||
public function update(Budget $budget, array $data) : Budget;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $date
|
||||
* @param int $amount
|
||||
*
|
||||
* @return mixed
|
||||
* @return BudgetLimit
|
||||
*/
|
||||
public function updateLimitAmount(Budget $budget, Carbon $date, int $amount);
|
||||
public function updateLimitAmount(Budget $budget, Carbon $date, int $amount) : BudgetLimit;
|
||||
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Sql\Query;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -19,6 +18,10 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class CategoryRepository implements CategoryRepositoryInterface
|
||||
{
|
||||
const SPENT = 1;
|
||||
const EARNED = 2;
|
||||
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
@@ -43,7 +46,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function earnedForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function earnedForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
|
||||
$collection = $this->user->categories()
|
||||
@@ -87,7 +90,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function listCategories()
|
||||
public function listCategories(): Collection
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = $this->user->categories()->orderBy('name', 'ASC')->get();
|
||||
@@ -114,7 +117,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
|
||||
$set = $this->user->categories()
|
||||
@@ -152,7 +155,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function listNoCategory(Carbon $start, Carbon $end)
|
||||
public function listNoCategory(Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
return $this->user
|
||||
->transactionjournals()
|
||||
@@ -177,7 +180,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function spentForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function spentForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
$query = $this->user->categories()
|
||||
@@ -228,9 +231,9 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sumEarnedNoCategory(Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function sumEarnedNoCategory(Collection $accounts, Carbon $start, Carbon $end): string
|
||||
{
|
||||
return $this->sumNoCategory($accounts, $start, $end, Query::EARNED);
|
||||
return $this->sumNoCategory($accounts, $start, $end, self::EARNED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,9 +246,9 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sumSpentNoCategory(Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function sumSpentNoCategory(Collection $accounts, Carbon $start, Carbon $end): string
|
||||
{
|
||||
return $this->sumNoCategory($accounts, $start, $end, Query::SPENT);
|
||||
return $this->sumNoCategory($accounts, $start, $end, self::SPENT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,10 +262,10 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function sumNoCategory(Collection $accounts, Carbon $start, Carbon $end, $group = Query::EARNED)
|
||||
protected function sumNoCategory(Collection $accounts, Carbon $start, Carbon $end, $group = self::EARNED)
|
||||
{
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
if ($group == Query::EARNED) {
|
||||
if ($group == self::EARNED) {
|
||||
$types = [TransactionType::DEPOSIT];
|
||||
} else {
|
||||
$types = [TransactionType::WITHDRAWAL];
|
||||
|
@@ -26,14 +26,14 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function earnedForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function earnedForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* Returns a list of all the categories belonging to a user.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function listCategories();
|
||||
public function listCategories(): Collection;
|
||||
|
||||
/**
|
||||
* This method returns a very special collection for each category:
|
||||
@@ -49,7 +49,7 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function listMultiYear(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* Returns a list of transaction journals in the range (all types, all accounts) that have no category
|
||||
@@ -60,7 +60,7 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function listNoCategory(Carbon $start, Carbon $end);
|
||||
public function listNoCategory(Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* Returns a collection of Categories appended with the amount of money that has been spent
|
||||
@@ -73,7 +73,7 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function spentForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function spentForAccountsPerMonth(Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* Returns the total amount of money related to transactions without any category connected to
|
||||
@@ -85,7 +85,7 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sumEarnedNoCategory(Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function sumEarnedNoCategory(Collection $accounts, Carbon $start, Carbon $end): string;
|
||||
|
||||
/**
|
||||
* Returns the total amount of money related to transactions without any category connected to
|
||||
@@ -97,6 +97,6 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sumSpentNoCategory(Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function sumSpentNoCategory(Collection $accounts, Carbon $start, Carbon $end): string;
|
||||
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countJournals(Category $category)
|
||||
public function countJournals(Category $category): int
|
||||
{
|
||||
return $category->transactionjournals()->count();
|
||||
|
||||
@@ -51,7 +51,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end)
|
||||
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end): int
|
||||
{
|
||||
return $category->transactionjournals()->before($end)->after($start)->count();
|
||||
}
|
||||
@@ -59,9 +59,9 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Category $category)
|
||||
public function destroy(Category $category): bool
|
||||
{
|
||||
$category->delete();
|
||||
|
||||
@@ -82,7 +82,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function earnedPerDay(Category $category, Carbon $start, Carbon $end)
|
||||
public function earnedPerDay(Category $category, Carbon $start, Carbon $end): array
|
||||
{
|
||||
/** @var Collection $query */
|
||||
$query = $category->transactionjournals()
|
||||
@@ -123,7 +123,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getFirstActivityDate(Category $category)
|
||||
public function getFirstActivityDate(Category $category): Carbon
|
||||
{
|
||||
/** @var TransactionJournal $first */
|
||||
$first = $category->transactionjournals()->orderBy('date', 'ASC')->first();
|
||||
@@ -141,7 +141,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournals(Category $category, $page)
|
||||
public function getJournals(Category $category, $page): Collection
|
||||
{
|
||||
$offset = $page > 0 ? $page * 50 : 0;
|
||||
|
||||
@@ -162,7 +162,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end)
|
||||
public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
|
||||
@@ -181,9 +181,9 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end)
|
||||
public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$offset = $page > 0 ? $page * 50 : 0;
|
||||
|
||||
@@ -201,7 +201,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function getLatestActivity(Category $category)
|
||||
public function getLatestActivity(Category $category): Carbon
|
||||
{
|
||||
$latest = $category->transactionjournals()
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
@@ -212,7 +212,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
return $latest->date;
|
||||
}
|
||||
|
||||
return null;
|
||||
return new Carbon('1900-01-01');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +229,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function spentPerDay(Category $category, Carbon $start, Carbon $end)
|
||||
public function spentPerDay(Category $category, Carbon $start, Carbon $end): array
|
||||
{
|
||||
/** @var Collection $query */
|
||||
$query = $category->transactionjournals()
|
||||
@@ -253,7 +253,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return Category
|
||||
*/
|
||||
public function store(array $data)
|
||||
public function store(array $data): Category
|
||||
{
|
||||
$newCategory = Category::firstOrCreateEncrypted(
|
||||
[
|
||||
@@ -272,7 +272,7 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
||||
*
|
||||
* @return Category
|
||||
*/
|
||||
public function update(Category $category, array $data)
|
||||
public function update(Category $category, array $data): Category
|
||||
{
|
||||
// update the account:
|
||||
$category->name = $data['name'];
|
||||
|
@@ -20,7 +20,7 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countJournals(Category $category);
|
||||
public function countJournals(Category $category): int;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
@@ -30,14 +30,14 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end);
|
||||
public function countJournalsInRange(Category $category, Carbon $start, Carbon $end): int;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy(Category $category);
|
||||
public function destroy(Category $category): bool;
|
||||
|
||||
/**
|
||||
* Returns an array with the following key:value pairs:
|
||||
@@ -53,7 +53,7 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function earnedPerDay(Category $category, Carbon $start, Carbon $end);
|
||||
public function earnedPerDay(Category $category, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* Find a category
|
||||
@@ -69,7 +69,7 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getFirstActivityDate(Category $category);
|
||||
public function getFirstActivityDate(Category $category): Carbon;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
@@ -77,7 +77,7 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournals(Category $category, $page);
|
||||
public function getJournals(Category $category, $page): Collection;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
@@ -88,7 +88,7 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end);
|
||||
public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
@@ -99,14 +99,14 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end);
|
||||
public function getJournalsInRange(Category $category, $page, Carbon $start, Carbon $end): Collection;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return Carbon|null
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getLatestActivity(Category $category);
|
||||
public function getLatestActivity(Category $category): Carbon;
|
||||
|
||||
/**
|
||||
* Returns an array with the following key:value pairs:
|
||||
@@ -122,7 +122,7 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function spentPerDay(Category $category, Carbon $start, Carbon $end);
|
||||
public function spentPerDay(Category $category, Carbon $start, Carbon $end): array;
|
||||
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return Category
|
||||
*/
|
||||
public function store(array $data);
|
||||
public function store(array $data): Category;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
@@ -138,5 +138,5 @@ interface SingleCategoryRepositoryInterface
|
||||
*
|
||||
* @return Category
|
||||
*/
|
||||
public function update(Category $category, array $data);
|
||||
public function update(Category $category, array $data): Category;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countJournals(TransactionCurrency $currency)
|
||||
public function countJournals(TransactionCurrency $currency): int
|
||||
{
|
||||
return $currency->transactionJournals()->count();
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function get()
|
||||
public function get(): Collection
|
||||
{
|
||||
return TransactionCurrency::get();
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function getCurrencyByPreference(Preference $preference)
|
||||
public function getCurrencyByPreference(Preference $preference): TransactionCurrency
|
||||
{
|
||||
$preferred = TransactionCurrency::whereCode($preference->data)->first();
|
||||
if (is_null($preferred)) {
|
||||
@@ -123,7 +123,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function store(array $data)
|
||||
public function store(array $data): TransactionCurrency
|
||||
{
|
||||
$currency = TransactionCurrency::create(
|
||||
[
|
||||
@@ -142,7 +142,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function update(TransactionCurrency $currency, array $data)
|
||||
public function update(TransactionCurrency $currency, array $data): TransactionCurrency
|
||||
{
|
||||
$currency->code = $data['code'];
|
||||
$currency->symbol = $data['symbol'];
|
||||
|
@@ -20,7 +20,7 @@ interface CurrencyRepositoryInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countJournals(TransactionCurrency $currency);
|
||||
public function countJournals(TransactionCurrency $currency): int;
|
||||
|
||||
/**
|
||||
* Find by ID
|
||||
@@ -61,21 +61,21 @@ interface CurrencyRepositoryInterface
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function get();
|
||||
public function get(): Collection;
|
||||
|
||||
/**
|
||||
* @param Preference $preference
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function getCurrencyByPreference(Preference $preference);
|
||||
public function getCurrencyByPreference(Preference $preference): TransactionCurrency;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function store(array $data);
|
||||
public function store(array $data): TransactionCurrency;
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
@@ -83,6 +83,6 @@ interface CurrencyRepositoryInterface
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function update(TransactionCurrency $currency, array $data);
|
||||
public function update(TransactionCurrency $currency, array $data): TransactionCurrency;
|
||||
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function cleanup()
|
||||
public function cleanup(): bool
|
||||
{
|
||||
$dayAgo = Carbon::create()->subDay();
|
||||
$set = ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s'))
|
||||
@@ -66,7 +66,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
/**
|
||||
* @return ExportJob
|
||||
*/
|
||||
public function create()
|
||||
public function create(): ExportJob
|
||||
{
|
||||
$exportJob = new ExportJob;
|
||||
$exportJob->user()->associate($this->user);
|
||||
@@ -81,11 +81,14 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* FIXME this may return null
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return ExportJob|null
|
||||
*/
|
||||
public function findByKey(string $key)
|
||||
public function findByKey(string $key): ExportJob
|
||||
{
|
||||
return $this->user->exportJobs()->where('key', $key)->first();
|
||||
}
|
||||
|
@@ -22,18 +22,18 @@ interface ExportJobRepositoryInterface
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function cleanup();
|
||||
public function cleanup(): bool;
|
||||
|
||||
/**
|
||||
* @return ExportJob
|
||||
*/
|
||||
public function create();
|
||||
public function create(): ExportJob;
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return ExportJob|null
|
||||
*/
|
||||
public function findByKey(string $key);
|
||||
public function findByKey(string $key): ExportJob;
|
||||
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ class JournalCollector
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function collect()
|
||||
public function collect(): Collection
|
||||
{
|
||||
// get all the journals:
|
||||
$ids = $this->accounts->pluck('id')->toArray();
|
||||
|
Reference in New Issue
Block a user