mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-04 19:53:44 +00:00
Fix #3901
This commit is contained in:
@@ -68,11 +68,8 @@ class CurrencyController extends Controller
|
||||
{
|
||||
use AccountFilter, TransactionFilter;
|
||||
|
||||
/** @var CurrencyRepositoryInterface The currency repository */
|
||||
private $repository;
|
||||
|
||||
/** @var UserRepositoryInterface The user repository */
|
||||
private $userRepository;
|
||||
private CurrencyRepositoryInterface $repository;
|
||||
private UserRepositoryInterface $userRepository;
|
||||
|
||||
|
||||
/**
|
||||
@@ -161,22 +158,14 @@ class CurrencyController extends Controller
|
||||
*/
|
||||
public function availableBudgets(TransactionCurrency $currency): JsonResponse
|
||||
{
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
|
||||
$manager = $this->getManager();
|
||||
// types to get, page size:
|
||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||
|
||||
// get list of available budgets. Count it and split it.
|
||||
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
$repository = app(BudgetRepositoryInterface::class);
|
||||
|
||||
/** @var AvailableBudgetRepositoryInterface $abRepository */
|
||||
$abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||
|
||||
$repository->setUser($admin);
|
||||
$collection = $abRepository->getAvailableBudgetsByCurrency($currency);
|
||||
$count = $collection->count();
|
||||
$availableBudgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
@@ -208,10 +197,10 @@ class CurrencyController extends Controller
|
||||
{
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var BillRepositoryInterface $repository */
|
||||
$repository = app(BillRepositoryInterface::class);
|
||||
/** @var BillRepositoryInterface $billRepos */
|
||||
$billRepos = app(BillRepositoryInterface::class);
|
||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||
$unfiltered = $repository->getBills();
|
||||
$unfiltered = $billRepos->getBills();
|
||||
|
||||
// filter and paginate list:
|
||||
$collection = $unfiltered->filter(
|
||||
@@ -303,9 +292,9 @@ class CurrencyController extends Controller
|
||||
*
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
* @codeCoverageIgnore
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(TransactionCurrency $currency): JsonResponse
|
||||
{
|
||||
@@ -459,9 +448,9 @@ class CurrencyController extends Controller
|
||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||
|
||||
// get list of budgets. Count it and split it.
|
||||
/** @var RecurringRepositoryInterface $repository */
|
||||
$repository = app(RecurringRepositoryInterface::class);
|
||||
$unfiltered = $repository->getAll();
|
||||
/** @var RecurringRepositoryInterface $recurringRepos */
|
||||
$recurringRepos = app(RecurringRepositoryInterface::class);
|
||||
$unfiltered = $recurringRepos->getAll();
|
||||
|
||||
// filter selection
|
||||
$collection = $unfiltered->filter(
|
||||
@@ -510,9 +499,9 @@ class CurrencyController extends Controller
|
||||
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||
|
||||
// get list of budgets. Count it and split it.
|
||||
/** @var RuleRepositoryInterface $repository */
|
||||
$repository = app(RuleRepositoryInterface::class);
|
||||
$unfiltered = $repository->getAll();
|
||||
/** @var RuleRepositoryInterface $ruleRepos */
|
||||
$ruleRepos = app(RuleRepositoryInterface::class);
|
||||
$unfiltered = $ruleRepos->getAll();
|
||||
|
||||
$collection = $unfiltered->filter(
|
||||
static function (Rule $rule) use ($currency) {
|
||||
@@ -594,8 +583,8 @@ class CurrencyController extends Controller
|
||||
*
|
||||
* @param CurrencyRequest $request
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function store(CurrencyRequest $request): JsonResponse
|
||||
{
|
||||
|
@@ -506,7 +506,14 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
*/
|
||||
public function getStoreRules(): Collection
|
||||
{
|
||||
$collection = $this->user->rules()->where('rules.active', 1)->with(['ruleGroup', 'ruleTriggers'])->get();
|
||||
$collection = $this->user->rules()
|
||||
->leftJoin('rule_groups', 'rule_groups.id', '=', 'rules.rule_group_id')
|
||||
->where('rules.active', 1)
|
||||
->where('rule_groups.active', 1)
|
||||
->orderBy('rule_groups.order', 'ASC')
|
||||
->orderBy('rules.order', 'ASC')
|
||||
->orderBy('rules.id', 'ASC')
|
||||
->with(['ruleGroup', 'ruleTriggers'])->get(['rules.*']);
|
||||
$filtered = new Collection;
|
||||
/** @var Rule $rule */
|
||||
foreach ($collection as $rule) {
|
||||
@@ -525,7 +532,14 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
*/
|
||||
public function getUpdateRules(): Collection
|
||||
{
|
||||
$collection = $this->user->rules()->where('rules.active', 1)->with(['ruleGroup', 'ruleTriggers'])->get();
|
||||
$collection = $this->user->rules()
|
||||
->leftJoin('rule_groups', 'rule_groups.id', '=', 'rules.rule_group_id')
|
||||
->where('rules.active', 1)
|
||||
->where('rule_groups.active', 1)
|
||||
->orderBy('rule_groups.order', 'ASC')
|
||||
->orderBy('rules.order', 'ASC')
|
||||
->orderBy('rules.id', 'ASC')
|
||||
->with(['ruleGroup', 'ruleTriggers'])->get();
|
||||
$filtered = new Collection;
|
||||
/** @var Rule $rule */
|
||||
foreach ($collection as $rule) {
|
||||
|
Reference in New Issue
Block a user