Skip to content

Firefly III: a personal finances manager

Fix #10441

Sander Dorigo4f07b089d273
diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php
index d70f894c6d..9ba3776f6d 100644
--- a/app/Http/Controllers/Budget/IndexController.php
+++ b/app/Http/Controllers/Budget/IndexController.php
@@ -137,7 +137,6 @@ class IndexController extends Controller
// get all inactive budgets, and simply list them:
$inactive = $this->repository->getInactiveBudgets();
$defaultCurrency = $this->defaultCurrency;
-
return view(
'budgets.index',
compact(
@@ -225,6 +224,7 @@ class IndexController extends Controller
'start_date' => $limit->start_date->isoFormat($this->monthAndDayFormat),
'end_date' => $limit->end_date->isoFormat($this->monthAndDayFormat),
'in_range' => $limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end),
+ 'total_days' => $limit->start_date->diffInDays($limit->end_date) + 1,
'currency_id' => $currency->id,
'currency_symbol' => $currency->symbol,
'currency_name' => $currency->name,
diff --git a/resources/views/budgets/index.twig b/resources/views/budgets/index.twig
index cdd4b359e1..becfb544f9 100644
--- a/resources/views/budgets/index.twig
+++ b/resources/views/budgets/index.twig
@@ -339,6 +339,7 @@
{% if spentInfo.currency_id == budgetLimit.currency_id and budgetLimit.in_range %}
{# the code below is used for budget limits INSIDE the current view range. #}
{% set countLimit = countLimit + 1 %}
+
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
{# the amount left is automatically calculated. #}
@@ -356,7 +357,9 @@
<br/>
{% endif %}
{% endfor %}
+
{% if countLimit == 0 %}
+
{# this code is used for budget limits OUTSIDE the current view range. #}
<span class="left_span" data-id="{{ budget.id }}" data-currency="{{ spentInfo.currency_id }}" data-limit="0"
class="amount_left" data-value="{{ spentInfo.spent }}">
@@ -366,7 +369,9 @@
{% endif %}
{% endfor %}
{% for budgetLimit in budget.budgeted %}
+ D
{% if null == budget.spent[budgetLimit.currency_id] %}
+ E
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
{{ formatAmountBySymbol(budgetLimit.amount, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }}
@@ -377,6 +382,10 @@
({{ formatAmountBySymbol(budgetLimit.amount / activeDaysLeft, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
{% endif %}
{% endif %}
+ {% if not budgetLimit.in_range %}
+ {# For issue #10441, add per day if the budget limit is out of range. #}
+ ({{ formatAmountBySymbol(budgetLimit.amount / budgetLimit.total_days, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
+ {% endif %}
</span>
<br/>
{% endif %}