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

156 lines
3.5 KiB
PHP
Raw Normal View History

2015-02-22 02:46:21 -06:00
<?php
/**
* BudgetRepositoryInterface.php
2020-02-16 07:00:57 -06:00
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* 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 01:40:00 -05:00
*
* This program is distributed in the hope that it will be useful,
2017-10-21 01:40:00 -05:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2017-10-21 01:40:00 -05: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/>.
*/
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;
use FireflyIII\Models\AutoBudget;
2019-10-30 14:02:21 -05:00
use FireflyIII\Exceptions\FireflyException;
2015-02-22 02:46:21 -06:00
use FireflyIII\Models\Budget;
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
{
/**
* Destroy all budgets.
*/
public function destroyAll(): void;
/**
* @param Budget $budget
*
* @return AutoBudget|null
*/
public function getAutoBudget(Budget $budget): ?AutoBudget;
2018-04-02 08:10:40 -05:00
/**
* @return bool
*/
public function cleanupBudgets(): bool;
2016-05-05 23:15:46 -05:00
/**
* @param Budget $budget
*
* @return bool
*/
public function destroy(Budget $budget): bool;
/**
2019-08-29 14:33:12 -05:00
* @param int|null $budgetId
* @param string|null $budgetName
*
* @return Budget|null
*/
2019-06-04 13:42:11 -05:00
public function findBudget(?int $budgetId, ?string $budgetName): ?Budget;
/**
* Find budget by name.
*
* @param string|null $name
*
* @return Budget|null
*/
public function findByName(?string $name): ?Budget;
/**
2019-08-30 00:49:08 -05:00
* TODO refactor to "find"
*
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-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
2019-03-02 07:12:09 -06:00
/**
* @param string $query
*
* @return Collection
*/
public function searchBudget(string $query): Collection;
2018-10-17 08:18:09 -05:00
/**
* @param Budget $budget
2019-08-29 14:33:12 -05:00
* @param int $order
2018-10-17 08:18:09 -05:00
*/
public function setBudgetOrder(Budget $budget, int $order): void;
2017-01-30 09:46:30 -06:00
/**
* @param User $user
*/
public function setUser(User $user);
2015-02-22 08:40:13 -06:00
/**
* @param array $data
*
* @return Budget
2019-10-30 14:02:21 -05:00
* @throws FireflyException
2015-02-22 08:40:13 -06:00
*/
2016-04-05 15:00:03 -05:00
public function store(array $data): Budget;
2015-02-22 08:40:13 -06:00
/**
* @param Budget $budget
2019-08-29 14:33:12 -05: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-03-29 01:14:32 -05:00
}