2015-02-22 09:46:21 +01:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* BudgetRepositoryInterface.php
|
2017-10-21 08:40:00 +02:00
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
2016-05-20 12:41:23 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* This file is part of Firefly III.
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02: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 14:44:05 +01:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2016-05-20 12:41:23 +02:00
|
|
|
*/
|
2017-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2015-02-22 09:46:21 +01:00
|
|
|
|
|
|
|
namespace FireflyIII\Repositories\Budget;
|
2015-02-23 21:19:16 +01:00
|
|
|
|
|
|
|
use Carbon\Carbon;
|
2018-06-24 08:33:06 +02:00
|
|
|
use FireflyIII\Models\AvailableBudget;
|
2015-02-22 09:46:21 +01:00
|
|
|
use FireflyIII\Models\Budget;
|
2016-04-05 22:00:03 +02:00
|
|
|
use FireflyIII\Models\BudgetLimit;
|
2016-12-22 16:36:56 +01:00
|
|
|
use FireflyIII\Models\TransactionCurrency;
|
2017-01-30 16:40:49 +01:00
|
|
|
use FireflyIII\User;
|
2015-04-05 10:36:28 +02:00
|
|
|
use Illuminate\Support\Collection;
|
2015-02-23 21:19:16 +01:00
|
|
|
|
2015-02-22 09:46:21 +01:00
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Interface BudgetRepositoryInterface.
|
2015-02-22 09:46:21 +01:00
|
|
|
*/
|
|
|
|
interface BudgetRepositoryInterface
|
|
|
|
{
|
2018-04-02 15:10:40 +02:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function cleanupBudgets(): bool;
|
|
|
|
|
2016-05-06 06:15:46 +02:00
|
|
|
/**
|
|
|
|
* @param Budget $budget
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function destroy(Budget $budget): bool;
|
|
|
|
|
2019-03-17 17:05:16 +01:00
|
|
|
/**
|
2019-08-29 21:33:12 +02:00
|
|
|
* @param int|null $budgetId
|
2019-03-17 17:05:16 +01:00
|
|
|
* @param string|null $budgetName
|
|
|
|
*
|
|
|
|
* @return Budget|null
|
|
|
|
*/
|
2019-06-04 20:42:11 +02:00
|
|
|
public function findBudget(?int $budgetId, ?string $budgetName): ?Budget;
|
2019-03-17 17:05:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find budget by name.
|
|
|
|
*
|
|
|
|
* @param string|null $name
|
|
|
|
*
|
|
|
|
* @return Budget|null
|
|
|
|
*/
|
|
|
|
public function findByName(?string $name): ?Budget;
|
|
|
|
|
2016-07-24 18:47:55 +02:00
|
|
|
/**
|
2019-08-30 07:49:08 +02:00
|
|
|
* TODO refactor to "find"
|
|
|
|
*
|
2018-07-05 18:02:02 +02:00
|
|
|
* @param int|null $budgetId
|
2016-07-24 18:47:55 +02:00
|
|
|
*
|
2018-02-16 15:19:19 +01:00
|
|
|
* @return Budget|null
|
2016-07-24 18:47:55 +02:00
|
|
|
*/
|
2018-07-05 18:02:02 +02:00
|
|
|
public function findNull(int $budgetId = null): ?Budget;
|
2016-07-24 18:47:55 +02:00
|
|
|
|
2016-05-06 10:32:26 +02:00
|
|
|
/**
|
|
|
|
* This method returns the oldest journal or transaction date known to this budget.
|
|
|
|
* Will cache result.
|
2016-05-11 09:08:18 +02:00
|
|
|
*
|
2016-05-06 10:32:26 +02:00
|
|
|
* @param Budget $budget
|
|
|
|
*
|
|
|
|
* @return Carbon
|
|
|
|
*/
|
2018-07-23 21:49:15 +02:00
|
|
|
public function firstUseDate(Budget $budget): ?Carbon;
|
2016-05-06 10:32:26 +02:00
|
|
|
|
2016-04-01 13:17:07 +02:00
|
|
|
/**
|
2016-05-06 06:15:46 +02:00
|
|
|
* @return Collection
|
2016-04-01 13:17:07 +02:00
|
|
|
*/
|
2016-05-06 06:15:46 +02:00
|
|
|
public function getActiveBudgets(): Collection;
|
2016-04-01 13:17:07 +02:00
|
|
|
|
2016-05-06 06:15:46 +02:00
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getBudgets(): Collection;
|
|
|
|
|
2018-06-06 21:23:00 +02:00
|
|
|
/**
|
|
|
|
* Get all budgets with these ID's.
|
|
|
|
*
|
|
|
|
* @param array $budgetIds
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getByIds(array $budgetIds): Collection;
|
|
|
|
|
2015-02-22 15:40:13 +01:00
|
|
|
/**
|
2016-01-20 15:21:27 +01:00
|
|
|
* @return Collection
|
2015-02-22 15:40:13 +01:00
|
|
|
*/
|
2016-05-06 06:15:46 +02:00
|
|
|
public function getInactiveBudgets(): Collection;
|
2015-02-22 09:46:21 +01:00
|
|
|
|
2019-03-02 14:12:09 +01:00
|
|
|
/**
|
|
|
|
* @param string $query
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function searchBudget(string $query): Collection;
|
|
|
|
|
2018-10-17 15:18:09 +02:00
|
|
|
/**
|
|
|
|
* @param Budget $budget
|
2019-08-29 21:33:12 +02:00
|
|
|
* @param int $order
|
2018-10-17 15:18:09 +02:00
|
|
|
*/
|
|
|
|
public function setBudgetOrder(Budget $budget, int $order): void;
|
|
|
|
|
2017-01-30 16:46:30 +01:00
|
|
|
/**
|
|
|
|
* @param User $user
|
|
|
|
*/
|
|
|
|
public function setUser(User $user);
|
|
|
|
|
2018-12-22 06:40:25 +01:00
|
|
|
/**
|
|
|
|
* @param Collection $accounts
|
2019-08-29 21:33:12 +02:00
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
2018-12-22 06:40:25 +01:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function spentInPeriodWoBudgetMc(Collection $accounts, Carbon $start, Carbon $end): array;
|
|
|
|
|
|
|
|
|
2015-02-22 15:40:13 +01:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @return Budget
|
|
|
|
*/
|
2016-04-05 22:00:03 +02:00
|
|
|
public function store(array $data): Budget;
|
2015-02-22 15:40:13 +01:00
|
|
|
|
2018-06-30 05:21:21 +02:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @return BudgetLimit
|
|
|
|
*/
|
|
|
|
public function storeBudgetLimit(array $data): BudgetLimit;
|
|
|
|
|
2015-02-22 15:40:13 +01:00
|
|
|
/**
|
|
|
|
* @param Budget $budget
|
2019-08-29 21:33:12 +02:00
|
|
|
* @param array $data
|
2015-02-22 15:40:13 +01:00
|
|
|
*
|
|
|
|
* @return Budget
|
|
|
|
*/
|
2016-12-03 21:03:20 +01:00
|
|
|
public function update(Budget $budget, array $data): Budget;
|
2015-02-22 15:40:13 +01:00
|
|
|
|
2018-06-24 08:33:06 +02:00
|
|
|
/**
|
|
|
|
* @param AvailableBudget $availableBudget
|
2019-08-29 21:33:12 +02:00
|
|
|
* @param array $data
|
2018-06-24 08:33:06 +02:00
|
|
|
*
|
|
|
|
* @return AvailableBudget
|
|
|
|
*/
|
|
|
|
public function updateAvailableBudget(AvailableBudget $availableBudget, array $data): AvailableBudget;
|
|
|
|
|
2018-06-24 13:20:29 +02:00
|
|
|
/**
|
|
|
|
* @param BudgetLimit $budgetLimit
|
2019-08-29 21:33:12 +02:00
|
|
|
* @param array $data
|
2018-06-24 13:20:29 +02:00
|
|
|
*
|
|
|
|
* @return BudgetLimit
|
|
|
|
*/
|
|
|
|
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit;
|
|
|
|
|
2019-08-16 21:38:35 +02:00
|
|
|
|
2015-02-22 15:40:13 +01:00
|
|
|
/**
|
2015-04-06 09:15:59 +02:00
|
|
|
* @param Budget $budget
|
2016-04-28 10:59:36 +02:00
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
2017-11-25 08:54:52 +01:00
|
|
|
* @param string $amount
|
2015-02-22 15:40:13 +01:00
|
|
|
*
|
2018-07-14 16:08:34 +02:00
|
|
|
* @return BudgetLimit|null
|
2015-02-22 15:40:13 +01:00
|
|
|
*/
|
2018-07-14 16:08:34 +02:00
|
|
|
public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): ?BudgetLimit;
|
2015-03-29 08:14:32 +02:00
|
|
|
}
|