mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-23 23:13:18 -06:00
Fix #3172
This commit is contained in:
parent
41e6c8f73e
commit
9331f8985a
@ -59,8 +59,6 @@ class BoxController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function available(): JsonResponse
|
public function available(): JsonResponse
|
||||||
{
|
{
|
||||||
/** @var BudgetRepositoryInterface $repository */
|
|
||||||
$repository = app(BudgetRepositoryInterface::class);
|
|
||||||
/** @var OperationsRepositoryInterface $opsRepository */
|
/** @var OperationsRepositoryInterface $opsRepository */
|
||||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
/** @var AvailableBudgetRepositoryInterface $abRepository */
|
/** @var AvailableBudgetRepositoryInterface $abRepository */
|
||||||
@ -102,13 +100,12 @@ class BoxController extends Controller
|
|||||||
$spent = $opsRepository->sumExpenses($start, $end, null, null, $currency);
|
$spent = $opsRepository->sumExpenses($start, $end, null, null, $currency);
|
||||||
$spentAmount = $spent[(int)$currency->id]['sum'] ?? '0';
|
$spentAmount = $spent[(int)$currency->id]['sum'] ?? '0';
|
||||||
$spentPerDay = '-1';
|
$spentPerDay = '-1';
|
||||||
if (1 === $availableBudgets->count()) {
|
if ($availableBudgets->count() > 0) {
|
||||||
$display = 0; // assume user overspent
|
$display = 0; // assume user overspent
|
||||||
$boxTitle = (string)trans('firefly.overspent');
|
$boxTitle = (string)trans('firefly.overspent');
|
||||||
/** @var AvailableBudget $availableBudget */
|
$totalAvailableSum = $availableBudgets->sum('amount');
|
||||||
$availableBudget = $availableBudgets->first();
|
|
||||||
// calculate with available budget.
|
// calculate with available budget.
|
||||||
$leftToSpendAmount = bcadd($availableBudget->amount, $spentAmount);
|
$leftToSpendAmount = bcadd($totalAvailableSum, $spentAmount);
|
||||||
if (1 === bccomp($leftToSpendAmount, '0')) {
|
if (1 === bccomp($leftToSpendAmount, '0')) {
|
||||||
$boxTitle = (string)trans('firefly.left_to_spend');
|
$boxTitle = (string)trans('firefly.left_to_spend');
|
||||||
$days = $today->diffInDays($end) + 1;
|
$days = $today->diffInDays($end) + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user