diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 1e4545d518..329f46fdc8 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -241,7 +241,8 @@ class BudgetController extends Controller return view( 'budgets.index', compact( - 'available', 'currentMonth', 'next', 'nextText', 'prev', 'prevText', 'periodStart', 'periodEnd', 'budgetInformation', 'inactive', 'budgets', + 'available', 'currentMonth', 'next', 'nextText', 'prev', 'prevText', + 'periodStart', 'periodEnd', 'budgetInformation', 'inactive', 'budgets', 'spent', 'budgeted', 'previousLoop', 'nextLoop', 'start' ) ); diff --git a/app/Support/Amount.php b/app/Support/Amount.php index d90a1a2de4..89ef0dea05 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -204,7 +204,7 @@ class Amount } /** - * @return TransactionCurrency + * @return \FireflyIII\Models\TransactionCurrency * @throws FireflyException */ public function getDefaultCurrency(): TransactionCurrency diff --git a/public/js/ff/budgets/index.js b/public/js/ff/budgets/index.js index ac233b85c4..01a00c9b0f 100644 --- a/public/js/ff/budgets/index.js +++ b/public/js/ff/budgets/index.js @@ -59,9 +59,26 @@ function updateBudgetedAmounts(e) { "use strict"; var target = $(e.target); var id = target.data('id'); + var value = target.val(); var original = target.data('original'); var difference = value - original; + + var spentCell = $('td[class="spent"][data-id="' + id + '"]'); + var leftCell = $('td[class="left"][data-id="' + id + '"]'); + var spentAmount = parseFloat(spentCell.data('spent')); + var newAmountLeft = spentAmount + parseFloat(value); + var amountLeftString = accounting.formatMoney(newAmountLeft); + if(newAmountLeft < 0) { + leftCell.html('' + amountLeftString + ''); + } + if(newAmountLeft > 0) { + leftCell.html('' + amountLeftString + ''); + } + if(newAmountLeft === 0.0) { + leftCell.html('' + amountLeftString + ''); + } + if (difference !== 0) { // add difference to 'budgeted' var budgeted = budgeted + difference; diff --git a/resources/views/budgets/index.twig b/resources/views/budgets/index.twig index 240b7e9845..00214b8c6c 100644 --- a/resources/views/budgets/index.twig +++ b/resources/views/budgets/index.twig @@ -176,61 +176,12 @@ step="1" min="0" name="amount" type="number"> -
- - - | -
-
-
-
- |
-
- {{ 'spent'|_ }}
- - {{ session('start').formatLocalized(monthAndDayFormat) }} - - {{ session('end').formatLocalized(monthAndDayFormat) }} - - |
- - - | -
-
|
-