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

283 lines
7.2 KiB
PHP
Raw Normal View History

2015-02-22 02:46:21 -06:00
<?php
/**
* BudgetRepositoryInterface.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-22 02:46:21 -06:00
namespace FireflyIII\Repositories\Budget;
2015-02-23 14:19:16 -06:00
use Carbon\Carbon;
2018-06-24 01:33:06 -05:00
use FireflyIII\Models\AvailableBudget;
2015-02-22 02:46:21 -06:00
use FireflyIII\Models\Budget;
2016-04-05 15:00:03 -05:00
use FireflyIII\Models\BudgetLimit;
2016-12-22 09:36:56 -06:00
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
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
/**
2017-11-15 05:25:49 -06:00
* Interface BudgetRepositoryInterface.
2015-02-22 02:46:21 -06:00
*/
interface BudgetRepositoryInterface
{
2018-05-07 13:35:14 -05:00
2018-03-24 00:46:37 -05:00
/**
* A method that returns the amount of money budgeted per day for this budget,
* on average.
*
* @param Budget $budget
*
* @return string
*/
public function budgetedPerDay(Budget $budget): string;
2018-04-02 08:10:40 -05:00
/**
* @return bool
*/
public function cleanupBudgets(): bool;
2017-09-27 01:45:27 -05:00
/**
* This method collects various info on budgets, used on the budget page and on the index.
*
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array;
2016-05-05 23:15:46 -05:00
/**
* @param Budget $budget
*
* @return bool
*/
public function destroy(Budget $budget): bool;
2018-06-24 01:33:06 -05:00
/**
* @param AvailableBudget $availableBudget
*/
public function destroyAvailableBudget(AvailableBudget $availableBudget): void;
/**
* Destroy a budget limit.
*
* @param BudgetLimit $budgetLimit
*/
public function destroyBudgetLimit(BudgetLimit $budgetLimit): void;
2018-02-16 08:19:19 -06:00
/**
2018-03-10 15:38:20 -06:00
* Find a budget.
2018-02-16 08:19:19 -06:00
*
2018-03-10 15:38:20 -06:00
* @param string $name
2018-02-16 08:19:19 -06:00
*
* @return Budget|null
*/
2018-03-10 15:38:20 -06:00
public function findByName(string $name): ?Budget;
2018-02-16 08:19:19 -06:00
/**
2018-07-05 11:02:02 -05:00
* @param int|null $budgetId
*
2018-02-16 08:19:19 -06:00
* @return Budget|null
*/
2018-07-05 11:02:02 -05:00
public function findNull(int $budgetId = null): ?Budget;
/**
* This method returns the oldest journal or transaction date known to this budget.
* Will cache result.
2016-05-11 02:08:18 -05:00
*
* @param Budget $budget
*
* @return Carbon
*/
2018-07-23 14:49:15 -05:00
public function firstUseDate(Budget $budget): ?Carbon;
2016-04-01 06:17:07 -05:00
/**
2016-05-05 23:15:46 -05:00
* @return Collection
2016-04-01 06:17:07 -05:00
*/
2016-05-05 23:15:46 -05:00
public function getActiveBudgets(): Collection;
2016-04-01 06:17:07 -05:00
2016-12-30 06:47:23 -06:00
/**
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
2018-06-24 06:20:29 -05:00
public function getAllBudgetLimits(Carbon $start = null, Carbon $end = null): Collection;
2016-12-30 06:47:23 -06:00
2016-12-22 09:36:56 -06:00
/**
* @param TransactionCurrency $currency
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string;
2018-06-24 01:33:06 -05:00
/**
* Returns all available budget objects.
*
* @return Collection
*/
public function getAvailableBudgets(): Collection;
/**
* Calculate the average amount in the budgets available in this period.
* Grouped by day.
*
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
public function getAverageAvailable(Carbon $start, Carbon $end): string;
2016-12-29 13:48:33 -06:00
/**
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
2018-06-24 06:20:29 -05:00
public function getBudgetLimits(Budget $budget, Carbon $start = null, Carbon $end = null): Collection;
2016-12-29 13:48:33 -06:00
2018-07-22 11:50:27 -05:00
/** @noinspection MoreThanThreeArgumentsInspection */
2016-11-19 06:37:44 -06:00
/**
* @param Collection $budgets
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
2016-11-19 06:37:44 -06:00
*/
public function getBudgetPeriodReport(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array;
2016-11-19 06:37:44 -06:00
2016-05-05 23:15:46 -05:00
/**
* @return Collection
*/
public function getBudgets(): Collection;
2018-06-06 14:23:00 -05:00
/**
* Get all budgets with these ID's.
*
* @param array $budgetIds
*
* @return Collection
*/
public function getByIds(array $budgetIds): Collection;
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-05-05 23:15:46 -05:00
public function getInactiveBudgets(): Collection;
2015-02-22 02:46:21 -06:00
/**
2016-12-15 10:16:46 -06:00
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function getNoBudgetPeriodReport(Collection $accounts, Carbon $start, Carbon $end): array;
2018-07-22 11:50:27 -05:00
/** @noinspection MoreThanThreeArgumentsInspection */
2016-12-22 09:36:56 -06:00
/**
* @param TransactionCurrency $currency
* @param Carbon $start
* @param Carbon $end
* @param string $amount
*
2018-06-24 01:33:06 -05:00
* @return AvailableBudget
2016-12-22 09:36:56 -06:00
*/
2018-06-24 01:33:06 -05:00
public function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): AvailableBudget;
2016-12-22 09:36:56 -06:00
2017-01-30 09:46:30 -06:00
/**
* @param User $user
*/
public function setUser(User $user);
2018-07-22 11:50:27 -05:00
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $budgets
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
2017-01-05 02:08:35 -06:00
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string;
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
2017-01-05 02:10:04 -06:00
public function spentInPeriodWoBudget(Collection $accounts, Carbon $start, Carbon $end): string;
2015-02-22 08:40:13 -06:00
/**
* @param array $data
*
* @return Budget
*/
2016-04-05 15:00:03 -05:00
public function store(array $data): Budget;
2015-02-22 08:40:13 -06:00
2018-06-29 22:21:21 -05:00
/**
* @param array $data
*
* @return BudgetLimit
*/
public function storeBudgetLimit(array $data): BudgetLimit;
2015-02-22 08:40:13 -06:00
/**
* @param Budget $budget
2015-02-23 14:19:16 -06:00
* @param array $data
2015-02-22 08:40:13 -06:00
*
* @return Budget
*/
2016-12-03 14:03:20 -06:00
public function update(Budget $budget, array $data): Budget;
2015-02-22 08:40:13 -06:00
2018-06-24 01:33:06 -05:00
/**
* @param AvailableBudget $availableBudget
* @param array $data
*
* @return AvailableBudget
*/
public function updateAvailableBudget(AvailableBudget $availableBudget, array $data): AvailableBudget;
2018-06-24 06:20:29 -05:00
/**
* @param BudgetLimit $budgetLimit
* @param array $data
*
* @return BudgetLimit
*/
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit;
2018-07-22 11:50:27 -05:00
/** @noinspection MoreThanThreeArgumentsInspection */
2015-02-22 08:40:13 -06:00
/**
* @param Budget $budget
2016-04-28 03:59:36 -05:00
* @param Carbon $start
* @param Carbon $end
2017-11-25 01:54:52 -06:00
* @param string $amount
2015-02-22 08:40:13 -06:00
*
* @return BudgetLimit|null
2015-02-22 08:40:13 -06:00
*/
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit;
2015-03-29 01:14:32 -05:00
}