Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -1,6 +1,5 @@
<?php
/*
* AvailableBudgetRepository.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -37,20 +36,16 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
{
use UserGroupTrait;
/**
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function getAvailableBudgetWithCurrency(Carbon $start, Carbon $end): array
{
$return = [];
$converter = new ExchangeRateConverter();
$default = app('amount')->getDefaultCurrency();
$availableBudgets = $this->userGroup->availableBudgets()
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->get();
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->get()
;
/** @var AvailableBudget $availableBudget */
foreach ($availableBudgets as $availableBudget) {
$currencyId = $availableBudget->transaction_currency_id;
@@ -72,6 +67,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
$return[$currencyId]['amount'] = bcadd($return[$currencyId]['amount'], $availableBudget->amount);
$return[$currencyId]['native_amount'] = bcadd($return[$currencyId]['native_amount'], $nativeAmount);
}
return $return;
}
}

View File

@@ -1,6 +1,5 @@
<?php
/*
* AvailableBudgetRepositoryInterface.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -33,19 +32,7 @@ use FireflyIII\User;
*/
interface AvailableBudgetRepositoryInterface
{
/**
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function getAvailableBudgetWithCurrency(Carbon $start, Carbon $end): array;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
}

View File

@@ -1,6 +1,5 @@
<?php
/*
* BudgetRepository.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -35,14 +34,12 @@ class BudgetRepository implements BudgetRepositoryInterface
{
use UserGroupTrait;
/**
* @inheritDoc
*/
public function getActiveBudgets(): Collection
{
return $this->userGroup->budgets()->where('active', true)
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')
->get();
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')
->get()
;
}
}

View File

@@ -1,6 +1,5 @@
<?php
/*
* BudgetRepositoryInterface.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -34,22 +33,9 @@ use Illuminate\Support\Collection;
*/
interface BudgetRepositoryInterface
{
/**
* @return Collection
*/
public function getActiveBudgets(): Collection;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* @param UserGroup $userGroup
*
* @return void
*/
public function setUserGroup(UserGroup $userGroup): void;
}

View File

@@ -1,6 +1,5 @@
<?php
/*
* OperationsRepository.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -40,7 +39,6 @@ class OperationsRepository implements OperationsRepositoryInterface
use UserGroupTrait;
/**
* @inheritDoc
* @throws FireflyException
*/
public function listExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $budgets = null): array
@@ -124,9 +122,6 @@ class OperationsRepository implements OperationsRepositoryInterface
return $array;
}
/**
* @return Collection
*/
private function getBudgets(): Collection
{
/** @var BudgetRepositoryInterface $repository */

View File

@@ -1,6 +1,5 @@
<?php
/*
* OperationsRepositoryInterface.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -38,20 +37,8 @@ interface OperationsRepositoryInterface
* This method returns a list of all the withdrawal transaction journals (as arrays) set in that period
* which have the specified budget set to them. It's grouped per currency, with as few details in the array
* as possible. Amounts are always negative.
*
* @param Carbon $start
* @param Carbon $end
* @param Collection|null $accounts
* @param Collection|null $budgets
*
* @return array
*/
public function listExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $budgets = null): array;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
}