mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-04 13:24:38 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			250 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			250 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * BudgetRepositoryInterface.php
 | 
						|
 * Copyright (c) 2017 thegrumpydictator@gmail.com
 | 
						|
 *
 | 
						|
 * This file is part of Firefly III.
 | 
						|
 *
 | 
						|
 * 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
 | 
						|
 * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
 | 
						|
 */
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace FireflyIII\Repositories\Budget;
 | 
						|
 | 
						|
use Carbon\Carbon;
 | 
						|
use FireflyIII\Models\Budget;
 | 
						|
use FireflyIII\Models\BudgetLimit;
 | 
						|
use FireflyIII\Models\TransactionCurrency;
 | 
						|
use FireflyIII\User;
 | 
						|
use Illuminate\Support\Collection;
 | 
						|
 | 
						|
/**
 | 
						|
 * Interface BudgetRepositoryInterface.
 | 
						|
 */
 | 
						|
interface BudgetRepositoryInterface
 | 
						|
{
 | 
						|
 | 
						|
    /**
 | 
						|
     * 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;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return bool
 | 
						|
     */
 | 
						|
    public function cleanupBudgets(): bool;
 | 
						|
 | 
						|
    /**
 | 
						|
     * 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
 | 
						|
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
 | 
						|
     */
 | 
						|
    public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     *
 | 
						|
     * @return bool
 | 
						|
     */
 | 
						|
    public function destroy(Budget $budget): bool;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Filters entries from the result set generated by getBudgetPeriodReport.
 | 
						|
     *
 | 
						|
     * @param Collection $set
 | 
						|
     * @param int        $budgetId
 | 
						|
     * @param array      $periods
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function filterAmounts(Collection $set, int $budgetId, array $periods): array;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Find a budget.
 | 
						|
     *
 | 
						|
     * @param int $budgetId
 | 
						|
     *
 | 
						|
     * @deprecated
 | 
						|
     *
 | 
						|
     * @return Budget
 | 
						|
     */
 | 
						|
    public function find(int $budgetId): Budget;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Find a budget.
 | 
						|
     *
 | 
						|
     * @param string $name
 | 
						|
     *
 | 
						|
     * @return Budget|null
 | 
						|
     */
 | 
						|
    public function findByName(string $name): ?Budget;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Find a budget or return NULL
 | 
						|
     *
 | 
						|
     * @param int $budgetId
 | 
						|
     *
 | 
						|
     * @return Budget|null
 | 
						|
     */
 | 
						|
    public function findNull(int $budgetId): ?Budget;
 | 
						|
 | 
						|
    /**
 | 
						|
     * This method returns the oldest journal or transaction date known to this budget.
 | 
						|
     * Will cache result.
 | 
						|
     *
 | 
						|
     * @param Budget $budget
 | 
						|
     *
 | 
						|
     * @return Carbon
 | 
						|
     */
 | 
						|
    public function firstUseDate(Budget $budget): Carbon;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getActiveBudgets(): Collection;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getAllBudgetLimits(Carbon $start, Carbon $end): Collection;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param TransactionCurrency $currency
 | 
						|
     * @param Carbon              $start
 | 
						|
     * @param Carbon              $end
 | 
						|
     *
 | 
						|
     * @return string
 | 
						|
     */
 | 
						|
    public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getBudgetLimits(Budget $budget, Carbon $start, Carbon $end): Collection;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Collection $budgets
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function getBudgetPeriodReport(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getBudgets(): Collection;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Get all budgets with these ID's.
 | 
						|
     *
 | 
						|
     * @param array $budgetIds
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getByIds(array $budgetIds): Collection;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getInactiveBudgets(): Collection;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function getNoBudgetPeriodReport(Collection $accounts, Carbon $start, Carbon $end): array;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param TransactionCurrency $currency
 | 
						|
     * @param Carbon              $start
 | 
						|
     * @param Carbon              $end
 | 
						|
     * @param string              $amount
 | 
						|
     *
 | 
						|
     * @return bool
 | 
						|
     */
 | 
						|
    public function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): bool;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param User $user
 | 
						|
     */
 | 
						|
    public function setUser(User $user);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Collection $budgets
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return string
 | 
						|
     */
 | 
						|
    public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return string
 | 
						|
     */
 | 
						|
    public function spentInPeriodWoBudget(Collection $accounts, Carbon $start, Carbon $end): string;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param array $data
 | 
						|
     *
 | 
						|
     * @return Budget
 | 
						|
     */
 | 
						|
    public function store(array $data): Budget;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     * @param array  $data
 | 
						|
     *
 | 
						|
     * @return Budget
 | 
						|
     */
 | 
						|
    public function update(Budget $budget, array $data): Budget;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     * @param string $amount
 | 
						|
     *
 | 
						|
     * @return BudgetLimit
 | 
						|
     */
 | 
						|
    public function updateLimitAmount(Budget $budget, Carbon $start, Carbon $end, string $amount): BudgetLimit;
 | 
						|
}
 |