mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-03 20:55:05 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			272 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			272 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
declare(strict_types = 1);
 | 
						|
 | 
						|
namespace FireflyIII\Repositories\Budget;
 | 
						|
 | 
						|
use Carbon\Carbon;
 | 
						|
use FireflyIII\Models\Budget;
 | 
						|
use FireflyIII\Models\LimitRepetition;
 | 
						|
use Illuminate\Pagination\LengthAwarePaginator;
 | 
						|
use Illuminate\Support\Collection;
 | 
						|
 | 
						|
/**
 | 
						|
 * Interface BudgetRepositoryInterface
 | 
						|
 *
 | 
						|
 * @package FireflyIII\Repositories\Budget
 | 
						|
 */
 | 
						|
interface BudgetRepositoryInterface
 | 
						|
{
 | 
						|
 | 
						|
    /**
 | 
						|
     *
 | 
						|
     * Same as ::spentInPeriod but corrects journals for a set of accounts
 | 
						|
     *
 | 
						|
     * @param Budget     $budget
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     * @param Collection $accounts
 | 
						|
     *
 | 
						|
     * @return string
 | 
						|
     */
 | 
						|
    public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    public function cleanupBudgets();
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     *
 | 
						|
     * @return boolean
 | 
						|
     */
 | 
						|
    public function destroy(Budget $budget);
 | 
						|
 | 
						|
    /**
 | 
						|
     * Find a budget.
 | 
						|
     *
 | 
						|
     * @param int $budgetId
 | 
						|
     *
 | 
						|
     * @return Budget
 | 
						|
     */
 | 
						|
    public function find(int $budgetId): Budget;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     *
 | 
						|
     * @return Carbon
 | 
						|
     */
 | 
						|
    public function firstActivity(Budget $budget);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getActiveBudgets();
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * Get the budgeted amounts for each budgets in each year.
 | 
						|
     *
 | 
						|
     * @param Collection $budgets
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getBudgetedPerYear(Collection $budgets, Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getBudgets();
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns an array with every budget in it and the expenses for each budget
 | 
						|
     * per month.
 | 
						|
     *
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function getBudgetsAndExpensesPerMonth(Collection $accounts, Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns an array with every budget in it and the expenses for each budget
 | 
						|
     * per year for.
 | 
						|
     *
 | 
						|
     * @param Collection $budgets
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function getBudgetsAndExpensesPerYear(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns a list of budgets, budget limits and limit repetitions
 | 
						|
     * (doubling any of them in a left join)
 | 
						|
     *
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getBudgetsAndLimitsInRange(Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     *
 | 
						|
     * @return LimitRepetition|null
 | 
						|
     */
 | 
						|
    public function getCurrentRepetition(Budget $budget, Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns all expenses for the given budget and the given accounts, in the given period.
 | 
						|
     *
 | 
						|
     * @param Budget     $budget
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getExpenses(Budget $budget, Collection $accounts, Carbon $start, Carbon $end):Collection;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns the expenses for this budget grouped per day, with the date
 | 
						|
     * in "date" (a string, not a Carbon) and the amount in "dailyAmount".
 | 
						|
     *
 | 
						|
     * @param Budget $budget
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getExpensesPerDay(Budget $budget, Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     *
 | 
						|
     * @return Carbon
 | 
						|
     */
 | 
						|
    public function getFirstBudgetLimitDate(Budget $budget);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getInactiveBudgets();
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns all the transaction journals for a limit, possibly limited by a limit repetition.
 | 
						|
     *
 | 
						|
     * @param Budget          $budget
 | 
						|
     * @param LimitRepetition $repetition
 | 
						|
     * @param int             $take
 | 
						|
     *
 | 
						|
     * @return LengthAwarePaginator
 | 
						|
     */
 | 
						|
    public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function getWithoutBudget(Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return string
 | 
						|
     */
 | 
						|
    public function getWithoutBudgetSum(Collection $accounts, Carbon $start, Carbon $end): string;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns an array with the following key:value pairs:
 | 
						|
     *
 | 
						|
     * yyyy-mm-dd:<array>
 | 
						|
     *
 | 
						|
     * That array contains:
 | 
						|
     *
 | 
						|
     * budgetid:<amount>
 | 
						|
     *
 | 
						|
     * Where yyyy-mm-dd is the date and <amount> is the money spent using WITHDRAWALS in the $budget
 | 
						|
     * from the given users accounts..
 | 
						|
     *
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns a list of expenses (in the field "spent", grouped per budget per account.
 | 
						|
     *
 | 
						|
     * @param Collection $budgets
 | 
						|
     * @param Collection $accounts
 | 
						|
     * @param Carbon     $start
 | 
						|
     * @param Carbon     $end
 | 
						|
     *
 | 
						|
     * @return Collection
 | 
						|
     */
 | 
						|
    public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end);
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns an array with the following key:value pairs:
 | 
						|
     *
 | 
						|
     * yyyy-mm-dd:<amount>
 | 
						|
     *
 | 
						|
     * Where yyyy-mm-dd is the date and <amount> is the money spent using WITHDRAWALS in the $budget
 | 
						|
     * from all the users accounts.
 | 
						|
     *
 | 
						|
     * @param Budget $budget
 | 
						|
     * @param Carbon $start
 | 
						|
     * @param Carbon $end
 | 
						|
     *
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function spentPerDay(Budget $budget, Carbon $start, Carbon $end): array;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param array $data
 | 
						|
     *
 | 
						|
     * @return Budget
 | 
						|
     */
 | 
						|
    public function store(array $data);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     * @param array  $data
 | 
						|
     *
 | 
						|
     * @return Budget
 | 
						|
     */
 | 
						|
    public function update(Budget $budget, array $data);
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param Budget $budget
 | 
						|
     * @param Carbon $date
 | 
						|
     * @param int    $amount
 | 
						|
     *
 | 
						|
     * @return mixed
 | 
						|
     */
 | 
						|
    public function updateLimitAmount(Budget $budget, Carbon $date, int $amount);
 | 
						|
 | 
						|
}
 |