Skip to content

Firefly III: a personal finances manager

Small additions to budget handling [skip ci]

James Colea94d476b75e1
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index dbabcbae5c..d611d0e9b3 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -168,6 +168,7 @@ class BudgetController extends Controller
$budgets = $repository->getBudgetsAndLimitsInRange($start, $end);
$allEntries = new Collection;
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
+ $format = strval(trans('config.month_and_day'));
/** @var Budget $budget */
@@ -185,6 +186,22 @@ class BudgetController extends Controller
$spent = $expenses;
$overspent = '0';
} else {
+
+ // update the display name if the range
+ // of the limit repetition does not match
+ // the session's range (for clarity).
+ if (
+ ($start->format('Y-m-d') != $budget->startdate->format('Y-m-d'))
+ || ($end->format('Y-m-d') != $budget->enddate->format('Y-m-d'))
+ ) {
+ $name .= ' ' . trans(
+ 'firefly.between_dates',
+ [
+ 'start' => $budget->startdate->formatLocalized($format),
+ 'end' => $budget->startdate->formatLocalized($format),
+ ]
+ );
+ }
$currentStart = clone $budget->startdate;
$currentEnd = clone $budget->enddate;
$expenses = $repository->balanceInPeriod($budget, $currentStart, $currentEnd, $accounts);
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 4fd6ca302f..05bbac919c 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -279,6 +279,7 @@ return [
'transaction_page_size_help' => 'Any list of transactions shows at most this many transactions',
'transaction_page_size_label' => 'Page size',
'budget_maximum' => 'Budget maximum',
+ 'between_dates' => '(:start and :end)',
// profile:
'change_your_password' => 'Change your password',
diff --git a/resources/views/reports/partials/balance.twig b/resources/views/reports/partials/balance.twig
index 77818df874..3a2bcf1f2e 100644
--- a/resources/views/reports/partials/balance.twig
+++ b/resources/views/reports/partials/balance.twig
@@ -25,11 +25,13 @@
{% if balanceLine.getBudget.id %}
<td>
<a href="{{ route('budgets.show',balanceLine.getBudget.id) }}">{{ balanceLine.getTitle }}</a>
+ {% if balanceLine.getStartdate and balanceLine.getEnddate %}
<span class="small"><br>
{{ balanceLine.getStartdate.formatLocalized(monthAndDayFormat) }}
&mdash;
{{ balanceLine.getEnddate.formatLocalized(monthAndDayFormat) }}
</span>
+ {% endif %}
</td>
<td>
{% if(balanceLine.getBudget.amount) %}