Skip to content

Firefly III: a personal finances manager

Fix attachment overview

James Cole36021d84cfca
diff --git a/app/Http/Controllers/Recurring/ShowController.php b/app/Http/Controllers/Recurring/ShowController.php
index 6d4c1a60f7..fa9b4a2445 100644
--- a/app/Http/Controllers/Recurring/ShowController.php
+++ b/app/Http/Controllers/Recurring/ShowController.php
@@ -26,9 +26,12 @@ namespace FireflyIII\Http\Controllers\Recurring;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
+use FireflyIII\Models\Attachment;
use FireflyIII\Models\Recurrence;
+use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
+use FireflyIII\Transformers\AttachmentTransformer;
use FireflyIII\Transformers\RecurrenceTransformer;
use Illuminate\Contracts\View\Factory;
use Illuminate\View\View;
@@ -71,13 +74,14 @@ class ShowController extends Controller
/**
* Show a single recurring transaction.
*
- * @param Recurrence $recurrence
+ * @param Recurrence $recurrence
*
* @return Factory|View
* @throws FireflyException
*/
public function show(Recurrence $recurrence)
{
+ $repos = app(AttachmentRepositoryInterface::class);
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);
$transformer->setParameters(new ParameterBag());
@@ -93,12 +97,25 @@ class ShowController extends Controller
$date = (new Carbon($occurrence))->startOfDay();
$set = [
'date' => $date,
- 'fired' => $this->recurring->createdPreviously($recurrence, $date) || $this->recurring->getJournalCount($recurrence, $date) > 0,
+ 'fired' => $this->recurring->createdPreviously($recurrence, $date)
+ || $this->recurring->getJournalCount($recurrence, $date) > 0,
];
$array['repetitions'][$index]['occurrences'][$item] = $set;
}
}
+ // add attachments to the recurrence object.
+ $attachments = $recurrence->attachments()->get();
+ $array['attachments'] = [];
+ $attachmentTransformer = app(AttachmentTransformer::class);
+ /** @var Attachment $attachment */
+ foreach ($attachments as $attachment) {
+ $item = $attachmentTransformer->transform($attachment);
+ $item['file_exists'] = $repos->exists($attachment); // TODO this should be part of the transformer
+ $array['attachments'][] = $item;
+
+ }
+
$subTitle = (string)trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
return view('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups', 'today'));
diff --git a/resources/views/recurring/show.twig b/resources/views/recurring/show.twig
index 2d4b181bae..17459a3ce9 100644
--- a/resources/views/recurring/show.twig
+++ b/resources/views/recurring/show.twig
@@ -21,7 +21,8 @@
</h3>
</div>
<div class="box-body">
- <p><em>{{ array.description }}</em></p>
+ <h4>{{ 'transaction_journal_meta'|_ }}</h4>
+ <p>{{ 'description'|_ }}: <em>{{ array.description }}</em></p>
{% if array.active == false %}
<p>
@@ -34,6 +35,8 @@
<li>{{ rep.description }}</li>
{% endfor %}
</ul>
+ <h4>{{ 'attachments'|_ }}</h4>
+ {% include 'list.attachments' with {attachments: array.attachments} %}
</div>
<div class="box-footer">
<div class="btn-group">