mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Final things.
This commit is contained in:
@@ -196,7 +196,23 @@ class BudgetLimitController extends Controller
|
|||||||
{
|
{
|
||||||
$amount = $request->get('amount');
|
$amount = $request->get('amount');
|
||||||
|
|
||||||
return response()->json($this->blRepository->update($budgetLimit, ['amount' => $amount])->toArray());
|
$limit = $this->blRepository->update($budgetLimit, ['amount' => $amount]);
|
||||||
|
$array = $limit->toArray();
|
||||||
|
|
||||||
|
$spentArr = $this->opsRepository->sumExpenses(
|
||||||
|
$limit->start_date, $limit->end_date, null, new Collection([$budgetLimit->budget]), $budgetLimit->transactionCurrency
|
||||||
|
);
|
||||||
|
$array['spent'] = $spentArr[$budgetLimit->transactionCurrency->id]['sum'] ?? '0';
|
||||||
|
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], $array['amount']));
|
||||||
|
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||||
|
$array['days_left'] = (string)$this->activeDaysLeft($limit->start_date, $limit->end_date);
|
||||||
|
// left per day:
|
||||||
|
$array['left_per_day'] = bcdiv(bcadd($array['spent'], $array['amount']), $array['days_left']);
|
||||||
|
|
||||||
|
// left per day formatted.
|
||||||
|
$array['left_per_day_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $array['left_per_day']);
|
||||||
|
|
||||||
|
return response()->json($array);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
public/v1/js/ff/budgets/index.js
vendored
8
public/v1/js/ff/budgets/index.js
vendored
@@ -107,7 +107,6 @@ function updateBudgetedAmount(e) {
|
|||||||
if (data.left_per_day > 0) {
|
if (data.left_per_day > 0) {
|
||||||
$('.left_span[data-limit="0"][data-id="' + budgetId + '"]').html(data.left_formatted + '(' + data.left_per_day_formatted + ')');
|
$('.left_span[data-limit="0"][data-id="' + budgetId + '"]').html(data.left_formatted + '(' + data.left_per_day_formatted + ')');
|
||||||
}
|
}
|
||||||
console.log(data);
|
|
||||||
//$('.left_span[data-limit="0"][data-id="' + budgetId + '"]').text('XXXXX');
|
//$('.left_span[data-limit="0"][data-id="' + budgetId + '"]').text('XXXXX');
|
||||||
|
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
@@ -118,7 +117,12 @@ function updateBudgetedAmount(e) {
|
|||||||
_token: token,
|
_token: token,
|
||||||
amount: input.val(),
|
amount: input.val(),
|
||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
alert('done!');
|
input.prop('disabled', false);
|
||||||
|
$('.left_span[data-limit="'+budgetLimitId+'"]').html(data.left_formatted);
|
||||||
|
if (data.left_per_day > 0) {
|
||||||
|
$('.left_span[data-limit="'+budgetLimitId+'"]').html(data.left_formatted + '(' + data.left_per_day_formatted + ')');
|
||||||
|
}
|
||||||
|
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
alert('I failed :(');
|
alert('I failed :(');
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user