From d23656aac97163db29bf32368ddd94514485ab44 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 4 Sep 2019 09:45:02 +0200 Subject: [PATCH] Code for #2466 --- .../Controllers/Recurring/IndexController.php | 6 ++++- resources/lang/en_US/list.php | 1 + resources/views/v1/recurring/index.twig | 26 ++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.php index 544d54cfe6..4e45f5984e 100644 --- a/app/Http/Controllers/Recurring/IndexController.php +++ b/app/Http/Controllers/Recurring/IndexController.php @@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Recurring; use Carbon\Carbon; -use FireflyIII\Exceptions\FireflyException; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Models\Recurrence; use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface; @@ -48,6 +47,7 @@ class IndexController extends Controller /** * IndexController constructor. + * * @codeCoverageIgnore */ public function __construct() @@ -82,6 +82,9 @@ class IndexController extends Controller $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page'); $pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $collection = $this->recurring->get(); + $today = new Carbon; + $year = new Carbon; + $year->addYear(); // split collection $total = $collection->count(); @@ -99,6 +102,7 @@ class IndexController extends Controller $array['first_date'] = new Carbon($array['first_date']); $array['repeat_until'] = null === $array['repeat_until'] ? null : new Carbon($array['repeat_until']); $array['latest_date'] = null === $array['latest_date'] ? null : new Carbon($array['latest_date']); + $array['occurrences'] = array_slice($this->recurring->getOccurrencesInRange($recurrence->recurrenceRepetitions->first(), $today, $year),0,1); $recurring[] = $array; } $paginator = new LengthAwarePaginator($recurring, $total, $pageSize, $page); diff --git a/resources/lang/en_US/list.php b/resources/lang/en_US/list.php index bb13e331f7..499ed1f971 100644 --- a/resources/lang/en_US/list.php +++ b/resources/lang/en_US/list.php @@ -37,6 +37,7 @@ return [ 'linked_to_rules' => 'Relevant rules', 'active' => 'Is active?', 'percentage' => 'pct.', + 'next_due' => 'Next due', 'transaction_type' => 'Type', 'lastActivity' => 'Last activity', 'balanceDiff' => 'Balance difference', diff --git a/resources/views/v1/recurring/index.twig b/resources/views/v1/recurring/index.twig index 24fb661c26..5d8ad31b4f 100644 --- a/resources/views/v1/recurring/index.twig +++ b/resources/views/v1/recurring/index.twig @@ -39,8 +39,9 @@   {{ trans('list.title') }} - {{ trans('list.transaction_s') }} + {{ trans('list.transaction_s') }} {{ trans('list.repetitions') }} + {{ trans('list.next_due') }} @@ -49,7 +50,8 @@
@@ -57,7 +59,7 @@ {% if rt.active == false %}{% endif %} {{ rt.type|_ }}: {{ rt.title }} - {% if rt.active == false %} ({{ 'inactive'|_|lower }}){% endif %} + {% if rt.active == false %} ({{ 'inactive'|_|lower }}){% endif %} {% if rt.description|length > 0 %}
{{ rt.description }}
{% endif %} @@ -86,12 +88,12 @@