mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Sort and clean up some code.
This commit is contained in:
@@ -117,6 +117,18 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a budget or return NULL
|
||||
*
|
||||
* @param int|null $budgetId |null
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function find(int $budgetId = null): ?Budget
|
||||
{
|
||||
return $this->user->budgets()->find($budgetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $budgetId
|
||||
* @param string|null $budgetName
|
||||
@@ -157,18 +169,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
return $this->user->budgets()->where('name', 'LIKE', $query)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a budget or return NULL
|
||||
*
|
||||
* @param int|null $budgetId |null
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function find(int $budgetId = null): ?Budget
|
||||
{
|
||||
return $this->user->budgets()->find($budgetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the oldest journal or transaction date known to this budget.
|
||||
* Will cache result.
|
||||
|
@@ -56,6 +56,14 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function destroyAutoBudget(Budget $budget): void;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int|null $budgetId
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function find(int $budgetId = null): ?Budget;
|
||||
|
||||
/**
|
||||
* @param int|null $budgetId
|
||||
* @param string|null $budgetName
|
||||
@@ -73,14 +81,6 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function findByName(?string $name): ?Budget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int|null $budgetId
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function find(int $budgetId = null): ?Budget;
|
||||
|
||||
/**
|
||||
* This method returns the oldest journal or transaction date known to this budget.
|
||||
* Will cache result.
|
||||
|
@@ -22,6 +22,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Budget;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
|
@@ -22,6 +22,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Budget;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\User;
|
||||
|
@@ -343,20 +343,10 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
$array[$foreignId]['sum'] = bcadd($array[$foreignId]['sum'], app('steam')->negative($journal['foreign_amount']));
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
private function getBudgets(): Collection
|
||||
{
|
||||
/** @var BudgetRepositoryInterface $repos */
|
||||
$repos = app(BudgetRepositoryInterface::class);
|
||||
|
||||
return $repos->getActiveBudgets();
|
||||
}
|
||||
|
||||
/**
|
||||
* For now, simply refer to whichever repository holds this function.
|
||||
* See reference nr. 14
|
||||
@@ -374,4 +364,15 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
|
||||
return $blRepository->getBudgetLimits($budget, $start, $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
private function getBudgets(): Collection
|
||||
{
|
||||
/** @var BudgetRepositoryInterface $repos */
|
||||
$repos = app(BudgetRepositoryInterface::class);
|
||||
|
||||
return $repos->getActiveBudgets();
|
||||
}
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ interface OperationsRepositoryInterface
|
||||
* @return string
|
||||
*/
|
||||
public function budgetedPerDay(Budget $budget): string;
|
||||
|
||||
/**
|
||||
* @param Collection $budgets
|
||||
* @param Collection $accounts
|
||||
|
Reference in New Issue
Block a user