2015-02-22 09:46:21 +01:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* BudgetRepositoryInterface.php
|
2020-02-16 14:00:57 +01:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2016-05-20 12:41:23 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 08:40:00 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-02 06:37:26 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://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;
|
2019-10-30 20:02:21 +01:00
|
|
|
use FireflyIII\Exceptions\FireflyException;
|
2015-02-22 09:46:21 +01:00
|
|
|
use FireflyIII\Models\Budget;
|
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
|
|
|
|
{
|
2019-09-27 21:35:21 +02:00
|
|
|
/**
|
|
|
|
* Destroy all budgets.
|
|
|
|
*/
|
|
|
|
public function destroyAll(): void;
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2015-02-22 15:40:13 +01:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @return Budget
|
2019-10-30 20:02:21 +01:00
|
|
|
* @throws FireflyException
|
2015-02-22 15:40:13 +01:00
|
|
|
*/
|
2016-04-05 22:00:03 +02:00
|
|
|
public function store(array $data): Budget;
|
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-03-29 08:14:32 +02:00
|
|
|
}
|