Remove deprecated method.

This commit is contained in:
James Cole 2020-08-02 12:13:23 +02:00
parent e29b2066c2
commit e7e21348eb
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
2 changed files with 12 additions and 18 deletions

View File

@ -41,9 +41,7 @@ use League\Fractal\Resource\Item;
*/ */
class AvailableBudgetController extends Controller class AvailableBudgetController extends Controller
{ {
/** @var AvailableBudgetRepositoryInterface */ private AvailableBudgetRepositoryInterface $abRepository;
private $abRepository;
/** /**
* AvailableBudgetController constructor. * AvailableBudgetController constructor.

View File

@ -38,12 +38,8 @@ use Illuminate\Support\Collection;
*/ */
class AvailableBudgetController extends Controller class AvailableBudgetController extends Controller
{ {
/** @var OperationsRepositoryInterface */ private OperationsRepositoryInterface $opsRepository;
private $opsRepository; private BudgetRepositoryInterface $repository;
/** @var BudgetRepositoryInterface */
private $repository;
/** /**
* AvailableBudgetController constructor. * AvailableBudgetController constructor.
@ -74,18 +70,18 @@ class AvailableBudgetController extends Controller
*/ */
public function overview(AvailableBudget $availableBudget): JsonResponse public function overview(AvailableBudget $availableBudget): JsonResponse
{ {
$currency = $availableBudget->transactionCurrency; $currency = $availableBudget->transactionCurrency;
$budgets = $this->repository->getActiveBudgets(); $budgets = $this->repository->getActiveBudgets();
$budgetInformation = $this->opsRepository->spentInPeriodMc($budgets, new Collection, $availableBudget->start_date, $availableBudget->end_date); $newBudgetInformation = $this->opsRepository->sumExpenses($availableBudget->start_date, $availableBudget->end_date, null, $budgets);
$spent = 0.0; $spent = '0';
// get for current currency foreach ($newBudgetInformation as $currencyId => $info) {
foreach ($budgetInformation as $spentInfo) { if ($currencyId === (int) $availableBudget->transaction_currency_id) {
if ($spentInfo['currency_id'] === $availableBudget->transaction_currency_id) { $spent = $info['sum'];
$spent = $spentInfo['amount'];
} }
} }
$left = bcadd($availableBudget->amount, (string) $spent);
$left = bcadd($availableBudget->amount, $spent);
// left less than zero? Set to zero. // left less than zero? Set to zero.
if (-1 === bccomp($left, '0')) { if (-1 === bccomp($left, '0')) {
$left = '0'; $left = '0';