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

121 lines
3.5 KiB
PHP
Raw Normal View History

2015-02-22 09:46:21 +01:00
<?php
2022-12-29 19:42:26 +01:00
/**
* BudgetRepositoryInterface.php
2020-02-16 14:00:57 +01: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 08:40:00 +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
* GNU Affero General Public License for more details.
2017-10-21 08:40:00 +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/>.
*/
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;
2021-03-12 06:20:01 +01:00
use FireflyIII\Models\AutoBudget;
2015-02-22 09:46:21 +01:00
use FireflyIII\Models\Budget;
use FireflyIII\User;
2023-02-19 08:43:28 +01:00
use Illuminate\Contracts\Auth\Authenticatable;
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
{
2022-03-29 14:59:58 +02:00
public function budgetEndsWith(string $query, int $limit): Collection;
2022-03-29 14:59:58 +02:00
public function budgetStartsWith(string $query, int $limit): Collection;
/**
* Returns the amount that is budgeted in a period.
*/
public function budgetedInPeriod(Carbon $start, Carbon $end): array;
/**
* Returns the amount that is budgeted in a period.
*/
public function budgetedInPeriodForBudget(Budget $budget, Carbon $start, Carbon $end): array;
2022-03-29 14:59:58 +02:00
public function cleanupBudgets(): bool;
2021-03-12 06:20:01 +01:00
public function destroy(Budget $budget): bool;
/**
2021-03-12 06:20:01 +01:00
* Destroy all budgets.
*/
2021-03-12 06:20:01 +01:00
public function destroyAll(): void;
public function destroyAutoBudget(Budget $budget): void;
public function find(?int $budgetId = null): ?Budget;
2021-08-20 20:49:42 +02:00
2019-06-04 20:42:11 +02:00
public function findBudget(?int $budgetId, ?string $budgetName): ?Budget;
/**
* Find budget by name.
*/
public function findByName(?string $name): ?Budget;
/**
* This method returns the oldest journal or transaction date known to this budget.
* Will cache result.
*/
2018-07-23 21:49:15 +02:00
public function firstUseDate(Budget $budget): ?Carbon;
2016-05-06 06:15:46 +02:00
public function getActiveBudgets(): Collection;
2016-04-01 13:17:07 +02:00
2021-03-12 06:20:01 +01:00
public function getAttachments(Budget $budget): Collection;
public function getAutoBudget(Budget $budget): ?AutoBudget;
2016-05-06 06:15:46 +02:00
public function getBudgets(): Collection;
2018-06-06 21:23:00 +02:00
/**
* Get all budgets with these ID's.
*/
public function getByIds(array $budgetIds): Collection;
2016-05-06 06:15:46 +02:00
public function getInactiveBudgets(): Collection;
2015-02-22 09:46:21 +01:00
2021-03-12 06:20:01 +01:00
public function getMaxOrder(): int;
2022-03-29 14:59:58 +02:00
public function getNoteText(Budget $budget): ?string;
2020-07-21 06:23:37 +02:00
public function searchBudget(string $query, int $limit): Collection;
2019-03-02 14:12:09 +01:00
2018-10-17 15:18:09 +02:00
public function setBudgetOrder(Budget $budget, int $order): void;
2023-12-20 19:35:52 +01:00
public function setUser(null|Authenticatable|User $user): void;
2017-01-30 16:46:30 +01:00
2022-06-06 16:41:54 +02:00
/**
* Used in the v2 API to calculate the amount of money spent in all active budgets.
*/
public function spentInPeriod(Carbon $start, Carbon $end): array;
/**
* Used in the v2 API to calculate the amount of money spent in a single budget..
*/
public function spentInPeriodForBudget(Budget $budget, Carbon $start, Carbon $end): array;
2015-02-22 15:40:13 +01:00
/**
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
2016-12-03 21:03:20 +01:00
public function update(Budget $budget, array $data): Budget;
2015-03-29 08:14:32 +02:00
}